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) {
void AstNumberingVisitor::VisitBlock(Block* node) {
IncrementNodeCount();
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());
VisitStatements(node->statements());
}
......@@ -582,6 +590,12 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
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())) {
// TODO(neis): We may want to allow Turbofan optimization here if
// --turbo-from-bytecode is set and we know that Ignition is used.
......
......@@ -3053,18 +3053,6 @@ void BytecodeGenerator::VisitRewritableExpression(RewritableExpression* expr) {
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() {
AccumulatorResultScope accumulator_execution_result(this);
Scope* scope = this->scope();
......@@ -3078,7 +3066,7 @@ void BytecodeGenerator::VisitNewLocalFunctionContext() {
builder()
->LoadAccumulatorWithRegister(Register::function_closure())
.StoreAccumulatorInRegister(closure)
.LoadLiteral(GetScopeInfo(scope, isolate()))
.LoadLiteral(scope->GetScopeInfo(isolate()))
.StoreAccumulatorInRegister(scope_info)
.CallRuntime(Runtime::kNewScriptContext, closure, 2);
} else {
......@@ -3126,7 +3114,7 @@ void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) {
Register closure = register_allocator()->NextConsecutiveRegister();
builder()
->LoadLiteral(GetScopeInfo(scope, isolate()))
->LoadLiteral(scope->GetScopeInfo(isolate()))
.StoreAccumulatorInRegister(scope_info);
VisitFunctionClosureForContext();
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