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
312
318 int ScriptId() const;
319
326 bool IsGraphAsync() const;
327
333 bool HasTopLevelAwait() const;
334
338 bool IsSourceTextModule() const;
339
343 bool IsSyntheticModule() const;
344
345 /*
346 * Callback defined in the embedder. This is responsible for setting
347 * the module's exported values with calls to SetSyntheticModuleExport().
348 * The callback must return a resolved Promise to indicate success (where no
349 * exception was thrown) and return an empy MaybeLocal to indicate falure
350 * (where an exception was thrown).
351 */
354
355 /*
356 * Deprecated version of SyntheticModuleEvaluationSteps: the returned value is
357 * still required to be a Promise, but that is only enforced at runtime.
358 */
359 // TODO(https://crbug.com/545375591): Remove once all embedders return a
360 // MaybeLocal<Promise>.
363
372 Isolate* isolate, Local<String> module_name,
373 const std::span<const Local<String>>& export_names,
374 SyntheticModuleEvaluationSteps evaluation_steps,
375 Local<Data> host_defined_options = Local<Data>());
376
377 // TODO(https://crbug.com/545375591): Advance to V8_DEPRECATED and then remove
378 // this overload once all embedders have been migrated to the one above.
380 "Use the CreateSyntheticModule overload whose evaluation_steps return a "
381 "MaybeLocal<Promise>")
382 static Local<Module> CreateSyntheticModule(
383 Isolate* isolate, Local<String> module_name,
384 const std::span<const Local<String>>& export_names,
386 Local<Data> host_defined_options = Local<Data>());
387
392 Local<Data> GetSyntheticModuleHostDefinedOptions() const;
393
401 V8_WARN_UNUSED_RESULT Maybe<bool> SetSyntheticModuleExport(
402 Isolate* isolate, Local<String> export_name, Local<Value> export_value);
403
412 GetStalledTopLevelAwaitMessages(Isolate* isolate);
413
414 V8_INLINE static Module* Cast(Data* data);
415
416 private:
417 static void CheckCast(Data* obj);
418};
419
421 public:
425 std::vector<int> GetCompileHints(Isolate* isolate) const;
426};
427
432class V8_EXPORT Script : public Data {
433 public:
438 Local<Context> context, Local<String> source,
439 ScriptOrigin* origin = nullptr);
440
448 Local<Data> host_defined_options);
449
454
458 int ScriptId() const;
459
465
470 V8_DEPRECATE_SOON("Use GetCompileHintsCollector instead")
471 std::vector<int> GetProducedCompileHints() const;
472
478 Local<CompileHintsCollector> GetCompileHintsCollector() const;
479};
480
482
487 public:
489
498 enum BufferPolicy { BufferNotOwned, BufferOwned };
499
501 : data(nullptr),
502 length(0),
503 rejected(false),
504 buffer_policy(BufferNotOwned) {}
505
506 // If buffer_policy is BufferNotOwned, the caller keeps the ownership of
507 // data and guarantees that it stays alive until the CachedData object is
508 // destroyed. If the policy is BufferOwned, the given data will be deleted
509 // (with delete[]) when the CachedData object is destroyed.
510 CachedData(const uint8_t* data, int length,
511 BufferPolicy buffer_policy = BufferNotOwned);
513
515 // Don't change order/existing values of this enum since it keys into the
516 // `code_cache_reject_reason` histogram. Append-only!
518 kMagicNumberMismatch = 1,
519 kVersionMismatch = 2,
520 kSourceMismatch = 3,
521 kFlagsMismatch = 5,
522 kChecksumMismatch = 6,
523 kInvalidHeader = 7,
524 kLengthMismatch = 8,
525 kReadOnlySnapshotChecksumMismatch = 9,
526
527 // This should always point at the last real enum value.
528 kLast = kReadOnlySnapshotChecksumMismatch
529 };
530
531 // Check if the CachedData can be loaded in the given isolate.
533
534 // TODO(marja): Async compilation; add constructors which take a callback
535 // which will be called when V8 no longer needs the data.
536 const uint8_t* data;
540
541 // Prevent copying.
542 CachedData(const CachedData&) = delete;
543 CachedData& operator=(const CachedData&) = delete;
544 };
545
547 // V8 did not attempt to find this script in its in-memory cache.
548 kNotAttempted,
549
550 // V8 found a previously compiled copy of this script in its in-memory
551 // cache. Any data generated by a streaming compilation or background
552 // deserialization was abandoned.
553 kHit,
554
555 // V8 didn't have any previously compiled data for this script.
556 kMiss,
557
558 // V8 had some previously compiled data for an identical script, but the
559 // data was incomplete.
560 kPartial,
561 };
562
563 // Details about what happened during a compilation.
565 InMemoryCacheResult in_memory_cache_result =
566 InMemoryCacheResult::kNotAttempted;
567
568 static constexpr int64_t kTimeNotMeasured = -1;
569 int64_t foreground_time_in_microseconds = kTimeNotMeasured;
570 int64_t background_time_in_microseconds = kTimeNotMeasured;
571 };
572
576 class Source {
577 public:
578 // Source takes ownership of both CachedData and CodeCacheConsumeTask.
579 // The caller *must* ensure that the cached data is from a trusted source.
580 V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
581 CachedData* cached_data = nullptr,
582 ConsumeCodeCacheTask* consume_cache_task = nullptr);
583 // Source takes ownership of both CachedData and CodeCacheConsumeTask.
584 V8_INLINE explicit Source(
585 Local<String> source_string, CachedData* cached_data = nullptr,
586 ConsumeCodeCacheTask* consume_cache_task = nullptr);
587 V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
588 CompileHintCallback callback, void* callback_data);
589 V8_INLINE ~Source() = default;
590
591 // Ownership of the CachedData or its buffers is *not* transferred to the
592 // caller. The CachedData object is alive as long as the Source object is
593 // alive.
594 V8_INLINE const CachedData* GetCachedData() const;
595
596 V8_INLINE const ScriptOriginOptions& GetResourceOptions() const;
597
598 V8_INLINE const CompilationDetails& GetCompilationDetails() const;
599
600 private:
601 friend class ScriptCompiler;
602
603 Local<String> source_string;
604
605 // Origin information
606 Local<Value> resource_name;
607 int resource_line_offset = -1;
608 int resource_column_offset = -1;
609 ScriptOriginOptions resource_options;
610 Local<Value> source_map_url;
611 Local<Data> host_defined_options;
612
613 // Cached data from previous compilation (if a kConsume*Cache flag is
614 // set), or hold newly generated cache data (kProduce*Cache flags) are
615 // set when calling a compile method.
616 std::unique_ptr<CachedData> cached_data;
617 std::unique_ptr<ConsumeCodeCacheTask> consume_cache_task;
618
619 // For requesting compile hints from the embedder.
620 CompileHintCallback compile_hint_callback = nullptr;
621 void* compile_hint_callback_data = nullptr;
622
623 // V8 writes this data and never reads it. It exists only to be informative
624 // to the embedder.
625 CompilationDetails compilation_details;
626 };
627
629 public:
630 virtual ~ExternalSourceStreamBase() = default;
631 };
632
638 public:
639 ~ExternalSourceStream() override = default;
640
662 virtual size_t GetMoreData(const uint8_t** src) = 0;
663 };
664
675 : public ExternalSourceStreamBase {
676 public:
677 enum class ChunkEncoding { kOneByte, kTwoByte };
678
679 ~FlexibleExternalSourceStream() override = default;
680
681 struct Chunk {
682 Chunk(const uint8_t* data, size_t position, size_t length_in_characters,
683 ChunkEncoding encoding)
684 : data(data),
685 position(position),
686 length_in_characters(length_in_characters),
687 encoding(encoding) {}
688 Chunk() : Chunk(nullptr, 0, 0, ChunkEncoding::kOneByte) {}
689
690 size_t end_position() const { return position + length_in_characters; }
691
692 const uint8_t* data;
693 size_t position;
696 };
697
705 virtual Chunk GetNextChunk() = 0;
706 };
707
715 public:
716 enum Encoding { ONE_BYTE, TWO_BYTE, UTF8, WINDOWS_1252, FLEXIBLE_UTF16 };
717
718 StreamedSource(std::unique_ptr<ExternalSourceStream> source_stream,
719 Encoding encoding);
721 std::unique_ptr<FlexibleExternalSourceStream> source_stream);
723
724 internal::ScriptStreamingData* impl() const { return impl_.get(); }
725
726 // Prevent copying.
729
730 CompilationDetails& compilation_details() { return compilation_details_; }
731
732 private:
733 std::unique_ptr<internal::ScriptStreamingData> impl_;
734
735 // V8 writes this data and never reads it. It exists only to be informative
736 // to the embedder.
737 CompilationDetails compilation_details_;
738 };
739
745 public:
746 void Run();
747
748 private:
749 friend class ScriptCompiler;
750
751 explicit ScriptStreamingTask(internal::ScriptStreamingData* data)
752 : data_(data) {}
753
754 internal::ScriptStreamingData* data_;
755 };
756
763 public:
765
766 void Run();
767
781 void SourceTextAvailable(Isolate* isolate, Local<String> source_text,
782 const ScriptOrigin& origin);
783
790
797
798 private:
799 friend class ScriptCompiler;
800
801 explicit ConsumeCodeCacheTask(
802 std::unique_ptr<internal::BackgroundDeserializeTask> impl);
803
804 std::unique_ptr<internal::BackgroundDeserializeTask> impl_;
805 };
806
808 kNoCompileOptions = 0,
809 kConsumeCodeCache = 1 << 0,
810 kEagerCompile = 1 << 1,
811 kProduceCompileHints = 1 << 2,
812 kConsumeCompileHints = 1 << 3,
813 kFollowCompileHintsMagicComment = 1 << 4,
814 kFollowCompileHintsPerFunctionMagicComment = 1 << 5,
815 };
816
817 static inline bool CompileOptionsIsValid(CompileOptions compile_options) {
818 // kConsumeCodeCache is mutually exclusive with all other flag bits.
819 if ((compile_options & kConsumeCodeCache) &&
820 compile_options != kConsumeCodeCache) {
821 return false;
822 }
823 // kEagerCompile is mutually exclusive with all other flag bits.
824 if ((compile_options & kEagerCompile) && compile_options != kEagerCompile) {
825 return false;
826 }
827 // We don't currently support producing and consuming compile hints at the
828 // same time.
829 constexpr int produce_and_consume = CompileOptions::kProduceCompileHints |
830 CompileOptions::kConsumeCompileHints;
831 if ((compile_options & produce_and_consume) == produce_and_consume) {
832 return false;
833 }
834 return true;
835 }
836
841 kNoCacheNoReason = 0,
858 };
859
875 Isolate* isolate, Source* source,
876 CompileOptions options = kNoCompileOptions,
877 NoCacheReason no_cache_reason = kNoCacheNoReason);
878
891 Local<Context> context, Source* source,
892 CompileOptions options = kNoCompileOptions,
893 NoCacheReason no_cache_reason = kNoCacheNoReason);
894
907 Isolate* isolate, StreamedSource* source,
908 ScriptType type = ScriptType::kClassic,
909 CompileOptions options = kNoCompileOptions,
910 CompileHintCallback compile_hint_callback = nullptr,
911 void* compile_hint_callback_data = nullptr);
912
914 Isolate* isolate, std::unique_ptr<CachedData> source);
916 Isolate* isolate, std::unique_ptr<CachedData> source);
917
926 Local<Context> context, StreamedSource* source,
927 Local<String> full_source_string, const ScriptOrigin& origin);
928
948 static uint32_t CachedDataVersionTag();
949
958 Isolate* isolate, Source* source,
959 CompileOptions options = kNoCompileOptions,
960 NoCacheReason no_cache_reason = kNoCacheNoReason);
961
970 Local<Context> context, StreamedSource* v8_source,
971 Local<String> full_source_string, const ScriptOrigin& origin);
972
984 Local<Context> context, Source* source, size_t arguments_count = 0,
985 Local<String> arguments[] = nullptr, size_t context_extension_count = 0,
986 Local<Object> context_extensions[] = nullptr,
987 CompileOptions options = kNoCompileOptions,
988 NoCacheReason no_cache_reason = kNoCacheNoReason);
989
996
1003 Local<UnboundModuleScript> unbound_module_script);
1004
1012
1013 private:
1014 static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
1015 Isolate* isolate, Source* source, CompileOptions options,
1016 NoCacheReason no_cache_reason);
1017
1018 static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInternal(
1019 Local<Context> context, Source* source, size_t arguments_count,
1020 Local<String> arguments[], size_t context_extension_count,
1021 Local<Object> context_extensions[], CompileOptions options,
1022 NoCacheReason no_cache_reason,
1023 Local<ScriptOrModule>* script_or_module_out);
1024};
1025
1026ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin,
1027 CachedData* data,
1028 ConsumeCodeCacheTask* consume_cache_task)
1029 : source_string(string),
1030 resource_name(origin.ResourceName()),
1031 resource_line_offset(origin.LineOffset()),
1032 resource_column_offset(origin.ColumnOffset()),
1033 resource_options(origin.Options()),
1034 source_map_url(origin.SourceMapUrl()),
1035 host_defined_options(origin.GetHostDefinedOptions()),
1036 cached_data(data),
1037 consume_cache_task(consume_cache_task) {}
1038
1040 ConsumeCodeCacheTask* consume_cache_task)
1041 : source_string(string),
1042 cached_data(data),
1043 consume_cache_task(consume_cache_task) {}
1044
1046 CompileHintCallback callback,
1047 void* callback_data)
1048 : source_string(string),
1049 resource_name(origin.ResourceName()),
1050 resource_line_offset(origin.LineOffset()),
1051 resource_column_offset(origin.ColumnOffset()),
1052 resource_options(origin.Options()),
1053 source_map_url(origin.SourceMapUrl()),
1054 host_defined_options(origin.GetHostDefinedOptions()),
1055 compile_hint_callback(callback),
1056 compile_hint_callback_data(callback_data) {}
1057
1059 const {
1060 return cached_data.get();
1061}
1062
1064 return resource_options;
1065}
1066
1069 return compilation_details;
1070}
1071
1073#ifdef V8_ENABLE_CHECKS
1074 CheckCast(data);
1075#endif
1076 return reinterpret_cast<ModuleRequest*>(data);
1077}
1078
1080#ifdef V8_ENABLE_CHECKS
1081 CheckCast(data);
1082#endif
1083 return reinterpret_cast<Module*>(data);
1084}
1085
1086} // namespace v8
1087
1088#endif // INCLUDE_V8_SCRIPT_H_
Definition: v8-script.h:420
std::vector< int > GetCompileHints(Isolate *isolate) const
Definition: v8-data.h:18
Definition: v8-data.h:77
Definition: v8-isolate.h:305
Definition: v8-local-handle.h:584
Definition: v8-local-handle.h:356
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:724
Definition: v8-maybe.h:39
Definition: v8-message.h:108
Definition: v8-script.h:140
static ModuleRequest * Cast(Data *data)
Definition: v8-script.h:1072
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)
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 >())
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:1079
Maybe< bool > InstantiateModule(Local< Context > context, ResolveModuleCallback module_callback, ResolveSourceCallback source_callback=nullptr)
bool IsSourceTextModule() const
Definition: v8-script.h:762
void SourceTextAvailable(Isolate *isolate, Local< String > source_text, const ScriptOrigin &origin)
Definition: v8-script.h:637
virtual size_t GetMoreData(const uint8_t **src)=0
Definition: v8-script.h:744
Definition: v8-script.h:576
Source(Local< String > source_string, const ScriptOrigin &origin, CachedData *cached_data=nullptr, ConsumeCodeCacheTask *consume_cache_task=nullptr)
Definition: v8-script.h:1026
const CompilationDetails & GetCompilationDetails() const
Definition: v8-script.h:1068
const CachedData * GetCachedData() const
Definition: v8-script.h:1058
const ScriptOriginOptions & GetResourceOptions() const
Definition: v8-script.h:1063
Definition: v8-script.h:714
internal::ScriptStreamingData * impl() const
Definition: v8-script.h:724
Encoding
Definition: v8-script.h:716
CompilationDetails & compilation_details()
Definition: v8-script.h:730
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:486
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:546
static bool CompileOptionsIsValid(CompileOptions compile_options)
Definition: v8-script.h:817
static CachedData * CreateCodeCache(Local< UnboundModuleScript > unbound_module_script)
NoCacheReason
Definition: v8-script.h:840
@ kNoCacheBecausePacScript
Definition: v8-script.h:852
@ kNoCacheBecauseV8Extension
Definition: v8-script.h:850
@ kNoCacheBecauseStreamingSource
Definition: v8-script.h:846
@ kNoCacheBecauseNoResource
Definition: v8-script.h:843
@ kNoCacheBecauseInlineScriptCacheTooCold
Definition: v8-script.h:857
@ kNoCacheBecauseStaticCodeCache
Definition: v8-script.h:856
@ kNoCacheBecauseInspector
Definition: v8-script.h:847
@ kNoCacheBecauseCacheTooCold
Definition: v8-script.h:849
@ kNoCacheBecauseScriptTooSmall
Definition: v8-script.h:848
@ kNoCacheBecauseCachingDisabled
Definition: v8-script.h:842
@ kNoCacheBecauseDeferredProduceCodeCache
Definition: v8-script.h:855
@ kNoCacheBecauseExtensionModule
Definition: v8-script.h:851
@ kNoCacheBecauseInlineScript
Definition: v8-script.h:844
@ kNoCacheBecauseInDocumentWrite
Definition: v8-script.h:853
@ kNoCacheBecauseModule
Definition: v8-script.h:845
@ kNoCacheBecauseResourceWithNoCacheHandler
Definition: v8-script.h:854
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:807
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:30
Definition: v8-message.h:64
Definition: v8-script.h:432
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-primitive.h:127
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:458
ModuleImportPhase
Definition: v8-callbacks.h:375
ScriptType
Definition: v8-script.h:481
Definition: v8-script.h:497
BufferPolicy buffer_policy
Definition: v8-script.h:539
const uint8_t * data
Definition: v8-script.h:536
CachedData(const CachedData &)=delete
CompatibilityCheckResult
Definition: v8-script.h:514
bool rejected
Definition: v8-script.h:538
CachedData(const uint8_t *data, int length, BufferPolicy buffer_policy=BufferNotOwned)
BufferPolicy
Definition: v8-script.h:498
@ BufferNotOwned
Definition: v8-script.h:498
CachedData()
Definition: v8-script.h:500
int length
Definition: v8-script.h:537
CompatibilityCheckResult CompatibilityCheck(Isolate *isolate)
CachedData & operator=(const CachedData &)=delete
Definition: v8-script.h:564
const uint8_t * data
Definition: v8-script.h:692
size_t length_in_characters
Definition: v8-script.h:694
ChunkEncoding encoding
Definition: v8-script.h:695
Chunk(const uint8_t *data, size_t position, size_t length_in_characters, ChunkEncoding encoding)
Definition: v8-script.h:682
size_t end_position() const
Definition: v8-script.h:690
#define V8_EXPORT
Definition: v8config.h:875
#define V8_INLINE
Definition: v8config.h:519
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:632
#define V8_DEPRECATED(message)
Definition: v8config.h:624
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:689