| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
| 10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
| (...skipping 3551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3562 HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry() { | 3562 HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry() { |
| 3563 HBasicBlock* loop_entry = CreateLoopHeaderBlock(); | 3563 HBasicBlock* loop_entry = CreateLoopHeaderBlock(); |
| 3564 Goto(loop_entry); | 3564 Goto(loop_entry); |
| 3565 set_current_block(loop_entry); | 3565 set_current_block(loop_entry); |
| 3566 return loop_entry; | 3566 return loop_entry; |
| 3567 } | 3567 } |
| 3568 | 3568 |
| 3569 | 3569 |
| 3570 HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry( | 3570 HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry( |
| 3571 IterationStatement* statement) { | 3571 IterationStatement* statement) { |
| 3572 HBasicBlock* loop_entry = osr()->HasOsrEntryAt(statement) | 3572 HBasicBlock* loop_entry; |
| 3573 ? osr()->BuildOsrLoopEntry(statement) | 3573 |
| 3574 : BuildLoopEntry(); | 3574 if (osr()->HasOsrEntryAt(statement)) { |
| 3575 loop_entry = osr()->BuildOsrLoopEntry(statement); |
| 3576 if (function_state()->IsInsideDoExpressionScope()) { |
| 3577 Bailout(kDoExpressionUnmodelable); |
| 3578 } |
| 3579 } else { |
| 3580 loop_entry = BuildLoopEntry(); |
| 3581 } |
| 3575 return loop_entry; | 3582 return loop_entry; |
| 3576 } | 3583 } |
| 3577 | 3584 |
| 3578 | 3585 |
| 3579 void HBasicBlock::FinishExit(HControlInstruction* instruction, | 3586 void HBasicBlock::FinishExit(HControlInstruction* instruction, |
| 3580 SourcePosition position) { | 3587 SourcePosition position) { |
| 3581 Finish(instruction, position); | 3588 Finish(instruction, position); |
| 3582 ClearEnvironment(); | 3589 ClearEnvironment(); |
| 3583 } | 3590 } |
| 3584 | 3591 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4037 compilation_info_(info), | 4044 compilation_info_(info), |
| 4038 call_context_(NULL), | 4045 call_context_(NULL), |
| 4039 inlining_kind_(inlining_kind), | 4046 inlining_kind_(inlining_kind), |
| 4040 function_return_(NULL), | 4047 function_return_(NULL), |
| 4041 test_context_(NULL), | 4048 test_context_(NULL), |
| 4042 entry_(NULL), | 4049 entry_(NULL), |
| 4043 arguments_object_(NULL), | 4050 arguments_object_(NULL), |
| 4044 arguments_elements_(NULL), | 4051 arguments_elements_(NULL), |
| 4045 inlining_id_(inlining_id), | 4052 inlining_id_(inlining_id), |
| 4046 outer_source_position_(SourcePosition::Unknown()), | 4053 outer_source_position_(SourcePosition::Unknown()), |
| 4054 do_expression_scope_count_(0), |
| 4047 outer_(owner->function_state()) { | 4055 outer_(owner->function_state()) { |
| 4048 if (outer_ != NULL) { | 4056 if (outer_ != NULL) { |
| 4049 // State for an inline function. | 4057 // State for an inline function. |
| 4050 if (owner->ast_context()->IsTest()) { | 4058 if (owner->ast_context()->IsTest()) { |
| 4051 HBasicBlock* if_true = owner->graph()->CreateBasicBlock(); | 4059 HBasicBlock* if_true = owner->graph()->CreateBasicBlock(); |
| 4052 HBasicBlock* if_false = owner->graph()->CreateBasicBlock(); | 4060 HBasicBlock* if_false = owner->graph()->CreateBasicBlock(); |
| 4053 if_true->MarkAsInlineReturnTarget(owner->current_block()); | 4061 if_true->MarkAsInlineReturnTarget(owner->current_block()); |
| 4054 if_false->MarkAsInlineReturnTarget(owner->current_block()); | 4062 if_false->MarkAsInlineReturnTarget(owner->current_block()); |
| 4055 TestContext* outer_test_context = TestContext::cast(owner->ast_context()); | 4063 TestContext* outer_test_context = TestContext::cast(owner->ast_context()); |
| 4056 Expression* cond = outer_test_context->condition(); | 4064 Expression* cond = outer_test_context->condition(); |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4821 | 4829 |
| 4822 return block; | 4830 return block; |
| 4823 } | 4831 } |
| 4824 | 4832 |
| 4825 | 4833 |
| 4826 void HOptimizedGraphBuilder::VisitContinueStatement( | 4834 void HOptimizedGraphBuilder::VisitContinueStatement( |
| 4827 ContinueStatement* stmt) { | 4835 ContinueStatement* stmt) { |
| 4828 DCHECK(!HasStackOverflow()); | 4836 DCHECK(!HasStackOverflow()); |
| 4829 DCHECK(current_block() != NULL); | 4837 DCHECK(current_block() != NULL); |
| 4830 DCHECK(current_block()->HasPredecessor()); | 4838 DCHECK(current_block()->HasPredecessor()); |
| 4839 |
| 4840 if (function_state()->IsInsideDoExpressionScope()) { |
| 4841 return Bailout(kDoExpressionUnmodelable); |
| 4842 } |
| 4843 |
| 4831 Scope* outer_scope = NULL; | 4844 Scope* outer_scope = NULL; |
| 4832 Scope* inner_scope = scope(); | 4845 Scope* inner_scope = scope(); |
| 4833 int drop_extra = 0; | 4846 int drop_extra = 0; |
| 4834 HBasicBlock* continue_block = break_scope()->Get( | 4847 HBasicBlock* continue_block = break_scope()->Get( |
| 4835 stmt->target(), BreakAndContinueScope::CONTINUE, | 4848 stmt->target(), BreakAndContinueScope::CONTINUE, |
| 4836 &outer_scope, &drop_extra); | 4849 &outer_scope, &drop_extra); |
| 4837 HValue* context = environment()->context(); | 4850 HValue* context = environment()->context(); |
| 4838 Drop(drop_extra); | 4851 Drop(drop_extra); |
| 4839 int context_pop_count = inner_scope->ContextChainLength(outer_scope); | 4852 int context_pop_count = inner_scope->ContextChainLength(outer_scope); |
| 4840 if (context_pop_count > 0) { | 4853 if (context_pop_count > 0) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4853 | 4866 |
| 4854 Goto(continue_block); | 4867 Goto(continue_block); |
| 4855 set_current_block(NULL); | 4868 set_current_block(NULL); |
| 4856 } | 4869 } |
| 4857 | 4870 |
| 4858 | 4871 |
| 4859 void HOptimizedGraphBuilder::VisitBreakStatement(BreakStatement* stmt) { | 4872 void HOptimizedGraphBuilder::VisitBreakStatement(BreakStatement* stmt) { |
| 4860 DCHECK(!HasStackOverflow()); | 4873 DCHECK(!HasStackOverflow()); |
| 4861 DCHECK(current_block() != NULL); | 4874 DCHECK(current_block() != NULL); |
| 4862 DCHECK(current_block()->HasPredecessor()); | 4875 DCHECK(current_block()->HasPredecessor()); |
| 4876 |
| 4877 if (function_state()->IsInsideDoExpressionScope()) { |
| 4878 return Bailout(kDoExpressionUnmodelable); |
| 4879 } |
| 4880 |
| 4863 Scope* outer_scope = NULL; | 4881 Scope* outer_scope = NULL; |
| 4864 Scope* inner_scope = scope(); | 4882 Scope* inner_scope = scope(); |
| 4865 int drop_extra = 0; | 4883 int drop_extra = 0; |
| 4866 HBasicBlock* break_block = break_scope()->Get( | 4884 HBasicBlock* break_block = break_scope()->Get( |
| 4867 stmt->target(), BreakAndContinueScope::BREAK, | 4885 stmt->target(), BreakAndContinueScope::BREAK, |
| 4868 &outer_scope, &drop_extra); | 4886 &outer_scope, &drop_extra); |
| 4869 HValue* context = environment()->context(); | 4887 HValue* context = environment()->context(); |
| 4870 Drop(drop_extra); | 4888 Drop(drop_extra); |
| 4871 int context_pop_count = inner_scope->ContextChainLength(outer_scope); | 4889 int context_pop_count = inner_scope->ContextChainLength(outer_scope); |
| 4872 if (context_pop_count > 0) { | 4890 if (context_pop_count > 0) { |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5512 void HOptimizedGraphBuilder::VisitNativeFunctionLiteral( | 5530 void HOptimizedGraphBuilder::VisitNativeFunctionLiteral( |
| 5513 NativeFunctionLiteral* expr) { | 5531 NativeFunctionLiteral* expr) { |
| 5514 DCHECK(!HasStackOverflow()); | 5532 DCHECK(!HasStackOverflow()); |
| 5515 DCHECK(current_block() != NULL); | 5533 DCHECK(current_block() != NULL); |
| 5516 DCHECK(current_block()->HasPredecessor()); | 5534 DCHECK(current_block()->HasPredecessor()); |
| 5517 return Bailout(kNativeFunctionLiteral); | 5535 return Bailout(kNativeFunctionLiteral); |
| 5518 } | 5536 } |
| 5519 | 5537 |
| 5520 | 5538 |
| 5521 void HOptimizedGraphBuilder::VisitDoExpression(DoExpression* expr) { | 5539 void HOptimizedGraphBuilder::VisitDoExpression(DoExpression* expr) { |
| 5540 DoExpressionScope scope(this); |
| 5522 DCHECK(!HasStackOverflow()); | 5541 DCHECK(!HasStackOverflow()); |
| 5523 DCHECK(current_block() != NULL); | 5542 DCHECK(current_block() != NULL); |
| 5524 DCHECK(current_block()->HasPredecessor()); | 5543 DCHECK(current_block()->HasPredecessor()); |
| 5525 return Bailout(kDoExpression); | 5544 CHECK_ALIVE(VisitBlock(expr->block())); |
| 5545 Visit(expr->result()); |
| 5526 } | 5546 } |
| 5527 | 5547 |
| 5528 | 5548 |
| 5529 void HOptimizedGraphBuilder::VisitConditional(Conditional* expr) { | 5549 void HOptimizedGraphBuilder::VisitConditional(Conditional* expr) { |
| 5530 DCHECK(!HasStackOverflow()); | 5550 DCHECK(!HasStackOverflow()); |
| 5531 DCHECK(current_block() != NULL); | 5551 DCHECK(current_block() != NULL); |
| 5532 DCHECK(current_block()->HasPredecessor()); | 5552 DCHECK(current_block()->HasPredecessor()); |
| 5533 HBasicBlock* cond_true = graph()->CreateBasicBlock(); | 5553 HBasicBlock* cond_true = graph()->CreateBasicBlock(); |
| 5534 HBasicBlock* cond_false = graph()->CreateBasicBlock(); | 5554 HBasicBlock* cond_false = graph()->CreateBasicBlock(); |
| 5535 CHECK_BAILOUT(VisitForControl(expr->condition(), cond_true, cond_false)); | 5555 CHECK_BAILOUT(VisitForControl(expr->condition(), cond_true, cond_false)); |
| (...skipping 7934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13470 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13490 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13471 } | 13491 } |
| 13472 | 13492 |
| 13473 #ifdef DEBUG | 13493 #ifdef DEBUG |
| 13474 graph_->Verify(false); // No full verify. | 13494 graph_->Verify(false); // No full verify. |
| 13475 #endif | 13495 #endif |
| 13476 } | 13496 } |
| 13477 | 13497 |
| 13478 } // namespace internal | 13498 } // namespace internal |
| 13479 } // namespace v8 | 13499 } // namespace v8 |
| OLD | NEW |