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

Unified Diff: src/arm/code-stubs-arm.cc

Issue 1701653002: Revert of [runtime] Turn ArgumentAccessStub into FastNewSloppyArgumentsStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/arm/interface-descriptors-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm/code-stubs-arm.cc
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc
index d776b08c656159521a78bc6b1e73ae795f5c3e58..0d139bb6620e9f5751108e7901a77910c70327ff 100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -1489,6 +1489,227 @@
}
+void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) {
+ // r1 : function
+ // r2 : number of parameters (tagged)
+ // r3 : parameters pointer
+
+ DCHECK(r1.is(ArgumentsAccessNewDescriptor::function()));
+ DCHECK(r2.is(ArgumentsAccessNewDescriptor::parameter_count()));
+ DCHECK(r3.is(ArgumentsAccessNewDescriptor::parameter_pointer()));
+
+ // Check if the calling frame is an arguments adaptor frame.
+ Label runtime;
+ __ ldr(r4, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
+ __ ldr(r0, MemOperand(r4, StandardFrameConstants::kContextOffset));
+ __ cmp(r0, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
+ __ b(ne, &runtime);
+
+ // Patch the arguments.length and the parameters pointer in the current frame.
+ __ ldr(r2, MemOperand(r4, ArgumentsAdaptorFrameConstants::kLengthOffset));
+ __ add(r4, r4, Operand(r2, LSL, 1));
+ __ add(r3, r4, Operand(StandardFrameConstants::kCallerSPOffset));
+
+ __ bind(&runtime);
+ __ Push(r1, r3, r2);
+ __ TailCallRuntime(Runtime::kNewSloppyArguments);
+}
+
+
+void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) {
+ // r1 : function
+ // r2 : number of parameters (tagged)
+ // r3 : parameters pointer
+ // Registers used over whole function:
+ // r5 : arguments count (tagged)
+ // r6 : mapped parameter count (tagged)
+
+ DCHECK(r1.is(ArgumentsAccessNewDescriptor::function()));
+ DCHECK(r2.is(ArgumentsAccessNewDescriptor::parameter_count()));
+ DCHECK(r3.is(ArgumentsAccessNewDescriptor::parameter_pointer()));
+
+ // Check if the calling frame is an arguments adaptor frame.
+ Label adaptor_frame, try_allocate, runtime;
+ __ ldr(r4, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
+ __ ldr(r0, MemOperand(r4, StandardFrameConstants::kContextOffset));
+ __ cmp(r0, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
+ __ b(eq, &adaptor_frame);
+
+ // No adaptor, parameter count = argument count.
+ __ mov(r5, r2);
+ __ mov(r6, r2);
+ __ b(&try_allocate);
+
+ // We have an adaptor frame. Patch the parameters pointer.
+ __ bind(&adaptor_frame);
+ __ ldr(r5, MemOperand(r4, ArgumentsAdaptorFrameConstants::kLengthOffset));
+ __ add(r4, r4, Operand(r5, LSL, 1));
+ __ add(r3, r4, Operand(StandardFrameConstants::kCallerSPOffset));
+
+ // r5 = argument count (tagged)
+ // r6 = parameter count (tagged)
+ // Compute the mapped parameter count = min(r6, r5) in r6.
+ __ mov(r6, r2);
+ __ cmp(r6, Operand(r5));
+ __ mov(r6, Operand(r5), LeaveCC, gt);
+
+ __ bind(&try_allocate);
+
+ // Compute the sizes of backing store, parameter map, and arguments object.
+ // 1. Parameter map, has 2 extra words containing context and backing store.
+ const int kParameterMapHeaderSize =
+ FixedArray::kHeaderSize + 2 * kPointerSize;
+ // If there are no mapped parameters, we do not need the parameter_map.
+ __ cmp(r6, Operand(Smi::FromInt(0)));
+ __ mov(r9, Operand::Zero(), LeaveCC, eq);
+ __ mov(r9, Operand(r6, LSL, 1), LeaveCC, ne);
+ __ add(r9, r9, Operand(kParameterMapHeaderSize), LeaveCC, ne);
+
+ // 2. Backing store.
+ __ add(r9, r9, Operand(r5, LSL, 1));
+ __ add(r9, r9, Operand(FixedArray::kHeaderSize));
+
+ // 3. Arguments object.
+ __ add(r9, r9, Operand(JSSloppyArgumentsObject::kSize));
+
+ // Do the allocation of all three objects in one go.
+ __ Allocate(r9, r0, r9, r4, &runtime, TAG_OBJECT);
+
+ // r0 = address of new object(s) (tagged)
+ // r2 = argument count (smi-tagged)
+ // Get the arguments boilerplate from the current native context into r4.
+ const int kNormalOffset =
+ Context::SlotOffset(Context::SLOPPY_ARGUMENTS_MAP_INDEX);
+ const int kAliasedOffset =
+ Context::SlotOffset(Context::FAST_ALIASED_ARGUMENTS_MAP_INDEX);
+
+ __ ldr(r4, NativeContextMemOperand());
+ __ cmp(r6, Operand::Zero());
+ __ ldr(r4, MemOperand(r4, kNormalOffset), eq);
+ __ ldr(r4, MemOperand(r4, kAliasedOffset), ne);
+
+ // r0 = address of new object (tagged)
+ // r2 = argument count (smi-tagged)
+ // r4 = address of arguments map (tagged)
+ // r6 = mapped parameter count (tagged)
+ __ str(r4, FieldMemOperand(r0, JSObject::kMapOffset));
+ __ LoadRoot(r9, Heap::kEmptyFixedArrayRootIndex);
+ __ str(r9, FieldMemOperand(r0, JSObject::kPropertiesOffset));
+ __ str(r9, FieldMemOperand(r0, JSObject::kElementsOffset));
+
+ // Set up the callee in-object property.
+ __ AssertNotSmi(r1);
+ __ str(r1, FieldMemOperand(r0, JSSloppyArgumentsObject::kCalleeOffset));
+
+ // Use the length (smi tagged) and set that as an in-object property too.
+ __ AssertSmi(r5);
+ __ str(r5, FieldMemOperand(r0, JSSloppyArgumentsObject::kLengthOffset));
+
+ // Set up the elements pointer in the allocated arguments object.
+ // If we allocated a parameter map, r4 will point there, otherwise
+ // it will point to the backing store.
+ __ add(r4, r0, Operand(JSSloppyArgumentsObject::kSize));
+ __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset));
+
+ // r0 = address of new object (tagged)
+ // r2 = argument count (tagged)
+ // r4 = address of parameter map or backing store (tagged)
+ // r6 = mapped parameter count (tagged)
+ // Initialize parameter map. If there are no mapped arguments, we're done.
+ Label skip_parameter_map;
+ __ cmp(r6, Operand(Smi::FromInt(0)));
+ // Move backing store address to r1, because it is
+ // expected there when filling in the unmapped arguments.
+ __ mov(r1, r4, LeaveCC, eq);
+ __ b(eq, &skip_parameter_map);
+
+ __ LoadRoot(r5, Heap::kSloppyArgumentsElementsMapRootIndex);
+ __ str(r5, FieldMemOperand(r4, FixedArray::kMapOffset));
+ __ add(r5, r6, Operand(Smi::FromInt(2)));
+ __ str(r5, FieldMemOperand(r4, FixedArray::kLengthOffset));
+ __ str(cp, FieldMemOperand(r4, FixedArray::kHeaderSize + 0 * kPointerSize));
+ __ add(r5, r4, Operand(r6, LSL, 1));
+ __ add(r5, r5, Operand(kParameterMapHeaderSize));
+ __ str(r5, FieldMemOperand(r4, FixedArray::kHeaderSize + 1 * kPointerSize));
+
+ // Copy the parameter slots and the holes in the arguments.
+ // We need to fill in mapped_parameter_count slots. They index the context,
+ // where parameters are stored in reverse order, at
+ // MIN_CONTEXT_SLOTS .. MIN_CONTEXT_SLOTS+parameter_count-1
+ // The mapped parameter thus need to get indices
+ // MIN_CONTEXT_SLOTS+parameter_count-1 ..
+ // MIN_CONTEXT_SLOTS+parameter_count-mapped_parameter_count
+ // We loop from right to left.
+ Label parameters_loop, parameters_test;
+ __ mov(r5, r6);
+ __ add(r9, r2, Operand(Smi::FromInt(Context::MIN_CONTEXT_SLOTS)));
+ __ sub(r9, r9, Operand(r6));
+ __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
+ __ add(r1, r4, Operand(r5, LSL, 1));
+ __ add(r1, r1, Operand(kParameterMapHeaderSize));
+
+ // r1 = address of backing store (tagged)
+ // r4 = address of parameter map (tagged), which is also the address of new
+ // object + Heap::kSloppyArgumentsObjectSize (tagged)
+ // r0 = temporary scratch (a.o., for address calculation)
+ // r5 = loop variable (tagged)
+ // ip = the hole value
+ __ jmp(&parameters_test);
+
+ __ bind(&parameters_loop);
+ __ sub(r5, r5, Operand(Smi::FromInt(1)));
+ __ mov(r0, Operand(r5, LSL, 1));
+ __ add(r0, r0, Operand(kParameterMapHeaderSize - kHeapObjectTag));
+ __ str(r9, MemOperand(r4, r0));
+ __ sub(r0, r0, Operand(kParameterMapHeaderSize - FixedArray::kHeaderSize));
+ __ str(ip, MemOperand(r1, r0));
+ __ add(r9, r9, Operand(Smi::FromInt(1)));
+ __ bind(&parameters_test);
+ __ cmp(r5, Operand(Smi::FromInt(0)));
+ __ b(ne, &parameters_loop);
+
+ // Restore r0 = new object (tagged) and r5 = argument count (tagged).
+ __ sub(r0, r4, Operand(JSSloppyArgumentsObject::kSize));
+ __ ldr(r5, FieldMemOperand(r0, JSSloppyArgumentsObject::kLengthOffset));
+
+ __ bind(&skip_parameter_map);
+ // r0 = address of new object (tagged)
+ // r1 = address of backing store (tagged)
+ // r5 = argument count (tagged)
+ // r6 = mapped parameter count (tagged)
+ // r9 = scratch
+ // Copy arguments header and remaining slots (if there are any).
+ __ LoadRoot(r9, Heap::kFixedArrayMapRootIndex);
+ __ str(r9, FieldMemOperand(r1, FixedArray::kMapOffset));
+ __ str(r5, FieldMemOperand(r1, FixedArray::kLengthOffset));
+
+ Label arguments_loop, arguments_test;
+ __ sub(r3, r3, Operand(r6, LSL, 1));
+ __ jmp(&arguments_test);
+
+ __ bind(&arguments_loop);
+ __ sub(r3, r3, Operand(kPointerSize));
+ __ ldr(r4, MemOperand(r3, 0));
+ __ add(r9, r1, Operand(r6, LSL, 1));
+ __ str(r4, FieldMemOperand(r9, FixedArray::kHeaderSize));
+ __ add(r6, r6, Operand(Smi::FromInt(1)));
+
+ __ bind(&arguments_test);
+ __ cmp(r6, Operand(r5));
+ __ b(lt, &arguments_loop);
+
+ // Return.
+ __ Ret();
+
+ // Do the runtime call to allocate the arguments object.
+ // r0 = address of new object (tagged)
+ // r5 = argument count (tagged)
+ __ bind(&runtime);
+ __ Push(r1, r3, r5);
+ __ TailCallRuntime(Runtime::kNewSloppyArguments);
+}
+
+
void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
// Return address is in lr.
Label slow;
@@ -4726,211 +4947,6 @@
}
-void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) {
- // ----------- S t a t e -------------
- // -- r1 : function
- // -- cp : context
- // -- fp : frame pointer
- // -- lr : return address
- // -----------------------------------
- __ AssertFunction(r1);
-
- // TODO(bmeurer): Cleanup to match the FastNewStrictArgumentsStub.
- __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
- __ ldr(r2,
- FieldMemOperand(r2, SharedFunctionInfo::kFormalParameterCountOffset));
- __ add(r3, fp, Operand(r2, LSL, kPointerSizeLog2 - 1));
- __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset));
-
- // r1 : function
- // r2 : number of parameters (tagged)
- // r3 : parameters pointer
- // Registers used over whole function:
- // r5 : arguments count (tagged)
- // r6 : mapped parameter count (tagged)
-
- // Check if the calling frame is an arguments adaptor frame.
- Label adaptor_frame, try_allocate, runtime;
- __ ldr(r4, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
- __ ldr(r0, MemOperand(r4, StandardFrameConstants::kContextOffset));
- __ cmp(r0, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
- __ b(eq, &adaptor_frame);
-
- // No adaptor, parameter count = argument count.
- __ mov(r5, r2);
- __ mov(r6, r2);
- __ b(&try_allocate);
-
- // We have an adaptor frame. Patch the parameters pointer.
- __ bind(&adaptor_frame);
- __ ldr(r5, MemOperand(r4, ArgumentsAdaptorFrameConstants::kLengthOffset));
- __ add(r4, r4, Operand(r5, LSL, 1));
- __ add(r3, r4, Operand(StandardFrameConstants::kCallerSPOffset));
-
- // r5 = argument count (tagged)
- // r6 = parameter count (tagged)
- // Compute the mapped parameter count = min(r6, r5) in r6.
- __ mov(r6, r2);
- __ cmp(r6, Operand(r5));
- __ mov(r6, Operand(r5), LeaveCC, gt);
-
- __ bind(&try_allocate);
-
- // Compute the sizes of backing store, parameter map, and arguments object.
- // 1. Parameter map, has 2 extra words containing context and backing store.
- const int kParameterMapHeaderSize =
- FixedArray::kHeaderSize + 2 * kPointerSize;
- // If there are no mapped parameters, we do not need the parameter_map.
- __ cmp(r6, Operand(Smi::FromInt(0)));
- __ mov(r9, Operand::Zero(), LeaveCC, eq);
- __ mov(r9, Operand(r6, LSL, 1), LeaveCC, ne);
- __ add(r9, r9, Operand(kParameterMapHeaderSize), LeaveCC, ne);
-
- // 2. Backing store.
- __ add(r9, r9, Operand(r5, LSL, 1));
- __ add(r9, r9, Operand(FixedArray::kHeaderSize));
-
- // 3. Arguments object.
- __ add(r9, r9, Operand(JSSloppyArgumentsObject::kSize));
-
- // Do the allocation of all three objects in one go.
- __ Allocate(r9, r0, r9, r4, &runtime, TAG_OBJECT);
-
- // r0 = address of new object(s) (tagged)
- // r2 = argument count (smi-tagged)
- // Get the arguments boilerplate from the current native context into r4.
- const int kNormalOffset =
- Context::SlotOffset(Context::SLOPPY_ARGUMENTS_MAP_INDEX);
- const int kAliasedOffset =
- Context::SlotOffset(Context::FAST_ALIASED_ARGUMENTS_MAP_INDEX);
-
- __ ldr(r4, NativeContextMemOperand());
- __ cmp(r6, Operand::Zero());
- __ ldr(r4, MemOperand(r4, kNormalOffset), eq);
- __ ldr(r4, MemOperand(r4, kAliasedOffset), ne);
-
- // r0 = address of new object (tagged)
- // r2 = argument count (smi-tagged)
- // r4 = address of arguments map (tagged)
- // r6 = mapped parameter count (tagged)
- __ str(r4, FieldMemOperand(r0, JSObject::kMapOffset));
- __ LoadRoot(r9, Heap::kEmptyFixedArrayRootIndex);
- __ str(r9, FieldMemOperand(r0, JSObject::kPropertiesOffset));
- __ str(r9, FieldMemOperand(r0, JSObject::kElementsOffset));
-
- // Set up the callee in-object property.
- __ AssertNotSmi(r1);
- __ str(r1, FieldMemOperand(r0, JSSloppyArgumentsObject::kCalleeOffset));
-
- // Use the length (smi tagged) and set that as an in-object property too.
- __ AssertSmi(r5);
- __ str(r5, FieldMemOperand(r0, JSSloppyArgumentsObject::kLengthOffset));
-
- // Set up the elements pointer in the allocated arguments object.
- // If we allocated a parameter map, r4 will point there, otherwise
- // it will point to the backing store.
- __ add(r4, r0, Operand(JSSloppyArgumentsObject::kSize));
- __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset));
-
- // r0 = address of new object (tagged)
- // r2 = argument count (tagged)
- // r4 = address of parameter map or backing store (tagged)
- // r6 = mapped parameter count (tagged)
- // Initialize parameter map. If there are no mapped arguments, we're done.
- Label skip_parameter_map;
- __ cmp(r6, Operand(Smi::FromInt(0)));
- // Move backing store address to r1, because it is
- // expected there when filling in the unmapped arguments.
- __ mov(r1, r4, LeaveCC, eq);
- __ b(eq, &skip_parameter_map);
-
- __ LoadRoot(r5, Heap::kSloppyArgumentsElementsMapRootIndex);
- __ str(r5, FieldMemOperand(r4, FixedArray::kMapOffset));
- __ add(r5, r6, Operand(Smi::FromInt(2)));
- __ str(r5, FieldMemOperand(r4, FixedArray::kLengthOffset));
- __ str(cp, FieldMemOperand(r4, FixedArray::kHeaderSize + 0 * kPointerSize));
- __ add(r5, r4, Operand(r6, LSL, 1));
- __ add(r5, r5, Operand(kParameterMapHeaderSize));
- __ str(r5, FieldMemOperand(r4, FixedArray::kHeaderSize + 1 * kPointerSize));
-
- // Copy the parameter slots and the holes in the arguments.
- // We need to fill in mapped_parameter_count slots. They index the context,
- // where parameters are stored in reverse order, at
- // MIN_CONTEXT_SLOTS .. MIN_CONTEXT_SLOTS+parameter_count-1
- // The mapped parameter thus need to get indices
- // MIN_CONTEXT_SLOTS+parameter_count-1 ..
- // MIN_CONTEXT_SLOTS+parameter_count-mapped_parameter_count
- // We loop from right to left.
- Label parameters_loop, parameters_test;
- __ mov(r5, r6);
- __ add(r9, r2, Operand(Smi::FromInt(Context::MIN_CONTEXT_SLOTS)));
- __ sub(r9, r9, Operand(r6));
- __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
- __ add(r1, r4, Operand(r5, LSL, 1));
- __ add(r1, r1, Operand(kParameterMapHeaderSize));
-
- // r1 = address of backing store (tagged)
- // r4 = address of parameter map (tagged), which is also the address of new
- // object + Heap::kSloppyArgumentsObjectSize (tagged)
- // r0 = temporary scratch (a.o., for address calculation)
- // r5 = loop variable (tagged)
- // ip = the hole value
- __ jmp(&parameters_test);
-
- __ bind(&parameters_loop);
- __ sub(r5, r5, Operand(Smi::FromInt(1)));
- __ mov(r0, Operand(r5, LSL, 1));
- __ add(r0, r0, Operand(kParameterMapHeaderSize - kHeapObjectTag));
- __ str(r9, MemOperand(r4, r0));
- __ sub(r0, r0, Operand(kParameterMapHeaderSize - FixedArray::kHeaderSize));
- __ str(ip, MemOperand(r1, r0));
- __ add(r9, r9, Operand(Smi::FromInt(1)));
- __ bind(&parameters_test);
- __ cmp(r5, Operand(Smi::FromInt(0)));
- __ b(ne, &parameters_loop);
-
- // Restore r0 = new object (tagged) and r5 = argument count (tagged).
- __ sub(r0, r4, Operand(JSSloppyArgumentsObject::kSize));
- __ ldr(r5, FieldMemOperand(r0, JSSloppyArgumentsObject::kLengthOffset));
-
- __ bind(&skip_parameter_map);
- // r0 = address of new object (tagged)
- // r1 = address of backing store (tagged)
- // r5 = argument count (tagged)
- // r6 = mapped parameter count (tagged)
- // r9 = scratch
- // Copy arguments header and remaining slots (if there are any).
- __ LoadRoot(r9, Heap::kFixedArrayMapRootIndex);
- __ str(r9, FieldMemOperand(r1, FixedArray::kMapOffset));
- __ str(r5, FieldMemOperand(r1, FixedArray::kLengthOffset));
-
- Label arguments_loop, arguments_test;
- __ sub(r3, r3, Operand(r6, LSL, 1));
- __ jmp(&arguments_test);
-
- __ bind(&arguments_loop);
- __ sub(r3, r3, Operand(kPointerSize));
- __ ldr(r4, MemOperand(r3, 0));
- __ add(r9, r1, Operand(r6, LSL, 1));
- __ str(r4, FieldMemOperand(r9, FixedArray::kHeaderSize));
- __ add(r6, r6, Operand(Smi::FromInt(1)));
-
- __ bind(&arguments_test);
- __ cmp(r6, Operand(r5));
- __ b(lt, &arguments_loop);
-
- // Return.
- __ Ret();
-
- // Do the runtime call to allocate the arguments object.
- // r0 = address of new object (tagged)
- // r5 = argument count (tagged)
- __ bind(&runtime);
- __ Push(r1, r3, r5);
- __ TailCallRuntime(Runtime::kNewSloppyArguments);
-}
-
-
void FastNewStrictArgumentsStub::Generate(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r1 : function
« no previous file with comments | « no previous file | src/arm/interface-descriptors-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698