Bug 1238935 - r=jonco a=sylvestre
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 10 Feb 2016 16:57:37 +0100
changeset 311208 c7b4a20b6294cb9b1d11f063c5a92dfcf677eab2
parent 311207 bfb97f135a931cbafe026f25c69a3ced1ccaba1f
child 311209 01e4f115b078b0d76ece6e7122212897c6cc156c
push id5602
push userkwierso@gmail.com
push dateThu, 11 Feb 2016 18:02:15 +0000
treeherdermozilla-beta@c7b4a20b6294 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco, sylvestre
bugs1238935
milestone45.0
Bug 1238935 - r=jonco a=sylvestre ba=sylvestre for a completely separate commit's binary change
js/src/jit/Lowering.cpp
--- a/js/src/jit/Lowering.cpp
+++ b/js/src/jit/Lowering.cpp
@@ -2433,28 +2433,37 @@ LIRGenerator::visitMonitorTypes(MMonitor
     LDefinition tmp = needTemp ? temp() : tempToUnbox();
 
     LMonitorTypes* lir = new(alloc()) LMonitorTypes(tmp);
     useBox(lir, LMonitorTypes::Input, ins->input());
     assignSnapshot(lir, Bailout_MonitorTypes);
     add(lir, ins);
 }
 
+// Returns true iff |def| is a constant that's either not a GC thing or is not
+// allocated in the nursery.
+static bool
+IsNonNurseryConstant(MDefinition* def)
+{
+    if (!def->isConstant())
+        return false;
+    Value v = def->toConstant()->value();
+    return !v.isMarkable() || !IsInsideNursery(v.toGCThing());
+}
+
 void
 LIRGenerator::visitPostWriteBarrier(MPostWriteBarrier* ins)
 {
     MOZ_ASSERT(ins->object()->type() == MIRType_Object);
 
     // LPostWriteBarrier assumes that if it has a constant object then that
     // object is tenured, and does not need to be tested for being in the
     // nursery. Ensure that assumption holds by lowering constant nursery
     // objects to a register.
-    bool useConstantObject =
-        ins->object()->isConstant() &&
-        !IsInsideNursery(&ins->object()->toConstant()->value().toObject());
+    bool useConstantObject = IsNonNurseryConstant(ins->object());
 
     switch (ins->value()->type()) {
       case MIRType_Object:
       case MIRType_ObjectOrNull: {
         LDefinition tmp = needTempForPostBarrier() ? temp() : LDefinition::BogusTemp();
         LPostWriteBarrierO* lir =
             new(alloc()) LPostWriteBarrierO(useConstantObject
                                             ? useOrConstant(ins->object())
@@ -3540,16 +3549,17 @@ LIRGenerator::visitSetPropertyCache(MSet
     MOZ_ASSERT(id->type() == MIRType_String ||
                id->type() == MIRType_Symbol ||
                id->type() == MIRType_Int32 ||
                id->type() == MIRType_Value);
 
     // If this is a SETPROP, the id is a constant string. Allow passing it as a
     // constant to reduce register allocation pressure.
     bool useConstId = id->type() == MIRType_String || id->type() == MIRType_Symbol;
+    bool useConstValue = IsNonNurseryConstant(ins->value());
 
     // Set the performs-call flag so that we don't omit the overrecursed check.
     // This is necessary because the cache can attach a scripted setter stub
     // that calls this script recursively.
     gen->setPerformsCall();
 
     // If the index might be an integer, we need some extra temp registers for
     // the dense and typed array element stubs.
@@ -3562,17 +3572,17 @@ LIRGenerator::visitSetPropertyCache(MSet
             tempToUnboxIndex = tempToUnbox();
         tempD = tempDouble();
         tempF32 = hasUnaliasedDouble() ? tempFloat32() : LDefinition::BogusTemp();
     }
 
     LInstruction* lir = new(alloc()) LSetPropertyCache(useRegister(ins->object()), temp(),
                                                        tempToUnboxIndex, tempD, tempF32);
     useBoxOrTypedOrConstant(lir, LSetPropertyCache::Id, id, useConstId);
-    useBoxOrTypedOrConstant(lir, LSetPropertyCache::Value, ins->value(), /* useConstant = */ true);
+    useBoxOrTypedOrConstant(lir, LSetPropertyCache::Value, ins->value(), useConstValue);
 
     add(lir, ins);
     assignSafepoint(lir, ins);
 }
 
 void
 LIRGenerator::visitCallSetElement(MCallSetElement* ins)
 {