Commit 27a60a38 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter] Create ScopeInfos in ast-numbering phase.

Creates ScopeInfos during the ast-numbering phase so that they
are already created during bytecode generation so that they don't
need to be allocated during concurrent bytecode generation.

BUG=v8:5203

Review-Url: https://codereview.chromium.org/2223283002
Cr-Commit-Position: refs/heads/master@{#38542}
parent 417b3010
...@@ -243,6 +243,14 @@ void AstNumberingVisitor::VisitCountOperation(CountOperation* node) { ...@@ -243,6 +243,14 @@ void AstNumberingVisitor::VisitCountOperation(CountOperation* node) {
void AstNumberingVisitor::VisitBlock(Block* node) { void AstNumberingVisitor::VisitBlock(Block* node) {
IncrementNodeCount(); IncrementNodeCount();
node->set_base_id(ReserveIdRange(Block::num_ids())); node->set_base_id(ReserveIdRange(Block::num_ids()));
if (FLAG_ignition && node->scope() != nullptr &&
node->scope()->NeedsContext()) {
// Create ScopeInfo while on the main thread to avoid allocation during
// potentially concurrent bytecode generation.
node->scope()->GetScopeInfo(isolate_);
}
if (node->scope() != NULL) VisitDeclarations(node->scope()->declarations()); if (node->scope() != NULL) VisitDeclarations(node->scope()->declarations());
VisitStatements(node->statements()); VisitStatements(node->statements());
} }
...@@ -582,6 +590,12 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) { ...@@ -582,6 +590,12 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
DisableCrankshaft(kRestParameter); DisableCrankshaft(kRestParameter);
} }
if (FLAG_ignition && scope->NeedsContext() && scope->is_script_scope()) {
// Create ScopeInfo while on the main thread to avoid allocation during
// potentially concurrent bytecode generation.
node->scope()->GetScopeInfo(isolate_);
}
if (IsGeneratorFunction(node->kind()) || IsAsyncFunction(node->kind())) { if (IsGeneratorFunction(node->kind()) || IsAsyncFunction(node->kind())) {
// TODO(neis): We may want to allow Turbofan optimization here if // TODO(neis): We may want to allow Turbofan optimization here if
// --turbo-from-bytecode is set and we know that Ignition is used. // --turbo-from-bytecode is set and we know that Ignition is used.
......
...@@ -3053,18 +3053,6 @@ void BytecodeGenerator::VisitRewritableExpression(RewritableExpression* expr) { ...@@ -3053,18 +3053,6 @@ void BytecodeGenerator::VisitRewritableExpression(RewritableExpression* expr) {
Visit(expr->expression()); Visit(expr->expression());
} }
namespace {
Handle<ScopeInfo> GetScopeInfo(Scope* scope, Isolate* isolate) {
// TODO(5203): Remove this temporary exception.
AllowHeapAllocation allow_allocation;
AllowHandleAllocation allow_handles;
AllowHandleDereference allow_deref;
return scope->GetScopeInfo(isolate);
}
} // namespace
void BytecodeGenerator::VisitNewLocalFunctionContext() { void BytecodeGenerator::VisitNewLocalFunctionContext() {
AccumulatorResultScope accumulator_execution_result(this); AccumulatorResultScope accumulator_execution_result(this);
Scope* scope = this->scope(); Scope* scope = this->scope();
...@@ -3078,7 +3066,7 @@ void BytecodeGenerator::VisitNewLocalFunctionContext() { ...@@ -3078,7 +3066,7 @@ void BytecodeGenerator::VisitNewLocalFunctionContext() {
builder() builder()
->LoadAccumulatorWithRegister(Register::function_closure()) ->LoadAccumulatorWithRegister(Register::function_closure())
.StoreAccumulatorInRegister(closure) .StoreAccumulatorInRegister(closure)
.LoadLiteral(GetScopeInfo(scope, isolate())) .LoadLiteral(scope->GetScopeInfo(isolate()))
.StoreAccumulatorInRegister(scope_info) .StoreAccumulatorInRegister(scope_info)
.CallRuntime(Runtime::kNewScriptContext, closure, 2); .CallRuntime(Runtime::kNewScriptContext, closure, 2);
} else { } else {
...@@ -3126,7 +3114,7 @@ void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) { ...@@ -3126,7 +3114,7 @@ void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) {
Register closure = register_allocator()->NextConsecutiveRegister(); Register closure = register_allocator()->NextConsecutiveRegister();
builder() builder()
->LoadLiteral(GetScopeInfo(scope, isolate())) ->LoadLiteral(scope->GetScopeInfo(isolate()))
.StoreAccumulatorInRegister(scope_info); .StoreAccumulatorInRegister(scope_info);
VisitFunctionClosureForContext(); VisitFunctionClosureForContext();
builder() builder()
......
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