Commit f5b83dec authored by jgruber's avatar jgruber Committed by Commit bot

[builtins] Always pass target and new target to C++ builtins

As a first step towards showing builtin frames in stack traces, we will now
push target and new target unconditionally.

Since the various specializations of BuiltinArguments are made redundant by
this change, we can remove them and all related code.

R=bmeurer@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2074063002
Cr-Commit-Position: refs/heads/master@{#37061}
parent 42279f16
...@@ -16,10 +16,7 @@ namespace internal { ...@@ -16,10 +16,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) {
void Builtins::Generate_Adaptor(MacroAssembler* masm,
CFunctionId id,
BuiltinExtraArguments extra_args) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r0 : number of arguments excluding receiver // -- r0 : number of arguments excluding receiver
// -- r1 : target // -- r1 : target
...@@ -38,23 +35,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, ...@@ -38,23 +35,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm,
__ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
// Insert extra arguments. // Insert extra arguments.
int num_extra_args = 0; const int num_extra_args = 2;
switch (extra_args) { __ Push(r1, r3);
case BuiltinExtraArguments::kTarget:
__ Push(r1);
++num_extra_args;
break;
case BuiltinExtraArguments::kNewTarget:
__ Push(r3);
++num_extra_args;
break;
case BuiltinExtraArguments::kTargetAndNewTarget:
__ Push(r1, r3);
num_extra_args += 2;
break;
case BuiltinExtraArguments::kNone:
break;
}
// JumpToExternalReference expects r0 to contain the number of arguments // JumpToExternalReference expects r0 to contain the number of arguments
// including the receiver and the extra arguments. // including the receiver and the extra arguments.
......
...@@ -32,10 +32,7 @@ static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, ...@@ -32,10 +32,7 @@ static void GenerateLoadInternalArrayFunction(MacroAssembler* masm,
__ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result);
} }
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) {
void Builtins::Generate_Adaptor(MacroAssembler* masm,
CFunctionId id,
BuiltinExtraArguments extra_args) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- x0 : number of arguments excluding receiver // -- x0 : number of arguments excluding receiver
// -- x1 : target // -- x1 : target
...@@ -54,23 +51,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, ...@@ -54,23 +51,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm,
__ Ldr(cp, FieldMemOperand(x1, JSFunction::kContextOffset)); __ Ldr(cp, FieldMemOperand(x1, JSFunction::kContextOffset));
// Insert extra arguments. // Insert extra arguments.
int num_extra_args = 0; const int num_extra_args = 2;
switch (extra_args) { __ Push(x1, x3);
case BuiltinExtraArguments::kTarget:
__ Push(x1);
++num_extra_args;
break;
case BuiltinExtraArguments::kNewTarget:
__ Push(x3);
++num_extra_args;
break;
case BuiltinExtraArguments::kTargetAndNewTarget:
__ Push(x1, x3);
num_extra_args += 2;
break;
case BuiltinExtraArguments::kNone:
break;
}
// JumpToExternalReference expects x0 to contain the number of arguments // JumpToExternalReference expects x0 to contain the number of arguments
// including the receiver and the extra arguments. // including the receiver and the extra arguments.
......
This diff is collapsed.
This diff is collapsed.
...@@ -318,7 +318,7 @@ void RuntimeCallStats::Print(std::ostream& os) { ...@@ -318,7 +318,7 @@ void RuntimeCallStats::Print(std::ostream& os) {
FOR_EACH_INTRINSIC(PRINT_COUNTER) FOR_EACH_INTRINSIC(PRINT_COUNTER)
#undef PRINT_COUNTER #undef PRINT_COUNTER
#define PRINT_COUNTER(name, type) entries.Add(&this->Builtin_##name); #define PRINT_COUNTER(name) entries.Add(&this->Builtin_##name);
BUILTIN_LIST_C(PRINT_COUNTER) BUILTIN_LIST_C(PRINT_COUNTER)
#undef PRINT_COUNTER #undef PRINT_COUNTER
...@@ -343,7 +343,7 @@ void RuntimeCallStats::Reset() { ...@@ -343,7 +343,7 @@ void RuntimeCallStats::Reset() {
FOR_EACH_INTRINSIC(RESET_COUNTER) FOR_EACH_INTRINSIC(RESET_COUNTER)
#undef RESET_COUNTER #undef RESET_COUNTER
#define RESET_COUNTER(name, type) this->Builtin_##name.Reset(); #define RESET_COUNTER(name) this->Builtin_##name.Reset();
BUILTIN_LIST_C(RESET_COUNTER) BUILTIN_LIST_C(RESET_COUNTER)
#undef RESET_COUNTER #undef RESET_COUNTER
......
...@@ -746,7 +746,7 @@ class RuntimeCallStats { ...@@ -746,7 +746,7 @@ class RuntimeCallStats {
RuntimeCallCounter Runtime_##name = RuntimeCallCounter(#name); RuntimeCallCounter Runtime_##name = RuntimeCallCounter(#name);
FOR_EACH_INTRINSIC(CALL_RUNTIME_COUNTER) FOR_EACH_INTRINSIC(CALL_RUNTIME_COUNTER)
#undef CALL_RUNTIME_COUNTER #undef CALL_RUNTIME_COUNTER
#define CALL_BUILTIN_COUNTER(name, type) \ #define CALL_BUILTIN_COUNTER(name) \
RuntimeCallCounter Builtin_##name = RuntimeCallCounter(#name); RuntimeCallCounter Builtin_##name = RuntimeCallCounter(#name);
BUILTIN_LIST_C(CALL_BUILTIN_COUNTER) BUILTIN_LIST_C(CALL_BUILTIN_COUNTER)
#undef CALL_BUILTIN_COUNTER #undef CALL_BUILTIN_COUNTER
......
...@@ -240,7 +240,7 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ...@@ -240,7 +240,7 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
}; };
static const RefTableEntry c_builtins[] = { static const RefTableEntry c_builtins[] = {
#define DEF_ENTRY_C(name, ignored) {Builtins::c_##name, "Builtins::" #name}, #define DEF_ENTRY_C(name) {Builtins::c_##name, "Builtins::" #name},
BUILTIN_LIST_C(DEF_ENTRY_C) BUILTIN_LIST_C(DEF_ENTRY_C)
#undef DEF_ENTRY_C #undef DEF_ENTRY_C
}; };
...@@ -252,7 +252,7 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ...@@ -252,7 +252,7 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
} }
static const RefTableEntry builtins[] = { static const RefTableEntry builtins[] = {
#define DEF_ENTRY_C(name, ignored) {Builtins::k##name, "Builtins::" #name}, #define DEF_ENTRY_C(name) {Builtins::k##name, "Builtins::" #name},
#define DEF_ENTRY_A(name, i1, i2) {Builtins::k##name, "Builtins::" #name}, #define DEF_ENTRY_A(name, i1, i2) {Builtins::k##name, "Builtins::" #name},
BUILTIN_LIST_C(DEF_ENTRY_C) BUILTIN_LIST_A(DEF_ENTRY_A) BUILTIN_LIST_C(DEF_ENTRY_C) BUILTIN_LIST_A(DEF_ENTRY_A)
BUILTIN_LIST_DEBUG_A(DEF_ENTRY_A) BUILTIN_LIST_DEBUG_A(DEF_ENTRY_A)
......
...@@ -16,10 +16,7 @@ namespace internal { ...@@ -16,10 +16,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) {
void Builtins::Generate_Adaptor(MacroAssembler* masm,
CFunctionId id,
BuiltinExtraArguments extra_args) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- eax : number of arguments excluding receiver // -- eax : number of arguments excluding receiver
// -- edi : target // -- edi : target
...@@ -39,19 +36,11 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, ...@@ -39,19 +36,11 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm,
__ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
// Insert extra arguments. // Insert extra arguments.
int num_extra_args = 0; const int num_extra_args = 2;
if (extra_args != BuiltinExtraArguments::kNone) { __ PopReturnAddressTo(ecx);
__ PopReturnAddressTo(ecx); __ Push(edi);
if (extra_args & BuiltinExtraArguments::kTarget) { __ Push(edx);
++num_extra_args; __ PushReturnAddressFrom(ecx);
__ Push(edi);
}
if (extra_args & BuiltinExtraArguments::kNewTarget) {
++num_extra_args;
__ Push(edx);
}
__ PushReturnAddressFrom(ecx);
}
// JumpToExternalReference expects eax to contain the number of arguments // JumpToExternalReference expects eax to contain the number of arguments
// including the receiver and the extra arguments. // including the receiver and the extra arguments.
......
...@@ -17,10 +17,7 @@ namespace internal { ...@@ -17,10 +17,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) {
void Builtins::Generate_Adaptor(MacroAssembler* masm,
CFunctionId id,
BuiltinExtraArguments extra_args) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a0 : number of arguments excluding receiver // -- a0 : number of arguments excluding receiver
// -- a1 : target // -- a1 : target
...@@ -39,23 +36,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, ...@@ -39,23 +36,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm,
__ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
// Insert extra arguments. // Insert extra arguments.
int num_extra_args = 0; const int num_extra_args = 2;
switch (extra_args) { __ Push(a1, a3);
case BuiltinExtraArguments::kTarget:
__ Push(a1);
++num_extra_args;
break;
case BuiltinExtraArguments::kNewTarget:
__ Push(a3);
++num_extra_args;
break;
case BuiltinExtraArguments::kTargetAndNewTarget:
__ Push(a1, a3);
num_extra_args += 2;
break;
case BuiltinExtraArguments::kNone:
break;
}
// JumpToExternalReference expects a0 to contain the number of arguments // JumpToExternalReference expects a0 to contain the number of arguments
// including the receiver and the extra arguments. // including the receiver and the extra arguments.
......
...@@ -16,10 +16,7 @@ namespace internal { ...@@ -16,10 +16,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) {
void Builtins::Generate_Adaptor(MacroAssembler* masm,
CFunctionId id,
BuiltinExtraArguments extra_args) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a0 : number of arguments excluding receiver // -- a0 : number of arguments excluding receiver
// -- a1 : target // -- a1 : target
...@@ -38,23 +35,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, ...@@ -38,23 +35,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm,
__ ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); __ ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
// Insert extra arguments. // Insert extra arguments.
int num_extra_args = 0; const int num_extra_args = 2;
switch (extra_args) { __ Push(a1, a3);
case BuiltinExtraArguments::kTarget:
__ Push(a1);
++num_extra_args;
break;
case BuiltinExtraArguments::kNewTarget:
__ Push(a3);
++num_extra_args;
break;
case BuiltinExtraArguments::kTargetAndNewTarget:
__ Push(a1, a3);
num_extra_args += 2;
break;
case BuiltinExtraArguments::kNone:
break;
}
// JumpToExternalReference expects a0 to contain the number of arguments // JumpToExternalReference expects a0 to contain the number of arguments
// including the receiver and the extra arguments. // including the receiver and the extra arguments.
......
...@@ -15,10 +15,7 @@ namespace internal { ...@@ -15,10 +15,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) {
void Builtins::Generate_Adaptor(MacroAssembler* masm,
CFunctionId id,
BuiltinExtraArguments extra_args) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- rax : number of arguments excluding receiver // -- rax : number of arguments excluding receiver
// -- rdi : target // -- rdi : target
...@@ -37,20 +34,13 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, ...@@ -37,20 +34,13 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm,
// ordinary functions). // ordinary functions).
__ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
// Insert extra arguments. // Unconditionally insert the target and new target as extra arguments. They
int num_extra_args = 0; // will be used by stack frame iterators when constructing the stack trace.
if (extra_args != BuiltinExtraArguments::kNone) { const int num_extra_args = 2;
__ PopReturnAddressTo(kScratchRegister); __ PopReturnAddressTo(kScratchRegister);
if (extra_args & BuiltinExtraArguments::kTarget) { __ Push(rdi);
++num_extra_args; __ Push(rdx);
__ Push(rdi); __ PushReturnAddressFrom(kScratchRegister);
}
if (extra_args & BuiltinExtraArguments::kNewTarget) {
++num_extra_args;
__ Push(rdx);
}
__ PushReturnAddressFrom(kScratchRegister);
}
// JumpToExternalReference expects rax to contain the number of arguments // JumpToExternalReference expects rax to contain the number of arguments
// including the receiver and the extra arguments. // including the receiver and the extra arguments.
......
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