| 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 4513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4524 DCHECK(!HasStackOverflow()); | 4524 DCHECK(!HasStackOverflow()); |
| 4525 DCHECK(current_block() != NULL); | 4525 DCHECK(current_block() != NULL); |
| 4526 DCHECK(current_block()->HasPredecessor()); | 4526 DCHECK(current_block()->HasPredecessor()); |
| 4527 | 4527 |
| 4528 Scope* outer_scope = scope(); | 4528 Scope* outer_scope = scope(); |
| 4529 Scope* scope = stmt->scope(); | 4529 Scope* scope = stmt->scope(); |
| 4530 BreakAndContinueInfo break_info(stmt, outer_scope); | 4530 BreakAndContinueInfo break_info(stmt, outer_scope); |
| 4531 | 4531 |
| 4532 { BreakAndContinueScope push(&break_info, this); | 4532 { BreakAndContinueScope push(&break_info, this); |
| 4533 if (scope != NULL) { | 4533 if (scope != NULL) { |
| 4534 // Load the function object. | 4534 if (scope->ContextLocalCount() > 0) { |
| 4535 Scope* declaration_scope = scope->DeclarationScope(); | 4535 // Load the function object. |
| 4536 HInstruction* function; | 4536 Scope* declaration_scope = scope->DeclarationScope(); |
| 4537 HValue* outer_context = environment()->context(); | 4537 HInstruction* function; |
| 4538 if (declaration_scope->is_script_scope() || | 4538 HValue* outer_context = environment()->context(); |
| 4539 declaration_scope->is_eval_scope()) { | 4539 if (declaration_scope->is_script_scope() || |
| 4540 function = new(zone()) HLoadContextSlot( | 4540 declaration_scope->is_eval_scope()) { |
| 4541 outer_context, Context::CLOSURE_INDEX, HLoadContextSlot::kNoCheck); | 4541 function = new(zone()) HLoadContextSlot( |
| 4542 } else { | 4542 outer_context, Context::CLOSURE_INDEX, HLoadContextSlot::kNoCheck)
; |
| 4543 function = New<HThisFunction>(); | 4543 } else { |
| 4544 function = New<HThisFunction>(); |
| 4545 } |
| 4546 AddInstruction(function); |
| 4547 // Allocate a block context and store it to the stack frame. |
| 4548 DCHECK(scope->GetScopeInfo()->ContextLength() > 0); |
| 4549 HInstruction* inner_context = Add<HAllocateBlockContext>( |
| 4550 outer_context, function, scope->GetScopeInfo()); |
| 4551 HInstruction* instr = Add<HStoreFrameContext>(inner_context); |
| 4552 environment()->BindContext(inner_context); |
| 4553 if (instr->HasObservableSideEffects()) { |
| 4554 AddSimulate(stmt->EntryId(), REMOVABLE_SIMULATE); |
| 4555 } |
| 4544 } | 4556 } |
| 4545 AddInstruction(function); | |
| 4546 // Allocate a block context and store it to the stack frame. | |
| 4547 HInstruction* inner_context = Add<HAllocateBlockContext>( | |
| 4548 outer_context, function, scope->GetScopeInfo()); | |
| 4549 HInstruction* instr = Add<HStoreFrameContext>(inner_context); | |
| 4550 set_scope(scope); | 4557 set_scope(scope); |
| 4551 environment()->BindContext(inner_context); | |
| 4552 if (instr->HasObservableSideEffects()) { | |
| 4553 AddSimulate(stmt->EntryId(), REMOVABLE_SIMULATE); | |
| 4554 } | |
| 4555 VisitDeclarations(scope->declarations()); | 4558 VisitDeclarations(scope->declarations()); |
| 4556 AddSimulate(stmt->DeclsId(), REMOVABLE_SIMULATE); | 4559 AddSimulate(stmt->DeclsId(), REMOVABLE_SIMULATE); |
| 4557 } | 4560 } |
| 4558 CHECK_BAILOUT(VisitStatements(stmt->statements())); | 4561 CHECK_BAILOUT(VisitStatements(stmt->statements())); |
| 4559 } | 4562 } |
| 4560 set_scope(outer_scope); | 4563 set_scope(outer_scope); |
| 4561 if (scope != NULL && current_block() != NULL) { | 4564 if (scope != NULL && current_block() != NULL && |
| 4565 scope->ContextLocalCount() > 0) { |
| 4562 HValue* inner_context = environment()->context(); | 4566 HValue* inner_context = environment()->context(); |
| 4563 HValue* outer_context = Add<HLoadNamedField>( | 4567 HValue* outer_context = Add<HLoadNamedField>( |
| 4564 inner_context, nullptr, | 4568 inner_context, nullptr, |
| 4565 HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX)); | 4569 HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX)); |
| 4566 | 4570 |
| 4567 HInstruction* instr = Add<HStoreFrameContext>(outer_context); | 4571 HInstruction* instr = Add<HStoreFrameContext>(outer_context); |
| 4568 environment()->BindContext(outer_context); | 4572 environment()->BindContext(outer_context); |
| 4569 if (instr->HasObservableSideEffects()) { | 4573 if (instr->HasObservableSideEffects()) { |
| 4570 AddSimulate(stmt->ExitId(), REMOVABLE_SIMULATE); | 4574 AddSimulate(stmt->ExitId(), REMOVABLE_SIMULATE); |
| 4571 } | 4575 } |
| (...skipping 8863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13435 if (ShouldProduceTraceOutput()) { | 13439 if (ShouldProduceTraceOutput()) { |
| 13436 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13440 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13437 } | 13441 } |
| 13438 | 13442 |
| 13439 #ifdef DEBUG | 13443 #ifdef DEBUG |
| 13440 graph_->Verify(false); // No full verify. | 13444 graph_->Verify(false); // No full verify. |
| 13441 #endif | 13445 #endif |
| 13442 } | 13446 } |
| 13443 | 13447 |
| 13444 } } // namespace v8::internal | 13448 } } // namespace v8::internal |
| OLD | NEW |