V8 Project
|
For compiling scripts. More...
#include <v8.h>
Classes | |
struct | CachedData |
Compilation data that the embedder can cache and pass back to speed up future compilations. More... | |
class | ExternalSourceStream |
For streaming incomplete script data to V8. More... | |
class | ScriptStreamingTask |
A streaming task which the embedder must run on a background thread to stream scripts into V8. More... | |
class | Source |
Source code which can be then compiled to a UnboundScript or Script. More... | |
class | StreamedSource |
Source code which can be streamed into V8 in pieces. More... | |
Public Types | |
enum | CompileOptions { kNoCompileOptions = 0 , kProduceParserCache , kConsumeParserCache , kProduceCodeCache , kConsumeCodeCache , kProduceDataToCache } |
Static Public Member Functions | |
static Local< UnboundScript > | CompileUnbound (Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions) |
Compiles the specified script (context-independent). More... | |
static Local< Script > | Compile (Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions) |
Compiles the specified script (bound to current context). More... | |
static ScriptStreamingTask * | StartStreamingScript (Isolate *isolate, StreamedSource *source, CompileOptions options=kNoCompileOptions) |
Returns a task which streams script data into V8, or NULL if the script cannot be streamed. More... | |
static Local< Script > | Compile (Isolate *isolate, StreamedSource *source, Handle< String > full_source_string, const ScriptOrigin &origin) |
Compiles a streamed script (bound to current context). More... | |
|
static |
Compiles the specified script (bound to current context).
source | Script source code. |
pre_data | Pre-parsing data, as obtained by ScriptData::PreCompile() using pre_data speeds compilation if it's done multiple times. Owned by caller, no references are kept when this function returns. |
Definition at line 1783 of file api.cc.
References CompileUnbound(), ENTER_V8, LOG_API, and ON_BAILOUT.
Referenced by v8::Script::Compile().
|
static |
Compiles a streamed script (bound to current context).
This can only be called after the streaming has finished (ScriptStreamingTask has been run). V8 doesn't construct the source string during streaming, so the embedder needs to pass the full source here.
Definition at line 1816 of file api.cc.
References v8::internal::Compiler::CompileStreamedScript(), ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::Isolate::factory(), v8::internal::Smi::FromInt(), v8::internal::Isolate::global_context(), v8::ScriptCompiler::StreamedSource::impl(), v8::internal::StreamedSource::info, v8::internal::Handle< T >::is_null(), LOG_API, NULL, v8::internal::Handle< T >::null(), ON_BAILOUT, v8::Utils::OpenHandle(), v8::internal::StreamedSource::parser, v8::internal::Isolate::ReportPendingMessages(), v8::ScriptOrigin::ResourceColumnOffset(), v8::ScriptOrigin::ResourceIsSharedCrossOrigin(), v8::ScriptOrigin::ResourceLineOffset(), v8::ScriptOrigin::ResourceName(), and v8::True().
|
static |
Compiles the specified script (context-independent).
Cached data as part of the source object can be optionally produced to be consumed later to speed up compilation of identical source scripts.
Note that when producing cached data, the source must point to NULL for cached data. When consuming cached data, the cached data must have been produced by the same version of V8.
source | Script source code. |
Definition at line 1703 of file api.cc.
References v8::ScriptCompiler::CachedData::BufferOwned, v8::ScriptCompiler::Source::cached_data, v8::internal::Compiler::CompileScript(), v8::ScriptCompiler::CachedData::data, v8::internal::ScriptData::data(), DCHECK, ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::Isolate::global_context(), v8::internal::Handle< T >::is_null(), kConsumeCodeCache, kConsumeParserCache, kNoCompileOptions, kProduceCodeCache, kProduceDataToCache, kProduceParserCache, v8::ScriptCompiler::CachedData::length, v8::internal::ScriptData::length(), LOG_API, v8::internal::NOT_NATIVES_CODE, NULL, ON_BAILOUT, v8::Utils::OpenHandle(), v8::internal::ScriptData::ReleaseDataOwnership(), v8::ScriptCompiler::Source::resource_column_offset, v8::ScriptCompiler::Source::resource_is_shared_cross_origin, v8::ScriptCompiler::Source::resource_line_offset, v8::ScriptCompiler::Source::resource_name, v8::ScriptCompiler::Source::source_string, and v8::True().
Referenced by Compile(), v8::Shell::CompileString(), and v8::Shell::RealmEval().
|
static |
Returns a task which streams script data into V8, or NULL if the script cannot be streamed.
The user is responsible for running the task on a background thread and deleting it. When ran, the task starts parsing the script, and it will request data from the StreamedSource as needed. When ScriptStreamingTask::Run exits, all data has been streamed and the script can be compiled (see Compile below).
This API allows to start the streaming with as little data as possible, and the remaining data (for example, the ScriptOrigin) is passed to Compile.
Definition at line 1797 of file api.cc.
References v8::internal::Isolate::global_context(), v8::ScriptCompiler::StreamedSource::impl(), and NULL.