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

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

Issue 2645743002: [builtins] Port parameter and argument-related code stubs to CSA (Closed)
Patch Set: Review feedback Created 3 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 | « BUILD.gn ('k') | 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 2b3891e5f613abdfe28dea8432853573988a5edb..bbdd0a7dd130acd526a0d1e96b25bc1afe4df6f6 100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -3104,495 +3104,6 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
GenerateCase(masm, FAST_ELEMENTS);
}
-
-void FastNewRestParameterStub::Generate(MacroAssembler* masm) {
- // ----------- S t a t e -------------
- // -- r1 : function
- // -- cp : context
- // -- fp : frame pointer
- // -- lr : return address
- // -----------------------------------
- __ AssertFunction(r1);
-
- // Make r2 point to the JavaScript frame.
- __ mov(r2, fp);
- if (skip_stub_frame()) {
- // For Ignition we need to skip the handler/stub frame to reach the
- // JavaScript frame for the function.
- __ ldr(r2, MemOperand(r2, StandardFrameConstants::kCallerFPOffset));
- }
- if (FLAG_debug_code) {
- Label ok;
- __ ldr(ip, MemOperand(r2, StandardFrameConstants::kFunctionOffset));
- __ cmp(ip, r1);
- __ b(eq, &ok);
- __ Abort(kInvalidFrameForFastNewRestArgumentsStub);
- __ bind(&ok);
- }
-
- // Check if we have rest parameters (only possible if we have an
- // arguments adaptor frame below the function frame).
- Label no_rest_parameters;
- __ ldr(r2, MemOperand(r2, StandardFrameConstants::kCallerFPOffset));
- __ ldr(ip, MemOperand(r2, CommonFrameConstants::kContextOrFrameTypeOffset));
- __ cmp(ip, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
- __ b(ne, &no_rest_parameters);
-
- // Check if the arguments adaptor frame contains more arguments than
- // specified by the function's internal formal parameter count.
- Label rest_parameters;
- __ ldr(r0, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset));
- __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
- __ ldr(r3,
- FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset));
- __ sub(r0, r0, r3, SetCC);
- __ b(gt, &rest_parameters);
-
- // Return an empty rest parameter array.
- __ bind(&no_rest_parameters);
- {
- // ----------- S t a t e -------------
- // -- cp : context
- // -- lr : return address
- // -----------------------------------
-
- // Allocate an empty rest parameter array.
- Label allocate, done_allocate;
- __ Allocate(JSArray::kSize, r0, r1, r2, &allocate, NO_ALLOCATION_FLAGS);
- __ bind(&done_allocate);
-
- // Setup the rest parameter array in r0.
- __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, r1);
- __ str(r1, FieldMemOperand(r0, JSArray::kMapOffset));
- __ LoadRoot(r1, Heap::kEmptyFixedArrayRootIndex);
- __ str(r1, FieldMemOperand(r0, JSArray::kPropertiesOffset));
- __ str(r1, FieldMemOperand(r0, JSArray::kElementsOffset));
- __ mov(r1, Operand(0));
- __ str(r1, FieldMemOperand(r0, JSArray::kLengthOffset));
- STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize);
- __ Ret();
-
- // Fall back to %AllocateInNewSpace.
- __ bind(&allocate);
- {
- FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
- __ Push(Smi::FromInt(JSArray::kSize));
- __ CallRuntime(Runtime::kAllocateInNewSpace);
- }
- __ jmp(&done_allocate);
- }
-
- __ bind(&rest_parameters);
- {
- // Compute the pointer to the first rest parameter (skippping the receiver).
- __ add(r2, r2, Operand(r0, LSL, kPointerSizeLog2 - 1));
- __ add(r2, r2,
- Operand(StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize));
-
- // ----------- S t a t e -------------
- // -- cp : context
- // -- r0 : number of rest parameters (tagged)
- // -- r1 : function
- // -- r2 : pointer to first rest parameters
- // -- lr : return address
- // -----------------------------------
-
- // Allocate space for the rest parameter array plus the backing store.
- Label allocate, done_allocate;
- __ mov(r6, Operand(JSArray::kSize + FixedArray::kHeaderSize));
- __ add(r6, r6, Operand(r0, LSL, kPointerSizeLog2 - 1));
- __ Allocate(r6, r3, r4, r5, &allocate, NO_ALLOCATION_FLAGS);
- __ bind(&done_allocate);
-
- // Setup the elements array in r3.
- __ LoadRoot(r1, Heap::kFixedArrayMapRootIndex);
- __ str(r1, FieldMemOperand(r3, FixedArray::kMapOffset));
- __ str(r0, FieldMemOperand(r3, FixedArray::kLengthOffset));
- __ add(r4, r3, Operand(FixedArray::kHeaderSize));
- {
- Label loop, done_loop;
- __ add(r1, r4, Operand(r0, LSL, kPointerSizeLog2 - 1));
- __ bind(&loop);
- __ cmp(r4, r1);
- __ b(eq, &done_loop);
- __ ldr(ip, MemOperand(r2, 1 * kPointerSize, NegPostIndex));
- __ str(ip, FieldMemOperand(r4, 0 * kPointerSize));
- __ add(r4, r4, Operand(1 * kPointerSize));
- __ b(&loop);
- __ bind(&done_loop);
- }
-
- // Setup the rest parameter array in r4.
- __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, r1);
- __ str(r1, FieldMemOperand(r4, JSArray::kMapOffset));
- __ LoadRoot(r1, Heap::kEmptyFixedArrayRootIndex);
- __ str(r1, FieldMemOperand(r4, JSArray::kPropertiesOffset));
- __ str(r3, FieldMemOperand(r4, JSArray::kElementsOffset));
- __ str(r0, FieldMemOperand(r4, JSArray::kLengthOffset));
- STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize);
- __ mov(r0, r4);
- __ Ret();
-
- // Fall back to %AllocateInNewSpace (if not too big).
- Label too_big_for_new_space;
- __ bind(&allocate);
- __ cmp(r6, Operand(kMaxRegularHeapObjectSize));
- __ b(gt, &too_big_for_new_space);
- {
- FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
- __ SmiTag(r6);
- __ Push(r0, r2, r6);
- __ CallRuntime(Runtime::kAllocateInNewSpace);
- __ mov(r3, r0);
- __ Pop(r0, r2);
- }
- __ jmp(&done_allocate);
-
- // Fall back to %NewRestParameter.
- __ bind(&too_big_for_new_space);
- __ push(r1);
- __ TailCallRuntime(Runtime::kNewRestParameter);
- }
-}
-
-
-void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) {
- // ----------- S t a t e -------------
- // -- r1 : function
- // -- cp : context
- // -- fp : frame pointer
- // -- lr : return address
- // -----------------------------------
- __ AssertFunction(r1);
-
- // Make r9 point to the JavaScript frame.
- __ mov(r9, fp);
- if (skip_stub_frame()) {
- // For Ignition we need to skip the handler/stub frame to reach the
- // JavaScript frame for the function.
- __ ldr(r9, MemOperand(r9, StandardFrameConstants::kCallerFPOffset));
- }
- if (FLAG_debug_code) {
- Label ok;
- __ ldr(ip, MemOperand(r9, StandardFrameConstants::kFunctionOffset));
- __ cmp(ip, r1);
- __ b(eq, &ok);
- __ Abort(kInvalidFrameForFastNewRestArgumentsStub);
- __ bind(&ok);
- }
-
- // TODO(bmeurer): Cleanup to match the FastNewStrictArgumentsStub.
- __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
- __ ldr(r2,
- FieldMemOperand(r2, SharedFunctionInfo::kFormalParameterCountOffset));
- __ add(r3, r9, Operand(r2, LSL, kPointerSizeLog2 - 1));
- __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset));
-
- // r1 : function
- // r2 : number of parameters (tagged)
- // r3 : parameters pointer
- // r9 : JavaScript frame 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(r9, StandardFrameConstants::kCallerFPOffset));
- __ ldr(r0, MemOperand(r4, CommonFrameConstants::kContextOrFrameTypeOffset));
- __ 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::kZero));
- __ 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, NO_ALLOCATION_FLAGS);
-
- // 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::kZero));
- // 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::kZero));
- __ 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
- // -- cp : context
- // -- fp : frame pointer
- // -- lr : return address
- // -----------------------------------
- __ AssertFunction(r1);
-
- // Make r2 point to the JavaScript frame.
- __ mov(r2, fp);
- if (skip_stub_frame()) {
- // For Ignition we need to skip the handler/stub frame to reach the
- // JavaScript frame for the function.
- __ ldr(r2, MemOperand(r2, StandardFrameConstants::kCallerFPOffset));
- }
- if (FLAG_debug_code) {
- Label ok;
- __ ldr(ip, MemOperand(r2, StandardFrameConstants::kFunctionOffset));
- __ cmp(ip, r1);
- __ b(eq, &ok);
- __ Abort(kInvalidFrameForFastNewRestArgumentsStub);
- __ bind(&ok);
- }
-
- // Check if we have an arguments adaptor frame below the function frame.
- Label arguments_adaptor, arguments_done;
- __ ldr(r3, MemOperand(r2, StandardFrameConstants::kCallerFPOffset));
- __ ldr(ip, MemOperand(r3, CommonFrameConstants::kContextOrFrameTypeOffset));
- __ cmp(ip, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
- __ b(eq, &arguments_adaptor);
- {
- __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
- __ ldr(r0, FieldMemOperand(
- r4, SharedFunctionInfo::kFormalParameterCountOffset));
- __ add(r2, r2, Operand(r0, LSL, kPointerSizeLog2 - 1));
- __ add(r2, r2,
- Operand(StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize));
- }
- __ b(&arguments_done);
- __ bind(&arguments_adaptor);
- {
- __ ldr(r0, MemOperand(r3, ArgumentsAdaptorFrameConstants::kLengthOffset));
- __ add(r2, r3, Operand(r0, LSL, kPointerSizeLog2 - 1));
- __ add(r2, r2,
- Operand(StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize));
- }
- __ bind(&arguments_done);
-
- // ----------- S t a t e -------------
- // -- cp : context
- // -- r0 : number of rest parameters (tagged)
- // -- r1 : function
- // -- r2 : pointer to first rest parameters
- // -- lr : return address
- // -----------------------------------
-
- // Allocate space for the strict arguments object plus the backing store.
- Label allocate, done_allocate;
- __ mov(r6, Operand(JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize));
- __ add(r6, r6, Operand(r0, LSL, kPointerSizeLog2 - 1));
- __ Allocate(r6, r3, r4, r5, &allocate, NO_ALLOCATION_FLAGS);
- __ bind(&done_allocate);
-
- // Setup the elements array in r3.
- __ LoadRoot(r1, Heap::kFixedArrayMapRootIndex);
- __ str(r1, FieldMemOperand(r3, FixedArray::kMapOffset));
- __ str(r0, FieldMemOperand(r3, FixedArray::kLengthOffset));
- __ add(r4, r3, Operand(FixedArray::kHeaderSize));
- {
- Label loop, done_loop;
- __ add(r1, r4, Operand(r0, LSL, kPointerSizeLog2 - 1));
- __ bind(&loop);
- __ cmp(r4, r1);
- __ b(eq, &done_loop);
- __ ldr(ip, MemOperand(r2, 1 * kPointerSize, NegPostIndex));
- __ str(ip, FieldMemOperand(r4, 0 * kPointerSize));
- __ add(r4, r4, Operand(1 * kPointerSize));
- __ b(&loop);
- __ bind(&done_loop);
- }
-
- // Setup the strict arguments object in r4.
- __ LoadNativeContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX, r1);
- __ str(r1, FieldMemOperand(r4, JSStrictArgumentsObject::kMapOffset));
- __ LoadRoot(r1, Heap::kEmptyFixedArrayRootIndex);
- __ str(r1, FieldMemOperand(r4, JSStrictArgumentsObject::kPropertiesOffset));
- __ str(r3, FieldMemOperand(r4, JSStrictArgumentsObject::kElementsOffset));
- __ str(r0, FieldMemOperand(r4, JSStrictArgumentsObject::kLengthOffset));
- STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize);
- __ mov(r0, r4);
- __ Ret();
-
- // Fall back to %AllocateInNewSpace (if not too big).
- Label too_big_for_new_space;
- __ bind(&allocate);
- __ cmp(r6, Operand(kMaxRegularHeapObjectSize));
- __ b(gt, &too_big_for_new_space);
- {
- FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
- __ SmiTag(r6);
- __ Push(r0, r2, r6);
- __ CallRuntime(Runtime::kAllocateInNewSpace);
- __ mov(r3, r0);
- __ Pop(r0, r2);
- }
- __ b(&done_allocate);
-
- // Fall back to %NewStrictArguments.
- __ bind(&too_big_for_new_space);
- __ push(r1);
- __ TailCallRuntime(Runtime::kNewStrictArguments);
-}
-
-
static int AddressOffset(ExternalReference ref0, ExternalReference ref1) {
return ref0.address() - ref1.address();
}
« no previous file with comments | « BUILD.gn ('k') | src/arm/interface-descriptors-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698