| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/ast.h" | 7 #include "src/ast.h" |
| 8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1775 back_edges.pc(i)) != INTERRUPT); | 1775 back_edges.pc(i)) != INTERRUPT); |
| 1776 } | 1776 } |
| 1777 return true; | 1777 return true; |
| 1778 } | 1778 } |
| 1779 #endif // DEBUG | 1779 #endif // DEBUG |
| 1780 | 1780 |
| 1781 | 1781 |
| 1782 FullCodeGenerator::EnterBlockScopeIfNeeded::EnterBlockScopeIfNeeded( | 1782 FullCodeGenerator::EnterBlockScopeIfNeeded::EnterBlockScopeIfNeeded( |
| 1783 FullCodeGenerator* codegen, Scope* scope, BailoutId entry_id, | 1783 FullCodeGenerator* codegen, Scope* scope, BailoutId entry_id, |
| 1784 BailoutId declarations_id, BailoutId exit_id) | 1784 BailoutId declarations_id, BailoutId exit_id) |
| 1785 : codegen_(codegen), scope_(scope), exit_id_(exit_id) { | 1785 : codegen_(codegen), exit_id_(exit_id) { |
| 1786 saved_scope_ = codegen_->scope(); | 1786 saved_scope_ = codegen_->scope(); |
| 1787 | 1787 |
| 1788 if (scope == NULL) { | 1788 if (scope == NULL) { |
| 1789 codegen_->PrepareForBailoutForId(entry_id, NO_REGISTERS); | 1789 codegen_->PrepareForBailoutForId(entry_id, NO_REGISTERS); |
| 1790 needs_block_context_ = false; |
| 1791 num_stack_slots_ = 0; |
| 1790 } else { | 1792 } else { |
| 1793 needs_block_context_ = scope->ContextLocalCount() > 0; |
| 1791 codegen_->scope_ = scope; | 1794 codegen_->scope_ = scope; |
| 1792 { | 1795 { |
| 1793 Comment cmnt(masm(), "[ Extend block context"); | 1796 Comment cmnt(masm(), "[ Extend block context"); |
| 1794 __ Push(scope->GetScopeInfo()); | |
| 1795 codegen_->PushFunctionArgumentForContextAllocation(); | |
| 1796 __ CallRuntime(Runtime::kPushBlockContext, 2); | |
| 1797 | 1797 |
| 1798 // Replace the context stored in the frame. | 1798 if (needs_block_context_) { |
| 1799 codegen_->StoreToFrameField(StandardFrameConstants::kContextOffset, | 1799 DCHECK(scope->GetScopeInfo()->ContextLength() > 0); |
| 1800 codegen_->context_register()); | 1800 __ Push(scope->GetScopeInfo()); |
| 1801 codegen_->PushFunctionArgumentForContextAllocation(); |
| 1802 __ CallRuntime(Runtime::kPushBlockContext, 2); |
| 1803 |
| 1804 // Replace the context stored in the frame. |
| 1805 codegen_->StoreToFrameField(StandardFrameConstants::kContextOffset, |
| 1806 codegen_->context_register()); |
| 1807 } |
| 1808 num_stack_slots_ = scope->num_stack_slots(); |
| 1809 codegen_->AllocateLocals(scope->num_stack_slots()); |
| 1801 codegen_->PrepareForBailoutForId(entry_id, NO_REGISTERS); | 1810 codegen_->PrepareForBailoutForId(entry_id, NO_REGISTERS); |
| 1802 } | 1811 } |
| 1803 { | 1812 { |
| 1804 Comment cmnt(masm(), "[ Declarations"); | 1813 Comment cmnt(masm(), "[ Declarations"); |
| 1805 codegen_->VisitDeclarations(scope->declarations()); | 1814 codegen_->VisitDeclarations(scope->declarations()); |
| 1806 codegen_->PrepareForBailoutForId(declarations_id, NO_REGISTERS); | 1815 codegen_->PrepareForBailoutForId(declarations_id, NO_REGISTERS); |
| 1807 } | 1816 } |
| 1808 } | 1817 } |
| 1809 } | 1818 } |
| 1810 | 1819 |
| 1811 | 1820 |
| 1812 FullCodeGenerator::EnterBlockScopeIfNeeded::~EnterBlockScopeIfNeeded() { | 1821 FullCodeGenerator::EnterBlockScopeIfNeeded::~EnterBlockScopeIfNeeded() { |
| 1813 if (scope_ != NULL) { | 1822 if (needs_block_context_) { |
| 1814 codegen_->LoadContextField(codegen_->context_register(), | 1823 codegen_->LoadContextField(codegen_->context_register(), |
| 1815 Context::PREVIOUS_INDEX); | 1824 Context::PREVIOUS_INDEX); |
| 1816 // Update local stack frame context field. | 1825 // Update local stack frame context field. |
| 1817 codegen_->StoreToFrameField(StandardFrameConstants::kContextOffset, | 1826 codegen_->StoreToFrameField(StandardFrameConstants::kContextOffset, |
| 1818 codegen_->context_register()); | 1827 codegen_->context_register()); |
| 1819 } | 1828 } |
| 1820 codegen_->PrepareForBailoutForId(exit_id_, NO_REGISTERS); | 1829 codegen_->PrepareForBailoutForId(exit_id_, NO_REGISTERS); |
| 1830 codegen_->DeallocateLocals(num_stack_slots_); |
| 1821 codegen_->scope_ = saved_scope_; | 1831 codegen_->scope_ = saved_scope_; |
| 1822 } | 1832 } |
| 1823 | 1833 |
| 1824 | 1834 |
| 1825 #undef __ | 1835 #undef __ |
| 1826 | 1836 |
| 1827 | 1837 |
| 1828 } } // namespace v8::internal | 1838 } } // namespace v8::internal |
| OLD | NEW |