Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 6698015: Implement strict mode arguments caller/callee. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 3573 matching lines...) Expand 10 before | Expand all | Expand 10 after
3584 // Slow-case: Handle non-smi or out-of-bounds access to arguments 3584 // Slow-case: Handle non-smi or out-of-bounds access to arguments
3585 // by calling the runtime system. 3585 // by calling the runtime system.
3586 __ bind(&slow); 3586 __ bind(&slow);
3587 __ pop(ebx); // Return address. 3587 __ pop(ebx); // Return address.
3588 __ push(edx); 3588 __ push(edx);
3589 __ push(ebx); 3589 __ push(ebx);
3590 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1); 3590 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1);
3591 } 3591 }
3592 3592
3593 3593
3594 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { 3594 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm,
3595 int boilerplate_index,
3596 int arguments_object_size) {
3595 // esp[0] : return address 3597 // esp[0] : return address
3596 // esp[4] : number of parameters 3598 // esp[4] : number of parameters
3597 // esp[8] : receiver displacement 3599 // esp[8] : receiver displacement
3598 // esp[16] : function 3600 // esp[16] : function
3599 3601
3602 ASSERT(type_ != NEW_OBJECT ||
3603 (boilerplate_index == Context::ARGUMENTS_BOILERPLATE_INDEX &&
3604 arguments_object_size == Heap::kArgumentsObjectSize));
3605 ASSERT(type_ != NEW_OBJECT_STRICT ||
3606 (boilerplate_index == Context::ARGUMENTS_BOILERPLATE_STRICT_INDEX &&
3607 arguments_object_size == Heap::kArgumentsObjectSizeStrict));
3608
3600 // The displacement is used for skipping the return address and the 3609 // The displacement is used for skipping the return address and the
3601 // frame pointer on the stack. It is the offset of the last 3610 // frame pointer on the stack. It is the offset of the last
3602 // parameter (if any) relative to the frame pointer. 3611 // parameter (if any) relative to the frame pointer.
3603 static const int kDisplacement = 2 * kPointerSize; 3612 static const int kDisplacement = 2 * kPointerSize;
3604 3613
3605 // Check if the calling frame is an arguments adaptor frame. 3614 // Check if the calling frame is an arguments adaptor frame.
3606 Label adaptor_frame, try_allocate, runtime; 3615 Label adaptor_frame, try_allocate, runtime;
3607 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); 3616 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
3608 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset)); 3617 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset));
3609 __ cmp(Operand(ecx), Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); 3618 __ cmp(Operand(ecx), Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
(...skipping 11 matching lines...) Expand all
3621 __ mov(Operand(esp, 2 * kPointerSize), edx); 3630 __ mov(Operand(esp, 2 * kPointerSize), edx);
3622 3631
3623 // Try the new space allocation. Start out with computing the size of 3632 // Try the new space allocation. Start out with computing the size of
3624 // the arguments object and the elements array. 3633 // the arguments object and the elements array.
3625 NearLabel add_arguments_object; 3634 NearLabel add_arguments_object;
3626 __ bind(&try_allocate); 3635 __ bind(&try_allocate);
3627 __ test(ecx, Operand(ecx)); 3636 __ test(ecx, Operand(ecx));
3628 __ j(zero, &add_arguments_object); 3637 __ j(zero, &add_arguments_object);
3629 __ lea(ecx, Operand(ecx, times_2, FixedArray::kHeaderSize)); 3638 __ lea(ecx, Operand(ecx, times_2, FixedArray::kHeaderSize));
3630 __ bind(&add_arguments_object); 3639 __ bind(&add_arguments_object);
3631 __ add(Operand(ecx), Immediate(Heap::kArgumentsObjectSize)); 3640 __ add(Operand(ecx), Immediate(arguments_object_size));
3632 3641
3633 // Do the allocation of both objects in one go. 3642 // Do the allocation of both objects in one go.
3634 __ AllocateInNewSpace(ecx, eax, edx, ebx, &runtime, TAG_OBJECT); 3643 __ AllocateInNewSpace(ecx, eax, edx, ebx, &runtime, TAG_OBJECT);
3635 3644
3636 // Get the arguments boilerplate from the current (global) context. 3645 // Get the arguments boilerplate from the current (global) context.
3637 int offset = Context::SlotOffset(Context::ARGUMENTS_BOILERPLATE_INDEX);
3638 __ mov(edi, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); 3646 __ mov(edi, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
3639 __ mov(edi, FieldOperand(edi, GlobalObject::kGlobalContextOffset)); 3647 __ mov(edi, FieldOperand(edi, GlobalObject::kGlobalContextOffset));
3640 __ mov(edi, Operand(edi, offset)); 3648 __ mov(edi, Operand(edi, Context::SlotOffset(boilerplate_index)));
3641 3649
3642 // Copy the JS object part. 3650 // Copy the JS object part.
3643 for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) { 3651 for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) {
3644 __ mov(ebx, FieldOperand(edi, i)); 3652 __ mov(ebx, FieldOperand(edi, i));
3645 __ mov(FieldOperand(eax, i), ebx); 3653 __ mov(FieldOperand(eax, i), ebx);
3646 } 3654 }
3647 3655
3648 // Setup the callee in-object property. 3656 if (type_ == NEW_OBJECT) {
3649 STATIC_ASSERT(Heap::arguments_callee_index == 0); 3657 // Setup the callee in-object property.
3650 __ mov(ebx, Operand(esp, 3 * kPointerSize)); 3658 STATIC_ASSERT(Heap::arguments_callee_index == 1);
3651 __ mov(FieldOperand(eax, JSObject::kHeaderSize), ebx); 3659 __ mov(ebx, Operand(esp, 3 * kPointerSize));
3660 __ mov(FieldOperand(eax, JSObject::kHeaderSize + kPointerSize), ebx);
Lasse Reichstein 2011/03/15 09:58:40 use FieldOperand(eax, JSObject::kHeaderSize + H
Martin Maly 2011/03/16 01:21:24 Done, although the new code is less pretty :( espe
3661 }
3652 3662
3653 // Get the length (smi tagged) and set that as an in-object property too. 3663 // Get the length (smi tagged) and set that as an in-object property too.
3654 STATIC_ASSERT(Heap::arguments_length_index == 1); 3664 STATIC_ASSERT(Heap::arguments_length_index == 0);
3655 __ mov(ecx, Operand(esp, 1 * kPointerSize)); 3665 __ mov(ecx, Operand(esp, 1 * kPointerSize));
3656 __ mov(FieldOperand(eax, JSObject::kHeaderSize + kPointerSize), ecx); 3666 __ mov(FieldOperand(eax, JSObject::kHeaderSize), ecx);
Lasse Reichstein 2011/03/15 09:58:40 Ditto here. Just do FieldOperand(eax, JSObject::k
Martin Maly 2011/03/16 01:21:24 Done.
3657 3667
3658 // If there are no actual arguments, we're done. 3668 // If there are no actual arguments, we're done.
3659 Label done; 3669 Label done;
3660 __ test(ecx, Operand(ecx)); 3670 __ test(ecx, Operand(ecx));
3661 __ j(zero, &done); 3671 __ j(zero, &done);
3662 3672
3663 // Get the parameters pointer from the stack. 3673 // Get the parameters pointer from the stack.
3664 __ mov(edx, Operand(esp, 2 * kPointerSize)); 3674 __ mov(edx, Operand(esp, 2 * kPointerSize));
3665 3675
3666 // Setup the elements pointer in the allocated arguments object and 3676 // Setup the elements pointer in the allocated arguments object and
3667 // initialize the header in the elements fixed array. 3677 // initialize the header in the elements fixed array.
3668 __ lea(edi, Operand(eax, Heap::kArgumentsObjectSize)); 3678 __ lea(edi, Operand(eax, arguments_object_size));
3669 __ mov(FieldOperand(eax, JSObject::kElementsOffset), edi); 3679 __ mov(FieldOperand(eax, JSObject::kElementsOffset), edi);
3670 __ mov(FieldOperand(edi, FixedArray::kMapOffset), 3680 __ mov(FieldOperand(edi, FixedArray::kMapOffset),
3671 Immediate(Factory::fixed_array_map())); 3681 Immediate(Factory::fixed_array_map()));
3682
3672 __ mov(FieldOperand(edi, FixedArray::kLengthOffset), ecx); 3683 __ mov(FieldOperand(edi, FixedArray::kLengthOffset), ecx);
3673 // Untag the length for the loop below. 3684 // Untag the length for the loop below.
3674 __ SmiUntag(ecx); 3685 __ SmiUntag(ecx);
3675 3686
3676 // Copy the fixed array slots. 3687 // Copy the fixed array slots.
3677 NearLabel loop; 3688 NearLabel loop;
3678 __ bind(&loop); 3689 __ bind(&loop);
3679 __ mov(ebx, Operand(edx, -1 * kPointerSize)); // Skip receiver. 3690 __ mov(ebx, Operand(edx, -1 * kPointerSize)); // Skip receiver.
3680 __ mov(FieldOperand(edi, FixedArray::kHeaderSize), ebx); 3691 __ mov(FieldOperand(edi, FixedArray::kHeaderSize), ebx);
3681 __ add(Operand(edi), Immediate(kPointerSize)); 3692 __ add(Operand(edi), Immediate(kPointerSize));
(...skipping 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after
6425 // Do a tail call to the rewritten stub. 6436 // Do a tail call to the rewritten stub.
6426 __ jmp(Operand(edi)); 6437 __ jmp(Operand(edi));
6427 } 6438 }
6428 6439
6429 6440
6430 #undef __ 6441 #undef __
6431 6442
6432 } } // namespace v8::internal 6443 } } // namespace v8::internal
6433 6444
6434 #endif // V8_TARGET_ARCH_IA32 6445 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698