Bug 916912 - Add addConstantDouble to avoid static double usage (r=jandem)

--HG--
extra : rebase_source : 831893b2a7406ffe40f2d3892e3dd1b563481267
This commit is contained in:
Luke Wagner 2013-09-17 10:34:20 -05:00
parent abc7b73662
commit 4e328e873f
2 changed files with 59 additions and 21 deletions

View File

@ -18,16 +18,13 @@
using namespace js;
using namespace js::jit;
void
MacroAssemblerX86::loadConstantDouble(double d, const FloatRegister &dest)
MacroAssemblerX86::Double *
MacroAssemblerX86::getDouble(double d)
{
if (maybeInlineDouble(d, dest))
return;
if (!doubleMap_.initialized()) {
enoughMemory_ &= doubleMap_.init();
if (!enoughMemory_)
return;
return NULL;
}
size_t doubleIndex;
DoubleMap::AddPtr p = doubleMap_.lookupForAdd(d);
@ -38,24 +35,42 @@ MacroAssemblerX86::loadConstantDouble(double d, const FloatRegister &dest)
enoughMemory_ &= doubles_.append(Double(d));
enoughMemory_ &= doubleMap_.add(p, d, doubleIndex);
if (!enoughMemory_)
return;
return NULL;
}
Double &dbl = doubles_[doubleIndex];
JS_ASSERT(!dbl.uses.bound());
masm.movsd_mr(reinterpret_cast<const void *>(dbl.uses.prev()), dest.code());
dbl.uses.setPrev(masm.size());
return &dbl;
}
void
MacroAssemblerX86::loadConstantFloat32(float f, const FloatRegister &dest)
MacroAssemblerX86::loadConstantDouble(double d, const FloatRegister &dest)
{
if (maybeInlineDouble(d, dest))
return;
Double *dbl = getDouble(d);
if (!dbl)
return;
masm.movsd_mr(reinterpret_cast<const void *>(dbl->uses.prev()), dest.code());
dbl->uses.setPrev(masm.size());
}
void
MacroAssemblerX86::addConstantDouble(double d, const FloatRegister &dest)
{
Double *dbl = getDouble(d);
if (!dbl)
return;
masm.addsd_mr(reinterpret_cast<const void *>(dbl->uses.prev()), dest.code());
dbl->uses.setPrev(masm.size());
}
MacroAssemblerX86::Float *
MacroAssemblerX86::getFloat(float f)
{
// Contrarily to loadConstantDouble, this one doesn't have any maybeInlineFloat,
// but that might be interesting to do it in the future.
if (!floatMap_.initialized()) {
enoughMemory_ &= floatMap_.init();
if (!enoughMemory_)
return;
return NULL;
}
size_t floatIndex;
FloatMap::AddPtr p = floatMap_.lookupForAdd(f);
@ -66,13 +81,33 @@ MacroAssemblerX86::loadConstantFloat32(float f, const FloatRegister &dest)
enoughMemory_ &= floats_.append(Float(f));
enoughMemory_ &= floatMap_.add(p, f, floatIndex);
if (!enoughMemory_)
return;
return NULL;
}
Float &flt = floats_[floatIndex];
JS_ASSERT(!flt.uses.bound());
return &flt;
}
masm.movss_mr(reinterpret_cast<const void *>(flt.uses.prev()), dest.code());
flt.uses.setPrev(masm.size());
void
MacroAssemblerX86::loadConstantFloat32(float f, const FloatRegister &dest)
{
// Contrary to loadConstantDouble, this one doesn't have any maybeInlineFloat,
// but that might be interesting to do it in the future.
Float *flt = getFloat(f);
if (!flt)
return;
masm.movss_mr(reinterpret_cast<const void *>(flt->uses.prev()), dest.code());
flt->uses.setPrev(masm.size());
}
void
MacroAssemblerX86::addConstantFloat32(float f, const FloatRegister &dest)
{
Float *flt = getFloat(f);
if (!flt)
return;
masm.addss_mr(reinterpret_cast<const void *>(flt->uses.prev()), dest.code());
flt->uses.setPrev(masm.size());
}
void

View File

@ -45,6 +45,9 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared
typedef HashMap<float, size_t, DefaultHasher<float>, SystemAllocPolicy> FloatMap;
FloatMap floatMap_;
Double *getDouble(double d);
Float *getFloat(float f);
protected:
MoveResolver moveResolver_;
@ -862,7 +865,9 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared
}
void loadConstantDouble(double d, const FloatRegister &dest);
void addConstantDouble(double d, const FloatRegister &dest);
void loadConstantFloat32(float f, const FloatRegister &dest);
void addConstantFloat32(float f, const FloatRegister &dest);
void branchTruncateDouble(const FloatRegister &src, const Register &dest, Label *fail) {
const uint32_t IndefiniteIntegerValue = 0x80000000;
@ -952,8 +957,7 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared
// dest is now a double with the int range.
// correct the double value by adding 0x80000000.
static const double NegativeOne = 2147483648.0;
addsd(Operand(&NegativeOne), dest);
addConstantDouble(2147483648.0, dest);
}
// Note: this function clobbers the source register.
@ -966,8 +970,7 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared
// dest is now a double with the int range.
// correct the double value by adding 0x80000000.
static const float NegativeOne = 2147483648.f;
addss(Operand(&NegativeOne), dest);
addConstantFloat32(2147483648.f, dest);
}
void inc64(AbsoluteAddress dest) {