Commit c152d459 authored by Wiktor Garbacz's avatar Wiktor Garbacz Committed by Commit Bot

Use ParseInfo fields instead of isolate.

A step towards removing isolate from ParseInfo.
Removing isolate from ParseInfo will make it easier to create and
execute parse tasks on background threads.

BUG=v8:6093

Change-Id: If5e7ba2f76f9f8422c26f47c9f0eb5b197114b25
Reviewed-on: https://chromium-review.googlesource.com/458000Reviewed-by: 's avatarDaniel Vogelheim <vogelheim@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Wiktor Garbacz <wiktorg@google.com>
Cr-Commit-Position: refs/heads/master@{#44089}
parent 30e5ec72
...@@ -34,7 +34,6 @@ BackgroundParsingTask::BackgroundParsingTask( ...@@ -34,7 +34,6 @@ BackgroundParsingTask::BackgroundParsingTask(
info->set_isolate(isolate); info->set_isolate(isolate);
info->set_source_stream(source->source_stream.get()); info->set_source_stream(source->source_stream.get());
info->set_source_stream_encoding(source->encoding); info->set_source_stream_encoding(source->encoding);
info->set_hash_seed(isolate->heap()->HashSeed());
info->set_unicode_cache(&source_->unicode_cache); info->set_unicode_cache(&source_->unicode_cache);
info->set_compile_options(options); info->set_compile_options(options);
info->set_allow_lazy_parsing(); info->set_allow_lazy_parsing();
......
...@@ -489,7 +489,7 @@ void SetSharedFunctionFlagsFromLiteral(FunctionLiteral* literal, ...@@ -489,7 +489,7 @@ void SetSharedFunctionFlagsFromLiteral(FunctionLiteral* literal,
bool Renumber(ParseInfo* parse_info, bool Renumber(ParseInfo* parse_info,
Compiler::EagerInnerFunctionLiterals* eager_literals) { Compiler::EagerInnerFunctionLiterals* eager_literals) {
RuntimeCallTimerScope runtimeTimer(parse_info->isolate(), RuntimeCallTimerScope runtimeTimer(parse_info->runtime_call_stats(),
&RuntimeCallStats::CompileRenumber); &RuntimeCallStats::CompileRenumber);
// CollectTypeProfile uses its own feedback slots. If we have existing // CollectTypeProfile uses its own feedback slots. If we have existing
...@@ -505,10 +505,9 @@ bool Renumber(ParseInfo* parse_info, ...@@ -505,10 +505,9 @@ bool Renumber(ParseInfo* parse_info,
parse_info->shared_info()->feedback_metadata()->HasTypeProfileSlot(); parse_info->shared_info()->feedback_metadata()->HasTypeProfileSlot();
} }
if (!AstNumbering::Renumber( if (!AstNumbering::Renumber(parse_info->stack_limit(), parse_info->zone(),
parse_info->isolate()->stack_guard()->real_climit(), parse_info->literal(), eager_literals,
parse_info->zone(), parse_info->literal(), eager_literals, collect_type_profile)) {
collect_type_profile)) {
return false; return false;
} }
if (!parse_info->shared_info().is_null()) { if (!parse_info->shared_info().is_null()) {
...@@ -1276,7 +1275,7 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { ...@@ -1276,7 +1275,7 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
bool Compiler::Analyze(ParseInfo* info, bool Compiler::Analyze(ParseInfo* info,
EagerInnerFunctionLiterals* eager_literals) { EagerInnerFunctionLiterals* eager_literals) {
DCHECK_NOT_NULL(info->literal()); DCHECK_NOT_NULL(info->literal());
RuntimeCallTimerScope runtimeTimer(info->isolate(), RuntimeCallTimerScope runtimeTimer(info->runtime_call_stats(),
&RuntimeCallStats::CompileAnalyse); &RuntimeCallStats::CompileAnalyse);
if (!Rewriter::Rewrite(info)) return false; if (!Rewriter::Rewrite(info)) return false;
DeclarationScope::Analyze(info, AnalyzeMode::kRegular); DeclarationScope::Analyze(info, AnalyzeMode::kRegular);
......
...@@ -37,29 +37,29 @@ ParseInfo::ParseInfo(AccountingAllocator* zone_allocator) ...@@ -37,29 +37,29 @@ ParseInfo::ParseInfo(AccountingAllocator* zone_allocator)
isolate_(nullptr), isolate_(nullptr),
cached_data_(nullptr), cached_data_(nullptr),
ast_value_factory_(nullptr), ast_value_factory_(nullptr),
ast_string_constants_(nullptr),
function_name_(nullptr), function_name_(nullptr),
runtime_call_stats_(nullptr),
literal_(nullptr), literal_(nullptr),
deferred_handles_(nullptr) {} deferred_handles_(nullptr) {}
ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared) ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared)
: ParseInfo(shared->GetIsolate()->allocator()) { : ParseInfo(shared->GetIsolate()->allocator()) {
isolate_ = shared->GetIsolate(); Isolate* isolate = shared->GetIsolate();
set_isolate(isolate);
set_toplevel(shared->is_toplevel()); set_toplevel(shared->is_toplevel());
set_allow_lazy_parsing(FLAG_lazy_inner_functions); set_allow_lazy_parsing(FLAG_lazy_inner_functions);
set_hash_seed(isolate_->heap()->HashSeed());
set_is_named_expression(shared->is_named_expression()); set_is_named_expression(shared->is_named_expression());
set_calls_eval(shared->scope_info()->CallsEval()); set_calls_eval(shared->scope_info()->CallsEval());
set_compiler_hints(shared->compiler_hints()); set_compiler_hints(shared->compiler_hints());
set_start_position(shared->start_position()); set_start_position(shared->start_position());
set_end_position(shared->end_position()); set_end_position(shared->end_position());
function_literal_id_ = shared->function_literal_id(); function_literal_id_ = shared->function_literal_id();
set_stack_limit(isolate_->stack_guard()->real_climit());
set_unicode_cache(isolate_->unicode_cache());
set_language_mode(shared->language_mode()); set_language_mode(shared->language_mode());
set_shared_info(shared); set_shared_info(shared);
set_module(shared->kind() == FunctionKind::kModule); set_module(shared->kind() == FunctionKind::kModule);
set_scope_info_is_empty(shared->scope_info() == ScopeInfo::Empty(isolate_)); set_scope_info_is_empty(shared->scope_info() == ScopeInfo::Empty(isolate));
Handle<Script> script(Script::cast(shared->script())); Handle<Script> script(Script::cast(shared->script()));
set_script(script); set_script(script);
...@@ -67,7 +67,7 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared) ...@@ -67,7 +67,7 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared)
set_eval(script->compilation_type() == Script::COMPILATION_TYPE_EVAL); set_eval(script->compilation_type() == Script::COMPILATION_TYPE_EVAL);
Handle<HeapObject> scope_info(shared->outer_scope_info()); Handle<HeapObject> scope_info(shared->outer_scope_info());
if (!scope_info->IsTheHole(isolate()) && if (!scope_info->IsTheHole(isolate) &&
Handle<ScopeInfo>::cast(scope_info)->length() > 0) { Handle<ScopeInfo>::cast(scope_info)->length() > 0) {
set_outer_scope_info(Handle<ScopeInfo>::cast(scope_info)); set_outer_scope_info(Handle<ScopeInfo>::cast(scope_info));
} }
...@@ -81,13 +81,9 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared, ...@@ -81,13 +81,9 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared,
ParseInfo::ParseInfo(Handle<Script> script) ParseInfo::ParseInfo(Handle<Script> script)
: ParseInfo(script->GetIsolate()->allocator()) { : ParseInfo(script->GetIsolate()->allocator()) {
isolate_ = script->GetIsolate(); set_isolate(script->GetIsolate());
set_allow_lazy_parsing(); set_allow_lazy_parsing();
set_toplevel(); set_toplevel();
set_hash_seed(isolate_->heap()->HashSeed());
set_stack_limit(isolate_->stack_guard()->real_climit());
set_unicode_cache(isolate_->unicode_cache());
set_script(script); set_script(script);
set_native(script->type() == Script::TYPE_NATIVE); set_native(script->type() == Script::TYPE_NATIVE);
...@@ -106,19 +102,16 @@ ParseInfo::~ParseInfo() { ...@@ -106,19 +102,16 @@ ParseInfo::~ParseInfo() {
ParseInfo* ParseInfo::AllocateWithoutScript(Handle<SharedFunctionInfo> shared) { ParseInfo* ParseInfo::AllocateWithoutScript(Handle<SharedFunctionInfo> shared) {
Isolate* isolate = shared->GetIsolate(); Isolate* isolate = shared->GetIsolate();
ParseInfo* p = new ParseInfo(isolate->allocator()); ParseInfo* p = new ParseInfo(isolate->allocator());
p->isolate_ = isolate;
p->set_isolate(isolate);
p->set_toplevel(shared->is_toplevel()); p->set_toplevel(shared->is_toplevel());
p->set_allow_lazy_parsing(FLAG_lazy_inner_functions); p->set_allow_lazy_parsing(FLAG_lazy_inner_functions);
p->set_hash_seed(isolate->heap()->HashSeed());
p->set_is_named_expression(shared->is_named_expression()); p->set_is_named_expression(shared->is_named_expression());
p->set_calls_eval(shared->scope_info()->CallsEval()); p->set_calls_eval(shared->scope_info()->CallsEval());
p->set_compiler_hints(shared->compiler_hints()); p->set_compiler_hints(shared->compiler_hints());
p->set_start_position(shared->start_position()); p->set_start_position(shared->start_position());
p->set_end_position(shared->end_position()); p->set_end_position(shared->end_position());
p->function_literal_id_ = shared->function_literal_id(); p->function_literal_id_ = shared->function_literal_id();
p->set_stack_limit(isolate->stack_guard()->real_climit());
p->set_unicode_cache(isolate->unicode_cache());
p->set_language_mode(shared->language_mode()); p->set_language_mode(shared->language_mode());
p->set_shared_info(shared); p->set_shared_info(shared);
p->set_module(shared->kind() == FunctionKind::kModule); p->set_module(shared->kind() == FunctionKind::kModule);
...@@ -164,6 +157,17 @@ void ParseInfo::set_deferred_handles(DeferredHandles* deferred_handles) { ...@@ -164,6 +157,17 @@ void ParseInfo::set_deferred_handles(DeferredHandles* deferred_handles) {
deferred_handles_.reset(deferred_handles); deferred_handles_.reset(deferred_handles);
} }
void ParseInfo::InitFromIsolate(Isolate* isolate) {
DCHECK_NOT_NULL(isolate);
set_hash_seed(isolate->heap()->HashSeed());
set_stack_limit(isolate->stack_guard()->real_climit());
set_unicode_cache(isolate->unicode_cache());
set_tail_call_elimination_enabled(
isolate->is_tail_call_elimination_enabled());
set_runtime_call_stats(isolate->counters()->runtime_call_stats());
set_ast_string_constants(isolate->ast_string_constants());
}
#ifdef DEBUG #ifdef DEBUG
bool ParseInfo::script_is_native() const { bool ParseInfo::script_is_native() const {
return script_->type() == Script::TYPE_NATIVE; return script_->type() == Script::TYPE_NATIVE;
......
...@@ -20,10 +20,12 @@ namespace internal { ...@@ -20,10 +20,12 @@ namespace internal {
class AccountingAllocator; class AccountingAllocator;
class AstRawString; class AstRawString;
class AstStringConstants;
class AstValueFactory; class AstValueFactory;
class DeclarationScope; class DeclarationScope;
class DeferredHandles; class DeferredHandles;
class FunctionLiteral; class FunctionLiteral;
class RuntimeCallStats;
class ScriptData; class ScriptData;
class SharedFunctionInfo; class SharedFunctionInfo;
class UnicodeCache; class UnicodeCache;
...@@ -42,6 +44,8 @@ class V8_EXPORT_PRIVATE ParseInfo { ...@@ -42,6 +44,8 @@ class V8_EXPORT_PRIVATE ParseInfo {
~ParseInfo(); ~ParseInfo();
void InitFromIsolate(Isolate* isolate);
static ParseInfo* AllocateWithoutScript(Handle<SharedFunctionInfo> shared); static ParseInfo* AllocateWithoutScript(Handle<SharedFunctionInfo> shared);
Zone* zone() const { return zone_.get(); } Zone* zone() const { return zone_.get(); }
...@@ -74,6 +78,8 @@ class V8_EXPORT_PRIVATE ParseInfo { ...@@ -74,6 +78,8 @@ class V8_EXPORT_PRIVATE ParseInfo {
FLAG_ACCESSOR(kDebug, is_debug, set_is_debug) FLAG_ACCESSOR(kDebug, is_debug, set_is_debug)
FLAG_ACCESSOR(kSerializing, will_serialize, set_will_serialize) FLAG_ACCESSOR(kSerializing, will_serialize, set_will_serialize)
FLAG_ACCESSOR(kScopeInfoIsEmpty, scope_info_is_empty, set_scope_info_is_empty) FLAG_ACCESSOR(kScopeInfoIsEmpty, scope_info_is_empty, set_scope_info_is_empty)
FLAG_ACCESSOR(kTailCallEliminationEnabled, is_tail_call_elimination_enabled,
set_tail_call_elimination_enabled)
#undef FLAG_ACCESSOR #undef FLAG_ACCESSOR
...@@ -185,6 +191,19 @@ class V8_EXPORT_PRIVATE ParseInfo { ...@@ -185,6 +191,19 @@ class V8_EXPORT_PRIVATE ParseInfo {
max_function_literal_id_ = max_function_literal_id; max_function_literal_id_ = max_function_literal_id;
} }
const AstStringConstants* ast_string_constants() const {
return ast_string_constants_;
}
void set_ast_string_constants(
const AstStringConstants* ast_string_constants) {
ast_string_constants_ = ast_string_constants;
}
RuntimeCallStats* runtime_call_stats() const { return runtime_call_stats_; }
void set_runtime_call_stats(RuntimeCallStats* runtime_call_stats) {
runtime_call_stats_ = runtime_call_stats;
}
// Getters for individual compiler hints. // Getters for individual compiler hints.
bool is_declaration() const; bool is_declaration() const;
FunctionKind function_kind() const; FunctionKind function_kind() const;
...@@ -199,7 +218,12 @@ class V8_EXPORT_PRIVATE ParseInfo { ...@@ -199,7 +218,12 @@ class V8_EXPORT_PRIVATE ParseInfo {
return maybe_outer_scope_info_; return maybe_outer_scope_info_;
} }
void clear_script() { script_ = Handle<Script>::null(); } void clear_script() { script_ = Handle<Script>::null(); }
void set_isolate(Isolate* isolate) { isolate_ = isolate; } void set_isolate(Isolate* isolate) {
if (isolate) {
InitFromIsolate(isolate);
}
isolate_ = isolate;
}
void set_shared_info(Handle<SharedFunctionInfo> shared) { shared_ = shared; } void set_shared_info(Handle<SharedFunctionInfo> shared) { shared_ = shared; }
void set_outer_scope_info(Handle<ScopeInfo> outer_scope_info) { void set_outer_scope_info(Handle<ScopeInfo> outer_scope_info) {
maybe_outer_scope_info_ = outer_scope_info; maybe_outer_scope_info_ = outer_scope_info;
...@@ -249,8 +273,8 @@ class V8_EXPORT_PRIVATE ParseInfo { ...@@ -249,8 +273,8 @@ class V8_EXPORT_PRIVATE ParseInfo {
kDebug = 1 << 10, kDebug = 1 << 10,
kSerializing = 1 << 11, kSerializing = 1 << 11,
kScopeInfoIsEmpty = 1 << 12, kScopeInfoIsEmpty = 1 << 12,
// ---------- Output flags -------------------------- kTailCallEliminationEnabled = 1 << 13,
kAstValueFactoryOwned = 1 << 13 kAstValueFactoryOwned = 1 << 14,
}; };
//------------- Inputs to parsing and scope analysis ----------------------- //------------- Inputs to parsing and scope analysis -----------------------
...@@ -283,7 +307,9 @@ class V8_EXPORT_PRIVATE ParseInfo { ...@@ -283,7 +307,9 @@ class V8_EXPORT_PRIVATE ParseInfo {
ScriptData** cached_data_; // used if available, populated if requested. ScriptData** cached_data_; // used if available, populated if requested.
PreParsedScopeData preparsed_scope_data_; PreParsedScopeData preparsed_scope_data_;
AstValueFactory* ast_value_factory_; // used if available, otherwise new. AstValueFactory* ast_value_factory_; // used if available, otherwise new.
const class AstStringConstants* ast_string_constants_;
const AstRawString* function_name_; const AstRawString* function_name_;
RuntimeCallStats* runtime_call_stats_;
//----------- Output of parsing and scope analysis ------------------------ //----------- Output of parsing and scope analysis ------------------------
FunctionLiteral* literal_; FunctionLiteral* literal_;
......
...@@ -503,8 +503,7 @@ Expression* Parser::NewV8Intrinsic(const AstRawString* name, ...@@ -503,8 +503,7 @@ Expression* Parser::NewV8Intrinsic(const AstRawString* name,
Parser::Parser(ParseInfo* info) Parser::Parser(ParseInfo* info)
: ParserBase<Parser>(info->zone(), &scanner_, info->stack_limit(), : ParserBase<Parser>(info->zone(), &scanner_, info->stack_limit(),
info->extension(), info->ast_value_factory(), info->extension(), info->ast_value_factory(),
info->isolate()->counters()->runtime_call_stats(), info->runtime_call_stats(), true),
true),
scanner_(info->unicode_cache()), scanner_(info->unicode_cache()),
reusable_preparser_(nullptr), reusable_preparser_(nullptr),
mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly.
...@@ -542,7 +541,7 @@ Parser::Parser(ParseInfo* info) ...@@ -542,7 +541,7 @@ Parser::Parser(ParseInfo* info)
info->extension() == nullptr && can_compile_lazily; info->extension() == nullptr && can_compile_lazily;
set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() &&
info->isolate()->is_tail_call_elimination_enabled()); info->is_tail_call_elimination_enabled());
set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); set_allow_harmony_do_expressions(FLAG_harmony_do_expressions);
set_allow_harmony_function_sent(FLAG_harmony_function_sent); set_allow_harmony_function_sent(FLAG_harmony_function_sent);
set_allow_harmony_restrictive_generators(FLAG_harmony_restrictive_generators); set_allow_harmony_restrictive_generators(FLAG_harmony_restrictive_generators);
...@@ -559,7 +558,7 @@ Parser::Parser(ParseInfo* info) ...@@ -559,7 +558,7 @@ Parser::Parser(ParseInfo* info)
if (info->ast_value_factory() == NULL) { if (info->ast_value_factory() == NULL) {
// info takes ownership of AstValueFactory. // info takes ownership of AstValueFactory.
info->set_ast_value_factory(new AstValueFactory( info->set_ast_value_factory(new AstValueFactory(
zone(), info->isolate()->ast_string_constants(), info->hash_seed())); zone(), info->ast_string_constants(), info->hash_seed()));
info->set_ast_value_factory_owned(); info->set_ast_value_factory_owned();
ast_value_factory_ = info->ast_value_factory(); ast_value_factory_ = info->ast_value_factory();
ast_node_factory_.set_ast_value_factory(ast_value_factory_); ast_node_factory_.set_ast_value_factory(ast_value_factory_);
......
...@@ -358,7 +358,8 @@ bool Rewriter::Rewrite(ParseInfo* info) { ...@@ -358,7 +358,8 @@ bool Rewriter::Rewrite(ParseInfo* info) {
DisallowHandleDereference no_deref; DisallowHandleDereference no_deref;
RuntimeCallTimerScope runtimeTimer( RuntimeCallTimerScope runtimeTimer(
info->isolate(), &RuntimeCallStats::CompileRewriteReturnResult); info->runtime_call_stats(),
&RuntimeCallStats::CompileRewriteReturnResult);
FunctionLiteral* function = info->literal(); FunctionLiteral* function = info->literal();
DCHECK_NOT_NULL(function); DCHECK_NOT_NULL(function);
...@@ -376,9 +377,8 @@ bool Rewriter::Rewrite(ParseInfo* info) { ...@@ -376,9 +377,8 @@ bool Rewriter::Rewrite(ParseInfo* info) {
if (!body->is_empty()) { if (!body->is_empty()) {
Variable* result = scope->AsDeclarationScope()->NewTemporary( Variable* result = scope->AsDeclarationScope()->NewTemporary(
info->ast_value_factory()->dot_result_string()); info->ast_value_factory()->dot_result_string());
Processor processor(info->isolate()->stack_guard()->real_climit(), Processor processor(info->stack_limit(), scope->AsDeclarationScope(),
scope->AsDeclarationScope(), result, result, info->ast_value_factory());
info->ast_value_factory());
processor.Process(body); processor.Process(body);
DCHECK_IMPLIES(scope->is_module_scope(), processor.result_assigned()); DCHECK_IMPLIES(scope->is_module_scope(), processor.result_assigned());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment