remove obsolete JSVAL_ERROR_COOKIE and JSVAL_FAIL (563063, r=dvander).
authorAndreas Gal <gal@mozilla.com>
Fri, 30 Apr 2010 15:21:09 -0700
changeset 41858 17d86251925526c126ee06cb6b4e41e361a641b0
parent 41857 13019f88d50f119f708bf2f5b1402cde78fdc8c4
child 41859 be3834aa1cee34a862c5160ab956d5fd1bdbfb4d
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdvander
bugs563063
milestone1.9.3a5pre
remove obsolete JSVAL_ERROR_COOKIE and JSVAL_FAIL (563063, r=dvander).
js/src/jsbuiltins.cpp
js/src/jsbuiltins.h
js/src/jstracer.cpp
--- a/js/src/jsbuiltins.cpp
+++ b/js/src/jsbuiltins.cpp
@@ -97,44 +97,40 @@ js_imod(int32 a, int32 b)
 {
     if (a < 0 || b <= 0)
         return -1;
     int r = a % b;
     return r;
 }
 JS_DEFINE_CALLINFO_2(extern, INT32, js_imod, INT32, INT32, 1, ACC_NONE)
 
-/* The following boxing/unboxing primitives we can't emit inline because
-   they either interact with the GC and depend on Spidermonkey's 32-bit
-   integer representation. */
-
 jsval FASTCALL
 js_BoxDouble(JSContext* cx, jsdouble d)
 {
     int32 i;
     if (JSDOUBLE_IS_INT(d, i) && INT_FITS_IN_JSVAL(i))
         return INT_TO_JSVAL(i);
     JS_ASSERT(JS_ON_TRACE(cx));
     jsval v; /* not rooted but ok here because we know GC won't run */
     if (!js_NewDoubleInRootedValue(cx, d, &v))
-        return JSVAL_ERROR_COOKIE;
+        return JSVAL_NULL;
     return v;
 }
 JS_DEFINE_CALLINFO_2(extern, JSVAL, js_BoxDouble, CONTEXT, DOUBLE, 1, ACC_NONE)
 
 jsval FASTCALL
 js_BoxInt32(JSContext* cx, int32 i)
 {
     if (JS_LIKELY(INT_FITS_IN_JSVAL(i)))
         return INT_TO_JSVAL(i);
     JS_ASSERT(JS_ON_TRACE(cx));
     jsval v; /* not rooted but ok here because we know GC won't run */
     jsdouble d = (jsdouble)i;
     if (!js_NewDoubleInRootedValue(cx, d, &v))
-        return JSVAL_ERROR_COOKIE;
+        return JSVAL_NULL;
     return v;
 }
 JS_DEFINE_CALLINFO_2(extern, JSVAL, js_BoxInt32, CONTEXT, INT32, 1, ACC_NONE)
 
 jsdouble FASTCALL
 js_UnboxDouble(jsval v)
 {
     if (JS_LIKELY(JSVAL_IS_INT(v)))
--- a/js/src/jsbuiltins.h
+++ b/js/src/jsbuiltins.h
@@ -43,17 +43,17 @@
 #ifdef JS_TRACER
 
 #include "nanojit/nanojit.h"
 
 #ifdef THIS
 #undef THIS
 #endif
 
-enum JSTNErrType { INFALLIBLE, FAIL_STATUS, FAIL_NULL, FAIL_NEG, FAIL_VOID, FAIL_COOKIE };
+enum JSTNErrType { INFALLIBLE, FAIL_STATUS, FAIL_NULL, FAIL_NEG, FAIL_VOID };
 enum { JSTN_ERRTYPE_MASK = 0x07, JSTN_UNBOX_AFTER = 0x08, JSTN_MORE = 0x10,
        JSTN_CONSTRUCTOR = 0x20 };
 
 #define JSTN_ERRTYPE(jstn)  ((jstn)->flags & JSTN_ERRTYPE_MASK)
 
 /*
  * Type describing a type specialization of a JSFastNative.
  *
@@ -96,24 +96,16 @@ struct JSSpecializedNative {
  * 'specializations' points to a static array of available specializations
  * terminated by the lack of having the JSTN_MORE flag set.
  */
 struct JSNativeTraceInfo {
     JSFastNative            native;
     JSSpecializedNative     *specializations;
 };
 
-/*
- * We use a magic boxed pointer value to represent error conditions that
- * trigger a side exit. The address is so low that it should never be actually
- * in use. If it is, a performance regression occurs, not an actual runtime
- * error.
- */
-#define JSVAL_ERROR_COOKIE OBJECT_TO_JSVAL((JSObject*)0x10)
-
 /* Macros used by JS_DEFINE_CALLINFOn. */
 #ifdef DEBUG
 #define _JS_CI_NAME(op) ,#op
 #else
 #define _JS_CI_NAME(op)
 #endif
 
 #define _JS_I32_ARGTYPE    nanojit::ARGTYPE_I
@@ -155,17 +147,16 @@ struct ClosureVarInfo;
  *
  *     _RETRY builtins indicate failure with a special return value that
  *     depends on the return type:
  *
  *         BOOL_RETRY: JSVAL_TO_BOOLEAN(JSVAL_VOID)
  *         INT32_RETRY: any negative value
  *         STRING_RETRY: NULL
  *         OBJECT_RETRY_NULL: NULL
- *         JSVAL_RETRY: JSVAL_ERROR_COOKIE
  *
  *     _RETRY function calls are faster than _FAIL calls.  Each _RETRY call
  *     saves two writes to cx->bailExit and a read from state->builtinStatus.
  *
  *   - All other traceable natives are infallible (e.g. Date.now, Math.log).
  *
  * Special builtins known to the tracer can have their own idiosyncratic
  * error codes.
@@ -189,17 +180,16 @@ struct ClosureVarInfo;
 #define _JS_CTYPE_THIS_DOUBLE       _JS_CTYPE(jsdouble,               _JS_F64,"D", "", INFALLIBLE)
 #define _JS_CTYPE_THIS_STRING       _JS_CTYPE(JSString *,             _JS_PTR,"S", "", INFALLIBLE)
 #define _JS_CTYPE_CALLEE            _JS_CTYPE(JSObject *,             _JS_PTR,"f","",  INFALLIBLE)
 #define _JS_CTYPE_CALLEE_PROTOTYPE  _JS_CTYPE(JSObject *,             _JS_PTR,"p","",  INFALLIBLE)
 #define _JS_CTYPE_FUNCTION          _JS_CTYPE(JSFunction *,           _JS_PTR, --, --, INFALLIBLE)
 #define _JS_CTYPE_PC                _JS_CTYPE(jsbytecode *,           _JS_PTR,"P", "", INFALLIBLE)
 #define _JS_CTYPE_JSVALPTR          _JS_CTYPE(jsval *,                _JS_PTR,"P", "", INFALLIBLE)
 #define _JS_CTYPE_JSVAL             _JS_JSVAL_CTYPE(                  _JS_PTR, "","v", INFALLIBLE)
-#define _JS_CTYPE_JSVAL_RETRY       _JS_JSVAL_CTYPE(                  _JS_PTR, --, --, FAIL_COOKIE)
 #define _JS_CTYPE_JSVAL_FAIL        _JS_JSVAL_CTYPE(                  _JS_PTR, --, --, FAIL_STATUS)
 #define _JS_CTYPE_JSID              _JS_CTYPE(jsid,                   _JS_PTR, --, --, INFALLIBLE)
 #define _JS_CTYPE_BOOL              _JS_CTYPE(JSBool,                 _JS_I32, "","i", INFALLIBLE)
 #define _JS_CTYPE_BOOL_RETRY        _JS_CTYPE(JSBool,                 _JS_I32, --, --, FAIL_VOID)
 #define _JS_CTYPE_BOOL_FAIL         _JS_CTYPE(JSBool,                 _JS_I32, --, --, FAIL_STATUS)
 #define _JS_CTYPE_INT32             _JS_CTYPE(int32,                  _JS_I32, "","i", INFALLIBLE)
 #define _JS_CTYPE_INT32_RETRY       _JS_CTYPE(int32,                  _JS_I32, --, --, FAIL_NEG)
 #define _JS_CTYPE_INT32_FAIL        _JS_CTYPE(int32,                  _JS_I32, --, --, FAIL_STATUS)
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -2741,17 +2741,16 @@ bool
 NativeToValue(JSContext* cx, jsval& v, TraceType type, double* slot)
 {
     JSBool ok;
     jsint i;
     jsdouble d;
     switch (type) {
       case TT_OBJECT:
         v = OBJECT_TO_JSVAL(*(JSObject**)slot);
-        JS_ASSERT(v != JSVAL_ERROR_COOKIE); /* don't leak JSVAL_ERROR_COOKIE */
         debug_only_printf(LC_TMTracer,
                           "object<%p:%s> ", (void*)JSVAL_TO_OBJECT(v),
                           JSVAL_IS_NULL(v)
                           ? "null"
                           : JSVAL_TO_OBJECT(v)->getClass()->name);
         break;
 
       case TT_INT32:
@@ -2774,17 +2773,16 @@ NativeToValue(JSContext* cx, jsval& v, T
         if (!ok) {
             js_ReportOutOfMemory(cx);
             return false;
         }
         return true;
 
       case TT_JSVAL:
         v = *(jsval*)slot;
-        JS_ASSERT(v != JSVAL_ERROR_COOKIE); /* don't leak JSVAL_ERROR_COOKIE */
         debug_only_printf(LC_TMTracer, "box<%p> ", (void*)v);
         break;
 
       case TT_STRING:
         v = STRING_TO_JSVAL(*(JSString**)slot);
         debug_only_printf(LC_TMTracer, "string<%p> ", (void*)(*(JSString**)slot));
         break;
 
@@ -9422,18 +9420,17 @@ TraceRecorder::box_jsval(jsval v, LIns* 
         if (fcallinfo(v_ins) == &js_UnboxDouble_ci)
             return fcallarg(v_ins, 0);
         if (isPromoteInt(v_ins)) {
             LIns* args[] = { demote(lir, v_ins), cx_ins };
             return lir->insCall(&js_BoxInt32_ci, args);
         }
         LIns* args[] = { v_ins, cx_ins };
         v_ins = lir->insCall(&js_BoxDouble_ci, args);
-        guard(false, lir->ins2(LIR_peq, v_ins, INS_CONSTWORD(JSVAL_ERROR_COOKIE)),
-              OOM_EXIT);
+        guard(false, lir->insEqP_0(v_ins), OOM_EXIT);
         return v_ins;
     }
     switch (JSVAL_TAG(v)) {
       case JSVAL_SPECIAL:
         return lir->ins2(LIR_pior, lir->ins2ImmI(LIR_pilsh, lir->insUI2P(v_ins), JSVAL_TAGBITS),
                          INS_CONSTWORD(JSVAL_SPECIAL));
       case JSVAL_OBJECT:
         return v_ins;
@@ -10665,19 +10662,16 @@ TraceRecorder::emitNativeCall(JSSpeciali
         break;
       case FAIL_NEG:
         res_ins = lir->ins1(LIR_i2f, res_ins);
         guard(false, lir->ins2(LIR_flt, res_ins, lir->insImmD(0)), OOM_EXIT);
         break;
       case FAIL_VOID:
         guard(false, lir->ins2ImmI(LIR_eq, res_ins, JSVAL_TO_SPECIAL(JSVAL_VOID)), OOM_EXIT);
         break;
-      case FAIL_COOKIE:
-        guard(false, lir->ins2(LIR_peq, res_ins, INS_CONSTWORD(JSVAL_ERROR_COOKIE)), OOM_EXIT);
-        break;
       default:;
     }
 
     set(&stackval(0 - (2 + argc)), res_ins);
 
     /*
      * The return value will be processed by NativeCallComplete since
      * we have to know the actual return value type for calls that return
@@ -15031,17 +15025,17 @@ CallIteratorNext(JSContext *cx, uintN ar
 static jsval FASTCALL
 CallIteratorNext_tn(JSContext* cx, jsbytecode* pc, JSObject* iterobj)
 {
     AutoValueRooter tvr(cx);
     JSBool ok = js_CallIteratorNext(cx, iterobj, tvr.addr());
 
     if (!ok) {
         SetBuiltinError(cx);
-        return JSVAL_ERROR_COOKIE;
+        return JSVAL_NULL; /* error occured, value doesn't matter. */
     }
     return tvr.value();
 }
 
 JS_DEFINE_TRCINFO_1(ObjectToIterator,
     (4, (static, OBJECT_FAIL, ObjectToIterator_tn, CONTEXT, PC, THIS, INT32, 0, ACC_STORE_ANY)))
 JS_DEFINE_TRCINFO_1(CallIteratorNext,
     (3, (static, JSVAL_FAIL,  CallIteratorNext_tn, CONTEXT, PC, THIS,        0, ACC_STORE_ANY)))