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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // Try to allocate the context in new space. | 118 // Try to allocate the context in new space. |
119 Label gc; | 119 Label gc; |
120 int length = slots_ + Context::MIN_CONTEXT_SLOTS; | 120 int length = slots_ + Context::MIN_CONTEXT_SLOTS; |
121 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize, | 121 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize, |
122 rax, rbx, rcx, &gc, TAG_OBJECT); | 122 rax, rbx, rcx, &gc, TAG_OBJECT); |
123 | 123 |
124 // Get the function from the stack. | 124 // Get the function from the stack. |
125 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); | 125 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); |
126 | 126 |
127 // Setup the object header. | 127 // Setup the object header. |
128 __ LoadRoot(kScratchRegister, Heap::kContextMapRootIndex); | 128 __ LoadRoot(kScratchRegister, Heap::kFunctionContextMapRootIndex); |
129 __ movq(FieldOperand(rax, HeapObject::kMapOffset), kScratchRegister); | 129 __ movq(FieldOperand(rax, HeapObject::kMapOffset), kScratchRegister); |
130 __ Move(FieldOperand(rax, FixedArray::kLengthOffset), Smi::FromInt(length)); | 130 __ Move(FieldOperand(rax, FixedArray::kLengthOffset), Smi::FromInt(length)); |
131 | 131 |
132 // Setup the fixed slots. | 132 // Setup the fixed slots. |
133 __ Set(rbx, 0); // Set to NULL. | 133 __ Set(rbx, 0); // Set to NULL. |
134 __ movq(Operand(rax, Context::SlotOffset(Context::CLOSURE_INDEX)), rcx); | 134 __ movq(Operand(rax, Context::SlotOffset(Context::CLOSURE_INDEX)), rcx); |
135 __ movq(Operand(rax, Context::SlotOffset(Context::FCONTEXT_INDEX)), rax); | 135 __ movq(Operand(rax, Context::SlotOffset(Context::FCONTEXT_INDEX)), rax); |
136 __ movq(Operand(rax, Context::SlotOffset(Context::PREVIOUS_INDEX)), rbx); | 136 __ movq(Operand(rax, Context::SlotOffset(Context::PREVIOUS_INDEX)), rbx); |
137 __ movq(Operand(rax, Context::SlotOffset(Context::EXTENSION_INDEX)), rbx); | 137 __ movq(Operand(rax, Context::SlotOffset(Context::EXTENSION_INDEX)), rbx); |
138 | 138 |
139 // Copy the global object from the surrounding context. | 139 // Copy the global object from the surrounding context. |
140 __ movq(rbx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 140 __ movq(rbx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
141 __ movq(Operand(rax, Context::SlotOffset(Context::GLOBAL_INDEX)), rbx); | 141 __ movq(Operand(rax, Context::SlotOffset(Context::GLOBAL_INDEX)), rbx); |
142 | 142 |
143 // Initialize the rest of the slots to undefined. | 143 // Initialize the rest of the slots to undefined. |
144 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); | 144 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); |
145 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { | 145 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { |
146 __ movq(Operand(rax, Context::SlotOffset(i)), rbx); | 146 __ movq(Operand(rax, Context::SlotOffset(i)), rbx); |
147 } | 147 } |
148 | 148 |
149 // Return and remove the on-stack parameter. | 149 // Return and remove the on-stack parameter. |
150 __ movq(rsi, rax); | 150 __ movq(rsi, rax); |
151 __ ret(1 * kPointerSize); | 151 __ ret(1 * kPointerSize); |
152 | 152 |
153 // Need to collect. Call into runtime system. | 153 // Need to collect. Call into runtime system. |
154 __ bind(&gc); | 154 __ bind(&gc); |
155 __ TailCallRuntime(Runtime::kNewContext, 1, 1); | 155 __ TailCallRuntime(Runtime::kNewFunctionContext, 1, 1); |
156 } | 156 } |
157 | 157 |
158 | 158 |
159 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { | 159 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { |
160 // Stack layout on entry: | 160 // Stack layout on entry: |
161 // | 161 // |
162 // [rsp + kPointerSize]: constant elements. | 162 // [rsp + kPointerSize]: constant elements. |
163 // [rsp + (2 * kPointerSize)]: literal index. | 163 // [rsp + (2 * kPointerSize)]: literal index. |
164 // [rsp + (3 * kPointerSize)]: literals array. | 164 // [rsp + (3 * kPointerSize)]: literals array. |
165 | 165 |
(...skipping 4961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5127 __ Drop(1); | 5127 __ Drop(1); |
5128 __ ret(2 * kPointerSize); | 5128 __ ret(2 * kPointerSize); |
5129 } | 5129 } |
5130 | 5130 |
5131 | 5131 |
5132 #undef __ | 5132 #undef __ |
5133 | 5133 |
5134 } } // namespace v8::internal | 5134 } } // namespace v8::internal |
5135 | 5135 |
5136 #endif // V8_TARGET_ARCH_X64 | 5136 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |