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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 void FastNewContextStub::Generate(MacroAssembler* masm) { | 121 void FastNewContextStub::Generate(MacroAssembler* masm) { |
122 // Try to allocate the context in new space. | 122 // Try to allocate the context in new space. |
123 Label gc; | 123 Label gc; |
124 int length = slots_ + Context::MIN_CONTEXT_SLOTS; | 124 int length = slots_ + Context::MIN_CONTEXT_SLOTS; |
125 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize, | 125 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize, |
126 eax, ebx, ecx, &gc, TAG_OBJECT); | 126 eax, ebx, ecx, &gc, TAG_OBJECT); |
127 | 127 |
128 // Get the function from the stack. | 128 // Get the function from the stack. |
129 __ mov(ecx, Operand(esp, 1 * kPointerSize)); | 129 __ mov(ecx, Operand(esp, 1 * kPointerSize)); |
130 | 130 |
131 // Setup the object header. | 131 // Set up the object header. |
132 Factory* factory = masm->isolate()->factory(); | 132 Factory* factory = masm->isolate()->factory(); |
133 __ mov(FieldOperand(eax, HeapObject::kMapOffset), | 133 __ mov(FieldOperand(eax, HeapObject::kMapOffset), |
134 factory->function_context_map()); | 134 factory->function_context_map()); |
135 __ mov(FieldOperand(eax, Context::kLengthOffset), | 135 __ mov(FieldOperand(eax, Context::kLengthOffset), |
136 Immediate(Smi::FromInt(length))); | 136 Immediate(Smi::FromInt(length))); |
137 | 137 |
138 // Setup the fixed slots. | 138 // Set up the fixed slots. |
139 __ Set(ebx, Immediate(0)); // Set to NULL. | 139 __ Set(ebx, Immediate(0)); // Set to NULL. |
140 __ mov(Operand(eax, Context::SlotOffset(Context::CLOSURE_INDEX)), ecx); | 140 __ mov(Operand(eax, Context::SlotOffset(Context::CLOSURE_INDEX)), ecx); |
141 __ mov(Operand(eax, Context::SlotOffset(Context::PREVIOUS_INDEX)), esi); | 141 __ mov(Operand(eax, Context::SlotOffset(Context::PREVIOUS_INDEX)), esi); |
142 __ mov(Operand(eax, Context::SlotOffset(Context::EXTENSION_INDEX)), ebx); | 142 __ mov(Operand(eax, Context::SlotOffset(Context::EXTENSION_INDEX)), ebx); |
143 | 143 |
144 // Copy the global object from the previous context. | 144 // Copy the global object from the previous context. |
145 __ mov(ebx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 145 __ mov(ebx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
146 __ mov(Operand(eax, Context::SlotOffset(Context::GLOBAL_INDEX)), ebx); | 146 __ mov(Operand(eax, Context::SlotOffset(Context::GLOBAL_INDEX)), ebx); |
147 | 147 |
148 // Initialize the rest of the slots to undefined. | 148 // Initialize the rest of the slots to undefined. |
(...skipping 23 matching lines...) Expand all Loading... |
172 int length = slots_ + Context::MIN_CONTEXT_SLOTS; | 172 int length = slots_ + Context::MIN_CONTEXT_SLOTS; |
173 __ AllocateInNewSpace(FixedArray::SizeFor(length), | 173 __ AllocateInNewSpace(FixedArray::SizeFor(length), |
174 eax, ebx, ecx, &gc, TAG_OBJECT); | 174 eax, ebx, ecx, &gc, TAG_OBJECT); |
175 | 175 |
176 // Get the function or sentinel from the stack. | 176 // Get the function or sentinel from the stack. |
177 __ mov(ecx, Operand(esp, 1 * kPointerSize)); | 177 __ mov(ecx, Operand(esp, 1 * kPointerSize)); |
178 | 178 |
179 // Get the serialized scope info from the stack. | 179 // Get the serialized scope info from the stack. |
180 __ mov(ebx, Operand(esp, 2 * kPointerSize)); | 180 __ mov(ebx, Operand(esp, 2 * kPointerSize)); |
181 | 181 |
182 // Setup the object header. | 182 // Set up the object header. |
183 Factory* factory = masm->isolate()->factory(); | 183 Factory* factory = masm->isolate()->factory(); |
184 __ mov(FieldOperand(eax, HeapObject::kMapOffset), | 184 __ mov(FieldOperand(eax, HeapObject::kMapOffset), |
185 factory->block_context_map()); | 185 factory->block_context_map()); |
186 __ mov(FieldOperand(eax, Context::kLengthOffset), | 186 __ mov(FieldOperand(eax, Context::kLengthOffset), |
187 Immediate(Smi::FromInt(length))); | 187 Immediate(Smi::FromInt(length))); |
188 | 188 |
189 // If this block context is nested in the global context we get a smi | 189 // If this block context is nested in the global context we get a smi |
190 // sentinel instead of a function. The block context should get the | 190 // sentinel instead of a function. The block context should get the |
191 // canonical empty function of the global context as its closure which | 191 // canonical empty function of the global context as its closure which |
192 // we still have to look up. | 192 // we still have to look up. |
193 Label after_sentinel; | 193 Label after_sentinel; |
194 __ JumpIfNotSmi(ecx, &after_sentinel, Label::kNear); | 194 __ JumpIfNotSmi(ecx, &after_sentinel, Label::kNear); |
195 if (FLAG_debug_code) { | 195 if (FLAG_debug_code) { |
196 const char* message = "Expected 0 as a Smi sentinel"; | 196 const char* message = "Expected 0 as a Smi sentinel"; |
197 __ cmp(ecx, 0); | 197 __ cmp(ecx, 0); |
198 __ Assert(equal, message); | 198 __ Assert(equal, message); |
199 } | 199 } |
200 __ mov(ecx, GlobalObjectOperand()); | 200 __ mov(ecx, GlobalObjectOperand()); |
201 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalContextOffset)); | 201 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalContextOffset)); |
202 __ mov(ecx, ContextOperand(ecx, Context::CLOSURE_INDEX)); | 202 __ mov(ecx, ContextOperand(ecx, Context::CLOSURE_INDEX)); |
203 __ bind(&after_sentinel); | 203 __ bind(&after_sentinel); |
204 | 204 |
205 // Setup the fixed slots. | 205 // Set up the fixed slots. |
206 __ mov(ContextOperand(eax, Context::CLOSURE_INDEX), ecx); | 206 __ mov(ContextOperand(eax, Context::CLOSURE_INDEX), ecx); |
207 __ mov(ContextOperand(eax, Context::PREVIOUS_INDEX), esi); | 207 __ mov(ContextOperand(eax, Context::PREVIOUS_INDEX), esi); |
208 __ mov(ContextOperand(eax, Context::EXTENSION_INDEX), ebx); | 208 __ mov(ContextOperand(eax, Context::EXTENSION_INDEX), ebx); |
209 | 209 |
210 // Copy the global object from the previous context. | 210 // Copy the global object from the previous context. |
211 __ mov(ebx, ContextOperand(esi, Context::GLOBAL_INDEX)); | 211 __ mov(ebx, ContextOperand(esi, Context::GLOBAL_INDEX)); |
212 __ mov(ContextOperand(eax, Context::GLOBAL_INDEX), ebx); | 212 __ mov(ContextOperand(eax, Context::GLOBAL_INDEX), ebx); |
213 | 213 |
214 // Initialize the rest of the slots to the hole value. | 214 // Initialize the rest of the slots to the hole value. |
215 if (slots_ == 1) { | 215 if (slots_ == 1) { |
(...skipping 3156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3372 // edi = address of boilerplate object (tagged) | 3372 // edi = address of boilerplate object (tagged) |
3373 // esp[0] = mapped parameter count (tagged) | 3373 // esp[0] = mapped parameter count (tagged) |
3374 // esp[8] = parameter count (tagged) | 3374 // esp[8] = parameter count (tagged) |
3375 // esp[12] = address of receiver argument | 3375 // esp[12] = address of receiver argument |
3376 // Copy the JS object part. | 3376 // Copy the JS object part. |
3377 for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) { | 3377 for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) { |
3378 __ mov(edx, FieldOperand(edi, i)); | 3378 __ mov(edx, FieldOperand(edi, i)); |
3379 __ mov(FieldOperand(eax, i), edx); | 3379 __ mov(FieldOperand(eax, i), edx); |
3380 } | 3380 } |
3381 | 3381 |
3382 // Setup the callee in-object property. | 3382 // Set up the callee in-object property. |
3383 STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1); | 3383 STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1); |
3384 __ mov(edx, Operand(esp, 4 * kPointerSize)); | 3384 __ mov(edx, Operand(esp, 4 * kPointerSize)); |
3385 __ mov(FieldOperand(eax, JSObject::kHeaderSize + | 3385 __ mov(FieldOperand(eax, JSObject::kHeaderSize + |
3386 Heap::kArgumentsCalleeIndex * kPointerSize), | 3386 Heap::kArgumentsCalleeIndex * kPointerSize), |
3387 edx); | 3387 edx); |
3388 | 3388 |
3389 // Use the length (smi tagged) and set that as an in-object property too. | 3389 // Use the length (smi tagged) and set that as an in-object property too. |
3390 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); | 3390 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); |
3391 __ mov(FieldOperand(eax, JSObject::kHeaderSize + | 3391 __ mov(FieldOperand(eax, JSObject::kHeaderSize + |
3392 Heap::kArgumentsLengthIndex * kPointerSize), | 3392 Heap::kArgumentsLengthIndex * kPointerSize), |
3393 ecx); | 3393 ecx); |
3394 | 3394 |
3395 // Setup the elements pointer in the allocated arguments object. | 3395 // Set up the elements pointer in the allocated arguments object. |
3396 // If we allocated a parameter map, edi will point there, otherwise to the | 3396 // If we allocated a parameter map, edi will point there, otherwise to the |
3397 // backing store. | 3397 // backing store. |
3398 __ lea(edi, Operand(eax, Heap::kArgumentsObjectSize)); | 3398 __ lea(edi, Operand(eax, Heap::kArgumentsObjectSize)); |
3399 __ mov(FieldOperand(eax, JSObject::kElementsOffset), edi); | 3399 __ mov(FieldOperand(eax, JSObject::kElementsOffset), edi); |
3400 | 3400 |
3401 // eax = address of new object (tagged) | 3401 // eax = address of new object (tagged) |
3402 // ebx = mapped parameter count (tagged) | 3402 // ebx = mapped parameter count (tagged) |
3403 // ecx = argument count (tagged) | 3403 // ecx = argument count (tagged) |
3404 // edi = address of parameter map or backing store (tagged) | 3404 // edi = address of parameter map or backing store (tagged) |
3405 // esp[0] = mapped parameter count (tagged) | 3405 // esp[0] = mapped parameter count (tagged) |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3564 ecx); | 3564 ecx); |
3565 | 3565 |
3566 // If there are no actual arguments, we're done. | 3566 // If there are no actual arguments, we're done. |
3567 Label done; | 3567 Label done; |
3568 __ test(ecx, ecx); | 3568 __ test(ecx, ecx); |
3569 __ j(zero, &done, Label::kNear); | 3569 __ j(zero, &done, Label::kNear); |
3570 | 3570 |
3571 // Get the parameters pointer from the stack. | 3571 // Get the parameters pointer from the stack. |
3572 __ mov(edx, Operand(esp, 2 * kPointerSize)); | 3572 __ mov(edx, Operand(esp, 2 * kPointerSize)); |
3573 | 3573 |
3574 // Setup the elements pointer in the allocated arguments object and | 3574 // Set up the elements pointer in the allocated arguments object and |
3575 // initialize the header in the elements fixed array. | 3575 // initialize the header in the elements fixed array. |
3576 __ lea(edi, Operand(eax, Heap::kArgumentsObjectSizeStrict)); | 3576 __ lea(edi, Operand(eax, Heap::kArgumentsObjectSizeStrict)); |
3577 __ mov(FieldOperand(eax, JSObject::kElementsOffset), edi); | 3577 __ mov(FieldOperand(eax, JSObject::kElementsOffset), edi); |
3578 __ mov(FieldOperand(edi, FixedArray::kMapOffset), | 3578 __ mov(FieldOperand(edi, FixedArray::kMapOffset), |
3579 Immediate(FACTORY->fixed_array_map())); | 3579 Immediate(FACTORY->fixed_array_map())); |
3580 | 3580 |
3581 __ mov(FieldOperand(edi, FixedArray::kLengthOffset), ecx); | 3581 __ mov(FieldOperand(edi, FixedArray::kLengthOffset), ecx); |
3582 // Untag the length for the loop below. | 3582 // Untag the length for the loop below. |
3583 __ SmiUntag(ecx); | 3583 __ SmiUntag(ecx); |
3584 | 3584 |
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4943 | 4943 |
4944 __ bind(&throw_normal_exception); | 4944 __ bind(&throw_normal_exception); |
4945 GenerateThrowTOS(masm); | 4945 GenerateThrowTOS(masm); |
4946 } | 4946 } |
4947 | 4947 |
4948 | 4948 |
4949 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 4949 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
4950 Label invoke, handler_entry, exit; | 4950 Label invoke, handler_entry, exit; |
4951 Label not_outermost_js, not_outermost_js_2; | 4951 Label not_outermost_js, not_outermost_js_2; |
4952 | 4952 |
4953 // Setup frame. | 4953 // Set up frame. |
4954 __ push(ebp); | 4954 __ push(ebp); |
4955 __ mov(ebp, esp); | 4955 __ mov(ebp, esp); |
4956 | 4956 |
4957 // Push marker in two places. | 4957 // Push marker in two places. |
4958 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; | 4958 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; |
4959 __ push(Immediate(Smi::FromInt(marker))); // context slot | 4959 __ push(Immediate(Smi::FromInt(marker))); // context slot |
4960 __ push(Immediate(Smi::FromInt(marker))); // function slot | 4960 __ push(Immediate(Smi::FromInt(marker))); // function slot |
4961 // Save callee-saved registers (C calling conventions). | 4961 // Save callee-saved registers (C calling conventions). |
4962 __ push(edi); | 4962 __ push(edi); |
4963 __ push(esi); | 4963 __ push(esi); |
(...skipping 2380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7344 false); | 7344 false); |
7345 __ pop(edx); | 7345 __ pop(edx); |
7346 __ ret(0); | 7346 __ ret(0); |
7347 } | 7347 } |
7348 | 7348 |
7349 #undef __ | 7349 #undef __ |
7350 | 7350 |
7351 } } // namespace v8::internal | 7351 } } // namespace v8::internal |
7352 | 7352 |
7353 #endif // V8_TARGET_ARCH_IA32 | 7353 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |