Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 1053063003: Make --always-opt also optimize top-level code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Skip failing tests. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 18fb49135e1e8a5751f3a4ecab7ed812815f4429..306afb6c12b14b1fe1cc1735a03394ac24210e0b 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -476,9 +476,7 @@ bool AstGraphBuilder::CreateGraph(bool constant_context, bool stack_check) {
int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
if (heap_slots > 0) {
// Push a new inner context scope for the function.
- Node* closure = GetFunctionClosure();
- Node* inner_context =
- BuildLocalFunctionContext(function_context_.get(), closure);
+ Node* inner_context = BuildLocalFunctionContext(function_context_.get());
ContextScope top_context(this, scope, inner_context);
CreateGraphBody(stack_check);
} else {
@@ -2474,7 +2472,8 @@ void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) {
Node* flags = jsgraph()->Constant(encoded_flags);
Node* pairs = jsgraph()->Constant(data);
const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals, 3);
- NewNode(op, current_context(), pairs, flags);
+ Node* call = NewNode(op, current_context(), pairs, flags);
+ PrepareFrameState(call, BailoutId::Declarations());
globals()->clear();
}
@@ -2633,10 +2632,14 @@ Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) {
}
-Node* AstGraphBuilder::BuildLocalFunctionContext(Node* context, Node* closure) {
+Node* AstGraphBuilder::BuildLocalFunctionContext(Node* context) {
+ Node* closure = GetFunctionClosure();
+
// Allocate a new local context.
- const Operator* op = javascript()->CreateFunctionContext();
- Node* local_context = NewNode(op, closure);
+ Node* local_context =
+ info()->scope()->is_script_scope()
+ ? BuildLocalScriptContext(info()->scope())
+ : NewNode(javascript()->CreateFunctionContext(), closure);
// Copy parameters into context if necessary.
int num_parameters = info()->scope()->num_parameters();
@@ -2656,12 +2659,25 @@ Node* AstGraphBuilder::BuildLocalFunctionContext(Node* context, Node* closure) {
}
+Node* AstGraphBuilder::BuildLocalScriptContext(Scope* scope) {
+ Node* closure = GetFunctionClosure();
+
+ // Allocate a new local context.
+ const Operator* op = javascript()->CreateScriptContext();
+ Node* scope_info = jsgraph()->Constant(scope->GetScopeInfo(isolate()));
+ Node* local_context = NewNode(op, closure, scope_info);
+ PrepareFrameState(local_context, BailoutId::FunctionEntry());
+
+ return local_context;
+}
+
+
Node* AstGraphBuilder::BuildLocalBlockContext(Scope* scope) {
Node* closure = GetFunctionClosure();
// Allocate a new local context.
const Operator* op = javascript()->CreateBlockContext();
- Node* scope_info = jsgraph()->Constant(scope->GetScopeInfo(info_->isolate()));
+ Node* scope_info = jsgraph()->Constant(scope->GetScopeInfo(isolate()));
Node* local_context = NewNode(op, scope_info, closure);
return local_context;

Powered by Google App Engine
This is Rietveld 408576698