Skip to content

Commit

Permalink
Bug 1112164 part 18 - PushRegsInMask: Do not spill SIMD register if t…
Browse files Browse the repository at this point in the history
…here is no support.
  • Loading branch information
rmottola committed Mar 11, 2019
1 parent a5d3813 commit 64bc725
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
2 changes: 2 additions & 0 deletions js/src/jit/shared/MacroAssembler-x86-shared.cpp
Expand Up @@ -17,6 +17,7 @@ MacroAssembler::PushRegsInMask(RegisterSet set, FloatRegisterSet simdSet)
{
FloatRegisterSet doubleSet(FloatRegisterSet::Subtract(set.fpus(), simdSet));
MOZ_ASSERT_IF(simdSet.empty(), doubleSet == set.fpus());
doubleSet = doubleSet.reduceSetForPush();
unsigned numSimd = simdSet.size();
unsigned numDouble = doubleSet.size();
int32_t diffF = doubleSet.getPushSizeInBytes() + numSimd * Simd128DataSize;
Expand Down Expand Up @@ -63,6 +64,7 @@ MacroAssembler::PopRegsInMaskIgnore(RegisterSet set, RegisterSet ignore, FloatRe
{
FloatRegisterSet doubleSet(FloatRegisterSet::Subtract(set.fpus(), simdSet));
MOZ_ASSERT_IF(simdSet.empty(), doubleSet == set.fpus());
doubleSet = doubleSet.reduceSetForPush();
unsigned numSimd = simdSet.size();
unsigned numDouble = doubleSet.size();
int32_t diffG = set.gprs().size() * sizeof(intptr_t);
Expand Down
6 changes: 5 additions & 1 deletion js/src/jit/x64/Assembler-x64.cpp
Expand Up @@ -307,7 +307,11 @@ Assembler::TraceJumpRelocations(JSTracer *trc, JitCode *code, CompactBufferReade
FloatRegisterSet
FloatRegister::ReduceSetForPush(const FloatRegisterSet &s)
{
return s;
if (JitSupportsSimd())
return s;

// Ignore all SIMD register.
return FloatRegisterSet(s.bits() & (Codes::AllPhysMask * Codes::SpreadScalar));
}
uint32_t
FloatRegister::GetPushSizeInBytes(const FloatRegisterSet &s)
Expand Down
20 changes: 19 additions & 1 deletion js/src/jit/x64/Trampoline-x64.cpp
Expand Up @@ -509,7 +509,25 @@ static void
PushBailoutFrame(MacroAssembler& masm, Register spArg)
{
// Push registers such that we can access them from [base + code].
masm.PushRegsInMask(AllRegs);
if (JitSupportsSimd()) {
masm.PushRegsInMask(AllRegs);
} else {
// When SIMD isn't supported, PushRegsInMask reduces the set of float
// registers to be double-sized, while the RegisterDump expects each of
// the float registers to have the maximal possible size
// (Simd128DataSize). To work around this, we just spill the double
// registers by hand here, using the register dump offset directly.
RegisterSet set = AllRegs;
for (GeneralRegisterBackwardIterator iter(set.gprs()); iter.more(); iter++)
masm.Push(*iter);

masm.reserveStack(sizeof(RegisterDump::FPUArray));
for (FloatRegisterBackwardIterator iter(set.fpus()); iter.more(); iter++) {
FloatRegister reg = *iter;
Address spillAddress(StackPointer, reg.getRegisterDumpOffsetInBytes());
masm.storeDouble(reg, spillAddress);
}
}

// Get the stack pointer into a register, pre-alignment.
masm.movq(rsp, spArg);
Expand Down
6 changes: 5 additions & 1 deletion js/src/jit/x86/Assembler-x86.cpp
Expand Up @@ -105,7 +105,11 @@ Assembler::TraceJumpRelocations(JSTracer *trc, JitCode *code, CompactBufferReade
FloatRegisterSet
FloatRegister::ReduceSetForPush(const FloatRegisterSet &s)
{
return s;
if (JitSupportsSimd())
return s;

// Ignore all SIMD register.
return FloatRegisterSet(s.bits() & (Codes::AllPhysMask * Codes::SpreadScalar));
}
uint32_t
FloatRegister::GetPushSizeInBytes(const FloatRegisterSet &s)
Expand Down
20 changes: 19 additions & 1 deletion js/src/jit/x86/Trampoline-x86.cpp
Expand Up @@ -503,7 +503,25 @@ static void
PushBailoutFrame(MacroAssembler& masm, uint32_t frameClass, Register spArg)
{
// Push registers such that we can access them from [base + code].
masm.PushRegsInMask(AllRegs);
if (JitSupportsSimd()) {
masm.PushRegsInMask(AllRegs);
} else {
// When SIMD isn't supported, PushRegsInMask reduces the set of float
// registers to be double-sized, while the RegisterDump expects each of
// the float registers to have the maximal possible size
// (Simd128DataSize). To work around this, we just spill the double
// registers by hand here, using the register dump offset directly.
RegisterSet set = AllRegs;
for (GeneralRegisterBackwardIterator iter(set.gprs()); iter.more(); iter++)
masm.Push(*iter);

masm.reserveStack(sizeof(RegisterDump::FPUArray));
for (FloatRegisterBackwardIterator iter(set.fpus()); iter.more(); iter++) {
FloatRegister reg = *iter;
Address spillAddress(StackPointer, reg.getRegisterDumpOffsetInBytes());
masm.storeDouble(reg, spillAddress);
}
}

// Push the bailout table number.
masm.push(Imm32(frameClass));
Expand Down

0 comments on commit 64bc725

Please sign in to comment.