Bug 678106: implement local increment/decrement, r=dvander
authorHannes Verschore <hverschore@mozilla.com>
Thu, 11 Aug 2011 10:28:39 -0700
changeset 108711 73b80b0c344a2c6716def0fe420da6e707954643
parent 108710 28a71ebcf6c56255a62e18926af1eea4c5a13762
child 108712 e4815c23236d76d1294d1529201341539f8cd507
push id2248
push userakeybl@mozilla.com
push dateMon, 08 Oct 2012 19:23:44 +0000
treeherdermozilla-aurora@118a3b748323 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs678106
milestone8.0a1
Bug 678106: implement local increment/decrement, r=dvander
js/src/ion/IonBuilder.cpp
js/src/ion/IonBuilder.h
--- a/js/src/ion/IonBuilder.cpp
+++ b/js/src/ion/IonBuilder.cpp
@@ -371,16 +371,22 @@ IonBuilder::inspectOpcode(JSOp op)
       case JSOP_BITAND:
       case JSOP_BITOR:
       case JSOP_BITXOR:
         return jsop_bitop(op);
 
       case JSOP_ADD:
       	return jsop_binary(op);
 
+      case JSOP_LOCALINC:
+      case JSOP_INCLOCAL:
+      case JSOP_LOCALDEC:
+      case JSOP_DECLOCAL:
+        return jsop_localinc(op);
+
       case JSOP_DOUBLE:
         return pushConstant(script->getConst(readIndex(pc)));
 
       case JSOP_STRING:
         return pushConstant(StringValue(atoms[GET_INDEX(pc)]));
 
       case JSOP_ZERO:
         return pushConstant(Int32Value(0));
@@ -1530,16 +1536,42 @@ IonBuilder::jsop_binary(JSOp op)
 
     current->add(ins);
     ins->infer(oracle->binaryOp(script, pc));
 
     current->push(ins);
     return true;
 }
 
+bool
+IonBuilder::jsop_localinc(JSOp op)
+{
+    int32 amt = (js_CodeSpec[op].format & JOF_INC) ? 1 : -1;
+    bool post_incr = !!(js_CodeSpec[op].format & JOF_POST);
+
+    if (post_incr)
+        current->pushLocal(GET_SLOTNO(pc));
+    
+    current->pushLocal(GET_SLOTNO(pc));
+
+    if (!pushConstant(Int32Value(amt)))
+        return false;
+
+    if (!jsop_binary(JSOP_ADD))
+        return false;
+
+    if (current->setLocal(GET_SLOTNO(pc)))
+        return false;
+
+    if (post_incr)
+        current->pop();
+
+    return true;
+}
+
 MBasicBlock *
 IonBuilder::newBlock(MBasicBlock *predecessor, jsbytecode *pc)
 {
     MBasicBlock *block = MBasicBlock::New(this, predecessor, pc, MBasicBlock::NORMAL);
     graph().addBlock(block);
     return block;
 }
 
--- a/js/src/ion/IonBuilder.h
+++ b/js/src/ion/IonBuilder.h
@@ -229,16 +229,17 @@ class IonBuilder : public MIRGenerator
     bool snapshotAt(MInstruction *ins, jsbytecode *pc);
     bool snapshotAfter(MInstruction *ins);
 
     bool pushConstant(const Value &v);
     bool jsop_bitnot(JSOp op);
     bool jsop_bitop(JSOp op);
     bool jsop_binary(JSOp op);
     bool jsop_ifeq(JSOp op);
+    bool jsop_localinc(JSOp op);
 
   private:
     JSAtom **atoms;
     MBasicBlock *current;
     Vector<CFGState, 8, IonAllocPolicy> cfgStack_;
     Vector<ControlFlowInfo, 4, IonAllocPolicy> loops_;
     Vector<ControlFlowInfo, 0, IonAllocPolicy> switches_;
     TypeOracle *oracle;