OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 frame_->Enter(); | 167 frame_->Enter(); |
168 | 168 |
169 // Allocate space for locals and initialize them. | 169 // Allocate space for locals and initialize them. |
170 frame_->AllocateStackSlots(); | 170 frame_->AllocateStackSlots(); |
171 // Initialize the function return target after the locals are set | 171 // Initialize the function return target after the locals are set |
172 // up, because it needs the expected frame height from the frame. | 172 // up, because it needs the expected frame height from the frame. |
173 function_return_.set_direction(JumpTarget::BIDIRECTIONAL); | 173 function_return_.set_direction(JumpTarget::BIDIRECTIONAL); |
174 function_return_is_shadowed_ = false; | 174 function_return_is_shadowed_ = false; |
175 | 175 |
176 // Allocate the local context if needed. | 176 // Allocate the local context if needed. |
177 int heap_slots = scope_->num_heap_slots(); | 177 int heap_slots = scope_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
178 if (heap_slots > 0) { | 178 if (heap_slots > 0) { |
179 Comment cmnt(masm_, "[ allocate local context"); | 179 Comment cmnt(masm_, "[ allocate local context"); |
180 // Allocate local context. | 180 // Allocate local context. |
181 // Get outer context and create a new context based on it. | 181 // Get outer context and create a new context based on it. |
182 frame_->PushFunction(); | 182 frame_->PushFunction(); |
183 Result context; | 183 Result context; |
184 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 184 if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
185 FastNewContextStub stub(heap_slots); | 185 FastNewContextStub stub(heap_slots); |
186 context = frame_->CallStub(&stub, 1); | 186 context = frame_->CallStub(&stub, 1); |
187 } else { | 187 } else { |
(...skipping 6546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6734 __ mov(FieldOperand(eax, HeapObject::kMapOffset), Factory::context_map()); | 6734 __ mov(FieldOperand(eax, HeapObject::kMapOffset), Factory::context_map()); |
6735 __ mov(FieldOperand(eax, Array::kLengthOffset), Immediate(length)); | 6735 __ mov(FieldOperand(eax, Array::kLengthOffset), Immediate(length)); |
6736 | 6736 |
6737 // Setup the fixed slots. | 6737 // Setup the fixed slots. |
6738 __ xor_(ebx, Operand(ebx)); // Set to NULL. | 6738 __ xor_(ebx, Operand(ebx)); // Set to NULL. |
6739 __ mov(Operand(eax, Context::SlotOffset(Context::CLOSURE_INDEX)), ecx); | 6739 __ mov(Operand(eax, Context::SlotOffset(Context::CLOSURE_INDEX)), ecx); |
6740 __ mov(Operand(eax, Context::SlotOffset(Context::FCONTEXT_INDEX)), eax); | 6740 __ mov(Operand(eax, Context::SlotOffset(Context::FCONTEXT_INDEX)), eax); |
6741 __ mov(Operand(eax, Context::SlotOffset(Context::PREVIOUS_INDEX)), ebx); | 6741 __ mov(Operand(eax, Context::SlotOffset(Context::PREVIOUS_INDEX)), ebx); |
6742 __ mov(Operand(eax, Context::SlotOffset(Context::EXTENSION_INDEX)), ebx); | 6742 __ mov(Operand(eax, Context::SlotOffset(Context::EXTENSION_INDEX)), ebx); |
6743 | 6743 |
6744 // Copy the global object from the surrounding context. | 6744 // Copy the global object from the surrounding context. We go through the |
6745 __ mov(ebx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 6745 // context in the function (ecx) to match the allocation behavior we have |
| 6746 // in the runtime system (see Heap::AllocateFunctionContext). |
| 6747 __ mov(ebx, FieldOperand(ecx, JSFunction::kContextOffset)); |
| 6748 __ mov(ebx, Operand(ebx, Context::SlotOffset(Context::GLOBAL_INDEX))); |
6746 __ mov(Operand(eax, Context::SlotOffset(Context::GLOBAL_INDEX)), ebx); | 6749 __ mov(Operand(eax, Context::SlotOffset(Context::GLOBAL_INDEX)), ebx); |
6747 | 6750 |
6748 // Initialize the rest of the slots to undefined. | 6751 // Initialize the rest of the slots to undefined. |
6749 __ mov(ebx, Factory::undefined_value()); | 6752 __ mov(ebx, Factory::undefined_value()); |
6750 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { | 6753 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { |
6751 __ mov(Operand(eax, Context::SlotOffset(i)), ebx); | 6754 __ mov(Operand(eax, Context::SlotOffset(i)), ebx); |
6752 } | 6755 } |
6753 | 6756 |
6754 // Return and remove the on-stack parameter. | 6757 // Return and remove the on-stack parameter. |
6755 __ mov(esi, Operand(eax)); | 6758 __ mov(esi, Operand(eax)); |
(...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8797 __ add(Operand(dest), Immediate(2)); | 8800 __ add(Operand(dest), Immediate(2)); |
8798 } | 8801 } |
8799 __ sub(Operand(count), Immediate(1)); | 8802 __ sub(Operand(count), Immediate(1)); |
8800 __ j(not_zero, &loop); | 8803 __ j(not_zero, &loop); |
8801 } | 8804 } |
8802 | 8805 |
8803 | 8806 |
8804 #undef __ | 8807 #undef __ |
8805 | 8808 |
8806 } } // namespace v8::internal | 8809 } } // namespace v8::internal |
OLD | NEW |