Bug 1111234 - SpiderMonkey: Use 8-bit immediate fields when possible for push and imull r=luke

This commit is contained in:
Dan Gohman 2014-12-15 20:53:59 -08:00
parent f12bc26b9e
commit fe78413f18
3 changed files with 27 additions and 8 deletions

View File

@ -1274,13 +1274,13 @@ class AssemblerX86Shared : public AssemblerShared
masm.imull_r(multiplier.code());
}
void imull(Imm32 imm, Register dest) {
masm.imull_i32r(dest.code(), imm.value, dest.code());
masm.imull_ir(imm.value, dest.code(), dest.code());
}
void imull(Register src, Register dest) {
masm.imull_rr(src.code(), dest.code());
}
void imull(Imm32 imm, Register src, Register dest) {
masm.imull_i32r(src.code(), imm.value, dest.code());
masm.imull_ir(imm.value, src.code(), dest.code());
}
void imull(const Operand &src, Register dest) {
switch (src.kind()) {
@ -1441,7 +1441,7 @@ class AssemblerX86Shared : public AssemblerShared
}
void push(const Imm32 imm) {
masm.push_i32(imm.value);
masm.push_i(imm.value);
}
void push(const Operand &src) {

View File

@ -264,6 +264,8 @@ private:
PRE_SSE_66 = 0x66,
OP_PUSH_Iz = 0x68,
OP_IMUL_GvEvIz = 0x69,
OP_PUSH_Ib = 0x6a,
OP_IMUL_GvEvIb = 0x6b,
OP_GROUP1_EbIb = 0x80,
OP_GROUP1_EvIz = 0x81,
OP_GROUP1_EvIb = 0x83,
@ -563,6 +565,18 @@ public:
m_formatter.oneByteOp(OP_POP_EAX, reg);
}
void push_i(int imm)
{
spew("push %s$0x%x", PRETTY_PRINT_OFFSET(imm));
if (CAN_SIGN_EXTEND_8_32(imm)) {
m_formatter.oneByteOp(OP_PUSH_Ib);
m_formatter.immediate8(imm);
} else {
m_formatter.oneByteOp(OP_PUSH_Iz);
m_formatter.immediate32(imm);
}
}
void push_i32(int imm)
{
spew("push %s$0x%x", PRETTY_PRINT_OFFSET(imm));
@ -1439,11 +1453,16 @@ public:
m_formatter.twoByteOp(OP2_IMUL_GvEv, offset, base, dst);
}
void imull_i32r(RegisterID src, int32_t value, RegisterID dst)
void imull_ir(int32_t value, RegisterID src, RegisterID dst)
{
spew("imull $%d, %s, %s", value, nameIReg(4, src), nameIReg(4, dst));
m_formatter.oneByteOp(OP_IMUL_GvEvIz, src, dst);
m_formatter.immediate32(value);
if (CAN_SIGN_EXTEND_8_32(value)) {
m_formatter.oneByteOp(OP_IMUL_GvEvIb, src, dst);
m_formatter.immediate8(value);
} else {
m_formatter.oneByteOp(OP_IMUL_GvEvIz, src, dst);
m_formatter.immediate32(value);
}
}
void idivl_r(RegisterID divisor)

View File

@ -204,7 +204,7 @@ class Assembler : public AssemblerX86Shared
// Actual assembly emitting functions.
void push(ImmGCPtr ptr) {
push(Imm32(uintptr_t(ptr.value)));
masm.push_i32(int32_t(ptr.value));
writeDataRelocation(ptr);
}
void push(ImmMaybeNurseryPtr ptr) {
@ -222,7 +222,7 @@ class Assembler : public AssemblerX86Shared
}
CodeOffsetLabel pushWithPatch(ImmWord word) {
push(Imm32(word.value));
masm.push_i32(int32_t(word.value));
return CodeOffsetLabel(masm.currentOffset());
}