| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 Label gc; | 122 Label gc; |
| 123 int length = slots_ + Context::MIN_CONTEXT_SLOTS; | 123 int length = slots_ + Context::MIN_CONTEXT_SLOTS; |
| 124 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize, | 124 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize, |
| 125 eax, ebx, ecx, &gc, TAG_OBJECT); | 125 eax, ebx, ecx, &gc, TAG_OBJECT); |
| 126 | 126 |
| 127 // Get the function from the stack. | 127 // Get the function from the stack. |
| 128 __ mov(ecx, Operand(esp, 1 * kPointerSize)); | 128 __ mov(ecx, Operand(esp, 1 * kPointerSize)); |
| 129 | 129 |
| 130 // Setup the object header. | 130 // Setup the object header. |
| 131 Factory* factory = masm->isolate()->factory(); | 131 Factory* factory = masm->isolate()->factory(); |
| 132 __ mov(FieldOperand(eax, HeapObject::kMapOffset), factory->context_map()); | 132 __ mov(FieldOperand(eax, HeapObject::kMapOffset), |
| 133 factory->function_context_map()); |
| 133 __ mov(FieldOperand(eax, Context::kLengthOffset), | 134 __ mov(FieldOperand(eax, Context::kLengthOffset), |
| 134 Immediate(Smi::FromInt(length))); | 135 Immediate(Smi::FromInt(length))); |
| 135 | 136 |
| 136 // Setup the fixed slots. | 137 // Setup the fixed slots. |
| 137 __ Set(ebx, Immediate(0)); // Set to NULL. | 138 __ Set(ebx, Immediate(0)); // Set to NULL. |
| 138 __ mov(Operand(eax, Context::SlotOffset(Context::CLOSURE_INDEX)), ecx); | 139 __ mov(Operand(eax, Context::SlotOffset(Context::CLOSURE_INDEX)), ecx); |
| 139 __ mov(Operand(eax, Context::SlotOffset(Context::FCONTEXT_INDEX)), eax); | 140 __ mov(Operand(eax, Context::SlotOffset(Context::FCONTEXT_INDEX)), eax); |
| 140 __ mov(Operand(eax, Context::SlotOffset(Context::PREVIOUS_INDEX)), ebx); | 141 __ mov(Operand(eax, Context::SlotOffset(Context::PREVIOUS_INDEX)), ebx); |
| 141 __ mov(Operand(eax, Context::SlotOffset(Context::EXTENSION_INDEX)), ebx); | 142 __ mov(Operand(eax, Context::SlotOffset(Context::EXTENSION_INDEX)), ebx); |
| 142 | 143 |
| 143 // Copy the global object from the surrounding context. We go through the | 144 // Copy the global object from the surrounding context. We go through the |
| 144 // context in the function (ecx) to match the allocation behavior we have | 145 // context in the function (ecx) to match the allocation behavior we have |
| 145 // in the runtime system (see Heap::AllocateFunctionContext). | 146 // in the runtime system (see Heap::AllocateFunctionContext). |
| 146 __ mov(ebx, FieldOperand(ecx, JSFunction::kContextOffset)); | 147 __ mov(ebx, FieldOperand(ecx, JSFunction::kContextOffset)); |
| 147 __ mov(ebx, Operand(ebx, Context::SlotOffset(Context::GLOBAL_INDEX))); | 148 __ mov(ebx, Operand(ebx, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 148 __ mov(Operand(eax, Context::SlotOffset(Context::GLOBAL_INDEX)), ebx); | 149 __ mov(Operand(eax, Context::SlotOffset(Context::GLOBAL_INDEX)), ebx); |
| 149 | 150 |
| 150 // Initialize the rest of the slots to undefined. | 151 // Initialize the rest of the slots to undefined. |
| 151 __ mov(ebx, factory->undefined_value()); | 152 __ mov(ebx, factory->undefined_value()); |
| 152 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { | 153 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { |
| 153 __ mov(Operand(eax, Context::SlotOffset(i)), ebx); | 154 __ mov(Operand(eax, Context::SlotOffset(i)), ebx); |
| 154 } | 155 } |
| 155 | 156 |
| 156 // Return and remove the on-stack parameter. | 157 // Return and remove the on-stack parameter. |
| 157 __ mov(esi, Operand(eax)); | 158 __ mov(esi, Operand(eax)); |
| 158 __ ret(1 * kPointerSize); | 159 __ ret(1 * kPointerSize); |
| 159 | 160 |
| 160 // Need to collect. Call into runtime system. | 161 // Need to collect. Call into runtime system. |
| 161 __ bind(&gc); | 162 __ bind(&gc); |
| 162 __ TailCallRuntime(Runtime::kNewContext, 1, 1); | 163 __ TailCallRuntime(Runtime::kNewFunctionContext, 1, 1); |
| 163 } | 164 } |
| 164 | 165 |
| 165 | 166 |
| 166 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { | 167 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { |
| 167 // Stack layout on entry: | 168 // Stack layout on entry: |
| 168 // | 169 // |
| 169 // [esp + kPointerSize]: constant elements. | 170 // [esp + kPointerSize]: constant elements. |
| 170 // [esp + (2 * kPointerSize)]: literal index. | 171 // [esp + (2 * kPointerSize)]: literal index. |
| 171 // [esp + (3 * kPointerSize)]: literals array. | 172 // [esp + (3 * kPointerSize)]: literals array. |
| 172 | 173 |
| (...skipping 6019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6192 __ Drop(1); | 6193 __ Drop(1); |
| 6193 __ ret(2 * kPointerSize); | 6194 __ ret(2 * kPointerSize); |
| 6194 } | 6195 } |
| 6195 | 6196 |
| 6196 | 6197 |
| 6197 #undef __ | 6198 #undef __ |
| 6198 | 6199 |
| 6199 } } // namespace v8::internal | 6200 } } // namespace v8::internal |
| 6200 | 6201 |
| 6201 #endif // V8_TARGET_ARCH_IA32 | 6202 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |