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 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2324 __ movq(Operand(rsp, 2 * kPointerSize), rdx); | 2324 __ movq(Operand(rsp, 2 * kPointerSize), rdx); |
2325 | 2325 |
2326 // Try the new space allocation. Start out with computing the size of | 2326 // Try the new space allocation. Start out with computing the size of |
2327 // the arguments object and the elements array. | 2327 // the arguments object and the elements array. |
2328 Label add_arguments_object; | 2328 Label add_arguments_object; |
2329 __ bind(&try_allocate); | 2329 __ bind(&try_allocate); |
2330 __ testl(rcx, rcx); | 2330 __ testl(rcx, rcx); |
2331 __ j(zero, &add_arguments_object); | 2331 __ j(zero, &add_arguments_object); |
2332 __ leal(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); | 2332 __ leal(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); |
2333 __ bind(&add_arguments_object); | 2333 __ bind(&add_arguments_object); |
2334 __ addl(rcx, Immediate(Heap::kArgumentsObjectSize)); | 2334 __ addl(rcx, Immediate(GetArgumentsObjectSize())); |
2335 | 2335 |
2336 // Do the allocation of both objects in one go. | 2336 // Do the allocation of both objects in one go. |
2337 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); | 2337 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); |
2338 | 2338 |
2339 // Get the arguments boilerplate from the current (global) context. | 2339 // Get the arguments boilerplate from the current (global) context. |
2340 int offset = Context::SlotOffset(Context::ARGUMENTS_BOILERPLATE_INDEX); | |
2341 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 2340 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
2342 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); | 2341 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); |
2343 __ movq(rdi, Operand(rdi, offset)); | 2342 __ movq(rdi, Operand(rdi, |
| 2343 Context::SlotOffset(GetArgumentsBoilerplateIndex()))); |
2344 | 2344 |
2345 // Copy the JS object part. | 2345 // Copy the JS object part. |
2346 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); | 2346 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); |
2347 __ movq(kScratchRegister, FieldOperand(rdi, 0 * kPointerSize)); | 2347 __ movq(kScratchRegister, FieldOperand(rdi, 0 * kPointerSize)); |
2348 __ movq(rdx, FieldOperand(rdi, 1 * kPointerSize)); | 2348 __ movq(rdx, FieldOperand(rdi, 1 * kPointerSize)); |
2349 __ movq(rbx, FieldOperand(rdi, 2 * kPointerSize)); | 2349 __ movq(rbx, FieldOperand(rdi, 2 * kPointerSize)); |
2350 __ movq(FieldOperand(rax, 0 * kPointerSize), kScratchRegister); | 2350 __ movq(FieldOperand(rax, 0 * kPointerSize), kScratchRegister); |
2351 __ movq(FieldOperand(rax, 1 * kPointerSize), rdx); | 2351 __ movq(FieldOperand(rax, 1 * kPointerSize), rdx); |
2352 __ movq(FieldOperand(rax, 2 * kPointerSize), rbx); | 2352 __ movq(FieldOperand(rax, 2 * kPointerSize), rbx); |
2353 | 2353 |
2354 // Setup the callee in-object property. | 2354 if (type_ == NEW_OBJECT) { |
2355 ASSERT(Heap::arguments_callee_index == 0); | 2355 // Setup the callee in-object property. |
2356 __ movq(kScratchRegister, Operand(rsp, 3 * kPointerSize)); | 2356 ASSERT(Heap::arguments_callee_index == 1); |
2357 __ movq(FieldOperand(rax, JSObject::kHeaderSize), kScratchRegister); | 2357 __ movq(kScratchRegister, Operand(rsp, 3 * kPointerSize)); |
| 2358 __ movq(FieldOperand(rax, JSObject::kHeaderSize + |
| 2359 Heap::arguments_callee_index * kPointerSize), |
| 2360 kScratchRegister); |
| 2361 } |
2358 | 2362 |
2359 // Get the length (smi tagged) and set that as an in-object property too. | 2363 // Get the length (smi tagged) and set that as an in-object property too. |
2360 ASSERT(Heap::arguments_length_index == 1); | 2364 ASSERT(Heap::arguments_length_index == 0); |
2361 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); | 2365 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); |
2362 __ movq(FieldOperand(rax, JSObject::kHeaderSize + kPointerSize), rcx); | 2366 __ movq(FieldOperand(rax, JSObject::kHeaderSize + |
| 2367 Heap::arguments_length_index * kPointerSize), |
| 2368 rcx); |
2363 | 2369 |
2364 // If there are no actual arguments, we're done. | 2370 // If there are no actual arguments, we're done. |
2365 Label done; | 2371 Label done; |
2366 __ SmiTest(rcx); | 2372 __ SmiTest(rcx); |
2367 __ j(zero, &done); | 2373 __ j(zero, &done); |
2368 | 2374 |
2369 // Get the parameters pointer from the stack and untag the length. | 2375 // Get the parameters pointer from the stack and untag the length. |
2370 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); | 2376 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); |
2371 | 2377 |
2372 // Setup the elements pointer in the allocated arguments object and | 2378 // Setup the elements pointer in the allocated arguments object and |
2373 // initialize the header in the elements fixed array. | 2379 // initialize the header in the elements fixed array. |
2374 __ lea(rdi, Operand(rax, Heap::kArgumentsObjectSize)); | 2380 __ lea(rdi, Operand(rax, GetArgumentsObjectSize())); |
2375 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi); | 2381 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi); |
2376 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex); | 2382 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex); |
2377 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister); | 2383 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister); |
2378 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx); | 2384 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx); |
2379 __ SmiToInteger32(rcx, rcx); // Untag length for the loop below. | 2385 __ SmiToInteger32(rcx, rcx); // Untag length for the loop below. |
2380 | 2386 |
2381 // Copy the fixed array slots. | 2387 // Copy the fixed array slots. |
2382 Label loop; | 2388 Label loop; |
2383 __ bind(&loop); | 2389 __ bind(&loop); |
2384 __ movq(kScratchRegister, Operand(rdx, -1 * kPointerSize)); // Skip receiver. | 2390 __ movq(kScratchRegister, Operand(rdx, -1 * kPointerSize)); // Skip receiver. |
(...skipping 2639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5024 // Do a tail call to the rewritten stub. | 5030 // Do a tail call to the rewritten stub. |
5025 __ jmp(rdi); | 5031 __ jmp(rdi); |
5026 } | 5032 } |
5027 | 5033 |
5028 | 5034 |
5029 #undef __ | 5035 #undef __ |
5030 | 5036 |
5031 } } // namespace v8::internal | 5037 } } // namespace v8::internal |
5032 | 5038 |
5033 #endif // V8_TARGET_ARCH_X64 | 5039 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |