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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1380113002: [turbofan] Call FastNewContextStub for function context. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comment. Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/js-operator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } 528 }
529 529
530 // Build receiver check for sloppy mode if necessary. 530 // Build receiver check for sloppy mode if necessary.
531 // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC? 531 // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC?
532 if (scope->has_this_declaration()) { 532 if (scope->has_this_declaration()) {
533 Node* original_receiver = env.RawParameterLookup(0); 533 Node* original_receiver = env.RawParameterLookup(0);
534 Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver); 534 Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver);
535 env.RawParameterBind(0, patched_receiver); 535 env.RawParameterBind(0, patched_receiver);
536 } 536 }
537 537
538 // Build function context only if there are context allocated variables. 538 // Build local context only if there are context allocated variables.
539 if (info()->num_heap_slots() > 0) { 539 if (info()->num_heap_slots() > 0) {
540 // Push a new inner context scope for the function. 540 // Push a new inner context scope for the current activation.
541 Node* inner_context = BuildLocalFunctionContext(GetFunctionContext()); 541 Node* inner_context = BuildLocalActivationContext(GetFunctionContext());
542 ContextScope top_context(this, scope, inner_context); 542 ContextScope top_context(this, scope, inner_context);
543 CreateGraphBody(stack_check); 543 CreateGraphBody(stack_check);
544 } else { 544 } else {
545 // Simply use the outer function context in building the graph. 545 // Simply use the outer function context in building the graph.
546 CreateGraphBody(stack_check); 546 CreateGraphBody(stack_check);
547 } 547 }
548 548
549 // Finish the basic structure of the graph. 549 // Finish the basic structure of the graph.
550 DCHECK_NE(0u, exit_controls_.size()); 550 DCHECK_NE(0u, exit_controls_.size());
551 int const input_count = static_cast<int>(exit_controls_.size()); 551 int const input_count = static_cast<int>(exit_controls_.size());
(...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after
3086 receiver_check.Else(); 3086 receiver_check.Else();
3087 environment()->Push(receiver); 3087 environment()->Push(receiver);
3088 receiver_check.End(); 3088 receiver_check.End();
3089 return environment()->Pop(); 3089 return environment()->Pop();
3090 } else { 3090 } else {
3091 return receiver; 3091 return receiver;
3092 } 3092 }
3093 } 3093 }
3094 3094
3095 3095
3096 Node* AstGraphBuilder::BuildLocalFunctionContext(Node* context) { 3096 Node* AstGraphBuilder::BuildLocalActivationContext(Node* context) {
3097 Scope* scope = info()->scope(); 3097 Scope* scope = info()->scope();
3098 Node* closure = GetFunctionClosure();
3099 3098
3100 // Allocate a new local context. 3099 // Allocate a new local context.
3101 Node* local_context = 3100 Node* local_context = scope->is_script_scope()
3102 scope->is_script_scope() 3101 ? BuildLocalScriptContext(scope)
3103 ? BuildLocalScriptContext(scope) 3102 : BuildLocalFunctionContext(scope);
3104 : NewNode(javascript()->CreateFunctionContext(), closure);
3105 3103
3106 if (scope->has_this_declaration() && scope->receiver()->IsContextSlot()) { 3104 if (scope->has_this_declaration() && scope->receiver()->IsContextSlot()) {
3107 Node* receiver = environment()->RawParameterLookup(0); 3105 Node* receiver = environment()->RawParameterLookup(0);
3108 // Context variable (at bottom of the context chain). 3106 // Context variable (at bottom of the context chain).
3109 Variable* variable = scope->receiver(); 3107 Variable* variable = scope->receiver();
3110 DCHECK_EQ(0, scope->ContextChainLength(variable->scope())); 3108 DCHECK_EQ(0, scope->ContextChainLength(variable->scope()));
3111 const Operator* op = javascript()->StoreContext(0, variable->index()); 3109 const Operator* op = javascript()->StoreContext(0, variable->index());
3112 NewNode(op, local_context, receiver); 3110 NewNode(op, local_context, receiver);
3113 } 3111 }
3114 3112
3115 // Copy parameters into context if necessary. 3113 // Copy parameters into context if necessary.
3116 int num_parameters = scope->num_parameters(); 3114 int num_parameters = scope->num_parameters();
3117 for (int i = 0; i < num_parameters; i++) { 3115 for (int i = 0; i < num_parameters; i++) {
3118 Variable* variable = scope->parameter(i); 3116 Variable* variable = scope->parameter(i);
3119 if (!variable->IsContextSlot()) continue; 3117 if (!variable->IsContextSlot()) continue;
3120 Node* parameter = environment()->RawParameterLookup(i + 1); 3118 Node* parameter = environment()->RawParameterLookup(i + 1);
3121 // Context variable (at bottom of the context chain). 3119 // Context variable (at bottom of the context chain).
3122 DCHECK_EQ(0, scope->ContextChainLength(variable->scope())); 3120 DCHECK_EQ(0, scope->ContextChainLength(variable->scope()));
3123 const Operator* op = javascript()->StoreContext(0, variable->index()); 3121 const Operator* op = javascript()->StoreContext(0, variable->index());
3124 NewNode(op, local_context, parameter); 3122 NewNode(op, local_context, parameter);
3125 } 3123 }
3126 3124
3127 return local_context; 3125 return local_context;
3128 } 3126 }
3129 3127
3130 3128
3129 Node* AstGraphBuilder::BuildLocalFunctionContext(Scope* scope) {
3130 DCHECK(scope->is_function_scope());
3131
3132 // Allocate a new local context.
3133 int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
3134 const Operator* op = javascript()->CreateFunctionContext(slot_count);
3135 Node* local_context = NewNode(op, GetFunctionClosure());
3136
3137 return local_context;
3138 }
3139
3140
3131 Node* AstGraphBuilder::BuildLocalScriptContext(Scope* scope) { 3141 Node* AstGraphBuilder::BuildLocalScriptContext(Scope* scope) {
3132 DCHECK(scope->is_script_scope()); 3142 DCHECK(scope->is_script_scope());
3133 3143
3134 // Allocate a new local context. 3144 // Allocate a new local context.
3135 Handle<ScopeInfo> scope_info = scope->GetScopeInfo(isolate()); 3145 Handle<ScopeInfo> scope_info = scope->GetScopeInfo(isolate());
3136 const Operator* op = javascript()->CreateScriptContext(scope_info); 3146 const Operator* op = javascript()->CreateScriptContext(scope_info);
3137 Node* local_context = NewNode(op, GetFunctionClosure()); 3147 Node* local_context = NewNode(op, GetFunctionClosure());
3138 PrepareFrameState(local_context, BailoutId::Prologue()); 3148 PrepareFrameState(local_context, BailoutId::Prologue());
3139 3149
3140 return local_context; 3150 return local_context;
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4262 // Phi does not exist yet, introduce one. 4272 // Phi does not exist yet, introduce one.
4263 value = NewPhi(inputs, value, control); 4273 value = NewPhi(inputs, value, control);
4264 value->ReplaceInput(inputs - 1, other); 4274 value->ReplaceInput(inputs - 1, other);
4265 } 4275 }
4266 return value; 4276 return value;
4267 } 4277 }
4268 4278
4269 } // namespace compiler 4279 } // namespace compiler
4270 } // namespace internal 4280 } // namespace internal
4271 } // namespace v8 4281 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/js-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698