Bug 937540 part 3 - Use placement new for GVN ValueNumberData. r=mjrosenb
authorJan de Mooij <jdemooij@mozilla.com>
Sat, 16 Nov 2013 10:15:33 +0100
changeset 154954 4d4d4d111dfd630a0ddf3ea76c31547810c66600
parent 154953 d06ce084e3a98cb4c94c291317897801688e06ba
child 154955 fc55a33f6b3f6c4588ecc15aa906b62e777a4853
push id36181
push userjandemooij@gmail.com
push dateSat, 16 Nov 2013 09:19:47 +0000
treeherdermozilla-inbound@fc55a33f6b3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmjrosenb
bugs937540
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 937540 part 3 - Use placement new for GVN ValueNumberData. r=mjrosenb
js/src/jit/ValueNumbering.cpp
js/src/jit/ValueNumbering.h
--- a/js/src/jit/ValueNumbering.cpp
+++ b/js/src/jit/ValueNumbering.cpp
@@ -15,16 +15,22 @@ using namespace js::jit;
 
 ValueNumberer::ValueNumberer(MIRGenerator *mir, MIRGraph &graph, bool optimistic)
   : mir(mir),
     graph_(graph),
     pessimisticPass_(!optimistic),
     count_(0)
 { }
 
+TempAllocator &
+ValueNumberer::alloc() const
+{
+    return mir->temp();
+}
+
 uint32_t
 ValueNumberer::lookupValue(MDefinition *ins)
 {
 
     ValueMap::AddPtr p = values.lookupForAdd(ins);
 
     if (p) {
         // make sure this is in the correct group
@@ -46,17 +52,17 @@ ValueNumberer::simplify(MDefinition *def
 
     MDefinition *ins = def->foldsTo(useValueNumbers);
 
     if (ins == def || !ins->updateForFolding(def))
         return def;
 
     // ensure this instruction has a VN
     if (!ins->valueNumberData())
-        ins->setValueNumberData(new ValueNumberData);
+        ins->setValueNumberData(new(alloc()) ValueNumberData);
     if (!ins->block()) {
         // In this case, we made a new def by constant folding, for
         // example, we replaced add(#3,#4) with a new const(#7) node.
 
         // We will only fold a phi into one of its operands.
         JS_ASSERT(!def->isPhi());
 
         def->block()->insertAfter(def->toInstruction(), ins->toInstruction());
@@ -78,17 +84,17 @@ ValueNumberer::simplifyControlInstructio
         return def;
 
     MDefinition *repl = def->foldsTo(false);
     if (repl == def || !repl->updateForFolding(def))
         return def;
 
     // Ensure this instruction has a value number.
     if (!repl->valueNumberData())
-        repl->setValueNumberData(new ValueNumberData);
+        repl->setValueNumberData(new(alloc()) ValueNumberData);
 
     MBasicBlock *block = def->block();
 
     // MControlInstructions should not have consumers.
     JS_ASSERT(repl->isControlInstruction());
     JS_ASSERT(!def->hasUses());
 
     if (def->isInWorklist())
@@ -172,19 +178,19 @@ ValueNumberer::computeValueNumbers()
 
     if (!values.init())
         return false;
     // Stick a VN object onto every mdefinition
     for (ReversePostorderIterator block(graph_.rpoBegin()); block != graph_.rpoEnd(); block++) {
         if (mir->shouldCancel("Value Numbering (preparation loop"))
             return false;
         for (MDefinitionIterator iter(*block); iter; iter++)
-            iter->setValueNumberData(new ValueNumberData);
+            iter->setValueNumberData(new(alloc()) ValueNumberData);
         MControlInstruction *jump = block->lastIns();
-        jump->setValueNumberData(new ValueNumberData);
+        jump->setValueNumberData(new(alloc()) ValueNumberData);
     }
 
     // Assign unique value numbers if pessimistic.
     // It might be productive to do this in the MDefinition constructor or
     // possibly in a previous pass, if it seems reasonable.
     if (pessimisticPass_) {
         for (ReversePostorderIterator block(graph_.rpoBegin()); block != graph_.rpoEnd(); block++) {
             for (MDefinitionIterator iter(*block); iter; iter++)
--- a/js/src/jit/ValueNumbering.h
+++ b/js/src/jit/ValueNumbering.h
@@ -45,16 +45,17 @@ class ValueNumberer
     };
 
     typedef HashMap<uint32_t,
                     DominatingValue,
                     DefaultHasher<uint32_t>,
                     IonAllocPolicy> InstructionMap;
 
   protected:
+    TempAllocator &alloc() const;
     uint32_t lookupValue(MDefinition *ins);
     MDefinition *findDominatingDef(InstructionMap &defs, MDefinition *ins, size_t index);
 
     MDefinition *simplify(MDefinition *def, bool useValueNumbers);
     MControlInstruction *simplifyControlInstruction(MControlInstruction *def);
     bool eliminateRedundancies();
 
     bool computeValueNumbers();