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 */
355
356 /*
357 * Deprecated version of SyntheticModuleEvaluationSteps: the returned value is
358 * still required to be a Promise, but that is only enforced at runtime.
359 */
360 // TODO(https://crbug.com/545375591): Remove once all embedders return a
361 // MaybeLocal<Promise>.
364
373 Isolate* isolate, Local<String> module_name,
374 const std::span<const Local<String>>& export_names,
375 SyntheticModuleEvaluationSteps evaluation_steps,
376 Local<Data> host_defined_options = Local<Data>());
377
378 // TODO(https://crbug.com/545375591): Advance to V8_DEPRECATED and then remove
379 // this overload once all embedders have been migrated to the one above.
381 "Use the CreateSyntheticModule overload whose evaluation_steps return a "
382 "MaybeLocal<Promise>")
383 static Local<Module> CreateSyntheticModule(
384 Isolate* isolate, Local<String> module_name,
385 const std::span<const Local<String>>& export_names,
387 Local<Data> host_defined_options = Local<Data>());
388
393 Local<Data> GetSyntheticModuleHostDefinedOptions() const;
394
402 V8_WARN_UNUSED_RESULT Maybe<bool> SetSyntheticModuleExport(
403 Isolate* isolate, Local<String> export_name, Local<Value> export_value);
404
413 GetStalledTopLevelAwaitMessages(Isolate* isolate);
414
415 V8_INLINE static Module* Cast(Data* data);
416
417 private:
418 static void CheckCast(Data* obj);
419};
420
422 public:
426 std::vector<int> GetCompileHints(Isolate* isolate) const;
427};
428
433class V8_EXPORT Script : public Data {
434 public:
439 Local<Context> context, Local<String> source,
440 ScriptOrigin* origin = nullptr);
441
449 Local<Data> host_defined_options);
450
455
459 int ScriptId() const;
460
466
471 V8_DEPRECATE_SOON("Use GetCompileHintsCollector instead")
472 std::vector<int> GetProducedCompileHints() const;
473
479 Local<CompileHintsCollector> GetCompileHintsCollector() const;
480};
481
483
488 public:
490
499 enum BufferPolicy { BufferNotOwned, BufferOwned };
500
502 : data(nullptr),
503 length(0),
504 rejected(false),
505 buffer_policy(BufferNotOwned) {}
506
507 // If buffer_policy is BufferNotOwned, the caller keeps the ownership of
508 // data and guarantees that it stays alive until the CachedData object is
509 // destroyed. If the policy is BufferOwned, the given data will be deleted
510 // (with delete[]) when the CachedData object is destroyed.
511 CachedData(const uint8_t* data, int length,
512 BufferPolicy buffer_policy = BufferNotOwned);
514
516 // Don't change order/existing values of this enum since it keys into the
517 // `code_cache_reject_reason` histogram. Append-only!
519 kMagicNumberMismatch = 1,
520 kVersionMismatch = 2,
521 kSourceMismatch = 3,
522 kFlagsMismatch = 5,
523 kChecksumMismatch = 6,
524 kInvalidHeader = 7,
525 kLengthMismatch = 8,
526 kReadOnlySnapshotChecksumMismatch = 9,
527
528 // This should always point at the last real enum value.
529 kLast = kReadOnlySnapshotChecksumMismatch
530 };
531
532 // Check if the CachedData can be loaded in the given isolate.
534
535 // TODO(marja): Async compilation; add constructors which take a callback
536 // which will be called when V8 no longer needs the data.
537 const uint8_t* data;
541
542 // Prevent copying.
543 CachedData(const CachedData&) = delete;
544 CachedData& operator=(const CachedData&) = delete;
545 };
546
548 // V8 did not attempt to find this script in its in-memory cache.
549 kNotAttempted,
550
551 // V8 found a previously compiled copy of this script in its in-memory
552 // cache. Any data generated by a streaming compilation or background
553 // deserialization was abandoned.
554 kHit,
555
556 // V8 didn't have any previously compiled data for this script.
557 kMiss,
558
559 // V8 had some previously compiled data for an identical script, but the
560 // data was incomplete.
561 kPartial,
562 };
563
564 // Details about what happened during a compilation.
566 InMemoryCacheResult in_memory_cache_result =
567 InMemoryCacheResult::kNotAttempted;
568
569 static constexpr int64_t kTimeNotMeasured = -1;
570 int64_t foreground_time_in_microseconds = kTimeNotMeasured;
571 int64_t background_time_in_microseconds = kTimeNotMeasured;
572 };
573
577 class Source {
578 public:
579 // Source takes ownership of both CachedData and CodeCacheConsumeTask.
580 // The caller *must* ensure that the cached data is from a trusted source.
581 V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
582 CachedData* cached_data = nullptr,
583 ConsumeCodeCacheTask* consume_cache_task = nullptr);
584 // Source takes ownership of both CachedData and CodeCacheConsumeTask.
585 V8_INLINE explicit Source(
586 Local<String> source_string, CachedData* cached_data = nullptr,
587 ConsumeCodeCacheTask* consume_cache_task = nullptr);
588 V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
589 CompileHintCallback callback, void* callback_data);
590 V8_INLINE ~Source() = default;
591
592 // Ownership of the CachedData or its buffers is *not* transferred to the
593 // caller. The CachedData object is alive as long as the Source object is
594 // alive.
595 V8_INLINE const CachedData* GetCachedData() const;
596
597 V8_INLINE const ScriptOriginOptions& GetResourceOptions() const;
598
599 V8_INLINE const CompilationDetails& GetCompilationDetails() const;
600
601 private:
602 friend class ScriptCompiler;
603
604 Local<String> source_string;
605
606 // Origin information
607 Local<Value> resource_name;
608 int resource_line_offset = -1;
609 int resource_column_offset = -1;
610 ScriptOriginOptions resource_options;
611 Local<Value> source_map_url;
612 Local<Data> host_defined_options;
613
614 // Cached data from previous compilation (if a kConsume*Cache flag is
615 // set), or hold newly generated cache data (kProduce*Cache flags) are
616 // set when calling a compile method.
617 std::unique_ptr<CachedData> cached_data;
618 std::unique_ptr<ConsumeCodeCacheTask> consume_cache_task;
619
620 // For requesting compile hints from the embedder.
621 CompileHintCallback compile_hint_callback = nullptr;
622 void* compile_hint_callback_data = nullptr;
623
624 // V8 writes this data and never reads it. It exists only to be informative
625 // to the embedder.
626 CompilationDetails compilation_details;
627 };
628
630 public:
631 virtual ~ExternalSourceStreamBase() = default;
632 };
633
639 public:
640 ~ExternalSourceStream() override = default;
641
663 virtual size_t GetMoreData(const uint8_t** src) = 0;
664 };
665
676 : public ExternalSourceStreamBase {
677 public:
678 enum class ChunkEncoding { kOneByte, kTwoByte };
679
680 ~FlexibleExternalSourceStream() override = default;
681
682 struct Chunk {
683 Chunk(const uint8_t* data, size_t position, size_t length_in_characters,
684 ChunkEncoding encoding)
685 : data(data),
686 position(position),
687 length_in_characters(length_in_characters),
688 encoding(encoding) {}
689 Chunk() : Chunk(nullptr, 0, 0, ChunkEncoding::kOneByte) {}
690
691 size_t end_position() const { return position + length_in_characters; }
692
693 const uint8_t* data;
694 size_t position;
697 };
698
706 virtual Chunk GetNextChunk() = 0;
707 };
708
716 public:
717 enum Encoding { ONE_BYTE, TWO_BYTE, UTF8, WINDOWS_1252, FLEXIBLE_UTF16 };
718
719 StreamedSource(std::unique_ptr<ExternalSourceStream> source_stream,
720 Encoding encoding);
722 std::unique_ptr<FlexibleExternalSourceStream> source_stream);
724
725 internal::ScriptStreamingData* impl() const { return impl_.get(); }
726
727 // Prevent copying.
730
731 CompilationDetails& compilation_details() { return compilation_details_; }
732
733 private:
734 std::unique_ptr<internal::ScriptStreamingData> impl_;
735
736 // V8 writes this data and never reads it. It exists only to be informative
737 // to the embedder.
738 CompilationDetails compilation_details_;
739 };
740
746 public:
747 void Run();
748
749 private:
750 friend class ScriptCompiler;
751
752 explicit ScriptStreamingTask(internal::ScriptStreamingData* data)
753 : data_(data) {}
754
755 internal::ScriptStreamingData* data_;
756 };
757
764 public:
766
767 void Run();
768
782 void SourceTextAvailable(Isolate* isolate, Local<String> source_text,
783 const ScriptOrigin& origin);
784
791
798
799 private:
800 friend class ScriptCompiler;
801
802 explicit ConsumeCodeCacheTask(
803 std::unique_ptr<internal::BackgroundDeserializeTask> impl);
804
805 std::unique_ptr<internal::BackgroundDeserializeTask> impl_;
806 };
807
809 kNoCompileOptions = 0,
810 kConsumeCodeCache = 1 << 0,
811 kEagerCompile = 1 << 1,
812 kProduceCompileHints = 1 << 2,
813 kConsumeCompileHints = 1 << 3,
814 kFollowCompileHintsMagicComment = 1 << 4,
815 kFollowCompileHintsPerFunctionMagicComment = 1 << 5,
816 };
817
818 static inline bool CompileOptionsIsValid(CompileOptions compile_options) {
819 // kConsumeCodeCache is mutually exclusive with all other flag bits.
820 if ((compile_options & kConsumeCodeCache) &&
821 compile_options != kConsumeCodeCache) {
822 return false;
823 }
824 // kEagerCompile is mutually exclusive with all other flag bits.
825 if ((compile_options & kEagerCompile) && compile_options != kEagerCompile) {
826 return false;
827 }
828 // We don't currently support producing and consuming compile hints at the
829 // same time.
830 constexpr int produce_and_consume = CompileOptions::kProduceCompileHints |
831 CompileOptions::kConsumeCompileHints;
832 if ((compile_options & produce_and_consume) == produce_and_consume) {
833 return false;
834 }
835 return true;
836 }
837
842 kNoCacheNoReason = 0,
859 };
860
876 Isolate* isolate, Source* source,
877 CompileOptions options = kNoCompileOptions,
878 NoCacheReason no_cache_reason = kNoCacheNoReason);
879
892 Local<Context> context, Source* source,
893 CompileOptions options = kNoCompileOptions,
894 NoCacheReason no_cache_reason = kNoCacheNoReason);
895
908 Isolate* isolate, StreamedSource* source,
909 ScriptType type = ScriptType::kClassic,
910 CompileOptions options = kNoCompileOptions,
911 CompileHintCallback compile_hint_callback = nullptr,
912 void* compile_hint_callback_data = nullptr);
913
915 Isolate* isolate, std::unique_ptr<CachedData> source);
917 Isolate* isolate, std::unique_ptr<CachedData> source);
918
927 Local<Context> context, StreamedSource* source,
928 Local<String> full_source_string, const ScriptOrigin& origin);
929
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:421
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-message.h:107
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:763
void SourceTextAvailable(Isolate *isolate, Local< String > source_text, const ScriptOrigin &origin)
Definition: v8-script.h:638
virtual size_t GetMoreData(const uint8_t **src)=0
Definition: v8-script.h:745
Definition: v8-script.h:577
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:715
internal::ScriptStreamingData * impl() const
Definition: v8-script.h:725
Encoding
Definition: v8-script.h:717
CompilationDetails & compilation_details()
Definition: v8-script.h:731
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:487
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:547
static bool CompileOptionsIsValid(CompileOptions compile_options)
Definition: v8-script.h:818
static CachedData * CreateCodeCache(Local< UnboundModuleScript > unbound_module_script)
NoCacheReason
Definition: v8-script.h:841
@ kNoCacheBecausePacScript
Definition: v8-script.h:853
@ kNoCacheBecauseV8Extension
Definition: v8-script.h:851
@ kNoCacheBecauseStreamingSource
Definition: v8-script.h:847
@ kNoCacheBecauseNoResource
Definition: v8-script.h:844
@ kNoCacheBecauseInlineScriptCacheTooCold
Definition: v8-script.h:858
@ kNoCacheBecauseStaticCodeCache
Definition: v8-script.h:857
@ kNoCacheBecauseInspector
Definition: v8-script.h:848
@ kNoCacheBecauseCacheTooCold
Definition: v8-script.h:850
@ kNoCacheBecauseScriptTooSmall
Definition: v8-script.h:849
@ kNoCacheBecauseCachingDisabled
Definition: v8-script.h:843
@ kNoCacheBecauseDeferredProduceCodeCache
Definition: v8-script.h:856
@ kNoCacheBecauseExtensionModule
Definition: v8-script.h:852
@ kNoCacheBecauseInlineScript
Definition: v8-script.h:845
@ kNoCacheBecauseInDocumentWrite
Definition: v8-script.h:854
@ kNoCacheBecauseModule
Definition: v8-script.h:846
@ kNoCacheBecauseResourceWithNoCacheHandler
Definition: v8-script.h:855
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:808
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:433
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:126
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:482
Definition: v8-script.h:498
BufferPolicy buffer_policy
Definition: v8-script.h:540
const uint8_t * data
Definition: v8-script.h:537
CachedData(const CachedData &)=delete
CompatibilityCheckResult
Definition: v8-script.h:515
bool rejected
Definition: v8-script.h:539
CachedData(const uint8_t *data, int length, BufferPolicy buffer_policy=BufferNotOwned)
BufferPolicy
Definition: v8-script.h:499
@ BufferNotOwned
Definition: v8-script.h:499
CachedData()
Definition: v8-script.h:501
int length
Definition: v8-script.h:538
CompatibilityCheckResult CompatibilityCheck(Isolate *isolate)
CachedData & operator=(const CachedData &)=delete
Definition: v8-script.h:565
const uint8_t * data
Definition: v8-script.h:693
size_t length_in_characters
Definition: v8-script.h:695
ChunkEncoding encoding
Definition: v8-script.h:696
Chunk(const uint8_t *data, size_t position, size_t length_in_characters, ChunkEncoding encoding)
Definition: v8-script.h:683
size_t end_position() const
Definition: v8-script.h:691
#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