| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 __ push(edx); | 84 __ push(edx); |
| 85 __ push(Immediate(Factory::false_value())); | 85 __ push(Immediate(Factory::false_value())); |
| 86 __ push(ecx); // Restore return address. | 86 __ push(ecx); // Restore return address. |
| 87 __ TailCallRuntime(Runtime::kNewClosure, 3, 1); | 87 __ TailCallRuntime(Runtime::kNewClosure, 3, 1); |
| 88 } | 88 } |
| 89 | 89 |
| 90 | 90 |
| 91 void FastNewContextStub::Generate(MacroAssembler* masm) { | 91 void FastNewContextStub::Generate(MacroAssembler* masm) { |
| 92 // Try to allocate the context in new space. | 92 // Try to allocate the context in new space. |
| 93 Label gc; | 93 Label gc; |
| 94 __ AllocateInNewSpace((slots_ * kPointerSize) + FixedArray::kHeaderSize, | 94 int length = slots_ + Context::MIN_CONTEXT_SLOTS; |
| 95 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize, |
| 95 eax, ebx, ecx, &gc, TAG_OBJECT); | 96 eax, ebx, ecx, &gc, TAG_OBJECT); |
| 96 | 97 |
| 97 // Get the function from the stack. | 98 // Get the function from the stack. |
| 98 __ mov(ecx, Operand(esp, 1 * kPointerSize)); | 99 __ mov(ecx, Operand(esp, 1 * kPointerSize)); |
| 99 | 100 |
| 100 // Setup the object header. | 101 // Setup the object header. |
| 101 __ mov(FieldOperand(eax, HeapObject::kMapOffset), Factory::context_map()); | 102 __ mov(FieldOperand(eax, HeapObject::kMapOffset), Factory::context_map()); |
| 102 __ mov(FieldOperand(eax, Context::kLengthOffset), | 103 __ mov(FieldOperand(eax, Context::kLengthOffset), |
| 103 Immediate(Smi::FromInt(slots_))); | 104 Immediate(Smi::FromInt(length))); |
| 104 | 105 |
| 105 // Setup the fixed slots. | 106 // Setup the fixed slots. |
| 106 __ Set(ebx, Immediate(0)); // Set to NULL. | 107 __ Set(ebx, Immediate(0)); // Set to NULL. |
| 107 __ mov(Operand(eax, Context::SlotOffset(Context::CLOSURE_INDEX)), ecx); | 108 __ mov(Operand(eax, Context::SlotOffset(Context::CLOSURE_INDEX)), ecx); |
| 108 __ mov(Operand(eax, Context::SlotOffset(Context::FCONTEXT_INDEX)), eax); | 109 __ mov(Operand(eax, Context::SlotOffset(Context::FCONTEXT_INDEX)), eax); |
| 109 __ mov(Operand(eax, Context::SlotOffset(Context::PREVIOUS_INDEX)), ebx); | 110 __ mov(Operand(eax, Context::SlotOffset(Context::PREVIOUS_INDEX)), ebx); |
| 110 __ mov(Operand(eax, Context::SlotOffset(Context::EXTENSION_INDEX)), ebx); | 111 __ mov(Operand(eax, Context::SlotOffset(Context::EXTENSION_INDEX)), ebx); |
| 111 | 112 |
| 112 // Copy the global object from the surrounding context. We go through the | 113 // Copy the global object from the surrounding context. We go through the |
| 113 // context in the function (ecx) to match the allocation behavior we have | 114 // context in the function (ecx) to match the allocation behavior we have |
| 114 // in the runtime system (see Heap::AllocateFunctionContext). | 115 // in the runtime system (see Heap::AllocateFunctionContext). |
| 115 __ mov(ebx, FieldOperand(ecx, JSFunction::kContextOffset)); | 116 __ mov(ebx, FieldOperand(ecx, JSFunction::kContextOffset)); |
| 116 __ mov(ebx, Operand(ebx, Context::SlotOffset(Context::GLOBAL_INDEX))); | 117 __ mov(ebx, Operand(ebx, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 117 __ mov(Operand(eax, Context::SlotOffset(Context::GLOBAL_INDEX)), ebx); | 118 __ mov(Operand(eax, Context::SlotOffset(Context::GLOBAL_INDEX)), ebx); |
| 118 | 119 |
| 119 // Initialize the rest of the slots to undefined. | 120 // Initialize the rest of the slots to undefined. |
| 120 __ mov(ebx, Factory::undefined_value()); | 121 __ mov(ebx, Factory::undefined_value()); |
| 121 for (int i = Context::MIN_CONTEXT_SLOTS; i < slots_; i++) { | 122 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { |
| 122 __ mov(Operand(eax, Context::SlotOffset(i)), ebx); | 123 __ mov(Operand(eax, Context::SlotOffset(i)), ebx); |
| 123 } | 124 } |
| 124 | 125 |
| 125 // Return and remove the on-stack parameter. | 126 // Return and remove the on-stack parameter. |
| 126 __ mov(esi, Operand(eax)); | 127 __ mov(esi, Operand(eax)); |
| 127 __ ret(1 * kPointerSize); | 128 __ ret(1 * kPointerSize); |
| 128 | 129 |
| 129 // Need to collect. Call into runtime system. | 130 // Need to collect. Call into runtime system. |
| 130 __ bind(&gc); | 131 __ bind(&gc); |
| 131 __ TailCallRuntime(Runtime::kNewContext, 1, 1); | 132 __ TailCallRuntime(Runtime::kNewContext, 1, 1); |
| (...skipping 6350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6482 // Do a tail call to the rewritten stub. | 6483 // Do a tail call to the rewritten stub. |
| 6483 __ jmp(Operand(edi)); | 6484 __ jmp(Operand(edi)); |
| 6484 } | 6485 } |
| 6485 | 6486 |
| 6486 | 6487 |
| 6487 #undef __ | 6488 #undef __ |
| 6488 | 6489 |
| 6489 } } // namespace v8::internal | 6490 } } // namespace v8::internal |
| 6490 | 6491 |
| 6491 #endif // V8_TARGET_ARCH_IA32 | 6492 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |