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) {}
155 return GetImportAttributes();
161 static void CheckCast(
Data* obj);
322 static void CheckCast(
Data* obj);
388 buffer_policy(BufferNotOwned) {}
402 kMagicNumberMismatch = 1,
403 kVersionMismatch = 2,
406 kChecksumMismatch = 6,
409 kReadOnlySnapshotChecksumMismatch = 9,
412 kLast = kReadOnlySnapshotChecksumMismatch
450 InMemoryCacheResult::kNotAttempted;
452 static constexpr int64_t kTimeNotMeasured = -1;
453 int64_t foreground_time_in_microseconds = kTimeNotMeasured;
454 int64_t background_time_in_microseconds = kTimeNotMeasured;
491 int resource_line_offset = -1;
492 int resource_column_offset = -1;
500 std::unique_ptr<CachedData> cached_data;
501 std::unique_ptr<ConsumeCodeCacheTask> consume_cache_task;
505 void* compile_hint_callback_data =
nullptr;
552 enum Encoding { ONE_BYTE, TWO_BYTE, UTF8, WINDOWS_1252 };
558 internal::ScriptStreamingData*
impl()
const {
return impl_.get(); }
567 std::unique_ptr<internal::ScriptStreamingData> impl_;
588 internal::ScriptStreamingData* data_;
636 std::unique_ptr<internal::BackgroundDeserializeTask> impl);
638 std::unique_ptr<internal::BackgroundDeserializeTask> impl_;
642 kNoCompileOptions = 0,
653 kNoCacheNoReason = 0,
667 kNoCacheBecauseDeferredProduceCodeCache
721 void* compile_hint_callback_data =
nullptr);
724 Isolate* isolate, std::unique_ptr<CachedData> source);
793 Local<
String> arguments[],
size_t context_extension_count,
801 Local<
String> arguments[] =
nullptr,
size_t context_extension_count = 0,
836 Local<
String> arguments[],
size_t context_extension_count,
845 : source_string(
string),
846 resource_name(origin.ResourceName()),
847 resource_line_offset(origin.LineOffset()),
848 resource_column_offset(origin.ColumnOffset()),
849 resource_options(origin.Options()),
850 source_map_url(origin.SourceMapUrl()),
851 host_defined_options(origin.GetHostDefinedOptions()),
853 consume_cache_task(consume_cache_task) {}
857 : source_string(string),
859 consume_cache_task(consume_cache_task) {}
864 : source_string(string),
865 resource_name(origin.ResourceName()),
866 resource_line_offset(origin.LineOffset()),
867 resource_column_offset(origin.ColumnOffset()),
868 resource_options(origin.Options()),
869 source_map_url(origin.SourceMapUrl()),
870 host_defined_options(origin.GetHostDefinedOptions()),
871 compile_hint_callback(callback),
872 compile_hint_callback_data(callback_data) {}
876 return cached_data.get();
880 return resource_options;
885 return compilation_details;
889#ifdef V8_ENABLE_CHECKS
896#ifdef V8_ENABLE_CHECKS
899 return reinterpret_cast<Module*
>(data);
Location(int line_number, int column_number)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Evaluate(Local< Context > context)
std::pair< LocalVector< Module >, LocalVector< Message > > GetStalledTopLevelAwaitMessages(Isolate *isolate)
Local< UnboundModuleScript > GetUnboundModuleScript()
static Local< Module > CreateSyntheticModule(Isolate *isolate, Local< String > module_name, const MemorySpan< const Local< String > > &export_names, SyntheticModuleEvaluationSteps evaluation_steps)
Local< FixedArray > GetModuleRequests() const
Local< Value > GetModuleNamespace()
Local< Value > GetException() const
V8_WARN_UNUSED_RESULT Maybe< bool > InstantiateModule(Local< Context > context, ResolveModuleCallback callback)
bool IsSyntheticModule() const
static V8_INLINE Module * Cast(Data *data)
Location SourceOffsetToLocation(int offset) const
int GetIdentityHash() const
bool IsSourceTextModule() const
V8_WARN_UNUSED_RESULT Maybe< bool > SetSyntheticModuleExport(Isolate *isolate, Local< String > export_name, Local< Value > export_value)
bool IsGraphAsync() const
static V8_INLINE ModuleRequest * Cast(Data *data)
int GetSourceOffset() const
Local< FixedArray > GetImportAttributes() const
Local< String > GetSpecifier() const
void SourceTextAvailable(Isolate *isolate, Local< String > source_text, const ScriptOrigin &origin)
bool ShouldMergeWithExistingScript() const
void MergeWithExistingScript()
virtual size_t GetMoreData(const uint8_t **src)=0
virtual ~ExternalSourceStream()=default
V8_INLINE ~Source()=default
V8_INLINE const CompilationDetails & GetCompilationDetails() const
V8_INLINE const CachedData * GetCachedData() const
V8_INLINE const ScriptOriginOptions & GetResourceOptions() const
V8_INLINE Source(Local< String > source_string, const ScriptOrigin &origin, CachedData *cached_data=nullptr, ConsumeCodeCacheTask *consume_cache_task=nullptr)
CompilationDetails & compilation_details()
internal::ScriptStreamingData * impl() const
StreamedSource & operator=(const StreamedSource &)=delete
StreamedSource(const StreamedSource &)=delete
StreamedSource(std::unique_ptr< ExternalSourceStream > source_stream, Encoding encoding)
static V8_WARN_UNUSED_RESULT MaybeLocal< Module > CompileModule(Local< Context > context, StreamedSource *v8_source, Local< String > full_source_string, const ScriptOrigin &origin)
static V8_WARN_UNUSED_RESULT MaybeLocal< Script > Compile(Local< Context > context, StreamedSource *source, Local< String > full_source_string, const ScriptOrigin &origin)
static ConsumeCodeCacheTask * StartConsumingCodeCache(Isolate *isolate, std::unique_ptr< CachedData > source)
@ kNoCacheBecauseScriptTooSmall
@ kNoCacheBecauseInlineScript
@ kNoCacheBecauseExtensionModule
@ kNoCacheBecauseCacheTooCold
@ kNoCacheBecauseStreamingSource
@ kNoCacheBecauseInspector
@ kNoCacheBecauseV8Extension
@ kNoCacheBecauseNoResource
@ kNoCacheBecausePacScript
@ kNoCacheBecauseCachingDisabled
@ kNoCacheBecauseResourceWithNoCacheHandler
@ kNoCacheBecauseInDocumentWrite
static V8_WARN_UNUSED_RESULT MaybeLocal< Script > Compile(Local< Context > context, Source *source, CompileOptions options=kNoCompileOptions, NoCacheReason no_cache_reason=kNoCacheNoReason)
static V8_WARN_UNUSED_RESULT MaybeLocal< UnboundScript > CompileUnboundScript(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions, NoCacheReason no_cache_reason=kNoCacheNoReason)
static uint32_t CachedDataVersionTag()
static V8_WARN_UNUSED_RESULT MaybeLocal< Module > CompileModule(Isolate *isolate, 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)
Local< UnboundScript > GetUnboundScript()
static V8_WARN_UNUSED_RESULT MaybeLocal< Script > Compile(Local< Context > context, Local< String > source, ScriptOrigin *origin=nullptr)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Run(Local< Context > context)
std::vector< int > GetProducedCompileHints() const
Local< Value > GetResourceName()
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Run(Local< Context > context, Local< Data > host_defined_options)
Local< Value > GetResourceName()
Local< Data > HostDefinedOptions()
Local< Value > GetSourceMappingURL()
Local< Value > GetSourceURL()
int GetColumnNumber(int code_pos=0)
Local< Script > BindToCurrentContext()
Local< Value > GetSourceMappingURL()
Local< Value > GetSourceURL()
int GetLineNumber(int code_pos=0)
Local< Value > GetScriptName()
bool(*)(int, void *) CompileHintCallback
CachedData(const CachedData &)=delete
CachedData & operator=(const CachedData &)=delete
BufferPolicy buffer_policy
CachedData(const uint8_t *data, int length, BufferPolicy buffer_policy=BufferNotOwned)
CompatibilityCheckResult CompatibilityCheck(Isolate *isolate)
#define V8_DEPRECATE_SOON(message)
#define V8_DEPRECATED(message)
#define V8_WARN_UNUSED_RESULT