Commit 35b47d89 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Unify InvokeBuiltin implementations across architectures.

This makes the implementations of MacroAssembler::InvokeBuiltin go
through the InvokeFunctionCode helper on all architectures. This helper
knows how to correctly set up all registers (i.e. argument count and the
new target value).

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/1488303008

Cr-Commit-Position: refs/heads/master@{#32646}
parent 1ecb2254
......@@ -2517,19 +2517,10 @@ void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag,
// You can't call a builtin without a valid frame.
DCHECK(flag == JUMP_FUNCTION || has_frame());
// Always initialize new target.
LoadRoot(r3, Heap::kUndefinedValueRootIndex);
// Fake a parameter count to avoid emitting code to do the check.
ParameterCount expected(0);
LoadNativeContextSlot(native_context_index, r1);
ldr(r2, FieldMemOperand(r1, JSFunction::kCodeEntryOffset));
if (flag == CALL_FUNCTION) {
call_wrapper.BeforeCall(CallSize(r2));
Call(r2);
call_wrapper.AfterCall();
} else {
DCHECK(flag == JUMP_FUNCTION);
Jump(r2);
}
InvokeFunctionCode(r1, no_reg, expected, expected, flag, call_wrapper);
}
......
......@@ -1707,20 +1707,10 @@ void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag,
// You can't call a builtin without a valid frame.
DCHECK(flag == JUMP_FUNCTION || has_frame());
// Always initialize new target.
LoadRoot(x3, Heap::kUndefinedValueRootIndex);
// Get the builtin entry in x2 and setup the function object in x1.
// Fake a parameter count to avoid emitting code to do the check.
ParameterCount expected(0);
LoadNativeContextSlot(native_context_index, x1);
Ldr(x2, FieldMemOperand(x1, JSFunction::kCodeEntryOffset));
if (flag == CALL_FUNCTION) {
call_wrapper.BeforeCall(CallSize(x2));
Call(x2);
call_wrapper.AfterCall();
} else {
DCHECK(flag == JUMP_FUNCTION);
Jump(x2);
}
InvokeFunctionCode(x1, no_reg, expected, expected, flag, call_wrapper);
}
......
......@@ -2116,9 +2116,7 @@ void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag,
// You can't call a builtin without a valid frame.
DCHECK(flag == JUMP_FUNCTION || has_frame());
// Rely on the assertion to check that the number of provided
// arguments match the expected number of arguments. Fake a
// parameter count to avoid emitting code to do the check.
// Fake a parameter count to avoid emitting code to do the check.
ParameterCount expected(0);
GetBuiltinFunction(edi, native_context_index);
InvokeFunctionCode(edi, no_reg, expected, expected, flag, call_wrapper);
......
......@@ -4557,19 +4557,10 @@ void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag,
// You can't call a builtin without a valid frame.
DCHECK(flag == JUMP_FUNCTION || has_frame());
// Always initialize new target.
LoadRoot(a3, Heap::kUndefinedValueRootIndex);
// Fake a parameter count to avoid emitting code to do the check.
ParameterCount expected(0);
LoadNativeContextSlot(native_context_index, a1);
lw(t9, FieldMemOperand(a1, JSFunction::kCodeEntryOffset));
if (flag == CALL_FUNCTION) {
call_wrapper.BeforeCall(CallSize(t9));
Call(t9);
call_wrapper.AfterCall();
} else {
DCHECK(flag == JUMP_FUNCTION);
Jump(t9);
}
InvokeFunctionCode(a1, no_reg, expected, expected, flag, call_wrapper);
}
......
......@@ -4898,19 +4898,10 @@ void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag,
// You can't call a builtin without a valid frame.
DCHECK(flag == JUMP_FUNCTION || has_frame());
// Always initialize new target.
LoadRoot(a3, Heap::kUndefinedValueRootIndex);
// Fake a parameter count to avoid emitting code to do the check.
ParameterCount expected(0);
LoadNativeContextSlot(native_context_index, a1);
ld(t9, FieldMemOperand(a1, JSFunction::kCodeEntryOffset));
if (flag == CALL_FUNCTION) {
call_wrapper.BeforeCall(CallSize(t9));
Call(t9);
call_wrapper.AfterCall();
} else {
DCHECK(flag == JUMP_FUNCTION);
Jump(t9);
}
InvokeFunctionCode(a1, no_reg, expected, expected, flag, call_wrapper);
}
......
......@@ -2342,19 +2342,10 @@ void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag,
// You can't call a builtin without a valid frame.
DCHECK(flag == JUMP_FUNCTION || has_frame());
// Always initialize new target.
LoadRoot(r6, Heap::kUndefinedValueRootIndex);
// Fake a parameter count to avoid emitting code to do the check.
ParameterCount expected(0);
LoadNativeContextSlot(native_context_index, r4);
LoadP(ip, FieldMemOperand(r4, JSFunction::kCodeEntryOffset));
if (flag == CALL_FUNCTION) {
call_wrapper.BeforeCall(CallSize(ip));
CallJSEntry(ip);
call_wrapper.AfterCall();
} else {
DCHECK(flag == JUMP_FUNCTION);
JumpToJSEntry(ip);
}
InvokeFunctionCode(r4, no_reg, expected, expected, flag, call_wrapper);
}
......
......@@ -704,9 +704,7 @@ void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag,
// You can't call a builtin without a valid frame.
DCHECK(flag == JUMP_FUNCTION || has_frame());
// Rely on the assertion to check that the number of provided
// arguments match the expected number of arguments. Fake a
// parameter count to avoid emitting code to do the check.
// Fake a parameter count to avoid emitting code to do the check.
ParameterCount expected(0);
LoadNativeContextSlot(native_context_index, rdi);
InvokeFunctionCode(rdi, no_reg, expected, expected, flag, call_wrapper);
......
......@@ -2080,9 +2080,7 @@ void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag,
// You can't call a builtin without a valid frame.
DCHECK(flag == JUMP_FUNCTION || has_frame());
// Rely on the assertion to check that the number of provided
// arguments match the expected number of arguments. Fake a
// parameter count to avoid emitting code to do the check.
// Fake a parameter count to avoid emitting code to do the check.
ParameterCount expected(0);
GetBuiltinFunction(edi, native_context_index);
InvokeFunctionCode(edi, no_reg, expected, expected, flag, call_wrapper);
......
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