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 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 back_edges.pc(i)) != INTERRUPT); | 1807 back_edges.pc(i)) != INTERRUPT); |
1808 } | 1808 } |
1809 return true; | 1809 return true; |
1810 } | 1810 } |
1811 #endif // DEBUG | 1811 #endif // DEBUG |
1812 | 1812 |
1813 | 1813 |
1814 FullCodeGenerator::EnterBlockScopeIfNeeded::EnterBlockScopeIfNeeded( | 1814 FullCodeGenerator::EnterBlockScopeIfNeeded::EnterBlockScopeIfNeeded( |
1815 FullCodeGenerator* codegen, Scope* scope, BailoutId entry_id, | 1815 FullCodeGenerator* codegen, Scope* scope, BailoutId entry_id, |
1816 BailoutId declarations_id, BailoutId exit_id) | 1816 BailoutId declarations_id, BailoutId exit_id) |
1817 : codegen_(codegen), scope_(scope), exit_id_(exit_id) { | 1817 : codegen_(codegen), exit_id_(exit_id) { |
1818 saved_scope_ = codegen_->scope(); | 1818 saved_scope_ = codegen_->scope(); |
1819 | 1819 |
1820 if (scope == NULL) { | 1820 if (scope == NULL) { |
1821 codegen_->PrepareForBailoutForId(entry_id, NO_REGISTERS); | 1821 codegen_->PrepareForBailoutForId(entry_id, NO_REGISTERS); |
| 1822 needs_block_context_ = false; |
1822 } else { | 1823 } else { |
| 1824 needs_block_context_ = scope->ContextLocalCount() > 0; |
1823 codegen_->scope_ = scope; | 1825 codegen_->scope_ = scope; |
1824 { | 1826 { |
1825 Comment cmnt(masm(), "[ Extend block context"); | 1827 if (needs_block_context_) { |
1826 __ Push(scope->GetScopeInfo(codegen->isolate())); | 1828 Comment cmnt(masm(), "[ Extend block context"); |
1827 codegen_->PushFunctionArgumentForContextAllocation(); | 1829 __ Push(scope->GetScopeInfo(codegen->isolate())); |
1828 __ CallRuntime(Runtime::kPushBlockContext, 2); | 1830 codegen_->PushFunctionArgumentForContextAllocation(); |
| 1831 __ CallRuntime(Runtime::kPushBlockContext, 2); |
1829 | 1832 |
1830 // Replace the context stored in the frame. | 1833 // Replace the context stored in the frame. |
1831 codegen_->StoreToFrameField(StandardFrameConstants::kContextOffset, | 1834 codegen_->StoreToFrameField(StandardFrameConstants::kContextOffset, |
1832 codegen_->context_register()); | 1835 codegen_->context_register()); |
| 1836 } |
| 1837 CHECK_EQ(0, scope->num_stack_slots()); |
1833 codegen_->PrepareForBailoutForId(entry_id, NO_REGISTERS); | 1838 codegen_->PrepareForBailoutForId(entry_id, NO_REGISTERS); |
1834 } | 1839 } |
1835 { | 1840 { |
1836 Comment cmnt(masm(), "[ Declarations"); | 1841 Comment cmnt(masm(), "[ Declarations"); |
1837 codegen_->VisitDeclarations(scope->declarations()); | 1842 codegen_->VisitDeclarations(scope->declarations()); |
1838 codegen_->PrepareForBailoutForId(declarations_id, NO_REGISTERS); | 1843 codegen_->PrepareForBailoutForId(declarations_id, NO_REGISTERS); |
1839 } | 1844 } |
1840 } | 1845 } |
1841 } | 1846 } |
1842 | 1847 |
1843 | 1848 |
1844 FullCodeGenerator::EnterBlockScopeIfNeeded::~EnterBlockScopeIfNeeded() { | 1849 FullCodeGenerator::EnterBlockScopeIfNeeded::~EnterBlockScopeIfNeeded() { |
1845 if (scope_ != NULL) { | 1850 if (needs_block_context_) { |
1846 codegen_->LoadContextField(codegen_->context_register(), | 1851 codegen_->LoadContextField(codegen_->context_register(), |
1847 Context::PREVIOUS_INDEX); | 1852 Context::PREVIOUS_INDEX); |
1848 // Update local stack frame context field. | 1853 // Update local stack frame context field. |
1849 codegen_->StoreToFrameField(StandardFrameConstants::kContextOffset, | 1854 codegen_->StoreToFrameField(StandardFrameConstants::kContextOffset, |
1850 codegen_->context_register()); | 1855 codegen_->context_register()); |
1851 } | 1856 } |
1852 codegen_->PrepareForBailoutForId(exit_id_, NO_REGISTERS); | 1857 codegen_->PrepareForBailoutForId(exit_id_, NO_REGISTERS); |
1853 codegen_->scope_ = saved_scope_; | 1858 codegen_->scope_ = saved_scope_; |
1854 } | 1859 } |
1855 | 1860 |
1856 | 1861 |
1857 #undef __ | 1862 #undef __ |
1858 | 1863 |
1859 | 1864 |
1860 } } // namespace v8::internal | 1865 } } // namespace v8::internal |
OLD | NEW |