Bug 1376819 Do not blind int16's, we believe these are safe to leave alone
MozReview-Commit-ID: F9lHNLommCo
--- a/js/src/jit/x64/MacroAssembler-x64-inl.h
+++ b/js/src/jit/x64/MacroAssembler-x64-inl.h
@@ -15,30 +15,35 @@ namespace js {
namespace jit {
//{{{ check_macroassembler_style
// ===============================================================
void
MacroAssembler::move64(Imm64 imm, Register64 dest)
{
- // Wipe out the top bit to avoid any potential sign extension problems
- uint64_t blind = 0x7FFFFFFF7FFFFFFFULL & js::GenerateRandomSeed() ;
- uint32_t blind_top = 0x7FFFFFFF & (blind >> 32);
- uint32_t blind_bot = 0x7FFFFFFF & (blind);
+ // Do not blind common constants that are (believed to be) safe
+ if(int64_t(imm.value) >= int64_t(-32768) && int64_t(imm.value) <= int64_t(32767)) {
+ movq(ImmWord(imm.value), dest.reg);
+ } else {
+ // Wipe out the top bit to avoid any potential sign extension problems
+ uint64_t blind = 0x7FFFFFFF7FFFFFFFULL & js::GenerateRandomSeed();
+ uint32_t blind_top = 0x7FFFFFFF & (blind >> 32);
+ uint32_t blind_bot = 0x7FFFFFFF & (blind);
- uint64_t blinded = imm.value ^ blind;
- // pre-rotate to save us one emitted assembly instruction
- blinded = (blinded >> 32) | (blinded << 32);
+ uint64_t blinded = imm.value ^ blind;
+ // pre-rotate to save us one emitted assembly instruction
+ blinded = (blinded >> 32) | (blinded << 32);
- movq(ImmWord(blinded), dest.reg);
+ movq(ImmWord(blinded), dest.reg);
- xorq(Imm32(blind_top), dest.reg);
- rorq(Imm32(32), dest.reg);
- xorq(Imm32(blind_bot), dest.reg);
+ xorq(Imm32(blind_top), dest.reg);
+ rorq(Imm32(32), dest.reg);
+ xorq(Imm32(blind_bot), dest.reg);
+ }
}
void
MacroAssembler::move64(Register64 src, Register64 dest)
{
movq(src.reg, dest.reg);
}
--- a/js/src/jit/x86-shared/MacroAssembler-x86-shared.h
+++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared.h
@@ -122,24 +122,30 @@ class MacroAssemblerX86Shared : public A
else
vucomiss(rhs, lhs);
}
void branchNegativeZero(FloatRegister reg, Register scratch, Label* label, bool maybeNonZero = true);
void branchNegativeZeroFloat32(FloatRegister reg, Register scratch, Label* label);
void move32(Imm32 imm, Register dest) {
- uint32_t blind = js::GenerateRandomSeed();
- uint32_t blinded = imm.value ^ blind;
-
// Use the ImmWord version of mov to register, which has special
// optimizations. Using uint32_t here ensures that the value
// is zero-extended.
- mov(ImmWord(blinded), dest);
- xorl(Imm32(blind), dest);
+
+ // Do not blind common constants that are (believed to be) safe
+ if(int32_t(imm.value) >= int32_t(-32768) && int32_t(imm.value) <= int32_t(32767)) {
+ mov(ImmWord(uint32_t(imm.value)), dest);
+ } else {
+ uint32_t blind = js::GenerateRandomSeed();
+ uint32_t blinded = imm.value ^ blind;
+
+ mov(ImmWord(blinded), dest);
+ xorl(Imm32(blind), dest);
+ }
}
void move32(Imm32 imm, const Operand& dest) {
movl(imm, dest);
}
void move32(Register src, Register dest) {
movl(src, dest);
}
void move32(Register src, const Operand& dest) {