Commit 6c85ae70 authored by Pierre Langlois's avatar Pierre Langlois Committed by Commit Bot

[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/558934Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Pierre Langlois <pierre.langlois@arm.com>
Cr-Commit-Position: refs/heads/master@{#46465}
parent b9b8cc9b
...@@ -649,7 +649,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) { ...@@ -649,7 +649,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
const int fp_argument_count = 0; const int fp_argument_count = 0;
AllowExternalCallThatCantCauseGC scope(masm); AllowExternalCallThatCantCauseGC scope(masm);
__ PrepareCallCFunction(argument_count, fp_argument_count, scratch); __ PrepareCallCFunction(argument_count, fp_argument_count);
__ mov(r0, Operand(ExternalReference::isolate_address(isolate()))); __ mov(r0, Operand(ExternalReference::isolate_address(isolate())));
__ CallCFunction( __ CallCFunction(
ExternalReference::store_buffer_overflow_function(isolate()), ExternalReference::store_buffer_overflow_function(isolate()),
...@@ -688,7 +688,7 @@ void MathPowStub::Generate(MacroAssembler* masm) { ...@@ -688,7 +688,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ push(lr); __ push(lr);
{ {
AllowExternalCallThatCantCauseGC scope(masm); AllowExternalCallThatCantCauseGC scope(masm);
__ PrepareCallCFunction(0, 2, scratch); __ PrepareCallCFunction(0, 2);
__ MovToFloatParameters(double_base, double_exponent); __ MovToFloatParameters(double_base, double_exponent);
__ CallCFunction( __ CallCFunction(
ExternalReference::power_double_double_function(isolate()), 0, 2); ExternalReference::power_double_double_function(isolate()), 0, 2);
...@@ -739,7 +739,7 @@ void MathPowStub::Generate(MacroAssembler* masm) { ...@@ -739,7 +739,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ push(lr); __ push(lr);
{ {
AllowExternalCallThatCantCauseGC scope(masm); AllowExternalCallThatCantCauseGC scope(masm);
__ PrepareCallCFunction(0, 2, scratch); __ PrepareCallCFunction(0, 2);
__ MovToFloatParameters(double_base, double_exponent); __ MovToFloatParameters(double_base, double_exponent);
__ CallCFunction(ExternalReference::power_double_double_function(isolate()), __ CallCFunction(ExternalReference::power_double_double_function(isolate()),
0, 2); 0, 2);
...@@ -931,7 +931,7 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -931,7 +931,7 @@ void CEntryStub::Generate(MacroAssembler* masm) {
isolate()); isolate());
{ {
FrameScope scope(masm, StackFrame::MANUAL); FrameScope scope(masm, StackFrame::MANUAL);
__ PrepareCallCFunction(3, 0, r0); __ PrepareCallCFunction(3, 0);
__ mov(r0, Operand(0)); __ mov(r0, Operand(0));
__ mov(r1, Operand(0)); __ mov(r1, Operand(0));
__ mov(r2, Operand(ExternalReference::isolate_address(isolate()))); __ mov(r2, Operand(ExternalReference::isolate_address(isolate())));
...@@ -2100,7 +2100,7 @@ void RecordWriteStub::GenerateIncremental(MacroAssembler* masm, Mode mode) { ...@@ -2100,7 +2100,7 @@ void RecordWriteStub::GenerateIncremental(MacroAssembler* masm, Mode mode) {
void RecordWriteStub::InformIncrementalMarker(MacroAssembler* masm) { void RecordWriteStub::InformIncrementalMarker(MacroAssembler* masm) {
regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode()); regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode());
int argument_count = 3; int argument_count = 3;
__ PrepareCallCFunction(argument_count, regs_.scratch0()); __ PrepareCallCFunction(argument_count);
Register address = Register address =
r0.is(regs_.address()) ? regs_.scratch0() : regs_.address(); r0.is(regs_.address()) ? regs_.scratch0() : regs_.address();
DCHECK(!address.is(regs_.object())); DCHECK(!address.is(regs_.object()));
...@@ -2620,7 +2620,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm, ...@@ -2620,7 +2620,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
if (FLAG_log_timer_events) { if (FLAG_log_timer_events) {
FrameScope frame(masm, StackFrame::MANUAL); FrameScope frame(masm, StackFrame::MANUAL);
__ PushSafepointRegisters(); __ PushSafepointRegisters();
__ PrepareCallCFunction(1, r0); __ PrepareCallCFunction(1);
__ mov(r0, Operand(ExternalReference::isolate_address(isolate))); __ mov(r0, Operand(ExternalReference::isolate_address(isolate)));
__ CallCFunction(ExternalReference::log_enter_external_function(isolate), __ CallCFunction(ExternalReference::log_enter_external_function(isolate),
1); 1);
...@@ -2636,7 +2636,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm, ...@@ -2636,7 +2636,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
if (FLAG_log_timer_events) { if (FLAG_log_timer_events) {
FrameScope frame(masm, StackFrame::MANUAL); FrameScope frame(masm, StackFrame::MANUAL);
__ PushSafepointRegisters(); __ PushSafepointRegisters();
__ PrepareCallCFunction(1, r0); __ PrepareCallCFunction(1);
__ mov(r0, Operand(ExternalReference::isolate_address(isolate))); __ mov(r0, Operand(ExternalReference::isolate_address(isolate)));
__ CallCFunction(ExternalReference::log_leave_external_function(isolate), __ CallCFunction(ExternalReference::log_leave_external_function(isolate),
1); 1);
...@@ -2696,7 +2696,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm, ...@@ -2696,7 +2696,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ bind(&delete_allocated_handles); __ bind(&delete_allocated_handles);
__ str(r5, MemOperand(r9, kLimitOffset)); __ str(r5, MemOperand(r9, kLimitOffset));
__ mov(r4, r0); __ mov(r4, r0);
__ PrepareCallCFunction(1, r5); __ PrepareCallCFunction(1);
__ mov(r0, Operand(ExternalReference::isolate_address(isolate))); __ mov(r0, Operand(ExternalReference::isolate_address(isolate)));
__ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate),
1); 1);
......
...@@ -156,7 +156,7 @@ void Deoptimizer::TableEntryGenerator::Generate() { ...@@ -156,7 +156,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
// Allocate a new deoptimizer object. // Allocate a new deoptimizer object.
// Pass four arguments in r0 to r3 and fifth argument on stack. // Pass four arguments in r0 to r3 and fifth argument on stack.
__ PrepareCallCFunction(6, r5); __ PrepareCallCFunction(6);
__ mov(r0, Operand(0)); __ mov(r0, Operand(0));
Label context_check; Label context_check;
__ ldr(r1, MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset)); __ ldr(r1, MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset));
...@@ -237,7 +237,7 @@ void Deoptimizer::TableEntryGenerator::Generate() { ...@@ -237,7 +237,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
// Compute the output frame in the deoptimizer. // Compute the output frame in the deoptimizer.
__ push(r0); // Preserve deoptimizer object across call. __ push(r0); // Preserve deoptimizer object across call.
// r0: deoptimizer object; r1: scratch. // r0: deoptimizer object; r1: scratch.
__ PrepareCallCFunction(1, r1); __ PrepareCallCFunction(1);
// Call Deoptimizer::ComputeOutputFrames(). // Call Deoptimizer::ComputeOutputFrames().
{ {
AllowExternalCallThatCantCauseGC scope(masm()); AllowExternalCallThatCantCauseGC scope(masm());
......
...@@ -726,7 +726,7 @@ void MacroAssembler::RecordWriteCodeEntryField(Register js_function, ...@@ -726,7 +726,7 @@ void MacroAssembler::RecordWriteCodeEntryField(Register js_function,
stm(db_w, sp, (kCallerSaved | lr.bit())); stm(db_w, sp, (kCallerSaved | lr.bit()));
int argument_count = 3; int argument_count = 3;
PrepareCallCFunction(argument_count, code_entry); PrepareCallCFunction(argument_count);
mov(r0, js_function); mov(r0, js_function);
mov(r1, dst); mov(r1, dst);
...@@ -3213,14 +3213,14 @@ void MacroAssembler::EmitSeqStringSetCharCheck(Register string, ...@@ -3213,14 +3213,14 @@ void MacroAssembler::EmitSeqStringSetCharCheck(Register string,
SmiUntag(index, index); SmiUntag(index, index);
} }
void MacroAssembler::PrepareCallCFunction(int num_reg_arguments, void MacroAssembler::PrepareCallCFunction(int num_reg_arguments,
int num_double_arguments, int num_double_arguments) {
Register scratch) {
int frame_alignment = ActivationFrameAlignment(); int frame_alignment = ActivationFrameAlignment();
int stack_passed_arguments = CalculateStackPassedWords( int stack_passed_arguments = CalculateStackPassedWords(
num_reg_arguments, num_double_arguments); num_reg_arguments, num_double_arguments);
if (frame_alignment > kPointerSize) { if (frame_alignment > kPointerSize) {
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
// Make stack end at alignment and make room for num_arguments - 4 words // Make stack end at alignment and make room for num_arguments - 4 words
// and the original value of sp. // and the original value of sp.
mov(scratch, sp); mov(scratch, sp);
...@@ -3233,13 +3233,6 @@ void MacroAssembler::PrepareCallCFunction(int num_reg_arguments, ...@@ -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) { void MacroAssembler::MovToFloatParameter(DwVfpRegister src) {
DCHECK(src.is(d0)); DCHECK(src.is(d0));
if (!use_eabi_hardfloat()) { if (!use_eabi_hardfloat()) {
......
...@@ -1053,10 +1053,7 @@ class MacroAssembler: public Assembler { ...@@ -1053,10 +1053,7 @@ class MacroAssembler: public Assembler {
// Needs a scratch register to do some arithmetic. This register will be // Needs a scratch register to do some arithmetic. This register will be
// trashed. // trashed.
void PrepareCallCFunction(int num_reg_arguments, void PrepareCallCFunction(int num_reg_arguments,
int num_double_registers, int num_double_registers = 0);
Register scratch);
void PrepareCallCFunction(int num_reg_arguments,
Register scratch);
// There are two ways of passing double arguments on ARM, depending on // There are two ways of passing double arguments on ARM, depending on
// whether soft or hard floating point ABI is used. These functions // whether soft or hard floating point ABI is used. These functions
......
...@@ -1663,7 +1663,7 @@ static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { ...@@ -1663,7 +1663,7 @@ static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) {
// r3 - new target // r3 - new target
FrameScope scope(masm, StackFrame::MANUAL); FrameScope scope(masm, StackFrame::MANUAL);
__ stm(db_w, sp, r0.bit() | r1.bit() | r3.bit() | fp.bit() | lr.bit()); __ 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()))); __ mov(r1, Operand(ExternalReference::isolate_address(masm->isolate())));
__ CallCFunction( __ CallCFunction(
ExternalReference::get_make_code_young_function(masm->isolate()), 2); ExternalReference::get_make_code_young_function(masm->isolate()), 2);
...@@ -1691,7 +1691,7 @@ void Builtins::Generate_MarkCodeAsExecutedOnce(MacroAssembler* masm) { ...@@ -1691,7 +1691,7 @@ void Builtins::Generate_MarkCodeAsExecutedOnce(MacroAssembler* masm) {
// r3 - new target // r3 - new target
FrameScope scope(masm, StackFrame::MANUAL); FrameScope scope(masm, StackFrame::MANUAL);
__ stm(db_w, sp, r0.bit() | r1.bit() | r3.bit() | fp.bit() | lr.bit()); __ 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()))); __ mov(r1, Operand(ExternalReference::isolate_address(masm->isolate())));
__ CallCFunction( __ CallCFunction(
ExternalReference::get_mark_code_as_executed_function(masm->isolate()), ExternalReference::get_mark_code_as_executed_function(masm->isolate()),
......
...@@ -469,7 +469,7 @@ Condition FlagsConditionToCondition(FlagsCondition condition) { ...@@ -469,7 +469,7 @@ Condition FlagsConditionToCondition(FlagsCondition condition) {
/* TODO(bmeurer): We should really get rid of this special instruction, */ \ /* TODO(bmeurer): We should really get rid of this special instruction, */ \
/* and generate a CallAddress instruction instead. */ \ /* and generate a CallAddress instruction instead. */ \
FrameScope scope(masm(), StackFrame::MANUAL); \ FrameScope scope(masm(), StackFrame::MANUAL); \
__ PrepareCallCFunction(0, 2, kScratchReg); \ __ PrepareCallCFunction(0, 2); \
__ MovToFloatParameters(i.InputDoubleRegister(0), \ __ MovToFloatParameters(i.InputDoubleRegister(0), \
i.InputDoubleRegister(1)); \ i.InputDoubleRegister(1)); \
__ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \
...@@ -484,7 +484,7 @@ Condition FlagsConditionToCondition(FlagsCondition condition) { ...@@ -484,7 +484,7 @@ Condition FlagsConditionToCondition(FlagsCondition condition) {
/* TODO(bmeurer): We should really get rid of this special instruction, */ \ /* TODO(bmeurer): We should really get rid of this special instruction, */ \
/* and generate a CallAddress instruction instead. */ \ /* and generate a CallAddress instruction instead. */ \
FrameScope scope(masm(), StackFrame::MANUAL); \ FrameScope scope(masm(), StackFrame::MANUAL); \
__ PrepareCallCFunction(0, 1, kScratchReg); \ __ PrepareCallCFunction(0, 1); \
__ MovToFloatParameter(i.InputDoubleRegister(0)); \ __ MovToFloatParameter(i.InputDoubleRegister(0)); \
__ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \
0, 1); \ 0, 1); \
...@@ -775,7 +775,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -775,7 +775,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
} }
case kArchPrepareCallCFunction: { case kArchPrepareCallCFunction: {
int const num_parameters = MiscField::decode(instr->opcode()); int const num_parameters = MiscField::decode(instr->opcode());
__ PrepareCallCFunction(num_parameters, kScratchReg); __ PrepareCallCFunction(num_parameters);
// Frame alignment requires using FP-relative frame addressing. // Frame alignment requires using FP-relative frame addressing.
frame_access_state()->SetFrameAccessToFP(); frame_access_state()->SetFrameAccessToFP();
break; break;
...@@ -1288,7 +1288,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1288,7 +1288,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
// TODO(bmeurer): We should really get rid of this special instruction, // TODO(bmeurer): We should really get rid of this special instruction,
// and generate a CallAddress instruction instead. // and generate a CallAddress instruction instead.
FrameScope scope(masm(), StackFrame::MANUAL); FrameScope scope(masm(), StackFrame::MANUAL);
__ PrepareCallCFunction(0, 2, kScratchReg); __ PrepareCallCFunction(0, 2);
__ MovToFloatParameters(i.InputDoubleRegister(0), __ MovToFloatParameters(i.InputDoubleRegister(0),
i.InputDoubleRegister(1)); i.InputDoubleRegister(1));
__ CallCFunction(ExternalReference::mod_two_doubles_operation(isolate()), __ CallCFunction(ExternalReference::mod_two_doubles_operation(isolate()),
...@@ -2637,7 +2637,7 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr, ...@@ -2637,7 +2637,7 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
// Therefore we emit a call to C here instead of a call to the runtime. // 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 // We use the context register as the scratch register, because we do
// not have a context here. // not have a context here.
__ PrepareCallCFunction(0, 0, cp); __ PrepareCallCFunction(0, 0);
__ CallCFunction( __ CallCFunction(
ExternalReference::wasm_call_trap_callback_for_testing(isolate()), ExternalReference::wasm_call_trap_callback_for_testing(isolate()),
0); 0);
......
...@@ -290,7 +290,7 @@ void RegExpMacroAssemblerARM::CheckNotBackReferenceIgnoreCase( ...@@ -290,7 +290,7 @@ void RegExpMacroAssemblerARM::CheckNotBackReferenceIgnoreCase(
} else { } else {
DCHECK(mode_ == UC16); DCHECK(mode_ == UC16);
int argument_count = 4; int argument_count = 4;
__ PrepareCallCFunction(argument_count, r2); __ PrepareCallCFunction(argument_count);
// r0 - offset of start of capture // r0 - offset of start of capture
// r1 - length of capture // r1 - length of capture
...@@ -665,7 +665,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) { ...@@ -665,7 +665,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) {
__ jmp(&return_r0); __ jmp(&return_r0);
__ bind(&stack_limit_hit); __ bind(&stack_limit_hit);
CallCheckStackGuardState(r0); CallCheckStackGuardState();
__ cmp(r0, Operand::Zero()); __ cmp(r0, Operand::Zero());
// If returned value is non-zero, we exit with the returned value as result. // If returned value is non-zero, we exit with the returned value as result.
__ b(ne, &return_r0); __ b(ne, &return_r0);
...@@ -841,7 +841,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) { ...@@ -841,7 +841,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) {
if (check_preempt_label_.is_linked()) { if (check_preempt_label_.is_linked()) {
SafeCallTarget(&check_preempt_label_); SafeCallTarget(&check_preempt_label_);
CallCheckStackGuardState(r0); CallCheckStackGuardState();
__ cmp(r0, Operand::Zero()); __ cmp(r0, Operand::Zero());
// If returning non-zero, we should end execution with the given // If returning non-zero, we should end execution with the given
// result as return value. // result as return value.
...@@ -860,7 +860,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) { ...@@ -860,7 +860,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) {
// Call GrowStack(backtrack_stackpointer(), &stack_base) // Call GrowStack(backtrack_stackpointer(), &stack_base)
static const int num_arguments = 3; static const int num_arguments = 3;
__ PrepareCallCFunction(num_arguments, r0); __ PrepareCallCFunction(num_arguments);
__ mov(r0, backtrack_stackpointer()); __ mov(r0, backtrack_stackpointer());
__ add(r1, frame_pointer(), Operand(kStackHighEnd)); __ add(r1, frame_pointer(), Operand(kStackHighEnd));
__ mov(r2, Operand(ExternalReference::isolate_address(isolate()))); __ mov(r2, Operand(ExternalReference::isolate_address(isolate())));
...@@ -1046,8 +1046,8 @@ void RegExpMacroAssemblerARM::WriteStackPointerToRegister(int reg) { ...@@ -1046,8 +1046,8 @@ void RegExpMacroAssemblerARM::WriteStackPointerToRegister(int reg) {
// Private methods: // Private methods:
void RegExpMacroAssemblerARM::CallCheckStackGuardState(Register scratch) { void RegExpMacroAssemblerARM::CallCheckStackGuardState() {
__ PrepareCallCFunction(3, scratch); __ PrepareCallCFunction(3);
// RegExp code frame pointer. // RegExp code frame pointer.
__ mov(r2, frame_pointer()); __ mov(r2, frame_pointer());
......
...@@ -140,7 +140,7 @@ class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler { ...@@ -140,7 +140,7 @@ class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler {
// Generate a call to CheckStackGuardState. // Generate a call to CheckStackGuardState.
void CallCheckStackGuardState(Register scratch); void CallCheckStackGuardState();
// The ebp-relative location of a regexp register. // The ebp-relative location of a regexp register.
MemOperand register_location(int register_index); MemOperand register_location(int register_index);
......
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