summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/compiler.h')
-rw-r--r--deps/v8/src/compiler.h99
1 files changed, 64 insertions, 35 deletions
diff --git a/deps/v8/src/compiler.h b/deps/v8/src/compiler.h
index b84134c14e..ca6b0893d0 100644
--- a/deps/v8/src/compiler.h
+++ b/deps/v8/src/compiler.h
@@ -13,6 +13,7 @@
#include "src/code-events.h"
#include "src/contexts.h"
#include "src/isolate.h"
+#include "src/unicode-cache.h"
#include "src/zone/zone.h"
namespace v8 {
@@ -23,11 +24,9 @@ class CompilationInfo;
class CompilationJob;
class JavaScriptFrame;
class ParseInfo;
+class Parser;
class ScriptData;
-template <typename T>
-class ThreadedList;
-template <typename T>
-class ThreadedListZoneEntry;
+struct ScriptStreamingData;
typedef std::forward_list<std::unique_ptr<CompilationJob>> CompilationJobList;
@@ -57,11 +56,12 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode);
static MaybeHandle<JSArray> CompileForLiveEdit(Handle<Script> script);
- // Compile top level code on a background thread. Should be finalized by
- // GetSharedFunctionInfoForBackgroundCompile.
- static std::unique_ptr<CompilationJob> CompileTopLevelOnBackgroundThread(
- ParseInfo* parse_info, AccountingAllocator* allocator,
- CompilationJobList* inner_function_jobs);
+ // Creates a new task that when run will parse and compile the streamed
+ // script associated with |streaming_data| and can be finalized with
+ // Compiler::GetSharedFunctionInfoForStreamedScript.
+ // Note: does not take ownership of streaming_data.
+ static ScriptCompiler::ScriptStreamingTask* NewBackgroundCompileTask(
+ ScriptStreamingData* streaming_data, Isolate* isolate);
// Generate and install code from previously queued compilation job.
static bool FinalizeCompilationJob(CompilationJob* job, Isolate* isolate);
@@ -71,17 +71,12 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
// offer this chance, optimized closure instantiation will not call this.
static void PostInstantiation(Handle<JSFunction> function, PretenureFlag);
- typedef ThreadedList<ThreadedListZoneEntry<FunctionLiteral*>>
- EagerInnerFunctionLiterals;
-
// Parser::Parse, then Compiler::Analyze.
static bool ParseAndAnalyze(ParseInfo* parse_info,
Handle<SharedFunctionInfo> shared_info,
Isolate* isolate);
- // Rewrite, analyze scopes, and renumber. If |eager_literals| is non-null, it
- // is appended with inner function literals which should be eagerly compiled.
- static bool Analyze(ParseInfo* parse_info,
- EagerInnerFunctionLiterals* eager_literals = nullptr);
+ // Rewrite and analyze scopes.
+ static bool Analyze(ParseInfo* parse_info);
// ===========================================================================
// The following family of methods instantiates new functions for scripts or
@@ -120,28 +115,34 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
Handle<Context> context, Handle<String> source,
ParseRestriction restriction, int parameters_end_pos);
- // Create a shared function info object for a String source within a context.
+ struct ScriptDetails {
+ ScriptDetails() : line_offset(0), column_offset(0) {}
+ explicit ScriptDetails(Handle<Object> script_name)
+ : line_offset(0), column_offset(0), name_obj(script_name) {}
+
+ int line_offset;
+ int column_offset;
+ i::MaybeHandle<i::Object> name_obj;
+ i::MaybeHandle<i::Object> source_map_url;
+ i::MaybeHandle<i::FixedArray> host_defined_options;
+ };
+
+ // Create a shared function info object for a String source.
static MaybeHandle<SharedFunctionInfo> GetSharedFunctionInfoForScript(
- Handle<String> source, MaybeHandle<Object> maybe_script_name,
- int line_offset, int column_offset, ScriptOriginOptions resource_options,
- MaybeHandle<Object> maybe_source_map_url, Handle<Context> context,
- v8::Extension* extension, ScriptData** cached_data,
- ScriptCompiler::CompileOptions compile_options,
+ Handle<String> source, const ScriptDetails& script_details,
+ ScriptOriginOptions origin_options, v8::Extension* extension,
+ ScriptData** cached_data, ScriptCompiler::CompileOptions compile_options,
ScriptCompiler::NoCacheReason no_cache_reason,
- NativesFlag is_natives_code,
- MaybeHandle<FixedArray> maybe_host_defined_options);
-
- // Create a shared function info object for a Script that has already been
- // parsed while the script was being loaded from a streamed source.
- static Handle<SharedFunctionInfo> GetSharedFunctionInfoForStreamedScript(
- Handle<Script> script, ParseInfo* info, int source_length);
+ NativesFlag is_natives_code);
- // Create a shared function info object for a Script that has already been
- // compiled on a background thread.
- static Handle<SharedFunctionInfo> GetSharedFunctionInfoForBackgroundCompile(
- Handle<Script> script, ParseInfo* parse_info, int source_length,
- CompilationJob* outer_function_job,
- CompilationJobList* inner_function_jobs);
+ // Create a shared function info object for a Script source that has already
+ // been parsed and possibly compiled on a background thread while being loaded
+ // from a streamed source. On return, the data held by |streaming_data| will
+ // have been released, however the object itself isn't freed and is still
+ // owned by the caller.
+ static MaybeHandle<SharedFunctionInfo> GetSharedFunctionInfoForStreamedScript(
+ Handle<String> source, const ScriptDetails& script_details,
+ ScriptOriginOptions origin_options, ScriptStreamingData* streaming_data);
// Create a shared function info object for the given function literal
// node (the code may be lazily compiled).
@@ -246,6 +247,34 @@ class V8_EXPORT_PRIVATE CompilationJob {
}
};
+// Contains all data which needs to be transmitted between threads for
+// background parsing and compiling and finalizing it on the main thread.
+struct ScriptStreamingData {
+ ScriptStreamingData(ScriptCompiler::ExternalSourceStream* source_stream,
+ ScriptCompiler::StreamedSource::Encoding encoding);
+ ~ScriptStreamingData();
+
+ void Release();
+
+ // Internal implementation of v8::ScriptCompiler::StreamedSource.
+ std::unique_ptr<ScriptCompiler::ExternalSourceStream> source_stream;
+ ScriptCompiler::StreamedSource::Encoding encoding;
+ std::unique_ptr<ScriptCompiler::CachedData> cached_data;
+
+ // Data needed for parsing, and data needed to to be passed between thread
+ // between parsing and compilation. These need to be initialized before the
+ // compilation starts.
+ UnicodeCache unicode_cache;
+ std::unique_ptr<ParseInfo> info;
+ std::unique_ptr<Parser> parser;
+
+ // Data needed for finalizing compilation after background compilation.
+ std::unique_ptr<CompilationJob> outer_function_job;
+ CompilationJobList inner_function_jobs;
+
+ DISALLOW_COPY_AND_ASSIGN(ScriptStreamingData);
+};
+
} // namespace internal
} // namespace v8