5#ifndef INCLUDE_V8_SCRIPT_H_
6#define INCLUDE_V8_SCRIPT_H_
32class BackgroundDeserializeTask;
33struct ScriptStreamingData;
91 static const int kNoScriptId = 0;
118 : line_number_(line_number), column_number_(column_number) {}
160 return GetImportAttributes();
166 static void CheckCast(
Data* obj);
338 static void CheckCast(
Data* obj);
387 std::vector<
int> GetProducedCompileHints() const;
420 buffer_policy(BufferNotOwned) {}
434 kMagicNumberMismatch = 1,
435 kVersionMismatch = 2,
438 kChecksumMismatch = 6,
441 kReadOnlySnapshotChecksumMismatch = 9,
444 kLast = kReadOnlySnapshotChecksumMismatch
482 InMemoryCacheResult::kNotAttempted;
484 static constexpr int64_t kTimeNotMeasured = -1;
485 int64_t foreground_time_in_microseconds = kTimeNotMeasured;
486 int64_t background_time_in_microseconds = kTimeNotMeasured;
523 int resource_line_offset = -1;
524 int resource_column_offset = -1;
532 std::unique_ptr<CachedData> cached_data;
533 std::unique_ptr<ConsumeCodeCacheTask> consume_cache_task;
537 void* compile_hint_callback_data =
nullptr;
584 enum Encoding { ONE_BYTE, TWO_BYTE, UTF8, WINDOWS_1252 };
590 internal::ScriptStreamingData*
impl()
const {
return impl_.get(); }
599 std::unique_ptr<internal::ScriptStreamingData> impl_;
620 internal::ScriptStreamingData* data_;
668 std::unique_ptr<internal::BackgroundDeserializeTask> impl);
670 std::unique_ptr<internal::BackgroundDeserializeTask> impl_;
674 kNoCompileOptions = 0,
675 kConsumeCodeCache = 1 << 0,
676 kEagerCompile = 1 << 1,
677 kProduceCompileHints = 1 << 2,
678 kConsumeCompileHints = 1 << 3,
679 kFollowCompileHintsMagicComment = 1 << 4,
684 if ((compile_options & kConsumeCodeCache) &&
685 compile_options != kConsumeCodeCache) {
689 if ((compile_options & kEagerCompile) && compile_options != kEagerCompile) {
694 constexpr int produce_and_consume = CompileOptions::kProduceCompileHints |
695 CompileOptions::kConsumeCompileHints;
696 if ((compile_options & produce_and_consume) == produce_and_consume) {
706 kNoCacheNoReason = 0,
720 kNoCacheBecauseDeferredProduceCodeCache
774 void* compile_hint_callback_data =
nullptr);
777 Isolate* isolate, std::unique_ptr<CachedData> source);
779 Isolate* isolate, std::unique_ptr<CachedData> source);
847 Local<String> arguments[] =
nullptr,
size_t context_extension_count = 0,
891 : source_string(string),
892 resource_name(origin.ResourceName()),
893 resource_line_offset(origin.LineOffset()),
894 resource_column_offset(origin.ColumnOffset()),
895 resource_options(origin.Options()),
896 source_map_url(origin.SourceMapUrl()),
897 host_defined_options(origin.GetHostDefinedOptions()),
899 consume_cache_task(consume_cache_task) {}
903 : source_string(string),
905 consume_cache_task(consume_cache_task) {}
910 : source_string(string),
911 resource_name(origin.ResourceName()),
912 resource_line_offset(origin.LineOffset()),
913 resource_column_offset(origin.ColumnOffset()),
914 resource_options(origin.Options()),
915 source_map_url(origin.SourceMapUrl()),
916 host_defined_options(origin.GetHostDefinedOptions()),
917 compile_hint_callback(callback),
918 compile_hint_callback_data(callback_data) {}
922 return cached_data.get();
926 return resource_options;
931 return compilation_details;
935#ifdef V8_ENABLE_CHECKS
942#ifdef V8_ENABLE_CHECKS
945 return reinterpret_cast<Module*
>(data);
Definition: v8-script.h:341
std::vector< int > GetCompileHints(Isolate *isolate) const
Definition: v8-isolate.h:261
Definition: v8-local-handle.h:492
Definition: v8-local-handle.h:266
Definition: v8-script.h:112
int GetLineNumber()
Definition: v8-script.h:114
Location(int line_number, int column_number)
Definition: v8-script.h:117
int GetColumnNumber()
Definition: v8-script.h:115
Definition: v8-local-handle.h:632
Definition: v8-maybe.h:32
Definition: v8-memory-span.h:64
Definition: v8-script.h:125
static ModuleRequest * Cast(Data *data)
Definition: v8-script.h:934
Local< FixedArray > GetImportAttributes() const
Local< String > GetSpecifier() const
ModuleImportPhase GetPhase() const
int GetSourceOffset() const
Definition: v8-script.h:172
Location SourceOffsetToLocation(int offset) const
MaybeLocal< Value > Evaluate(Local< Context > context)
Local< Value > GetModuleNamespace()
Maybe< bool > SetSyntheticModuleExport(Isolate *isolate, Local< String > export_name, Local< Value > export_value)
Local< FixedArray > GetModuleRequests() const
bool IsGraphAsync() const
bool HasTopLevelAwait() const
bool IsSyntheticModule() const
Local< Value > GetException() const
std::pair< LocalVector< Module >, LocalVector< Message > > GetStalledTopLevelAwaitMessages(Isolate *isolate)
Status
Definition: v8-script.h:181
@ kInstantiating
Definition: v8-script.h:183
@ kInstantiated
Definition: v8-script.h:184
@ kUninstantiated
Definition: v8-script.h:182
@ kEvaluating
Definition: v8-script.h:185
@ kEvaluated
Definition: v8-script.h:186
int GetIdentityHash() const
static Local< Module > CreateSyntheticModule(Isolate *isolate, Local< String > module_name, const MemorySpan< const Local< String > > &export_names, SyntheticModuleEvaluationSteps evaluation_steps)
Local< UnboundModuleScript > GetUnboundModuleScript()
static Module * Cast(Data *data)
Definition: v8-script.h:941
Maybe< bool > InstantiateModule(Local< Context > context, ResolveModuleCallback module_callback, ResolveSourceCallback source_callback=nullptr)
bool IsSourceTextModule() const
Definition: v8-script.h:628
void MergeWithExistingScript()
bool ShouldMergeWithExistingScript() const
void SourceTextAvailable(Isolate *isolate, Local< String > source_text, const ScriptOrigin &origin)
Definition: v8-script.h:548
virtual size_t GetMoreData(const uint8_t **src)=0
virtual ~ExternalSourceStream()=default
Definition: v8-script.h:610
Definition: v8-script.h:492
Source(Local< String > source_string, const ScriptOrigin &origin, CachedData *cached_data=nullptr, ConsumeCodeCacheTask *consume_cache_task=nullptr)
Definition: v8-script.h:888
const CompilationDetails & GetCompilationDetails() const
Definition: v8-script.h:930
const CachedData * GetCachedData() const
Definition: v8-script.h:920
const ScriptOriginOptions & GetResourceOptions() const
Definition: v8-script.h:925
Definition: v8-script.h:582
internal::ScriptStreamingData * impl() const
Definition: v8-script.h:590
Encoding
Definition: v8-script.h:584
CompilationDetails & compilation_details()
Definition: v8-script.h:596
StreamedSource & operator=(const StreamedSource &)=delete
StreamedSource(const StreamedSource &)=delete
StreamedSource(std::unique_ptr< ExternalSourceStream > source_stream, Encoding encoding)
Definition: v8-script.h:402
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:462
static bool CompileOptionsIsValid(CompileOptions compile_options)
Definition: v8-script.h:682
static CachedData * CreateCodeCache(Local< UnboundModuleScript > unbound_module_script)
NoCacheReason
Definition: v8-script.h:705
@ kNoCacheBecausePacScript
Definition: v8-script.h:717
@ kNoCacheBecauseV8Extension
Definition: v8-script.h:715
@ kNoCacheBecauseStreamingSource
Definition: v8-script.h:711
@ kNoCacheBecauseNoResource
Definition: v8-script.h:708
@ kNoCacheBecauseInspector
Definition: v8-script.h:712
@ kNoCacheBecauseCacheTooCold
Definition: v8-script.h:714
@ kNoCacheBecauseScriptTooSmall
Definition: v8-script.h:713
@ kNoCacheBecauseCachingDisabled
Definition: v8-script.h:707
@ kNoCacheBecauseExtensionModule
Definition: v8-script.h:716
@ kNoCacheBecauseInlineScript
Definition: v8-script.h:709
@ kNoCacheBecauseInDocumentWrite
Definition: v8-script.h:718
@ kNoCacheBecauseModule
Definition: v8-script.h:710
@ kNoCacheBecauseResourceWithNoCacheHandler
Definition: v8-script.h:719
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:673
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:28
Definition: v8-message.h:62
Definition: v8-script.h:353
static MaybeLocal< Script > Compile(Local< Context > context, Local< String > source, ScriptOrigin *origin=nullptr)
MaybeLocal< Value > Run(Local< Context > context)
Local< UnboundScript > GetUnboundScript()
MaybeLocal< Value > Run(Local< Context > context, Local< Data > host_defined_options)
Local< Value > GetResourceName()
Definition: v8-script.h:97
Local< Value > GetSourceURL()
Local< Value > GetSourceMappingURL()
Definition: v8-script.h:60
int GetColumnNumber(int code_pos=0)
Local< Value > GetSourceMappingURL()
Local< Value > GetScriptName()
int GetLineNumber(int code_pos=0)
Local< Value > GetSourceURL()
Local< Script > BindToCurrentContext()
Definition: libplatform.h:15
bool(*)(int, void *) CompileHintCallback
Definition: v8-callbacks.h:418
ModuleImportPhase
Definition: v8-callbacks.h:336
ScriptType
Definition: v8-script.h:397
Definition: v8-script.h:413
BufferPolicy buffer_policy
Definition: v8-script.h:455
const uint8_t * data
Definition: v8-script.h:452
CachedData(const CachedData &)=delete
CompatibilityCheckResult
Definition: v8-script.h:430
bool rejected
Definition: v8-script.h:454
CachedData(const uint8_t *data, int length, BufferPolicy buffer_policy=BufferNotOwned)
BufferPolicy
Definition: v8-script.h:414
@ BufferNotOwned
Definition: v8-script.h:414
CachedData()
Definition: v8-script.h:416
int length
Definition: v8-script.h:453
CompatibilityCheckResult CompatibilityCheck(Isolate *isolate)
CachedData & operator=(const CachedData &)=delete
Definition: v8-script.h:480
#define V8_EXPORT
Definition: v8config.h:793
#define V8_INLINE
Definition: v8config.h:499
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:603
#define V8_DEPRECATED(message)
Definition: v8config.h:595
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:660