Loading...
Searching...
No Matches
v8-script.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_V8_SCRIPT_H_
6#define INCLUDE_V8_SCRIPT_H_
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include <memory>
12#include <span>
13#include <tuple>
14#include <vector>
15
16#include "v8-callbacks.h" // NOLINT(build/include_directory)
17#include "v8-data.h" // NOLINT(build/include_directory)
18#include "v8-local-handle.h" // NOLINT(build/include_directory)
19#include "v8-maybe.h" // NOLINT(build/include_directory)
20#include "v8-message.h" // NOLINT(build/include_directory)
21#include "v8config.h" // NOLINT(build/include_directory)
22
23namespace v8 {
24
25class Function;
26class Message;
27class Object;
28class PrimitiveArray;
29class Script;
30
31namespace internal {
32class BackgroundDeserializeTask;
33struct ScriptStreamingData;
34} // namespace internal
35
43 public:
49
55};
56
61 public:
66
67 /*
68 * A unique id.
69 */
70 int ScriptId() const;
71 V8_DEPRECATE_SOON("Use ScriptId")
72 int GetId() const;
73
74 Local<Value> GetScriptName();
75
79 Local<Value> GetSourceURL();
83 Local<Value> GetSourceMappingURL();
84
89 int GetLineNumber(int code_pos = 0);
90
95 int GetColumnNumber(int code_pos = 0);
96
97 static const int kNoScriptId = 0;
98};
99
104 public:
113
114 /*
115 * A unique id.
116 */
117 int ScriptId() const;
118
119 static const int kNoScriptId = 0;
120};
121
122static_assert(UnboundModuleScript::kNoScriptId == UnboundScript::kNoScriptId);
123
128 public:
129 int GetLineNumber() { return line_number_; }
130 int GetColumnNumber() { return column_number_; }
131
132 Location(int line_number, int column_number)
133 : line_number_(line_number), column_number_(column_number) {}
134
135 private:
136 int line_number_;
137 int column_number_;
138};
139
141 public:
146
151
156 int GetSourceOffset() const;
157
172
173 V8_DEPRECATED("Use GetImportAttributes instead")
174 Local<FixedArray> GetImportAssertions() const {
175 return GetImportAttributes();
176 }
177
178 V8_INLINE static ModuleRequest* Cast(Data* data);
179
180 private:
181 static void CheckCast(Data* obj);
182};
183
187class V8_EXPORT Module : public Data {
188 public:
196 enum Status {
202 kErrored
203 };
204
211
216
221
226
232
236 int GetIdentityHash() const;
237
239 Local<Context> context, Local<String> specifier,
240 Local<FixedArray> import_attributes, Local<Module> referrer);
242 Local<Context> context, Local<String> specifier,
243 Local<FixedArray> import_attributes, Local<Module> referrer);
244
246 Local<Context> context, size_t module_request_index,
247 Local<Module> referrer);
249 Local<Context> context, size_t module_request_index,
250 Local<Module> referrer);
251
260 Local<Context> context, ResolveModuleCallback module_callback,
261 ResolveSourceCallback source_callback = nullptr);
262
270 Local<Context> context, ResolveModuleByIndexCallback module_callback,
271 ResolveSourceByIndexCallback source_callback = nullptr);
272
284
296 Local<Context> context);
297
305
313
319 int ScriptId() const;
320
327 bool IsGraphAsync() const;
328
334 bool HasTopLevelAwait() const;
335
339 bool IsSourceTextModule() const;
340
344 bool IsSyntheticModule() const;
345
346 /*
347 * Callback defined in the embedder. This is responsible for setting
348 * the module's exported values with calls to SetSyntheticModuleExport().
349 * The callback must return a resolved Promise to indicate success (where no
350 * exception was thrown) and return an empy MaybeLocal to indicate falure
351 * (where an exception was thrown).
352 */
353 // TODO(caiolima): Change this to `MaybeLocal<Promise>` given it's expected a
354 // Promise as return.
357
366 Isolate* isolate, Local<String> module_name,
367 const std::span<const Local<String>>& export_names,
368 SyntheticModuleEvaluationSteps evaluation_steps,
369 Local<Data> host_defined_options = Local<Data>());
370
376
385 Isolate* isolate, Local<String> export_name, Local<Value> export_value);
386
394 std::pair<LocalVector<Module>, LocalVector<Message>>
396
397 V8_INLINE static Module* Cast(Data* data);
398
399 private:
400 static void CheckCast(Data* obj);
401};
402
404 public:
408 std::vector<int> GetCompileHints(Isolate* isolate) const;
409};
410
415class V8_EXPORT Script : public Data {
416 public:
421 Local<Context> context, Local<String> source,
422 ScriptOrigin* origin = nullptr);
423
431 Local<Data> host_defined_options);
432
437
441 int ScriptId() const;
442
448
453 V8_DEPRECATE_SOON("Use GetCompileHintsCollector instead")
454 std::vector<int> GetProducedCompileHints() const;
455
461 Local<CompileHintsCollector> GetCompileHintsCollector() const;
462};
463
465
470 public:
472
481 enum BufferPolicy { BufferNotOwned, BufferOwned };
482
484 : data(nullptr),
485 length(0),
486 rejected(false),
487 buffer_policy(BufferNotOwned) {}
488
489 // If buffer_policy is BufferNotOwned, the caller keeps the ownership of
490 // data and guarantees that it stays alive until the CachedData object is
491 // destroyed. If the policy is BufferOwned, the given data will be deleted
492 // (with delete[]) when the CachedData object is destroyed.
493 CachedData(const uint8_t* data, int length,
494 BufferPolicy buffer_policy = BufferNotOwned);
496
498 // Don't change order/existing values of this enum since it keys into the
499 // `code_cache_reject_reason` histogram. Append-only!
501 kMagicNumberMismatch = 1,
502 kVersionMismatch = 2,
503 kSourceMismatch = 3,
504 kFlagsMismatch = 5,
505 kChecksumMismatch = 6,
506 kInvalidHeader = 7,
507 kLengthMismatch = 8,
508 kReadOnlySnapshotChecksumMismatch = 9,
509
510 // This should always point at the last real enum value.
511 kLast = kReadOnlySnapshotChecksumMismatch
512 };
513
514 // Check if the CachedData can be loaded in the given isolate.
516
517 // TODO(marja): Async compilation; add constructors which take a callback
518 // which will be called when V8 no longer needs the data.
519 const uint8_t* data;
523
524 // Prevent copying.
525 CachedData(const CachedData&) = delete;
526 CachedData& operator=(const CachedData&) = delete;
527 };
528
530 // V8 did not attempt to find this script in its in-memory cache.
531 kNotAttempted,
532
533 // V8 found a previously compiled copy of this script in its in-memory
534 // cache. Any data generated by a streaming compilation or background
535 // deserialization was abandoned.
536 kHit,
537
538 // V8 didn't have any previously compiled data for this script.
539 kMiss,
540
541 // V8 had some previously compiled data for an identical script, but the
542 // data was incomplete.
543 kPartial,
544 };
545
546 // Details about what happened during a compilation.
548 InMemoryCacheResult in_memory_cache_result =
549 InMemoryCacheResult::kNotAttempted;
550
551 static constexpr int64_t kTimeNotMeasured = -1;
552 int64_t foreground_time_in_microseconds = kTimeNotMeasured;
553 int64_t background_time_in_microseconds = kTimeNotMeasured;
554 };
555
559 class Source {
560 public:
561 // Source takes ownership of both CachedData and CodeCacheConsumeTask.
562 // The caller *must* ensure that the cached data is from a trusted source.
563 V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
564 CachedData* cached_data = nullptr,
565 ConsumeCodeCacheTask* consume_cache_task = nullptr);
566 // Source takes ownership of both CachedData and CodeCacheConsumeTask.
567 V8_INLINE explicit Source(
568 Local<String> source_string, CachedData* cached_data = nullptr,
569 ConsumeCodeCacheTask* consume_cache_task = nullptr);
570 V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
571 CompileHintCallback callback, void* callback_data);
572 V8_INLINE ~Source() = default;
573
574 // Ownership of the CachedData or its buffers is *not* transferred to the
575 // caller. The CachedData object is alive as long as the Source object is
576 // alive.
577 V8_INLINE const CachedData* GetCachedData() const;
578
579 V8_INLINE const ScriptOriginOptions& GetResourceOptions() const;
580
581 V8_INLINE const CompilationDetails& GetCompilationDetails() const;
582
583 private:
584 friend class ScriptCompiler;
585
586 Local<String> source_string;
587
588 // Origin information
589 Local<Value> resource_name;
590 int resource_line_offset = -1;
591 int resource_column_offset = -1;
592 ScriptOriginOptions resource_options;
593 Local<Value> source_map_url;
594 Local<Data> host_defined_options;
595
596 // Cached data from previous compilation (if a kConsume*Cache flag is
597 // set), or hold newly generated cache data (kProduce*Cache flags) are
598 // set when calling a compile method.
599 std::unique_ptr<CachedData> cached_data;
600 std::unique_ptr<ConsumeCodeCacheTask> consume_cache_task;
601
602 // For requesting compile hints from the embedder.
603 CompileHintCallback compile_hint_callback = nullptr;
604 void* compile_hint_callback_data = nullptr;
605
606 // V8 writes this data and never reads it. It exists only to be informative
607 // to the embedder.
608 CompilationDetails compilation_details;
609 };
610
612 public:
613 virtual ~ExternalSourceStreamBase() = default;
614 };
615
621 public:
622 ~ExternalSourceStream() override = default;
623
645 virtual size_t GetMoreData(const uint8_t** src) = 0;
646 };
647
658 : public ExternalSourceStreamBase {
659 public:
660 enum class ChunkEncoding { kOneByte, kTwoByte };
661
662 ~FlexibleExternalSourceStream() override = default;
663
664 struct Chunk {
665 Chunk(const uint8_t* data, size_t position, size_t length_in_characters,
666 ChunkEncoding encoding)
667 : data(data),
668 position(position),
669 length_in_characters(length_in_characters),
670 encoding(encoding) {}
671 Chunk() : Chunk(nullptr, 0, 0, ChunkEncoding::kOneByte) {}
672
673 size_t end_position() const { return position + length_in_characters; }
674
675 const uint8_t* data;
676 size_t position;
679 };
680
688 virtual Chunk GetNextChunk() = 0;
689 };
690
698 public:
699 enum Encoding { ONE_BYTE, TWO_BYTE, UTF8, WINDOWS_1252, FLEXIBLE_UTF16 };
700
701 StreamedSource(std::unique_ptr<ExternalSourceStream> source_stream,
702 Encoding encoding);
704 std::unique_ptr<FlexibleExternalSourceStream> source_stream);
706
707 internal::ScriptStreamingData* impl() const { return impl_.get(); }
708
709 // Prevent copying.
712
713 CompilationDetails& compilation_details() { return compilation_details_; }
714
715 private:
716 std::unique_ptr<internal::ScriptStreamingData> impl_;
717
718 // V8 writes this data and never reads it. It exists only to be informative
719 // to the embedder.
720 CompilationDetails compilation_details_;
721 };
722
728 public:
729 void Run();
730
731 private:
732 friend class ScriptCompiler;
733
734 explicit ScriptStreamingTask(internal::ScriptStreamingData* data)
735 : data_(data) {}
736
737 internal::ScriptStreamingData* data_;
738 };
739
746 public:
748
749 void Run();
750
764 void SourceTextAvailable(Isolate* isolate, Local<String> source_text,
765 const ScriptOrigin& origin);
766
773
780
781 private:
782 friend class ScriptCompiler;
783
784 explicit ConsumeCodeCacheTask(
785 std::unique_ptr<internal::BackgroundDeserializeTask> impl);
786
787 std::unique_ptr<internal::BackgroundDeserializeTask> impl_;
788 };
789
791 kNoCompileOptions = 0,
792 kConsumeCodeCache = 1 << 0,
793 kEagerCompile = 1 << 1,
794 kProduceCompileHints = 1 << 2,
795 kConsumeCompileHints = 1 << 3,
796 kFollowCompileHintsMagicComment = 1 << 4,
797 kFollowCompileHintsPerFunctionMagicComment = 1 << 5,
798 };
799
800 static inline bool CompileOptionsIsValid(CompileOptions compile_options) {
801 // kConsumeCodeCache is mutually exclusive with all other flag bits.
802 if ((compile_options & kConsumeCodeCache) &&
803 compile_options != kConsumeCodeCache) {
804 return false;
805 }
806 // kEagerCompile is mutually exclusive with all other flag bits.
807 if ((compile_options & kEagerCompile) && compile_options != kEagerCompile) {
808 return false;
809 }
810 // We don't currently support producing and consuming compile hints at the
811 // same time.
812 constexpr int produce_and_consume = CompileOptions::kProduceCompileHints |
813 CompileOptions::kConsumeCompileHints;
814 if ((compile_options & produce_and_consume) == produce_and_consume) {
815 return false;
816 }
817 return true;
818 }
819
824 kNoCacheNoReason = 0,
841 };
842
858 Isolate* isolate, Source* source,
859 CompileOptions options = kNoCompileOptions,
860 NoCacheReason no_cache_reason = kNoCacheNoReason);
861
874 Local<Context> context, Source* source,
875 CompileOptions options = kNoCompileOptions,
876 NoCacheReason no_cache_reason = kNoCacheNoReason);
877
890 Isolate* isolate, StreamedSource* source,
891 ScriptType type = ScriptType::kClassic,
892 CompileOptions options = kNoCompileOptions,
893 CompileHintCallback compile_hint_callback = nullptr,
894 void* compile_hint_callback_data = nullptr);
895
897 Isolate* isolate, std::unique_ptr<CachedData> source);
899 Isolate* isolate, std::unique_ptr<CachedData> source);
900
909 Local<Context> context, StreamedSource* source,
910 Local<String> full_source_string, const ScriptOrigin& origin);
911
930 static uint32_t CachedDataVersionTag();
931
940 Isolate* isolate, Source* source,
941 CompileOptions options = kNoCompileOptions,
942 NoCacheReason no_cache_reason = kNoCacheNoReason);
943
952 Local<Context> context, StreamedSource* v8_source,
953 Local<String> full_source_string, const ScriptOrigin& origin);
954
966 Local<Context> context, Source* source, size_t arguments_count = 0,
967 Local<String> arguments[] = nullptr, size_t context_extension_count = 0,
968 Local<Object> context_extensions[] = nullptr,
969 CompileOptions options = kNoCompileOptions,
970 NoCacheReason no_cache_reason = kNoCacheNoReason);
971
978
985 Local<UnboundModuleScript> unbound_module_script);
986
994
995 private:
996 static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
997 Isolate* isolate, Source* source, CompileOptions options,
998 NoCacheReason no_cache_reason);
999
1000 static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInternal(
1001 Local<Context> context, Source* source, size_t arguments_count,
1002 Local<String> arguments[], size_t context_extension_count,
1003 Local<Object> context_extensions[], CompileOptions options,
1004 NoCacheReason no_cache_reason,
1005 Local<ScriptOrModule>* script_or_module_out);
1006};
1007
1008ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin,
1009 CachedData* data,
1010 ConsumeCodeCacheTask* consume_cache_task)
1011 : source_string(string),
1012 resource_name(origin.ResourceName()),
1013 resource_line_offset(origin.LineOffset()),
1014 resource_column_offset(origin.ColumnOffset()),
1015 resource_options(origin.Options()),
1016 source_map_url(origin.SourceMapUrl()),
1017 host_defined_options(origin.GetHostDefinedOptions()),
1018 cached_data(data),
1019 consume_cache_task(consume_cache_task) {}
1020
1022 ConsumeCodeCacheTask* consume_cache_task)
1023 : source_string(string),
1024 cached_data(data),
1025 consume_cache_task(consume_cache_task) {}
1026
1028 CompileHintCallback callback,
1029 void* callback_data)
1030 : source_string(string),
1031 resource_name(origin.ResourceName()),
1032 resource_line_offset(origin.LineOffset()),
1033 resource_column_offset(origin.ColumnOffset()),
1034 resource_options(origin.Options()),
1035 source_map_url(origin.SourceMapUrl()),
1036 host_defined_options(origin.GetHostDefinedOptions()),
1037 compile_hint_callback(callback),
1038 compile_hint_callback_data(callback_data) {}
1039
1041 const {
1042 return cached_data.get();
1043}
1044
1046 return resource_options;
1047}
1048
1051 return compilation_details;
1052}
1053
1055#ifdef V8_ENABLE_CHECKS
1056 CheckCast(data);
1057#endif
1058 return reinterpret_cast<ModuleRequest*>(data);
1059}
1060
1062#ifdef V8_ENABLE_CHECKS
1063 CheckCast(data);
1064#endif
1065 return reinterpret_cast<Module*>(data);
1066}
1067
1068} // namespace v8
1069
1070#endif // INCLUDE_V8_SCRIPT_H_
Definition: v8-script.h:403
std::vector< int > GetCompileHints(Isolate *isolate) const
Definition: v8-data.h:18
Definition: v8-data.h:77
Definition: v8-isolate.h:292
Definition: v8-local-handle.h:594
Definition: v8-local-handle.h:366
Definition: v8-script.h:127
int GetLineNumber()
Definition: v8-script.h:129
Location(int line_number, int column_number)
Definition: v8-script.h:132
int GetColumnNumber()
Definition: v8-script.h:130
Definition: v8-local-handle.h:734
Definition: v8-maybe.h:39
Definition: v8-script.h:140
static ModuleRequest * Cast(Data *data)
Definition: v8-script.h:1054
Local< FixedArray > GetImportAttributes() const
Local< String > GetSpecifier() const
ModuleImportPhase GetPhase() const
int GetSourceOffset() const
Definition: v8-script.h:187
Local< Value > GetResourceName() const
MaybeLocal< Promise > Evaluate(Local< Context > context)
Location SourceOffsetToLocation(int offset) const
Maybe< bool > InstantiateModule(Local< Context > context, ResolveModuleByIndexCallback module_callback, ResolveSourceByIndexCallback source_callback=nullptr)
Maybe< bool > SetSyntheticModuleExport(Isolate *isolate, Local< String > export_name, Local< Value > export_value)
Local< FixedArray > GetModuleRequests() const
bool IsGraphAsync() const
bool HasTopLevelAwait() const
int ScriptId() const
Status GetStatus() const
bool IsSyntheticModule() const
Local< Value > GetException() const
static Local< Module > CreateSyntheticModule(Isolate *isolate, Local< String > module_name, const std::span< const Local< String > > &export_names, SyntheticModuleEvaluationSteps evaluation_steps, Local< Data > host_defined_options=Local< Data >())
std::pair< LocalVector< Module >, LocalVector< Message > > GetStalledTopLevelAwaitMessages(Isolate *isolate)
Status
Definition: v8-script.h:196
@ kInstantiating
Definition: v8-script.h:198
@ kInstantiated
Definition: v8-script.h:199
@ kUninstantiated
Definition: v8-script.h:197
@ kEvaluating
Definition: v8-script.h:200
@ kEvaluated
Definition: v8-script.h:201
int GetIdentityHash() const
Local< UnboundModuleScript > GetUnboundModuleScript()
Local< Value > GetModuleNamespace(v8::ModuleImportPhase phase=v8::ModuleImportPhase::kEvaluation)
MaybeLocal< Promise > EvaluateForImportDefer(Local< Context > context)
static Module * Cast(Data *data)
Definition: v8-script.h:1061
Maybe< bool > InstantiateModule(Local< Context > context, ResolveModuleCallback module_callback, ResolveSourceCallback source_callback=nullptr)
bool IsSourceTextModule() const
Local< Data > GetSyntheticModuleHostDefinedOptions() const
Definition: v8-script.h:745
void SourceTextAvailable(Isolate *isolate, Local< String > source_text, const ScriptOrigin &origin)
Definition: v8-script.h:620
virtual size_t GetMoreData(const uint8_t **src)=0
Definition: v8-script.h:727
Definition: v8-script.h:559
Source(Local< String > source_string, const ScriptOrigin &origin, CachedData *cached_data=nullptr, ConsumeCodeCacheTask *consume_cache_task=nullptr)
Definition: v8-script.h:1008
const CompilationDetails & GetCompilationDetails() const
Definition: v8-script.h:1050
const CachedData * GetCachedData() const
Definition: v8-script.h:1040
const ScriptOriginOptions & GetResourceOptions() const
Definition: v8-script.h:1045
Definition: v8-script.h:697
internal::ScriptStreamingData * impl() const
Definition: v8-script.h:707
Encoding
Definition: v8-script.h:699
CompilationDetails & compilation_details()
Definition: v8-script.h:713
StreamedSource & operator=(const StreamedSource &)=delete
StreamedSource(const StreamedSource &)=delete
StreamedSource(std::unique_ptr< FlexibleExternalSourceStream > source_stream)
StreamedSource(std::unique_ptr< ExternalSourceStream > source_stream, Encoding encoding)
Definition: v8-script.h:469
static CachedData * CreateCodeCacheForFunction(Local< Function > function)
static MaybeLocal< Function > CompileFunction(Local< Context > context, Source *source, size_t arguments_count=0, Local< String > arguments[]=nullptr, size_t context_extension_count=0, Local< Object > context_extensions[]=nullptr, CompileOptions options=kNoCompileOptions, NoCacheReason no_cache_reason=kNoCacheNoReason)
InMemoryCacheResult
Definition: v8-script.h:529
static bool CompileOptionsIsValid(CompileOptions compile_options)
Definition: v8-script.h:800
static CachedData * CreateCodeCache(Local< UnboundModuleScript > unbound_module_script)
NoCacheReason
Definition: v8-script.h:823
@ kNoCacheBecausePacScript
Definition: v8-script.h:835
@ kNoCacheBecauseV8Extension
Definition: v8-script.h:833
@ kNoCacheBecauseStreamingSource
Definition: v8-script.h:829
@ kNoCacheBecauseNoResource
Definition: v8-script.h:826
@ kNoCacheBecauseInlineScriptCacheTooCold
Definition: v8-script.h:840
@ kNoCacheBecauseStaticCodeCache
Definition: v8-script.h:839
@ kNoCacheBecauseInspector
Definition: v8-script.h:830
@ kNoCacheBecauseCacheTooCold
Definition: v8-script.h:832
@ kNoCacheBecauseScriptTooSmall
Definition: v8-script.h:831
@ kNoCacheBecauseCachingDisabled
Definition: v8-script.h:825
@ kNoCacheBecauseDeferredProduceCodeCache
Definition: v8-script.h:838
@ kNoCacheBecauseExtensionModule
Definition: v8-script.h:834
@ kNoCacheBecauseInlineScript
Definition: v8-script.h:827
@ kNoCacheBecauseInDocumentWrite
Definition: v8-script.h:836
@ kNoCacheBecauseModule
Definition: v8-script.h:828
@ kNoCacheBecauseResourceWithNoCacheHandler
Definition: v8-script.h:837
static ConsumeCodeCacheTask * StartConsumingCodeCacheOnBackground(Isolate *isolate, std::unique_ptr< CachedData > source)
static CachedData * CreateCodeCache(Local< UnboundScript > unbound_script)
static MaybeLocal< Module > CompileModule(Local< Context > context, StreamedSource *v8_source, Local< String > full_source_string, const ScriptOrigin &origin)
CompileOptions
Definition: v8-script.h:790
static MaybeLocal< Script > Compile(Local< Context > context, StreamedSource *source, Local< String > full_source_string, const ScriptOrigin &origin)
static MaybeLocal< Script > Compile(Local< Context > context, Source *source, CompileOptions options=kNoCompileOptions, NoCacheReason no_cache_reason=kNoCacheNoReason)
static ScriptStreamingTask * StartStreaming(Isolate *isolate, StreamedSource *source, ScriptType type=ScriptType::kClassic, CompileOptions options=kNoCompileOptions, CompileHintCallback compile_hint_callback=nullptr, void *compile_hint_callback_data=nullptr)
static uint32_t CachedDataVersionTag()
static MaybeLocal< UnboundScript > CompileUnboundScript(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions, NoCacheReason no_cache_reason=kNoCacheNoReason)
static ConsumeCodeCacheTask * StartConsumingCodeCache(Isolate *isolate, std::unique_ptr< CachedData > source)
static MaybeLocal< Module > CompileModule(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions, NoCacheReason no_cache_reason=kNoCacheNoReason)
Definition: v8-script.h:42
Local< Value > GetResourceName()
Local< Data > HostDefinedOptions()
Definition: v8-message.h:29
Definition: v8-message.h:63
Definition: v8-script.h:415
static MaybeLocal< Script > Compile(Local< Context > context, Local< String > source, ScriptOrigin *origin=nullptr)
MaybeLocal< Value > Run(Local< Context > context)
Local< UnboundScript > GetUnboundScript()
int ScriptId() const
MaybeLocal< Value > Run(Local< Context > context, Local< Data > host_defined_options)
Local< Value > GetResourceName()
Definition: v8-script.h:103
Local< Value > GetSourceURL()
Local< Value > GetSourceMappingURL()
Definition: v8-script.h:60
int ScriptId() const
Local< Script > BindToCurrentContext()
Definition: v8-value.h:32
Definition: libplatform.h:15
bool(*)(int, void *) CompileHintCallback
Definition: v8-callbacks.h:435
ModuleImportPhase
Definition: v8-callbacks.h:352
ScriptType
Definition: v8-script.h:464
Definition: v8-script.h:480
BufferPolicy buffer_policy
Definition: v8-script.h:522
const uint8_t * data
Definition: v8-script.h:519
CachedData(const CachedData &)=delete
CompatibilityCheckResult
Definition: v8-script.h:497
bool rejected
Definition: v8-script.h:521
CachedData(const uint8_t *data, int length, BufferPolicy buffer_policy=BufferNotOwned)
BufferPolicy
Definition: v8-script.h:481
@ BufferNotOwned
Definition: v8-script.h:481
CachedData()
Definition: v8-script.h:483
int length
Definition: v8-script.h:520
CompatibilityCheckResult CompatibilityCheck(Isolate *isolate)
CachedData & operator=(const CachedData &)=delete
Definition: v8-script.h:547
const uint8_t * data
Definition: v8-script.h:675
size_t length_in_characters
Definition: v8-script.h:677
ChunkEncoding encoding
Definition: v8-script.h:678
Chunk(const uint8_t *data, size_t position, size_t length_in_characters, ChunkEncoding encoding)
Definition: v8-script.h:665
size_t end_position() const
Definition: v8-script.h:673
#define V8_EXPORT
Definition: v8config.h:867
#define V8_INLINE
Definition: v8config.h:511
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:624
#define V8_DEPRECATED(message)
Definition: v8config.h:616
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:681