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(rdx); | 84 __ push(rdx); |
85 __ Push(Factory::false_value()); | 85 __ Push(Factory::false_value()); |
86 __ push(rcx); // Restore return address. | 86 __ push(rcx); // 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 rax, rbx, rcx, &gc, TAG_OBJECT); | 96 rax, rbx, rcx, &gc, TAG_OBJECT); |
96 | 97 |
97 // Get the function from the stack. | 98 // Get the function from the stack. |
98 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); | 99 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); |
99 | 100 |
100 // Setup the object header. | 101 // Setup the object header. |
101 __ LoadRoot(kScratchRegister, Heap::kContextMapRootIndex); | 102 __ LoadRoot(kScratchRegister, Heap::kContextMapRootIndex); |
102 __ movq(FieldOperand(rax, HeapObject::kMapOffset), kScratchRegister); | 103 __ movq(FieldOperand(rax, HeapObject::kMapOffset), kScratchRegister); |
103 __ Move(FieldOperand(rax, FixedArray::kLengthOffset), Smi::FromInt(slots_)); | 104 __ Move(FieldOperand(rax, FixedArray::kLengthOffset), Smi::FromInt(length)); |
104 | 105 |
105 // Setup the fixed slots. | 106 // Setup the fixed slots. |
106 __ Set(rbx, 0); // Set to NULL. | 107 __ Set(rbx, 0); // Set to NULL. |
107 __ movq(Operand(rax, Context::SlotOffset(Context::CLOSURE_INDEX)), rcx); | 108 __ movq(Operand(rax, Context::SlotOffset(Context::CLOSURE_INDEX)), rcx); |
108 __ movq(Operand(rax, Context::SlotOffset(Context::FCONTEXT_INDEX)), rax); | 109 __ movq(Operand(rax, Context::SlotOffset(Context::FCONTEXT_INDEX)), rax); |
109 __ movq(Operand(rax, Context::SlotOffset(Context::PREVIOUS_INDEX)), rbx); | 110 __ movq(Operand(rax, Context::SlotOffset(Context::PREVIOUS_INDEX)), rbx); |
110 __ movq(Operand(rax, Context::SlotOffset(Context::EXTENSION_INDEX)), rbx); | 111 __ movq(Operand(rax, Context::SlotOffset(Context::EXTENSION_INDEX)), rbx); |
111 | 112 |
112 // Copy the global object from the surrounding context. | 113 // Copy the global object from the surrounding context. |
113 __ movq(rbx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 114 __ movq(rbx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
114 __ movq(Operand(rax, Context::SlotOffset(Context::GLOBAL_INDEX)), rbx); | 115 __ movq(Operand(rax, Context::SlotOffset(Context::GLOBAL_INDEX)), rbx); |
115 | 116 |
116 // Initialize the rest of the slots to undefined. | 117 // Initialize the rest of the slots to undefined. |
117 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); | 118 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); |
118 for (int i = Context::MIN_CONTEXT_SLOTS; i < slots_; i++) { | 119 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { |
119 __ movq(Operand(rax, Context::SlotOffset(i)), rbx); | 120 __ movq(Operand(rax, Context::SlotOffset(i)), rbx); |
120 } | 121 } |
121 | 122 |
122 // Return and remove the on-stack parameter. | 123 // Return and remove the on-stack parameter. |
123 __ movq(rsi, rax); | 124 __ movq(rsi, rax); |
124 __ ret(1 * kPointerSize); | 125 __ ret(1 * kPointerSize); |
125 | 126 |
126 // Need to collect. Call into runtime system. | 127 // Need to collect. Call into runtime system. |
127 __ bind(&gc); | 128 __ bind(&gc); |
128 __ TailCallRuntime(Runtime::kNewContext, 1, 1); | 129 __ TailCallRuntime(Runtime::kNewContext, 1, 1); |
(...skipping 4260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4389 | 4390 |
4390 // Do a tail call to the rewritten stub. | 4391 // Do a tail call to the rewritten stub. |
4391 __ jmp(rdi); | 4392 __ jmp(rdi); |
4392 } | 4393 } |
4393 | 4394 |
4394 #undef __ | 4395 #undef __ |
4395 | 4396 |
4396 } } // namespace v8::internal | 4397 } } // namespace v8::internal |
4397 | 4398 |
4398 #endif // V8_TARGET_ARCH_X64 | 4399 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |