[arm] Cleanup MacroAssembler::PrepareCallCFunction to use ip

The PrepareCallCFunction methods would take a scratch register as arguments when
they can simply use ip. The reason to do this, apart from simplifying the code,
is that TurboFan's code generator uses r9 as a scratch for this when it could
just as well use ip.

Bug: v8:6553
Change-Id: I0ed762d201f7ff8b8ed074da758227a8db95fca7
Reviewed-on: https://chromium-review.googlesource.com/558934
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Pierre Langlois <pierre.langlois@arm.com>
Cr-Commit-Position: refs/heads/master@{#46465}
This commit is contained in:
Pierre Langlois 2017-06-09 14:02:33 +01:00 committed by Commit Bot
parent b9b8cc9bad
commit 6c85ae7039
8 changed files with 29 additions and 39 deletions

View File

@ -649,7 +649,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
const int fp_argument_count = 0;
AllowExternalCallThatCantCauseGC scope(masm);
__ PrepareCallCFunction(argument_count, fp_argument_count, scratch);
__ PrepareCallCFunction(argument_count, fp_argument_count);
__ mov(r0, Operand(ExternalReference::isolate_address(isolate())));
__ CallCFunction(
ExternalReference::store_buffer_overflow_function(isolate()),
@ -688,7 +688,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ push(lr);
{
AllowExternalCallThatCantCauseGC scope(masm);
__ PrepareCallCFunction(0, 2, scratch);
__ PrepareCallCFunction(0, 2);
__ MovToFloatParameters(double_base, double_exponent);
__ CallCFunction(
ExternalReference::power_double_double_function(isolate()), 0, 2);
@ -739,7 +739,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ push(lr);
{
AllowExternalCallThatCantCauseGC scope(masm);
__ PrepareCallCFunction(0, 2, scratch);
__ PrepareCallCFunction(0, 2);
__ MovToFloatParameters(double_base, double_exponent);
__ CallCFunction(ExternalReference::power_double_double_function(isolate()),
0, 2);
@ -931,7 +931,7 @@ void CEntryStub::Generate(MacroAssembler* masm) {
isolate());
{
FrameScope scope(masm, StackFrame::MANUAL);
__ PrepareCallCFunction(3, 0, r0);
__ PrepareCallCFunction(3, 0);
__ mov(r0, Operand(0));
__ mov(r1, Operand(0));
__ mov(r2, Operand(ExternalReference::isolate_address(isolate())));
@ -2100,7 +2100,7 @@ void RecordWriteStub::GenerateIncremental(MacroAssembler* masm, Mode mode) {
void RecordWriteStub::InformIncrementalMarker(MacroAssembler* masm) {
regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode());
int argument_count = 3;
__ PrepareCallCFunction(argument_count, regs_.scratch0());
__ PrepareCallCFunction(argument_count);
Register address =
r0.is(regs_.address()) ? regs_.scratch0() : regs_.address();
DCHECK(!address.is(regs_.object()));
@ -2620,7 +2620,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
if (FLAG_log_timer_events) {
FrameScope frame(masm, StackFrame::MANUAL);
__ PushSafepointRegisters();
__ PrepareCallCFunction(1, r0);
__ PrepareCallCFunction(1);
__ mov(r0, Operand(ExternalReference::isolate_address(isolate)));
__ CallCFunction(ExternalReference::log_enter_external_function(isolate),
1);
@ -2636,7 +2636,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
if (FLAG_log_timer_events) {
FrameScope frame(masm, StackFrame::MANUAL);
__ PushSafepointRegisters();
__ PrepareCallCFunction(1, r0);
__ PrepareCallCFunction(1);
__ mov(r0, Operand(ExternalReference::isolate_address(isolate)));
__ CallCFunction(ExternalReference::log_leave_external_function(isolate),
1);
@ -2696,7 +2696,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ bind(&delete_allocated_handles);
__ str(r5, MemOperand(r9, kLimitOffset));
__ mov(r4, r0);
__ PrepareCallCFunction(1, r5);
__ PrepareCallCFunction(1);
__ mov(r0, Operand(ExternalReference::isolate_address(isolate)));
__ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate),
1);

View File

@ -156,7 +156,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
// Allocate a new deoptimizer object.
// Pass four arguments in r0 to r3 and fifth argument on stack.
__ PrepareCallCFunction(6, r5);
__ PrepareCallCFunction(6);
__ mov(r0, Operand(0));
Label context_check;
__ ldr(r1, MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset));
@ -237,7 +237,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
// Compute the output frame in the deoptimizer.
__ push(r0); // Preserve deoptimizer object across call.
// r0: deoptimizer object; r1: scratch.
__ PrepareCallCFunction(1, r1);
__ PrepareCallCFunction(1);
// Call Deoptimizer::ComputeOutputFrames().
{
AllowExternalCallThatCantCauseGC scope(masm());

View File

@ -726,7 +726,7 @@ void MacroAssembler::RecordWriteCodeEntryField(Register js_function,
stm(db_w, sp, (kCallerSaved | lr.bit()));
int argument_count = 3;
PrepareCallCFunction(argument_count, code_entry);
PrepareCallCFunction(argument_count);
mov(r0, js_function);
mov(r1, dst);
@ -3213,14 +3213,14 @@ void MacroAssembler::EmitSeqStringSetCharCheck(Register string,
SmiUntag(index, index);
}
void MacroAssembler::PrepareCallCFunction(int num_reg_arguments,
int num_double_arguments,
Register scratch) {
int num_double_arguments) {
int frame_alignment = ActivationFrameAlignment();
int stack_passed_arguments = CalculateStackPassedWords(
num_reg_arguments, num_double_arguments);
if (frame_alignment > kPointerSize) {
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
// Make stack end at alignment and make room for num_arguments - 4 words
// and the original value of sp.
mov(scratch, sp);
@ -3233,13 +3233,6 @@ void MacroAssembler::PrepareCallCFunction(int num_reg_arguments,
}
}
void MacroAssembler::PrepareCallCFunction(int num_reg_arguments,
Register scratch) {
PrepareCallCFunction(num_reg_arguments, 0, scratch);
}
void MacroAssembler::MovToFloatParameter(DwVfpRegister src) {
DCHECK(src.is(d0));
if (!use_eabi_hardfloat()) {

View File

@ -1053,10 +1053,7 @@ class MacroAssembler: public Assembler {
// Needs a scratch register to do some arithmetic. This register will be
// trashed.
void PrepareCallCFunction(int num_reg_arguments,
int num_double_registers,
Register scratch);
void PrepareCallCFunction(int num_reg_arguments,
Register scratch);
int num_double_registers = 0);
// There are two ways of passing double arguments on ARM, depending on
// whether soft or hard floating point ABI is used. These functions

View File

@ -1663,7 +1663,7 @@ static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) {
// r3 - new target
FrameScope scope(masm, StackFrame::MANUAL);
__ stm(db_w, sp, r0.bit() | r1.bit() | r3.bit() | fp.bit() | lr.bit());
__ PrepareCallCFunction(2, 0, r2);
__ PrepareCallCFunction(2, 0);
__ mov(r1, Operand(ExternalReference::isolate_address(masm->isolate())));
__ CallCFunction(
ExternalReference::get_make_code_young_function(masm->isolate()), 2);
@ -1691,7 +1691,7 @@ void Builtins::Generate_MarkCodeAsExecutedOnce(MacroAssembler* masm) {
// r3 - new target
FrameScope scope(masm, StackFrame::MANUAL);
__ stm(db_w, sp, r0.bit() | r1.bit() | r3.bit() | fp.bit() | lr.bit());
__ PrepareCallCFunction(2, 0, r2);
__ PrepareCallCFunction(2, 0);
__ mov(r1, Operand(ExternalReference::isolate_address(masm->isolate())));
__ CallCFunction(
ExternalReference::get_mark_code_as_executed_function(masm->isolate()),

View File

@ -469,7 +469,7 @@ Condition FlagsConditionToCondition(FlagsCondition condition) {
/* TODO(bmeurer): We should really get rid of this special instruction, */ \
/* and generate a CallAddress instruction instead. */ \
FrameScope scope(masm(), StackFrame::MANUAL); \
__ PrepareCallCFunction(0, 2, kScratchReg); \
__ PrepareCallCFunction(0, 2); \
__ MovToFloatParameters(i.InputDoubleRegister(0), \
i.InputDoubleRegister(1)); \
__ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \
@ -484,7 +484,7 @@ Condition FlagsConditionToCondition(FlagsCondition condition) {
/* TODO(bmeurer): We should really get rid of this special instruction, */ \
/* and generate a CallAddress instruction instead. */ \
FrameScope scope(masm(), StackFrame::MANUAL); \
__ PrepareCallCFunction(0, 1, kScratchReg); \
__ PrepareCallCFunction(0, 1); \
__ MovToFloatParameter(i.InputDoubleRegister(0)); \
__ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \
0, 1); \
@ -775,7 +775,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
}
case kArchPrepareCallCFunction: {
int const num_parameters = MiscField::decode(instr->opcode());
__ PrepareCallCFunction(num_parameters, kScratchReg);
__ PrepareCallCFunction(num_parameters);
// Frame alignment requires using FP-relative frame addressing.
frame_access_state()->SetFrameAccessToFP();
break;
@ -1288,7 +1288,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
// TODO(bmeurer): We should really get rid of this special instruction,
// and generate a CallAddress instruction instead.
FrameScope scope(masm(), StackFrame::MANUAL);
__ PrepareCallCFunction(0, 2, kScratchReg);
__ PrepareCallCFunction(0, 2);
__ MovToFloatParameters(i.InputDoubleRegister(0),
i.InputDoubleRegister(1));
__ CallCFunction(ExternalReference::mod_two_doubles_operation(isolate()),
@ -2637,7 +2637,7 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
// Therefore we emit a call to C here instead of a call to the runtime.
// We use the context register as the scratch register, because we do
// not have a context here.
__ PrepareCallCFunction(0, 0, cp);
__ PrepareCallCFunction(0, 0);
__ CallCFunction(
ExternalReference::wasm_call_trap_callback_for_testing(isolate()),
0);

View File

@ -290,7 +290,7 @@ void RegExpMacroAssemblerARM::CheckNotBackReferenceIgnoreCase(
} else {
DCHECK(mode_ == UC16);
int argument_count = 4;
__ PrepareCallCFunction(argument_count, r2);
__ PrepareCallCFunction(argument_count);
// r0 - offset of start of capture
// r1 - length of capture
@ -665,7 +665,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) {
__ jmp(&return_r0);
__ bind(&stack_limit_hit);
CallCheckStackGuardState(r0);
CallCheckStackGuardState();
__ cmp(r0, Operand::Zero());
// If returned value is non-zero, we exit with the returned value as result.
__ b(ne, &return_r0);
@ -841,7 +841,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) {
if (check_preempt_label_.is_linked()) {
SafeCallTarget(&check_preempt_label_);
CallCheckStackGuardState(r0);
CallCheckStackGuardState();
__ cmp(r0, Operand::Zero());
// If returning non-zero, we should end execution with the given
// result as return value.
@ -860,7 +860,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) {
// Call GrowStack(backtrack_stackpointer(), &stack_base)
static const int num_arguments = 3;
__ PrepareCallCFunction(num_arguments, r0);
__ PrepareCallCFunction(num_arguments);
__ mov(r0, backtrack_stackpointer());
__ add(r1, frame_pointer(), Operand(kStackHighEnd));
__ mov(r2, Operand(ExternalReference::isolate_address(isolate())));
@ -1046,8 +1046,8 @@ void RegExpMacroAssemblerARM::WriteStackPointerToRegister(int reg) {
// Private methods:
void RegExpMacroAssemblerARM::CallCheckStackGuardState(Register scratch) {
__ PrepareCallCFunction(3, scratch);
void RegExpMacroAssemblerARM::CallCheckStackGuardState() {
__ PrepareCallCFunction(3);
// RegExp code frame pointer.
__ mov(r2, frame_pointer());

View File

@ -140,7 +140,7 @@ class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler {
// Generate a call to CheckStackGuardState.
void CallCheckStackGuardState(Register scratch);
void CallCheckStackGuardState();
// The ebp-relative location of a regexp register.
MemOperand register_location(int register_index);