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 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2282 // Slow-case: Handle non-smi or out-of-bounds access to arguments | 2282 // Slow-case: Handle non-smi or out-of-bounds access to arguments |
2283 // by calling the runtime system. | 2283 // by calling the runtime system. |
2284 __ bind(&slow); | 2284 __ bind(&slow); |
2285 __ pop(rbx); // Return address. | 2285 __ pop(rbx); // Return address. |
2286 __ push(rdx); | 2286 __ push(rdx); |
2287 __ push(rbx); | 2287 __ push(rbx); |
2288 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1); | 2288 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1); |
2289 } | 2289 } |
2290 | 2290 |
2291 | 2291 |
2292 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { | 2292 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm, |
| 2293 int boilerplate_index, |
| 2294 int arguments_object_size) { |
2293 // rsp[0] : return address | 2295 // rsp[0] : return address |
2294 // rsp[8] : number of parameters | 2296 // rsp[8] : number of parameters |
2295 // rsp[16] : receiver displacement | 2297 // rsp[16] : receiver displacement |
2296 // rsp[24] : function | 2298 // rsp[24] : function |
2297 | 2299 |
| 2300 ASSERT(type_ != NEW_OBJECT || |
| 2301 (boilerplate_index == Context::ARGUMENTS_BOILERPLATE_INDEX && |
| 2302 arguments_object_size == Heap::kArgumentsObjectSize)); |
| 2303 ASSERT(type_ != NEW_OBJECT_STRICT || |
| 2304 (boilerplate_index == Context::ARGUMENTS_BOILERPLATE_STRICT_INDEX && |
| 2305 arguments_object_size == Heap::kArgumentsObjectSizeStrict)); |
| 2306 |
2298 // The displacement is used for skipping the return address and the | 2307 // The displacement is used for skipping the return address and the |
2299 // frame pointer on the stack. It is the offset of the last | 2308 // frame pointer on the stack. It is the offset of the last |
2300 // parameter (if any) relative to the frame pointer. | 2309 // parameter (if any) relative to the frame pointer. |
2301 static const int kDisplacement = 2 * kPointerSize; | 2310 static const int kDisplacement = 2 * kPointerSize; |
2302 | 2311 |
2303 // Check if the calling frame is an arguments adaptor frame. | 2312 // Check if the calling frame is an arguments adaptor frame. |
2304 Label adaptor_frame, try_allocate, runtime; | 2313 Label adaptor_frame, try_allocate, runtime; |
2305 __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 2314 __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
2306 __ SmiCompare(Operand(rdx, StandardFrameConstants::kContextOffset), | 2315 __ SmiCompare(Operand(rdx, StandardFrameConstants::kContextOffset), |
2307 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 2316 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
(...skipping 16 matching lines...) Expand all Loading... |
2324 __ movq(Operand(rsp, 2 * kPointerSize), rdx); | 2333 __ movq(Operand(rsp, 2 * kPointerSize), rdx); |
2325 | 2334 |
2326 // Try the new space allocation. Start out with computing the size of | 2335 // Try the new space allocation. Start out with computing the size of |
2327 // the arguments object and the elements array. | 2336 // the arguments object and the elements array. |
2328 Label add_arguments_object; | 2337 Label add_arguments_object; |
2329 __ bind(&try_allocate); | 2338 __ bind(&try_allocate); |
2330 __ testl(rcx, rcx); | 2339 __ testl(rcx, rcx); |
2331 __ j(zero, &add_arguments_object); | 2340 __ j(zero, &add_arguments_object); |
2332 __ leal(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); | 2341 __ leal(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); |
2333 __ bind(&add_arguments_object); | 2342 __ bind(&add_arguments_object); |
2334 __ addl(rcx, Immediate(Heap::kArgumentsObjectSize)); | 2343 __ addl(rcx, Immediate(arguments_object_size)); |
2335 | 2344 |
2336 // Do the allocation of both objects in one go. | 2345 // Do the allocation of both objects in one go. |
2337 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); | 2346 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); |
2338 | 2347 |
2339 // Get the arguments boilerplate from the current (global) context. | 2348 // 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))); | 2349 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
2342 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); | 2350 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); |
2343 __ movq(rdi, Operand(rdi, offset)); | 2351 __ movq(rdi, Operand(rdi, Context::SlotOffset(boilerplate_index))); |
2344 | 2352 |
2345 // Copy the JS object part. | 2353 // Copy the JS object part. |
2346 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); | 2354 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); |
2347 __ movq(kScratchRegister, FieldOperand(rdi, 0 * kPointerSize)); | 2355 __ movq(kScratchRegister, FieldOperand(rdi, 0 * kPointerSize)); |
2348 __ movq(rdx, FieldOperand(rdi, 1 * kPointerSize)); | 2356 __ movq(rdx, FieldOperand(rdi, 1 * kPointerSize)); |
2349 __ movq(rbx, FieldOperand(rdi, 2 * kPointerSize)); | 2357 __ movq(rbx, FieldOperand(rdi, 2 * kPointerSize)); |
2350 __ movq(FieldOperand(rax, 0 * kPointerSize), kScratchRegister); | 2358 __ movq(FieldOperand(rax, 0 * kPointerSize), kScratchRegister); |
2351 __ movq(FieldOperand(rax, 1 * kPointerSize), rdx); | 2359 __ movq(FieldOperand(rax, 1 * kPointerSize), rdx); |
2352 __ movq(FieldOperand(rax, 2 * kPointerSize), rbx); | 2360 __ movq(FieldOperand(rax, 2 * kPointerSize), rbx); |
2353 | 2361 |
2354 // Setup the callee in-object property. | 2362 if (type_ == NEW_OBJECT) { |
2355 ASSERT(Heap::arguments_callee_index == 0); | 2363 // Setup the callee in-object property. |
2356 __ movq(kScratchRegister, Operand(rsp, 3 * kPointerSize)); | 2364 ASSERT(Heap::arguments_callee_index == 1); |
2357 __ movq(FieldOperand(rax, JSObject::kHeaderSize), kScratchRegister); | 2365 __ movq(kScratchRegister, Operand(rsp, 3 * kPointerSize)); |
| 2366 __ movq(FieldOperand(rax, JSObject::kHeaderSize + kPointerSize), |
| 2367 kScratchRegister); |
| 2368 } |
2358 | 2369 |
2359 // Get the length (smi tagged) and set that as an in-object property too. | 2370 // Get the length (smi tagged) and set that as an in-object property too. |
2360 ASSERT(Heap::arguments_length_index == 1); | 2371 ASSERT(Heap::arguments_length_index == 0); |
2361 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); | 2372 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); |
2362 __ movq(FieldOperand(rax, JSObject::kHeaderSize + kPointerSize), rcx); | 2373 __ movq(FieldOperand(rax, JSObject::kHeaderSize), rcx); |
2363 | 2374 |
2364 // If there are no actual arguments, we're done. | 2375 // If there are no actual arguments, we're done. |
2365 Label done; | 2376 Label done; |
2366 __ SmiTest(rcx); | 2377 __ SmiTest(rcx); |
2367 __ j(zero, &done); | 2378 __ j(zero, &done); |
2368 | 2379 |
2369 // Get the parameters pointer from the stack and untag the length. | 2380 // Get the parameters pointer from the stack and untag the length. |
2370 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); | 2381 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); |
2371 | 2382 |
2372 // Setup the elements pointer in the allocated arguments object and | 2383 // Setup the elements pointer in the allocated arguments object and |
2373 // initialize the header in the elements fixed array. | 2384 // initialize the header in the elements fixed array. |
2374 __ lea(rdi, Operand(rax, Heap::kArgumentsObjectSize)); | 2385 __ lea(rdi, Operand(rax, arguments_object_size)); |
2375 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi); | 2386 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi); |
2376 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex); | 2387 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex); |
2377 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister); | 2388 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister); |
2378 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx); | 2389 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx); |
2379 __ SmiToInteger32(rcx, rcx); // Untag length for the loop below. | 2390 __ SmiToInteger32(rcx, rcx); // Untag length for the loop below. |
2380 | 2391 |
2381 // Copy the fixed array slots. | 2392 // Copy the fixed array slots. |
2382 Label loop; | 2393 Label loop; |
2383 __ bind(&loop); | 2394 __ bind(&loop); |
2384 __ movq(kScratchRegister, Operand(rdx, -1 * kPointerSize)); // Skip receiver. | 2395 __ 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. | 5035 // Do a tail call to the rewritten stub. |
5025 __ jmp(rdi); | 5036 __ jmp(rdi); |
5026 } | 5037 } |
5027 | 5038 |
5028 | 5039 |
5029 #undef __ | 5040 #undef __ |
5030 | 5041 |
5031 } } // namespace v8::internal | 5042 } } // namespace v8::internal |
5032 | 5043 |
5033 #endif // V8_TARGET_ARCH_X64 | 5044 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |