Bug 1238935 - r=jonco a=sylvestre
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 10 Feb 2016 16:57:37 +0100
changeset 303924 06d13ff7785d72f269f73d007366013798d08188
parent 303923 81b7b203feb1f497c32c0f4902888365335f7571
child 303925 02156c26b928dfdb8076fd09c32ba7ca311ff360
push id9055
push userkwierso@gmail.com
push dateThu, 11 Feb 2016 17:57:11 +0000
treeherdermozilla-aurora@06d13ff7785d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco, sylvestre
bugs1238935
milestone46.0a2
Bug 1238935 - r=jonco a=sylvestre
js/src/jit/Lowering.cpp
--- a/js/src/jit/Lowering.cpp
+++ b/js/src/jit/Lowering.cpp
@@ -2473,28 +2473,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())
@@ -3590,16 +3599,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.
@@ -3612,17 +3622,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)
 {