OLD | NEW |
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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 info_(info), | 433 info_(info), |
434 jsgraph_(jsgraph), | 434 jsgraph_(jsgraph), |
435 environment_(nullptr), | 435 environment_(nullptr), |
436 ast_context_(nullptr), | 436 ast_context_(nullptr), |
437 globals_(0, local_zone), | 437 globals_(0, local_zone), |
438 execution_control_(nullptr), | 438 execution_control_(nullptr), |
439 execution_context_(nullptr), | 439 execution_context_(nullptr), |
440 try_nesting_level_(0), | 440 try_nesting_level_(0), |
441 input_buffer_size_(0), | 441 input_buffer_size_(0), |
442 input_buffer_(nullptr), | 442 input_buffer_(nullptr), |
443 exit_control_(nullptr), | 443 exit_controls_(local_zone), |
444 loop_assignment_analysis_(loop), | 444 loop_assignment_analysis_(loop), |
445 state_values_cache_(jsgraph), | 445 state_values_cache_(jsgraph), |
446 liveness_analyzer_(static_cast<size_t>(info->scope()->num_stack_slots()), | 446 liveness_analyzer_(static_cast<size_t>(info->scope()->num_stack_slots()), |
447 local_zone), | 447 local_zone), |
448 js_type_feedback_(js_type_feedback) { | 448 js_type_feedback_(js_type_feedback) { |
449 InitializeAstVisitor(info->isolate(), local_zone); | 449 InitializeAstVisitor(info->isolate(), local_zone); |
450 } | 450 } |
451 | 451 |
452 | 452 |
453 Node* AstGraphBuilder::GetFunctionClosure() { | 453 Node* AstGraphBuilder::GetFunctionClosure() { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 Node* inner_context = | 528 Node* inner_context = |
529 BuildLocalFunctionContext(function_context_.get(), patched_receiver); | 529 BuildLocalFunctionContext(function_context_.get(), patched_receiver); |
530 ContextScope top_context(this, scope, inner_context); | 530 ContextScope top_context(this, scope, inner_context); |
531 CreateGraphBody(stack_check); | 531 CreateGraphBody(stack_check); |
532 } else { | 532 } else { |
533 // Simply use the outer function context in building the graph. | 533 // Simply use the outer function context in building the graph. |
534 CreateGraphBody(stack_check); | 534 CreateGraphBody(stack_check); |
535 } | 535 } |
536 | 536 |
537 // Finish the basic structure of the graph. | 537 // Finish the basic structure of the graph. |
538 graph()->SetEnd(graph()->NewNode(common()->End(), exit_control())); | 538 DCHECK_NE(0u, exit_controls_.size()); |
| 539 int const input_count = static_cast<int>(exit_controls_.size()); |
| 540 Node** const inputs = &exit_controls_.front(); |
| 541 Node* end = graph()->NewNode(common()->End(input_count), input_count, inputs); |
| 542 graph()->SetEnd(end); |
539 | 543 |
540 // Compute local variable liveness information and use it to relax | 544 // Compute local variable liveness information and use it to relax |
541 // frame states. | 545 // frame states. |
542 ClearNonLiveSlotsInFrameStates(); | 546 ClearNonLiveSlotsInFrameStates(); |
543 | 547 |
544 // Failures indicated by stack overflow. | 548 // Failures indicated by stack overflow. |
545 return !HasStackOverflow(); | 549 return !HasStackOverflow(); |
546 } | 550 } |
547 | 551 |
548 | 552 |
(...skipping 3005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3554 } | 3558 } |
3555 } | 3559 } |
3556 } | 3560 } |
3557 | 3561 |
3558 return result; | 3562 return result; |
3559 } | 3563 } |
3560 | 3564 |
3561 | 3565 |
3562 void AstGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { | 3566 void AstGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { |
3563 if (environment()->IsMarkedAsUnreachable()) return; | 3567 if (environment()->IsMarkedAsUnreachable()) return; |
3564 if (exit_control() != NULL) { | |
3565 exit = MergeControl(exit_control(), exit); | |
3566 } | |
3567 environment()->MarkAsUnreachable(); | 3568 environment()->MarkAsUnreachable(); |
3568 set_exit_control(exit); | 3569 exit_controls_.push_back(exit); |
3569 } | 3570 } |
3570 | 3571 |
3571 | 3572 |
3572 void AstGraphBuilder::Environment::Merge(Environment* other) { | 3573 void AstGraphBuilder::Environment::Merge(Environment* other) { |
3573 DCHECK(values_.size() == other->values_.size()); | 3574 DCHECK(values_.size() == other->values_.size()); |
3574 DCHECK(contexts_.size() == other->contexts_.size()); | 3575 DCHECK(contexts_.size() == other->contexts_.size()); |
3575 | 3576 |
3576 // Nothing to do if the other environment is dead. | 3577 // Nothing to do if the other environment is dead. |
3577 if (other->IsMarkedAsUnreachable()) return; | 3578 if (other->IsMarkedAsUnreachable()) return; |
3578 | 3579 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3767 // Phi does not exist yet, introduce one. | 3768 // Phi does not exist yet, introduce one. |
3768 value = NewPhi(inputs, value, control); | 3769 value = NewPhi(inputs, value, control); |
3769 value->ReplaceInput(inputs - 1, other); | 3770 value->ReplaceInput(inputs - 1, other); |
3770 } | 3771 } |
3771 return value; | 3772 return value; |
3772 } | 3773 } |
3773 | 3774 |
3774 } // namespace compiler | 3775 } // namespace compiler |
3775 } // namespace internal | 3776 } // namespace internal |
3776 } // namespace v8 | 3777 } // namespace v8 |
OLD | NEW |