Commit 5528ce70 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

MIPS: Cleaned up calling-related methods in the assembler.

Patterned after r8482, Cleaned up calling-related methods in the ARM assembler.

On MIPS I completely refactored the Jump and Call methods.
All the Jump and Call macro helpers have been replaced with overloaded functions
(matching the ARM version) and using default parameter values where possible.
The previously mostly-unused CallSize function is utilized as well (same as on ARM).
The unused Jump(Operand, ...) and Call(Operand, ...) versions have been completely removed.
I also removed the Jump(BranchDelaySlot, ...) and Call(BranchDelaySlot,...) methods as
they were unused and declaring them would either result in a lot of unused code or the
previously experienced macro-hell. The only exception to this is for Ret() where the
branch delay slot is often used.

This fixes the failing debug tests for example cctest test-debug/DebugStepFor.

Ported r8482 (41cb9ed)

Patch by Daniel Kalmar <kalmard@homejinni.com>

BUG=
TEST=

Review URL: http://codereview.chromium.org//7328013
Patch from Paul Lind <plind44@gmail.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8585 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a15d8652
...@@ -779,8 +779,13 @@ class Assembler : public AssemblerBase { ...@@ -779,8 +779,13 @@ class Assembler : public AssemblerBase {
void fcmp(FPURegister src1, const double src2, FPUCondition cond); void fcmp(FPURegister src1, const double src2, FPUCondition cond);
// Check the code size generated from label to here. // Check the code size generated from label to here.
int InstructionsGeneratedSince(Label* l) { int SizeOfCodeGeneratedSince(Label* label) {
return (pc_offset() - l->pos()) / kInstrSize; return pc_offset() - label->pos();
}
// Check the number of instructions generated from label to here.
int InstructionsGeneratedSince(Label* label) {
return SizeOfCodeGeneratedSince(label) / kInstrSize;
} }
// Class for scoping postponing the trampoline pool generation. // Class for scoping postponing the trampoline pool generation.
......
...@@ -634,7 +634,7 @@ void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { ...@@ -634,7 +634,7 @@ void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
__ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
__ lw(a2, FieldMemOperand(a2, SharedFunctionInfo::kConstructStubOffset)); __ lw(a2, FieldMemOperand(a2, SharedFunctionInfo::kConstructStubOffset));
__ Addu(t9, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); __ Addu(t9, a2, Operand(Code::kHeaderSize - kHeapObjectTag));
__ Jump(Operand(t9)); __ Jump(t9);
// a0: number of arguments // a0: number of arguments
// a1: called object // a1: called object
...@@ -1075,8 +1075,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ...@@ -1075,8 +1075,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
// Invoke the code and pass argc as a0. // Invoke the code and pass argc as a0.
__ mov(a0, a3); __ mov(a0, a3);
if (is_construct) { if (is_construct) {
__ Call(masm->isolate()->builtins()->JSConstructCall(), __ Call(masm->isolate()->builtins()->JSConstructCall());
RelocInfo::CODE_TARGET);
} else { } else {
ParameterCount actual(a0); ParameterCount actual(a0);
__ InvokeFunction(a1, actual, CALL_FUNCTION, __ InvokeFunction(a1, actual, CALL_FUNCTION,
......
...@@ -390,11 +390,11 @@ void FloatingPointHelper::LoadSmis(MacroAssembler* masm, ...@@ -390,11 +390,11 @@ void FloatingPointHelper::LoadSmis(MacroAssembler* masm,
__ mov(scratch1, a0); __ mov(scratch1, a0);
ConvertToDoubleStub stub1(a3, a2, scratch1, scratch2); ConvertToDoubleStub stub1(a3, a2, scratch1, scratch2);
__ push(ra); __ push(ra);
__ Call(stub1.GetCode(), RelocInfo::CODE_TARGET); __ Call(stub1.GetCode());
// Write Smi from a1 to a1 and a0 in double format. // Write Smi from a1 to a1 and a0 in double format.
__ mov(scratch1, a1); __ mov(scratch1, a1);
ConvertToDoubleStub stub2(a1, a0, scratch1, scratch2); ConvertToDoubleStub stub2(a1, a0, scratch1, scratch2);
__ Call(stub2.GetCode(), RelocInfo::CODE_TARGET); __ Call(stub2.GetCode());
__ pop(ra); __ pop(ra);
} }
} }
...@@ -476,7 +476,7 @@ void FloatingPointHelper::LoadNumber(MacroAssembler* masm, ...@@ -476,7 +476,7 @@ void FloatingPointHelper::LoadNumber(MacroAssembler* masm,
__ mov(scratch1, object); __ mov(scratch1, object);
ConvertToDoubleStub stub(dst2, dst1, scratch1, scratch2); ConvertToDoubleStub stub(dst2, dst1, scratch1, scratch2);
__ push(ra); __ push(ra);
__ Call(stub.GetCode(), RelocInfo::CODE_TARGET); __ Call(stub.GetCode());
__ pop(ra); __ pop(ra);
} }
...@@ -1101,7 +1101,7 @@ static void EmitSmiNonsmiComparison(MacroAssembler* masm, ...@@ -1101,7 +1101,7 @@ static void EmitSmiNonsmiComparison(MacroAssembler* masm,
__ mov(t6, rhs); __ mov(t6, rhs);
ConvertToDoubleStub stub1(a1, a0, t6, t5); ConvertToDoubleStub stub1(a1, a0, t6, t5);
__ push(ra); __ push(ra);
__ Call(stub1.GetCode(), RelocInfo::CODE_TARGET); __ Call(stub1.GetCode());
__ pop(ra); __ pop(ra);
} }
...@@ -1136,7 +1136,7 @@ static void EmitSmiNonsmiComparison(MacroAssembler* masm, ...@@ -1136,7 +1136,7 @@ static void EmitSmiNonsmiComparison(MacroAssembler* masm,
__ mov(t6, lhs); __ mov(t6, lhs);
ConvertToDoubleStub stub2(a3, a2, t6, t5); ConvertToDoubleStub stub2(a3, a2, t6, t5);
__ push(ra); __ push(ra);
__ Call(stub2.GetCode(), RelocInfo::CODE_TARGET); __ Call(stub2.GetCode());
__ pop(ra); __ pop(ra);
// Load rhs to a double in a1, a0. // Load rhs to a double in a1, a0.
if (rhs.is(a0)) { if (rhs.is(a0)) {
......
This diff is collapsed.
This diff is collapsed.
...@@ -99,44 +99,11 @@ class MacroAssembler: public Assembler { ...@@ -99,44 +99,11 @@ class MacroAssembler: public Assembler {
// macro assembler. // macro assembler.
MacroAssembler(Isolate* isolate, void* buffer, int size); MacroAssembler(Isolate* isolate, void* buffer, int size);
// Arguments macros. // Arguments macros.
#define COND_TYPED_ARGS Condition cond, Register r1, const Operand& r2 #define COND_TYPED_ARGS Condition cond, Register r1, const Operand& r2
#define COND_ARGS cond, r1, r2 #define COND_ARGS cond, r1, r2
// Prototypes. // Cases when relocation is not needed.
// Prototypes for functions with no target (eg Ret()).
#define DECLARE_NOTARGET_PROTOTYPE(Name) \
void Name(BranchDelaySlot bd = PROTECT); \
void Name(COND_TYPED_ARGS, BranchDelaySlot bd = PROTECT); \
inline void Name(BranchDelaySlot bd, COND_TYPED_ARGS) { \
Name(COND_ARGS, bd); \
}
// Prototypes for functions with a target.
// Cases when relocation may be needed.
#define DECLARE_RELOC_PROTOTYPE(Name, target_type) \
void Name(target_type target, \
RelocInfo::Mode rmode, \
BranchDelaySlot bd = PROTECT); \
inline void Name(BranchDelaySlot bd, \
target_type target, \
RelocInfo::Mode rmode) { \
Name(target, rmode, bd); \
} \
void Name(target_type target, \
RelocInfo::Mode rmode, \
COND_TYPED_ARGS, \
BranchDelaySlot bd = PROTECT); \
inline void Name(BranchDelaySlot bd, \
target_type target, \
RelocInfo::Mode rmode, \
COND_TYPED_ARGS) { \
Name(target, rmode, COND_ARGS, bd); \
}
// Cases when relocation is not needed.
#define DECLARE_NORELOC_PROTOTYPE(Name, target_type) \ #define DECLARE_NORELOC_PROTOTYPE(Name, target_type) \
void Name(target_type target, BranchDelaySlot bd = PROTECT); \ void Name(target_type target, BranchDelaySlot bd = PROTECT); \
inline void Name(BranchDelaySlot bd, target_type target) { \ inline void Name(BranchDelaySlot bd, target_type target) { \
...@@ -151,44 +118,44 @@ class MacroAssembler: public Assembler { ...@@ -151,44 +118,44 @@ class MacroAssembler: public Assembler {
Name(target, COND_ARGS, bd); \ Name(target, COND_ARGS, bd); \
} }
// Target prototypes.
#define DECLARE_JUMP_CALL_PROTOTYPES(Name) \
DECLARE_NORELOC_PROTOTYPE(Name, Register) \
DECLARE_NORELOC_PROTOTYPE(Name, const Operand&) \
DECLARE_RELOC_PROTOTYPE(Name, byte*) \
DECLARE_RELOC_PROTOTYPE(Name, Handle<Code>)
#define DECLARE_BRANCH_PROTOTYPES(Name) \ #define DECLARE_BRANCH_PROTOTYPES(Name) \
DECLARE_NORELOC_PROTOTYPE(Name, Label*) \ DECLARE_NORELOC_PROTOTYPE(Name, Label*) \
DECLARE_NORELOC_PROTOTYPE(Name, int16_t) DECLARE_NORELOC_PROTOTYPE(Name, int16_t)
DECLARE_BRANCH_PROTOTYPES(Branch)
DECLARE_BRANCH_PROTOTYPES(BranchAndLink)
DECLARE_JUMP_CALL_PROTOTYPES(Jump) #undef DECLARE_BRANCH_PROTOTYPES
DECLARE_JUMP_CALL_PROTOTYPES(Call)
DECLARE_BRANCH_PROTOTYPES(Branch)
DECLARE_BRANCH_PROTOTYPES(BranchAndLink)
DECLARE_NOTARGET_PROTOTYPE(Ret)
#undef COND_TYPED_ARGS #undef COND_TYPED_ARGS
#undef COND_ARGS #undef COND_ARGS
#undef DECLARE_NOTARGET_PROTOTYPE
#undef DECLARE_NORELOC_PROTOTYPE
#undef DECLARE_RELOC_PROTOTYPE
#undef DECLARE_JUMP_CALL_PROTOTYPES
#undef DECLARE_BRANCH_PROTOTYPES
void CallWithAstId(Handle<Code> code,
// Jump, Call, and Ret pseudo instructions implementing inter-working.
#define COND_ARGS Condition cond = al, Register rs = zero_reg, \
const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT
void Jump(Register target, COND_ARGS);
void Jump(intptr_t target, RelocInfo::Mode rmode, COND_ARGS);
void Jump(Address target, RelocInfo::Mode rmode, COND_ARGS);
void Jump(Handle<Code> code, RelocInfo::Mode rmode, COND_ARGS);
int CallSize(Register target, COND_ARGS);
void Call(Register target, COND_ARGS);
int CallSize(Address target, RelocInfo::Mode rmode, COND_ARGS);
void Call(Address target, RelocInfo::Mode rmode, COND_ARGS);
int CallSize(Handle<Code> code,
RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
unsigned ast_id = kNoASTId, unsigned ast_id = kNoASTId,
Condition cond = al, COND_ARGS);
Register r1 = zero_reg, void Call(Handle<Code> code,
const Operand& r2 = Operand(zero_reg)); RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
unsigned ast_id = kNoASTId,
COND_ARGS);
void Ret(COND_ARGS);
inline void Ret(BranchDelaySlot bd) {
Ret(al, zero_reg, Operand(zero_reg), bd);
}
int CallSize(Register reg); #undef COND_ARGS
int CallSize(Handle<Code> code, RelocInfo::Mode rmode);
// Emit code to discard a non-negative number of pointer-sized elements // Emit code to discard a non-negative number of pointer-sized elements
// from the stack, clobbering only the sp register. // from the stack, clobbering only the sp register.
...@@ -1135,17 +1102,6 @@ DECLARE_NOTARGET_PROTOTYPE(Ret) ...@@ -1135,17 +1102,6 @@ DECLARE_NOTARGET_PROTOTYPE(Ret)
void Jr(Label* L, BranchDelaySlot bdslot); void Jr(Label* L, BranchDelaySlot bdslot);
void Jalr(Label* L, BranchDelaySlot bdslot); void Jalr(Label* L, BranchDelaySlot bdslot);
void Jump(intptr_t target, RelocInfo::Mode rmode,
BranchDelaySlot bd = PROTECT);
void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = cc_always,
Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg),
BranchDelaySlot bd = PROTECT);
void Call(intptr_t target, RelocInfo::Mode rmode,
BranchDelaySlot bd = PROTECT);
void Call(intptr_t target, RelocInfo::Mode rmode, Condition cond = cc_always,
Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg),
BranchDelaySlot bd = PROTECT);
// Helper functions for generating invokes. // Helper functions for generating invokes.
void InvokePrologue(const ParameterCount& expected, void InvokePrologue(const ParameterCount& expected,
const ParameterCount& actual, const ParameterCount& actual,
......
...@@ -179,7 +179,7 @@ void RegExpMacroAssemblerMIPS::Backtrack() { ...@@ -179,7 +179,7 @@ void RegExpMacroAssemblerMIPS::Backtrack() {
// Pop Code* offset from backtrack stack, add Code* and jump to location. // Pop Code* offset from backtrack stack, add Code* and jump to location.
Pop(a0); Pop(a0);
__ Addu(a0, a0, code_pointer()); __ Addu(a0, a0, code_pointer());
__ Jump(Operand(a0)); __ Jump(a0);
} }
...@@ -1238,7 +1238,7 @@ void RegExpCEntryStub::Generate(MacroAssembler* masm_) { ...@@ -1238,7 +1238,7 @@ void RegExpCEntryStub::Generate(MacroAssembler* masm_) {
__ Call(t9); __ Call(t9);
__ lw(ra, MemOperand(sp, 0)); __ lw(ra, MemOperand(sp, 0));
__ Addu(sp, sp, Operand(stack_alignment)); __ Addu(sp, sp, Operand(stack_alignment));
__ Jump(Operand(ra)); __ Jump(ra);
} }
......
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