Commit 9385fd40 authored by bjaideep's avatar bjaideep Committed by Commit Bot

PPC/s390: [builtins] Start refactoring the Apply builtin.

Port af76779a

Original Commit Message:

    This splits the monolithic Apply builtin into several smaller builtins,
    namely CallVargargs and ConstructVarargs, which accept a length and a
    FixedArray of elements and deal with the actual stack manipulation, and
    CallWithArrayLike / ConstructWithArrayLike that deal with getting the
    elements from the receiver (for Function.prototype.apply, Reflect.apply
    and Reflect.construct), which can now be written using the CSA.

    The idea is that these builtins can be reused by TurboFan directly in
    the future when we optimize apply better, and that we can also reuse the
    core logic in the handling of spread calls/constructs.

R=bmeurer@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=v8:4587,v8:5269
LOG=N

Review-Url: https://codereview.chromium.org/2932833002
Cr-Commit-Position: refs/heads/master@{#45826}
parent 3b16f676
This diff is collapsed.
This diff is collapsed.
...@@ -155,6 +155,16 @@ void CallTrampolineDescriptor::InitializePlatformSpecific( ...@@ -155,6 +155,16 @@ void CallTrampolineDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void CallVarargsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r3 : number of arguments (on the stack, not including receiver)
// r4 : the target to call
// r5 : arguments list (FixedArray)
// r7 : arguments list length (untagged)
Register registers[] = {r4, r3, r5, r7};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallForwardVarargsDescriptor::InitializePlatformSpecific( void CallForwardVarargsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// r3 : number of arguments // r3 : number of arguments
...@@ -164,6 +174,25 @@ void CallForwardVarargsDescriptor::InitializePlatformSpecific( ...@@ -164,6 +174,25 @@ void CallForwardVarargsDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void CallWithArrayLikeDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r4 : the target to call
// r5 : the arguments list
Register registers[] = {r4, r5};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ConstructVarargsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r3 : number of arguments (on the stack, not including receiver)
// r4 : the target to call
// r6 : the new target
// r5 : arguments list (FixedArray)
// r7 : arguments list length (untagged)
Register registers[] = {r4, r6, r3, r5, r7};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ConstructForwardVarargsDescriptor::InitializePlatformSpecific( void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// r3 : number of arguments // r3 : number of arguments
...@@ -174,6 +203,15 @@ void ConstructForwardVarargsDescriptor::InitializePlatformSpecific( ...@@ -174,6 +203,15 @@ void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r4 : the target to call
// r6 : the new target
// r5 : the arguments list
Register registers[] = {r4, r6, r5};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ConstructStubDescriptor::InitializePlatformSpecific( void ConstructStubDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// r3 : number of arguments // r3 : number of arguments
......
...@@ -2598,6 +2598,17 @@ void MacroAssembler::AssertSmi(Register object) { ...@@ -2598,6 +2598,17 @@ void MacroAssembler::AssertSmi(Register object) {
} }
} }
void MacroAssembler::AssertFixedArray(Register object) {
if (emit_debug_code()) {
STATIC_ASSERT(kSmiTag == 0);
TestIfSmi(object, r0);
Check(ne, kOperandIsASmiAndNotAFixedArray, cr0);
push(object);
CompareObjectType(object, object, object, FIXED_ARRAY_TYPE);
pop(object);
Check(eq, kOperandIsNotAFixedArray);
}
}
void MacroAssembler::AssertFunction(Register object) { void MacroAssembler::AssertFunction(Register object) {
if (emit_debug_code()) { if (emit_debug_code()) {
......
...@@ -1303,6 +1303,9 @@ class MacroAssembler : public Assembler { ...@@ -1303,6 +1303,9 @@ class MacroAssembler : public Assembler {
#define SmiWordOffset(offset) offset #define SmiWordOffset(offset) offset
#endif #endif
// Abort execution if argument is not a FixedArray, enabled via --debug-code.
void AssertFixedArray(Register object);
void AssertFunction(Register object); void AssertFunction(Register object);
// Abort execution if argument is not a JSBoundFunction, // Abort execution if argument is not a JSBoundFunction,
......
...@@ -145,6 +145,16 @@ void CallTrampolineDescriptor::InitializePlatformSpecific( ...@@ -145,6 +145,16 @@ void CallTrampolineDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void CallVarargsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r2 : number of arguments (on the stack, not including receiver)
// r3 : the target to call
// r4 : arguments list (FixedArray)
// r6 : arguments list length (untagged)
Register registers[] = {r3, r2, r4, r6};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallForwardVarargsDescriptor::InitializePlatformSpecific( void CallForwardVarargsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// r2 : number of arguments // r2 : number of arguments
...@@ -154,6 +164,25 @@ void CallForwardVarargsDescriptor::InitializePlatformSpecific( ...@@ -154,6 +164,25 @@ void CallForwardVarargsDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void CallWithArrayLikeDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r3 : the target to call
// r4 : the arguments list
Register registers[] = {r3, r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ConstructVarargsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r2 : number of arguments (on the stack, not including receiver)
// r3 : the target to call
// r5 : the new target
// r4 : arguments list (FixedArray)
// r6 : arguments list length (untagged)
Register registers[] = {r3, r5, r2, r4, r6};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ConstructForwardVarargsDescriptor::InitializePlatformSpecific( void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// r2 : number of arguments // r2 : number of arguments
...@@ -164,6 +193,15 @@ void ConstructForwardVarargsDescriptor::InitializePlatformSpecific( ...@@ -164,6 +193,15 @@ void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r3 : the target to call
// r5 : the new target
// r4 : the arguments list
Register registers[] = {r3, r5, r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ConstructStubDescriptor::InitializePlatformSpecific( void ConstructStubDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// r2 : number of arguments // r2 : number of arguments
......
...@@ -2374,6 +2374,18 @@ void MacroAssembler::AssertSmi(Register object) { ...@@ -2374,6 +2374,18 @@ void MacroAssembler::AssertSmi(Register object) {
} }
} }
void MacroAssembler::AssertFixedArray(Register object) {
if (emit_debug_code()) {
STATIC_ASSERT(kSmiTag == 0);
TestIfSmi(object);
Check(ne, kOperandIsASmiAndNotAFixedArray, cr0);
push(object);
CompareObjectType(object, object, object, FIXED_ARRAY_TYPE);
pop(object);
Check(eq, kOperandIsNotAFixedArray);
}
}
void MacroAssembler::AssertFunction(Register object) { void MacroAssembler::AssertFunction(Register object) {
if (emit_debug_code()) { if (emit_debug_code()) {
STATIC_ASSERT(kSmiTag == 0); STATIC_ASSERT(kSmiTag == 0);
......
...@@ -1621,6 +1621,9 @@ class MacroAssembler : public Assembler { ...@@ -1621,6 +1621,9 @@ class MacroAssembler : public Assembler {
#define SmiWordOffset(offset) offset #define SmiWordOffset(offset) offset
#endif #endif
// Abort execution if argument is not a FixedArray, enabled via --debug-code.
void AssertFixedArray(Register object);
void AssertFunction(Register object); void AssertFunction(Register object);
// Abort execution if argument is not a JSBoundFunction, // Abort execution if argument is not a JSBoundFunction,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment