[JAEGER] Merge from fatval.
authorDavid Anderson <danderson@mozilla.com>
Tue, 25 May 2010 18:22:09 -0700
changeset 52603 7e41ce873f384141ad1c40ebb1ad1dc18ab9ff73
parent 52599 4711b8dc9dc52deedbefa95cc080876aab6a6161 (current diff)
parent 52602 315c8e2f3d5bbc34a78b4064775ad555e3d5e452 (diff)
child 52604 6d5526c51d107f087836a9ff0715bb711a2a6b23
push idunknown
push userunknown
push dateunknown
milestone1.9.3a5pre
[JAEGER] Merge from fatval.
js/src/jsapi.h
js/src/jsopcode.cpp
js/src/jsops.cpp
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -224,17 +224,17 @@ BOOLEAN_TO_JSVAL(JSBool b)
     l.s.payload.boo = b;
     return l.asBits;
 }
 
 static JS_ALWAYS_INLINE JSBool
 JSVAL_IS_PRIMITIVE(jsval v)
 {
     jsval_layout l = { v };
-    return (l.s.mask32 & JSVAL_MASK32_OBJECT) == JSVAL_MASK32_CLEAR;
+    return (l.s.mask32 & JSVAL_MASK32_OBJECT) <= JSVAL_MASK32_CLEAR;
 }
 
 static JS_ALWAYS_INLINE JSBool
 JSVAL_IS_GCTHING(jsval v)
 {
     jsval_layout l = { v };
     return (l.s.mask32 & JSVAL_MASK32_GCTHING) > JSVAL_MASK32_CLEAR;
 }
--- a/js/src/jsobjinlines.h
+++ b/js/src/jsobjinlines.h
@@ -456,18 +456,19 @@ JSObject::thisObject(JSContext *cx)
 inline bool
 JSObject::thisObject(JSContext *cx, const js::Value &v, js::Value *vp)
 {
     if (JSObjectOp thisOp = v.asObject().map->ops->thisObject) {
         JSObject *pobj = thisOp(cx, &v.asObject());
         if (!pobj)
             return false;
         vp->setObject(*pobj);
+    } else {
+        *vp = v;
     }
-    *vp = v;
     return true;
 }
 
 namespace js {
 
 typedef Vector<PropertyDescriptor, 1> PropertyDescriptorArray;
 
 class AutoDescriptorArray : private AutoGCRooter
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -127,16 +127,26 @@ const char *js_CodeName[] = {
     name,
 #include "jsopcode.tbl"
 #undef OPDEF
 };
 #endif
 
 /************************************************************************/
 
+// Convert an atom to a double, also allowing the possibility that the 
+// atom is a double, which the standard ATOM_TO_JSVAL API does not.
+static jsval
+ExtAtomToJsval(const JSAtom *atom)
+{
+    return ATOM_IS_DOUBLE(atom) 
+         ? DOUBLE_TO_JSVAL(*ATOM_TO_DOUBLE(atom))
+         : ATOM_TO_JSVAL(atom);
+}
+
 static ptrdiff_t
 GetJumpOffset(jsbytecode *pc, jsbytecode *pc2)
 {
     uint32 type;
 
     type = JOF_OPTYPE(*pc);
     if (JOF_TYPE_IS_EXTENDED_JUMP(type))
         return GET_JUMPX_OFFSET(pc2);
@@ -367,17 +377,17 @@ js_Disassemble1(JSContext *cx, JSScript 
         break;
 
       case JOF_ATOM:
       case JOF_OBJECT:
       case JOF_REGEXP:
         index = js_GetIndexFromBytecode(cx, script, pc, 0);
         if (type == JOF_ATOM) {
             JS_GET_SCRIPT_ATOM(script, pc, index, atom);
-            v = ATOM_TO_JSVAL(atom);
+            v = ExtAtomToJsval(atom);
         } else {
             if (type == JOF_OBJECT)
                 obj = script->getObject(index);
             else
                 obj = script->getRegExp(index);
             v = OBJECT_TO_JSVAL(obj);
         }
         bytes = ToDisassemblySource(cx, v);
@@ -444,17 +454,17 @@ js_Disassemble1(JSContext *cx, JSScript 
         pc2 += UINT16_LEN;
         fprintf(fp, " offset %d npairs %u", (intN) off, (uintN) npairs);
         while (npairs) {
             JS_GET_SCRIPT_ATOM(script, pc, GET_INDEX(pc2), atom);
             pc2 += INDEX_LEN;
             off = GetJumpOffset(pc, pc2);
             pc2 += jmplen;
 
-            bytes = ToDisassemblySource(cx, ATOM_TO_JSVAL(atom));
+            bytes = ToDisassemblySource(cx, ExtAtomToJsval(atom));
             if (!bytes)
                 return 0;
             fprintf(fp, "\n\t%s: %d", bytes, (intN) off);
             npairs--;
         }
         len = 1 + pc2 - pc;
         break;
       }
@@ -468,17 +478,17 @@ js_Disassemble1(JSContext *cx, JSScript 
         break;
 
       case JOF_SLOTATOM:
       case JOF_SLOTOBJECT:
         fprintf(fp, " %u", GET_SLOTNO(pc));
         index = js_GetIndexFromBytecode(cx, script, pc, SLOTNO_LEN);
         if (type == JOF_SLOTATOM) {
             JS_GET_SCRIPT_ATOM(script, pc, index, atom);
-            v = ATOM_TO_JSVAL(atom);
+            v = ExtAtomToJsval(atom);
         } else {
             obj = script->getObject(index);
             v = OBJECT_TO_JSVAL(obj);
         }
         bytes = ToDisassemblySource(cx, v);
         if (!bytes)
             return 0;
         fprintf(fp, " %s", bytes);
@@ -4336,19 +4346,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                         GET_SOURCE_NOTE_ATOM(sn, table[k].label);
                     } else {
                         table[k].label = NULL;
                     }
                     JS_GET_SCRIPT_ATOM(jp->script, pc, GET_INDEX(pc2), atom);
                     pc2 += INDEX_LEN;
                     off2 = GetJumpOffset(pc, pc2);
                     pc2 += jmplen;
-                    table[k].key = ATOM_IS_DOUBLE(atom) 
-                                 ? DOUBLE_TO_JSVAL(*ATOM_TO_DOUBLE(atom))
-                                 : ATOM_TO_JSVAL(atom);
+                    table[k].key = ExtAtomToJsval(atom);
                     table[k].offset = off2;
                 }
 
                 ok = DecompileSwitch(ss, table, (uintN)npairs, pc, len, off,
                                      JS_FALSE);
                 cx->free(table);
                 if (!ok)
                     return NULL;
--- a/js/src/jsops.cpp
+++ b/js/src/jsops.cpp
@@ -3955,17 +3955,17 @@ END_VARLEN_CASE
 
 {
 BEGIN_CASE(JSOP_RETSUB)
     /* Pop [exception or hole, retsub pc-index]. */
     Value rval, lval;
     POP_COPY_TO(rval);
     POP_COPY_TO(lval);
     JS_ASSERT(lval.isBoolean());
-    if (lval.isBoolean()) {
+    if (lval.asBoolean()) {
         /*
          * 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.
          */
         cx->throwing = JS_TRUE;
         cx->exception = rval;