OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 void FullCodeGenerator::VisitBlock(Block* stmt) { | 811 void FullCodeGenerator::VisitBlock(Block* stmt) { |
812 Comment cmnt(masm_, "[ Block"); | 812 Comment cmnt(masm_, "[ Block"); |
813 NestedBlock nested_block(this, stmt); | 813 NestedBlock nested_block(this, stmt); |
814 SetStatementPosition(stmt); | 814 SetStatementPosition(stmt); |
815 | 815 |
816 Scope* saved_scope = scope(); | 816 Scope* saved_scope = scope(); |
817 // Push a block context when entering a block with block scoped variables. | 817 // Push a block context when entering a block with block scoped variables. |
818 if (stmt->block_scope() != NULL) { | 818 if (stmt->block_scope() != NULL) { |
819 { Comment cmnt(masm_, "[ Extend block context"); | 819 { Comment cmnt(masm_, "[ Extend block context"); |
820 scope_ = stmt->block_scope(); | 820 scope_ = stmt->block_scope(); |
821 __ Push(scope_->GetSerializedScopeInfo()); | 821 Handle<SerializedScopeInfo> scope_info = scope_->GetSerializedScopeInfo(); |
| 822 int heap_slots = |
| 823 scope_info->NumberOfContextSlots() - Context::MIN_CONTEXT_SLOTS; |
| 824 __ Push(scope_info); |
822 PushFunctionArgumentForContextAllocation(); | 825 PushFunctionArgumentForContextAllocation(); |
823 __ CallRuntime(Runtime::kPushBlockContext, 2); | 826 if (heap_slots <= FastNewBlockContextStub::kMaximumSlots) { |
| 827 FastNewBlockContextStub stub(heap_slots); |
| 828 __ CallStub(&stub); |
| 829 } else { |
| 830 __ CallRuntime(Runtime::kPushBlockContext, 2); |
| 831 } |
| 832 |
| 833 // Replace the context stored in the frame. |
824 StoreToFrameField(StandardFrameConstants::kContextOffset, | 834 StoreToFrameField(StandardFrameConstants::kContextOffset, |
825 context_register()); | 835 context_register()); |
826 } | 836 } |
827 { Comment cmnt(masm_, "[ Declarations"); | 837 { Comment cmnt(masm_, "[ Declarations"); |
828 VisitDeclarations(scope_->declarations()); | 838 VisitDeclarations(scope_->declarations()); |
829 } | 839 } |
830 } | 840 } |
831 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 841 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); |
832 VisitStatements(stmt->statements()); | 842 VisitStatements(stmt->statements()); |
833 scope_ = saved_scope; | 843 scope_ = saved_scope; |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 } | 1345 } |
1336 | 1346 |
1337 return false; | 1347 return false; |
1338 } | 1348 } |
1339 | 1349 |
1340 | 1350 |
1341 #undef __ | 1351 #undef __ |
1342 | 1352 |
1343 | 1353 |
1344 } } // namespace v8::internal | 1354 } } // namespace v8::internal |
OLD | NEW |