Bug 810375 part 3 - Compile JSOP_DUP. r=djvj
authorJan de Mooij <jdemooij@mozilla.com>
Mon, 12 Nov 2012 13:09:10 +0100
changeset 112740 281c54efd9918d37eb6121f751119141a7165cb5
parent 112739 79b5f9e429d0debf7c7aed5a30e14a0feb898936
child 112741 210ba1717fe0b2aa954776d06634d7957864ab58
push id1351
push userjandemooij@gmail.com
push dateMon, 12 Nov 2012 12:18:00 +0000
reviewersdjvj
bugs810375
milestone19.0a1
Bug 810375 part 3 - Compile JSOP_DUP. r=djvj
js/src/ion/BaselineCompiler.cpp
js/src/ion/BaselineCompiler.h
--- a/js/src/ion/BaselineCompiler.cpp
+++ b/js/src/ion/BaselineCompiler.cpp
@@ -191,16 +191,31 @@ BaselineCompiler::emit_JSOP_NOP()
 bool
 BaselineCompiler::emit_JSOP_POP()
 {
     frame.pop();
     return true;
 }
 
 bool
+BaselineCompiler::emit_JSOP_DUP()
+{
+    // Keep top stack value in R0, sync the rest so that we can use R1. We use
+    // separate registers because every register can be used by at most one
+    // StackValue.
+    frame.popRegsAndSync(1);
+    masm.moveValue(R0, R1);
+
+    // inc/dec ops use DUP followed by ONE, ADD. Push R0 last to avoid a move.
+    frame.push(R1);
+    frame.push(R0);
+    return true;
+}
+
+bool
 BaselineCompiler::emit_JSOP_GOTO()
 {
     frame.syncStack(0);
 
     jsbytecode *target = pc + GET_JUMP_OFFSET(pc);
     masm.jump(labelOf(target));
     return true;
 }
--- a/js/src/ion/BaselineCompiler.h
+++ b/js/src/ion/BaselineCompiler.h
@@ -27,16 +27,17 @@
 #endif
 
 namespace js {
 namespace ion {
 
 #define OPCODE_LIST(_)         \
     _(JSOP_NOP)                \
     _(JSOP_POP)                \
+    _(JSOP_DUP)                \
     _(JSOP_GOTO)               \
     _(JSOP_IFNE)               \
     _(JSOP_POS)                \
     _(JSOP_LOOPHEAD)           \
     _(JSOP_LOOPENTRY)          \
     _(JSOP_ZERO)               \
     _(JSOP_ONE)                \
     _(JSOP_INT8)               \