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

Side by Side Diff: src/arm/code-stubs-arm.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
« no previous file with comments | « no previous file | src/arm/codegen-arm.h » ('j') | src/bootstrapper.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4784 matching lines...) Expand 10 before | Expand all | Expand 10 after
4795 __ Jump(lr); 4795 __ Jump(lr);
4796 4796
4797 // Slow-case: Handle non-smi or out-of-bounds access to arguments 4797 // Slow-case: Handle non-smi or out-of-bounds access to arguments
4798 // by calling the runtime system. 4798 // by calling the runtime system.
4799 __ bind(&slow); 4799 __ bind(&slow);
4800 __ push(r1); 4800 __ push(r1);
4801 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1); 4801 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1);
4802 } 4802 }
4803 4803
4804 4804
4805 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { 4805 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm,
4806 int boilerplate_index,
4807 int arguments_object_size) {
Lasse Reichstein 2011/03/15 09:58:40 Could you get these values from methods on Argumen
Martin Maly 2011/03/16 01:21:24 Done.
4806 // sp[0] : number of parameters 4808 // sp[0] : number of parameters
4807 // sp[4] : receiver displacement 4809 // sp[4] : receiver displacement
4808 // sp[8] : function 4810 // sp[8] : function
4809 4811
4812 ASSERT(type_ != NEW_OBJECT ||
4813 (boilerplate_index == Context::ARGUMENTS_BOILERPLATE_INDEX &&
4814 arguments_object_size == Heap::kArgumentsObjectSize));
4815 ASSERT(type_ != NEW_OBJECT_STRICT ||
4816 (boilerplate_index == Context::ARGUMENTS_BOILERPLATE_STRICT_INDEX &&
4817 arguments_object_size == Heap::kArgumentsObjectSizeStrict));
4818
4810 // Check if the calling frame is an arguments adaptor frame. 4819 // Check if the calling frame is an arguments adaptor frame.
4811 Label adaptor_frame, try_allocate, runtime; 4820 Label adaptor_frame, try_allocate, runtime;
4812 __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); 4821 __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
4813 __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset)); 4822 __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset));
4814 __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); 4823 __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
4815 __ b(eq, &adaptor_frame); 4824 __ b(eq, &adaptor_frame);
4816 4825
4817 // Get the length from the frame. 4826 // Get the length from the frame.
4818 __ ldr(r1, MemOperand(sp, 0)); 4827 __ ldr(r1, MemOperand(sp, 0));
4819 __ b(&try_allocate); 4828 __ b(&try_allocate);
4820 4829
4821 // Patch the arguments.length and the parameters pointer. 4830 // Patch the arguments.length and the parameters pointer.
4822 __ bind(&adaptor_frame); 4831 __ bind(&adaptor_frame);
4823 __ ldr(r1, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset)); 4832 __ ldr(r1, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset));
4824 __ str(r1, MemOperand(sp, 0)); 4833 __ str(r1, MemOperand(sp, 0));
4825 __ add(r3, r2, Operand(r1, LSL, kPointerSizeLog2 - kSmiTagSize)); 4834 __ add(r3, r2, Operand(r1, LSL, kPointerSizeLog2 - kSmiTagSize));
4826 __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset)); 4835 __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset));
4827 __ str(r3, MemOperand(sp, 1 * kPointerSize)); 4836 __ str(r3, MemOperand(sp, 1 * kPointerSize));
4828 4837
4829 // Try the new space allocation. Start out with computing the size 4838 // Try the new space allocation. Start out with computing the size
4830 // of the arguments object and the elements array in words. 4839 // of the arguments object and the elements array in words.
4831 Label add_arguments_object; 4840 Label add_arguments_object;
4832 __ bind(&try_allocate); 4841 __ bind(&try_allocate);
4833 __ cmp(r1, Operand(0, RelocInfo::NONE)); 4842 __ cmp(r1, Operand(0, RelocInfo::NONE));
4834 __ b(eq, &add_arguments_object); 4843 __ b(eq, &add_arguments_object);
4835 __ mov(r1, Operand(r1, LSR, kSmiTagSize)); 4844 __ mov(r1, Operand(r1, LSR, kSmiTagSize));
4836 __ add(r1, r1, Operand(FixedArray::kHeaderSize / kPointerSize)); 4845 __ add(r1, r1, Operand(FixedArray::kHeaderSize / kPointerSize));
4837 __ bind(&add_arguments_object); 4846 __ bind(&add_arguments_object);
4838 __ add(r1, r1, Operand(Heap::kArgumentsObjectSize / kPointerSize)); 4847 __ add(r1, r1, Operand(arguments_object_size / kPointerSize));
4839 4848
4840 // Do the allocation of both objects in one go. 4849 // Do the allocation of both objects in one go.
4841 __ AllocateInNewSpace( 4850 __ AllocateInNewSpace(
4842 r1, 4851 r1,
4843 r0, 4852 r0,
4844 r2, 4853 r2,
4845 r3, 4854 r3,
4846 &runtime, 4855 &runtime,
4847 static_cast<AllocationFlags>(TAG_OBJECT | SIZE_IN_WORDS)); 4856 static_cast<AllocationFlags>(TAG_OBJECT | SIZE_IN_WORDS));
4848 4857
4849 // Get the arguments boilerplate from the current (global) context. 4858 // Get the arguments boilerplate from the current (global) context.
4850 int offset = Context::SlotOffset(Context::ARGUMENTS_BOILERPLATE_INDEX);
4851 __ ldr(r4, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); 4859 __ ldr(r4, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
4852 __ ldr(r4, FieldMemOperand(r4, GlobalObject::kGlobalContextOffset)); 4860 __ ldr(r4, FieldMemOperand(r4, GlobalObject::kGlobalContextOffset));
4853 __ ldr(r4, MemOperand(r4, offset)); 4861 __ ldr(r4, MemOperand(r4, Context::SlotOffset(boilerplate_index)));
4854 4862
4855 // Copy the JS object part. 4863 // Copy the JS object part.
4856 __ CopyFields(r0, r4, r3.bit(), JSObject::kHeaderSize / kPointerSize); 4864 __ CopyFields(r0, r4, r3.bit(), JSObject::kHeaderSize / kPointerSize);
4857 4865
4858 // Setup the callee in-object property. 4866 if (type_ == NEW_OBJECT) {
4859 STATIC_ASSERT(Heap::arguments_callee_index == 0); 4867 // Setup the callee in-object property.
4860 __ ldr(r3, MemOperand(sp, 2 * kPointerSize)); 4868 STATIC_ASSERT(Heap::arguments_callee_index == 1);
4861 __ str(r3, FieldMemOperand(r0, JSObject::kHeaderSize)); 4869 __ ldr(r3, MemOperand(sp, 2 * kPointerSize));
4870 __ str(r3, FieldMemOperand(r0, JSObject::kHeaderSize + kPointerSize));
4871 }
4862 4872
4863 // Get the length (smi tagged) and set that as an in-object property too. 4873 // Get the length (smi tagged) and set that as an in-object property too.
4864 STATIC_ASSERT(Heap::arguments_length_index == 1); 4874 STATIC_ASSERT(Heap::arguments_length_index == 0);
4865 __ ldr(r1, MemOperand(sp, 0 * kPointerSize)); 4875 __ ldr(r1, MemOperand(sp, 0 * kPointerSize));
4866 __ str(r1, FieldMemOperand(r0, JSObject::kHeaderSize + kPointerSize)); 4876 __ str(r1, FieldMemOperand(r0, JSObject::kHeaderSize));
4867 4877
4868 // If there are no actual arguments, we're done. 4878 // If there are no actual arguments, we're done.
4869 Label done; 4879 Label done;
4870 __ cmp(r1, Operand(0, RelocInfo::NONE)); 4880 __ cmp(r1, Operand(0, RelocInfo::NONE));
4871 __ b(eq, &done); 4881 __ b(eq, &done);
4872 4882
4873 // Get the parameters pointer from the stack. 4883 // Get the parameters pointer from the stack.
4874 __ ldr(r2, MemOperand(sp, 1 * kPointerSize)); 4884 __ ldr(r2, MemOperand(sp, 1 * kPointerSize));
4875 4885
4876 // Setup the elements pointer in the allocated arguments object and 4886 // Setup the elements pointer in the allocated arguments object and
4877 // initialize the header in the elements fixed array. 4887 // initialize the header in the elements fixed array.
4878 __ add(r4, r0, Operand(Heap::kArgumentsObjectSize)); 4888 __ add(r4, r0, Operand(arguments_object_size));
4879 __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset)); 4889 __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset));
4880 __ LoadRoot(r3, Heap::kFixedArrayMapRootIndex); 4890 __ LoadRoot(r3, Heap::kFixedArrayMapRootIndex);
4881 __ str(r3, FieldMemOperand(r4, FixedArray::kMapOffset)); 4891 __ str(r3, FieldMemOperand(r4, FixedArray::kMapOffset));
4882 __ str(r1, FieldMemOperand(r4, FixedArray::kLengthOffset)); 4892 __ str(r1, FieldMemOperand(r4, FixedArray::kLengthOffset));
4883 __ mov(r1, Operand(r1, LSR, kSmiTagSize)); // Untag the length for the loop. 4893 __ mov(r1, Operand(r1, LSR, kSmiTagSize)); // Untag the length for the loop.
4884 4894
4885 // Copy the fixed array slots. 4895 // Copy the fixed array slots.
4886 Label loop; 4896 Label loop;
4887 // Setup r4 to point to the first array slot. 4897 // Setup r4 to point to the first array slot.
4888 __ add(r4, r4, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 4898 __ add(r4, r4, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
(...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after
6848 __ str(pc, MemOperand(sp, 0)); 6858 __ str(pc, MemOperand(sp, 0));
6849 __ Jump(target); // Call the C++ function. 6859 __ Jump(target); // Call the C++ function.
6850 } 6860 }
6851 6861
6852 6862
6853 #undef __ 6863 #undef __
6854 6864
6855 } } // namespace v8::internal 6865 } } // namespace v8::internal
6856 6866
6857 #endif // V8_TARGET_ARCH_ARM 6867 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/codegen-arm.h » ('j') | src/bootstrapper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698