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

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

Issue 936003002: Make AstGraphBuilder::function_context a SetOncePointer again. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-graph-builder-stack-overflow
Patch Set: Created 5 years, 10 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') | no next file » | 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/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info, 372 AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info,
373 JSGraph* jsgraph, LoopAssignmentAnalysis* loop) 373 JSGraph* jsgraph, LoopAssignmentAnalysis* loop)
374 : local_zone_(local_zone), 374 : local_zone_(local_zone),
375 info_(info), 375 info_(info),
376 jsgraph_(jsgraph), 376 jsgraph_(jsgraph),
377 environment_(nullptr), 377 environment_(nullptr),
378 ast_context_(nullptr), 378 ast_context_(nullptr),
379 globals_(0, local_zone), 379 globals_(0, local_zone),
380 execution_control_(nullptr), 380 execution_control_(nullptr),
381 execution_context_(nullptr), 381 execution_context_(nullptr),
382 function_context_(nullptr),
383 input_buffer_size_(0), 382 input_buffer_size_(0),
384 input_buffer_(nullptr), 383 input_buffer_(nullptr),
385 exit_control_(nullptr), 384 exit_control_(nullptr),
386 loop_assignment_analysis_(loop) { 385 loop_assignment_analysis_(loop) {
387 InitializeAstVisitor(info->isolate(), local_zone); 386 InitializeAstVisitor(info->isolate(), local_zone);
388 } 387 }
389 388
390 389
391 Node* AstGraphBuilder::GetFunctionClosure() { 390 Node* AstGraphBuilder::GetFunctionClosure() {
392 if (!function_closure_.is_set()) { 391 if (!function_closure_.is_set()) {
393 const Operator* op = 392 const Operator* op =
394 common()->Parameter(Linkage::kJSFunctionCallClosureParamIndex); 393 common()->Parameter(Linkage::kJSFunctionCallClosureParamIndex);
395 Node* node = NewNode(op, graph()->start()); 394 Node* node = NewNode(op, graph()->start());
396 function_closure_.set(node); 395 function_closure_.set(node);
397 } 396 }
398 return function_closure_.get(); 397 return function_closure_.get();
399 } 398 }
400 399
401 400
402 Node* AstGraphBuilder::GetFunctionContext() { 401 Node* AstGraphBuilder::GetFunctionContext() {
403 DCHECK(function_context_ != nullptr); 402 if (!function_context_.is_set()) {
404 return function_context_; 403 function_context_.set(NewOuterContextParam());
404 }
405 return function_context_.get();
405 } 406 }
406 407
407 408
408 Node* AstGraphBuilder::NewOuterContextParam() { 409 Node* AstGraphBuilder::NewOuterContextParam() {
409 // Parameter (arity + 1) is special for the outer context of the function 410 // Parameter (arity + 1) is special for the outer context of the function
410 const Operator* op = common()->Parameter(info()->num_parameters() + 1); 411 const Operator* op = common()->Parameter(info()->num_parameters() + 1);
411 return NewNode(op, graph()->start()); 412 return NewNode(op, graph()->start());
412 } 413 }
413 414
414 415
(...skipping 20 matching lines...) Expand all
435 Environment env(this, scope, graph()->start()); 436 Environment env(this, scope, graph()->start());
436 set_environment(&env); 437 set_environment(&env);
437 438
438 if (info()->is_osr()) { 439 if (info()->is_osr()) {
439 // Use OSR normal entry as the start of the top-level environment. 440 // Use OSR normal entry as the start of the top-level environment.
440 // It will be replaced with {Dead} after typing and optimizations. 441 // It will be replaced with {Dead} after typing and optimizations.
441 NewNode(common()->OsrNormalEntry()); 442 NewNode(common()->OsrNormalEntry());
442 } 443 }
443 444
444 // Initialize the incoming context. 445 // Initialize the incoming context.
445 function_context_ = NewOuterContextParam(); 446 Node* outer_context = GetFunctionContext();
446 ContextScope incoming(this, scope, function_context_); 447 ContextScope incoming(this, scope, outer_context);
447 448
448 // Build receiver check for sloppy mode if necessary. 449 // Build receiver check for sloppy mode if necessary.
449 // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC? 450 // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC?
450 Node* original_receiver = env.Lookup(scope->receiver()); 451 Node* original_receiver = env.Lookup(scope->receiver());
451 Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver); 452 Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver);
452 env.Bind(scope->receiver(), patched_receiver); 453 env.Bind(scope->receiver(), patched_receiver);
453 454
454 // Build function context only if there are context allocated variables. 455 // Build function context only if there are context allocated variables.
455 int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; 456 int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
456 if (heap_slots > 0) { 457 if (heap_slots > 0) {
457 // Push a new inner context scope for the function. 458 // Push a new inner context scope for the function.
458 Node* closure = GetFunctionClosure(); 459 Node* closure = GetFunctionClosure();
459 Node* inner_context = BuildLocalFunctionContext(function_context_, closure); 460 Node* inner_context = BuildLocalFunctionContext(outer_context, closure);
460 ContextScope top_context(this, scope, inner_context); 461 ContextScope top_context(this, scope, inner_context);
461 CreateGraphBody(); 462 CreateGraphBody();
462 } else { 463 } else {
463 // Simply use the outer function context in building the graph. 464 // Simply use the outer function context in building the graph.
464 CreateGraphBody(); 465 CreateGraphBody();
465 } 466 }
466 467
467 // Finish the basic structure of the graph. 468 // Finish the basic structure of the graph.
468 graph()->SetEnd(graph()->NewNode(common()->End(), exit_control())); 469 graph()->SetEnd(graph()->NewNode(common()->End(), exit_control()));
469 470
(...skipping 2733 matching lines...) Expand 10 before | Expand all | Expand 10 after
3203 // Phi does not exist yet, introduce one. 3204 // Phi does not exist yet, introduce one.
3204 value = NewPhi(inputs, value, control); 3205 value = NewPhi(inputs, value, control);
3205 value->ReplaceInput(inputs - 1, other); 3206 value->ReplaceInput(inputs - 1, other);
3206 } 3207 }
3207 return value; 3208 return value;
3208 } 3209 }
3209 3210
3210 } // namespace compiler 3211 } // namespace compiler
3211 } // namespace internal 3212 } // namespace internal
3212 } // namespace v8 3213 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698