Fix POP_STACK to take a macro out param.
authorBrendan Eich <brendan@mozilla.org>
Fri, 23 May 2008 22:18:36 -0700
changeset 17169 9f158c90185bcae0c60c7376b9039095c3202bca
parent 17168 ef81950a59e686a777e38f128901b352befcd381
child 17170 5783ce0bad4f085912b1697ccfed22b61e150798
push idunknown
push userunknown
push dateunknown
milestone1.9.1a1pre
Fix POP_STACK to take a macro out param.
js/src/jsinterp.cpp
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -2211,17 +2211,17 @@ js_DumpOpMeters()
     fclose(fp);
 }
 
 #endif /* JS_OPSMETER */
 
 #else /* !defined js_invoke_c__ */
 
 #define PUSH_STACK(v)    (*regs.sp++ = (v))
-#define POP_STACK()      (*--regs.sp)
+#define POP_STACK(v)     ((v) = *--regs.sp)
 #define STORE_STACK(n,v) (regs.sp[n] = (v))
 #define FETCH_STACK(n,v) ((v) = regs.sp[n])
 #define ADJUST_STACK(n)  (regs.sp += (n))
 
 /*
  * Push the jsdouble d using sp from the lexical environment. Try to convert d
  * to a jsint that fits in a jsval, otherwise GC-alloc space for it and push a
  * reference.
@@ -2806,17 +2806,17 @@ interrupt:
             rtmp = regs.sp[-1];
             regs.sp[-1] = regs.sp[-2];
             regs.sp[-2] = rtmp;
           END_CASE(JSOP_SWAP)
 
           BEGIN_CASE(JSOP_SETRVAL)
           BEGIN_CASE(JSOP_POPV)
             ASSERT_NOT_THROWING(cx);
-            fp->rval = POP_STACK();
+            POP_STACK(fp->rval);
           END_CASE(JSOP_POPV)
 
           BEGIN_CASE(JSOP_ENTERWITH)
             if (!js_EnterWith(cx, -1))
                 goto error;
 
             /*
              * We must ensure that different "with" blocks have different
@@ -2833,17 +2833,17 @@ interrupt:
           BEGIN_CASE(JSOP_LEAVEWITH)
             JS_ASSERT(regs.sp[-1] == OBJECT_TO_JSVAL(fp->scopeChain));
             ADJUST_STACK(-1);
             js_LeaveWith(cx);
           END_CASE(JSOP_LEAVEWITH)
 
           BEGIN_CASE(JSOP_RETURN)
             CHECK_BRANCH(-1);
-            fp->rval = POP_STACK();
+            POP_STACK(fp->rval);
             /* FALL THROUGH */
 
           BEGIN_CASE(JSOP_RETRVAL)    /* fp->rval already set */
           BEGIN_CASE(JSOP_STOP)
             /*
              * When the inlined frame exits with an exception or an error, ok
              * will be false after the inline_return label.
              */
@@ -2928,17 +2928,17 @@ interrupt:
                     len = JSOP_CALL_LENGTH;
                     DO_NEXT_OP(len);
                 }
                 goto error;
             }
             goto exit;
 
           BEGIN_CASE(JSOP_DEFAULT)
-            (void) POP_STACK();
+            ADJUST_STACK(-1);
             /* FALL THROUGH */
           BEGIN_CASE(JSOP_GOTO)
             len = GET_JUMP_OFFSET(regs.pc);
             CHECK_BRANCH(len);
           END_VARLEN_CASE
 
           BEGIN_CASE(JSOP_IFEQ)
             POP_BOOLEAN(cx, rval, cond);
@@ -2972,17 +2972,17 @@ interrupt:
             if (cond == JS_FALSE) {
                 len = GET_JUMP_OFFSET(regs.pc);
                 PUSH_STACK(rval);
                 DO_NEXT_OP(len);
             }
           END_CASE(JSOP_AND)
 
           BEGIN_CASE(JSOP_DEFAULTX)
-            (void) POP_STACK();
+            ADJUST_STACK(-1);
             /* FALL THROUGH */
           BEGIN_CASE(JSOP_GOTOX)
             len = GET_JUMPX_OFFSET(regs.pc);
             CHECK_BRANCH(len);
           END_VARLEN_CASE
 
           BEGIN_CASE(JSOP_IFEQX)
             POP_BOOLEAN(cx, rval, cond);
@@ -3532,28 +3532,28 @@ interrupt:
           END_CASE(JSOP_STRICTEQ)
 
           BEGIN_CASE(JSOP_STRICTNE)
             STRICT_EQUALITY_OP(!=);
           END_CASE(JSOP_STRICTNE)
 
           BEGIN_CASE(JSOP_CASE)
             STRICT_EQUALITY_OP(==);
-            (void) POP_STACK();
+            ADJUST_STACK(-1);
             if (cond) {
                 len = GET_JUMP_OFFSET(regs.pc);
                 CHECK_BRANCH(len);
                 DO_NEXT_OP(len);
             }
             PUSH_STACK(lval);
           END_CASE(JSOP_CASE)
 
           BEGIN_CASE(JSOP_CASEX)
             STRICT_EQUALITY_OP(==);
-            (void) POP_STACK();
+            ADJUST_STACK(-1);
             if (cond) {
                 len = GET_JUMPX_OFFSET(regs.pc);
                 CHECK_BRANCH(len);
                 DO_NEXT_OP(len);
             }
             PUSH_STACK(lval);
           END_CASE(JSOP_CASEX)
 
@@ -5160,17 +5160,17 @@ interrupt:
             pc2 = regs.pc;
             len = GET_JUMP_OFFSET(pc2);
 
             /*
              * ECMAv2+ forbids conversion of discriminant, so we will skip to
              * the default case if the discriminant isn't already an int jsval.
              * (This opcode is emitted only for dense jsint-domain switches.)
              */
-            rval = POP_STACK();
+            POP_STACK(rval);
             if (!JSVAL_IS_INT(rval))
                 DO_NEXT_OP(len);
             i = JSVAL_TO_INT(rval);
 
             pc2 += JUMP_OFFSET_LEN;
             low = GET_JUMP_OFFSET(pc2);
             pc2 += JUMP_OFFSET_LEN;
             high = GET_JUMP_OFFSET(pc2);
@@ -5188,17 +5188,17 @@ interrupt:
             pc2 = regs.pc;
             len = GET_JUMPX_OFFSET(pc2);
 
             /*
              * ECMAv2+ forbids conversion of discriminant, so we will skip to
              * the default case if the discriminant isn't already an int jsval.
              * (This opcode is emitted only for dense jsint-domain switches.)
              */
-            rval = POP_STACK();
+            POP_STACK(rval);
             if (!JSVAL_IS_INT(rval))
                 DO_NEXT_OP(len);
             i = JSVAL_TO_INT(rval);
 
             pc2 += JUMPX_OFFSET_LEN;
             low = GET_JUMP_OFFSET(pc2);
             pc2 += JUMP_OFFSET_LEN;
             high = GET_JUMP_OFFSET(pc2);
@@ -5221,17 +5221,17 @@ interrupt:
 
           do_lookup_switch:
             /*
              * JSOP_LOOKUPSWITCH and JSOP_LOOKUPSWITCHX are never used if
              * any atom index in it would exceed 64K limit.
              */
             JS_ASSERT(atoms == script->atomMap.vector);
             pc2 = regs.pc;
-            lval = POP_STACK();
+            POP_STACK(lval);
 
             if (!JSVAL_IS_NUMBER(lval) &&
                 !JSVAL_IS_STRING(lval) &&
                 !JSVAL_IS_BOOLEAN(lval)) {
                 goto end_lookup_switch;
             }
 
             pc2 += off;
@@ -6140,18 +6140,18 @@ interrupt:
           BEGIN_CASE(JSOP_GOSUBX)
             PUSH_STACK(JSVAL_FALSE);
             i = PTRDIFF(regs.pc, script->main, jsbytecode) + JSOP_GOSUBX_LENGTH;
             len = GET_JUMPX_OFFSET(regs.pc);
             PUSH_STACK(INT_TO_JSVAL(i));
           END_VARLEN_CASE
 
           BEGIN_CASE(JSOP_RETSUB)
-            rval = POP_STACK();
-            lval = POP_STACK();
+            POP_STACK(rval);
+            POP_STACK(lval);
             JS_ASSERT(JSVAL_IS_BOOLEAN(lval));
             if (JSVAL_TO_BOOLEAN(lval)) {
                 /*
                  * Exception was pending during finally, throw it *before* we
                  * adjust pc, because pc indexes into script->trynotes.  This
                  * turns out not to be necessary, but it seems clearer.  And
                  * it points out a FIXME: 350509, due to Igor Bukanov.
                  */
@@ -6168,35 +6168,35 @@ interrupt:
             JS_ASSERT(cx->throwing);
             PUSH_STACK(cx->exception);
             cx->throwing = JS_FALSE;
           END_CASE(JSOP_EXCEPTION)
 
           BEGIN_CASE(JSOP_THROWING)
             JS_ASSERT(!cx->throwing);
             cx->throwing = JS_TRUE;
-            cx->exception = POP_STACK();
+            POP_STACK(cx->exception);
           END_CASE(JSOP_THROWING)
 
           BEGIN_CASE(JSOP_THROW)
             JS_ASSERT(!cx->throwing);
             cx->throwing = JS_TRUE;
-            cx->exception = POP_STACK();
+            POP_STACK(cx->exception);
             /* let the code at error try to catch the exception. */
             goto error;
 
           BEGIN_CASE(JSOP_SETLOCALPOP)
             /*
              * The stack must have a block with at least one local slot below
              * the exception object.
              */
             JS_ASSERT(regs.sp - fp->spbase >= 2);
             slot = GET_UINT16(regs.pc);
             JS_ASSERT(slot + 1 < script->depth);
-            fp->spbase[slot] = POP_STACK();
+            POP_STACK(fp->spbase[slot]);
           END_CASE(JSOP_SETLOCALPOP)
 
           BEGIN_CASE(JSOP_INSTANCEOF)
             FETCH_STACK(-1, rval);
             if (JSVAL_IS_PRIMITIVE(rval) ||
                 !(obj = JSVAL_TO_OBJECT(rval))->map->ops->hasInstance) {
                 js_ReportValueError(cx, JSMSG_BAD_INSTANCEOF_RHS,
                                     -1, rval, NULL);
@@ -6234,17 +6234,17 @@ interrupt:
                 LOAD_INTERRUPT_HANDLER(cx);
             }
           }
           END_CASE(JSOP_DEBUGGER)
 #endif /* JS_HAS_DEBUGGER_KEYWORD */
 
 #if JS_HAS_XML_SUPPORT
           BEGIN_CASE(JSOP_DEFXMLNS)
-            rval = POP_STACK();
+            POP_STACK(rval);
             if (!js_SetDefaultXMLNamespace(cx, rval))
                 goto error;
           END_CASE(JSOP_DEFXMLNS)
 
           BEGIN_CASE(JSOP_ANYNAME)
             if (!js_GetAnyName(cx, &rval))
                 goto error;
             PUSH_STACK(rval);