Make branch instructions traceable using a new primitive guard_boolean_is_true.
authorAndreas Gal <gal@uci.edu>
Mon, 26 May 2008 23:33:23 -0700
changeset 17177 77e835f850beea7167ae6a665607c0991e531fd0
parent 17176 bc4ea1dfdb2db4f84f18cd9e712b541cb0c0f7ac
child 17178 cca08ddd5e978ee3e055b576b522f884a57720e2
push id1452
push usershaver@mozilla.com
push dateFri, 22 Aug 2008 00:08:22 +0000
treeherderautoland@d13bb0868596 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.1a1pre
Make branch instructions traceable using a new primitive guard_boolean_is_true.
js/src/jsinterp.cpp
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -2749,16 +2749,20 @@ static inline void prim_ilsh(jsint& a, j
 static inline void prim_irsh(jsint& a, jsint& b, jsint& r) {
     r = a >> (b & 31);
 }
 
 static inline void prim_ursh(uint32& a, jsint& b, uint32& r) {
     r = a >> (b & 31);
 }
 
+static inline bool guard_boolean_is_true(JSBool& cond) {
+    return cond;
+}
+
 /*
  * The monitor observers backward branches and triggers the trace recorder. This
  * is the only part of the tracing system that is always enabled and thus incurs 
  * a mild runtime overhead even when not tracing.
  */
 static inline void monitor_branch(JSContext* cx, JSFrameRegs& regs, int offset) {
 }
 
@@ -3371,90 +3375,90 @@ js_Interpret(JSContext *cx)
           TRACE_CASE(JSOP_DEFAULT)
             ADJUST_STACK(-1);
             /* FALL THROUGH */
           TRACE_CASE(JSOP_GOTO)
             len = GET_JUMP_OFFSET(regs.pc);
             CHECK_BRANCH(len);
           END_VARLEN_CASE
 
-          BEGIN_CASE(JSOP_IFEQ)
+          TRACE_CASE(JSOP_IFEQ)
             POP_BOOLEAN(cx, rval, cond);
-            if (cond == JS_FALSE) {
+            if (!guard_boolean_is_true(cond)) {
                 len = GET_JUMP_OFFSET(regs.pc);
                 CHECK_BRANCH(len);
                 DO_NEXT_OP(len);
             }
           END_CASE(JSOP_IFEQ)
 
-          BEGIN_CASE(JSOP_IFNE)
+          TRACE_CASE(JSOP_IFNE)
             POP_BOOLEAN(cx, rval, cond);
-            if (cond != JS_FALSE) {
+            if (guard_boolean_is_true(cond)) {
                 len = GET_JUMP_OFFSET(regs.pc);
                 CHECK_BRANCH(len);
                 DO_NEXT_OP(len);
             }
           END_CASE(JSOP_IFNE)
 
-          BEGIN_CASE(JSOP_OR)
+          TRACE_CASE(JSOP_OR)
             POP_BOOLEAN(cx, rval, cond);
-            if (cond == JS_TRUE) {
+            if (guard_boolean_is_true(cond)) {
                 len = GET_JUMP_OFFSET(regs.pc);
                 PUSH_STACK(rval);
                 DO_NEXT_OP(len);
             }
           END_CASE(JSOP_OR)
 
-          BEGIN_CASE(JSOP_AND)
+          TRACE_CASE(JSOP_AND)
             POP_BOOLEAN(cx, rval, cond);
-            if (cond == JS_FALSE) {
+            if (!guard_boolean_is_true(cond)) {
                 len = GET_JUMP_OFFSET(regs.pc);
                 PUSH_STACK(rval);
                 DO_NEXT_OP(len);
             }
           END_CASE(JSOP_AND)
 
-          BEGIN_CASE(JSOP_DEFAULTX)
+          TRACE_CASE(JSOP_DEFAULTX)
             ADJUST_STACK(-1);
             /* FALL THROUGH */
-          BEGIN_CASE(JSOP_GOTOX)
+          TRACE_CASE(JSOP_GOTOX)
             len = GET_JUMPX_OFFSET(regs.pc);
             CHECK_BRANCH(len);
           END_VARLEN_CASE
 
-          BEGIN_CASE(JSOP_IFEQX)
+          TRACE_CASE(JSOP_IFEQX)
             POP_BOOLEAN(cx, rval, cond);
-            if (cond == JS_FALSE) {
+            if (!guard_boolean_is_true(cond)) {
                 len = GET_JUMPX_OFFSET(regs.pc);
                 CHECK_BRANCH(len);
                 DO_NEXT_OP(len);
             }
           END_CASE(JSOP_IFEQX)
 
-          BEGIN_CASE(JSOP_IFNEX)
+          TRACE_CASE(JSOP_IFNEX)
             POP_BOOLEAN(cx, rval, cond);
-            if (cond != JS_FALSE) {
+            if (guard_boolean_is_true(cond)) {
                 len = GET_JUMPX_OFFSET(regs.pc);
                 CHECK_BRANCH(len);
                 DO_NEXT_OP(len);
             }
           END_CASE(JSOP_IFNEX)
 
-          BEGIN_CASE(JSOP_ORX)
+          TRACE_CASE(JSOP_ORX)
             POP_BOOLEAN(cx, rval, cond);
-            if (cond == JS_TRUE) {
+            if (guard_boolean_is_true(cond)) {
                 len = GET_JUMPX_OFFSET(regs.pc);
                 PUSH_STACK(rval);
                 DO_NEXT_OP(len);
             }
           END_CASE(JSOP_ORX)
 
-          BEGIN_CASE(JSOP_ANDX)
+          TRACE_CASE(JSOP_ANDX)
             POP_BOOLEAN(cx, rval, cond);
-            if (cond == JS_FALSE) {
+            if (!guard_boolean_is_true(cond)) {
                 len = GET_JUMPX_OFFSET(regs.pc);
                 PUSH_STACK(rval);
                 DO_NEXT_OP(len);
             }
           END_CASE(JSOP_ANDX)
 
 /*
  * If the index value at sp[n] is not an int that fits in a jsval, it could