OSSP CVS Repository

ossp - Difference in ossp-pkg/js/src/jsinterp.c versions 1.3 and 1.4
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/js/src/jsinterp.c 1.3 -> 1.4

--- jsinterp.c   2006/07/22 20:31:56     1.3
+++ jsinterp.c   2006/07/24 18:38:27     1.4
@@ -1,5 +1,5 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sw=4 et tw=78:
+ * vim: set ts=8 sw=4 et tw=80:
  *
  * ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
@@ -460,6 +460,8 @@
 JSBool
 js_ComputeThis(JSContext *cx, JSObject *thisp, JSStackFrame *fp)
 {
+    JSObject *parent;
+
     if (thisp && OBJ_GET_CLASS(cx, thisp) != &js_CallClass) {
         /* Some objects (e.g., With) delegate 'this' to another object. */
         thisp = OBJ_THIS_OBJECT(cx, thisp);
@@ -488,26 +490,13 @@
          */
         JS_ASSERT(!(fp->flags & JSFRAME_CONSTRUCTING));
         if (JSVAL_IS_PRIMITIVE(fp->argv[-2]) ||
-            !OBJ_GET_PARENT(cx, JSVAL_TO_OBJECT(fp->argv[-2]))) {
+            !(parent = OBJ_GET_PARENT(cx, JSVAL_TO_OBJECT(fp->argv[-2])))) {
             thisp = cx->globalObject;
         } else {
-            jsid id;
-            jsval v;
-            uintN attrs;
-
-            /* Walk up the parent chain. */
-            thisp = JSVAL_TO_OBJECT(fp->argv[-2]);
-            id = ATOM_TO_JSID(cx->runtime->atomState.parentAtom);
-            for (;;) {
-                if (!OBJ_CHECK_ACCESS(cx, thisp, id, JSACC_PARENT, &v, &attrs))
-                    return JS_FALSE;
-                if (JSVAL_IS_VOID(v))
-                    v = OBJ_GET_SLOT(cx, thisp, JSSLOT_PARENT);
-                JS_ASSERT(JSVAL_TO_OBJECT(v) == OBJ_GET_PARENT(cx, thisp));
-                if (JSVAL_IS_NULL(v))
-                    break;
-                thisp = JSVAL_TO_OBJECT(v);
-            }
+            /* walk up to find the top-level object */
+            thisp = parent;
+            while ((parent = OBJ_GET_PARENT(cx, thisp)) != NULL)
+                thisp = parent;
         }
     }
     fp->thisp = thisp;
@@ -2009,17 +1998,6 @@
                         LOAD_INTERRUPT_HANDLER(rt);
                     }
                 }
-
-#if JS_HAS_CALL_OBJECT
-                /*
-                 * If frame has a call object, sync values and clear the back-
-                 * pointer. This can happen for a lightweight function if it
-                 * calls eval unexpectedly (in a way that is hidden from the
-                 * compiler). See bug 325540.
-                 */
-                if (fp->callobj)
-                    ok &= js_PutCallObject(cx, fp);
-#endif
 #if JS_HAS_ARGS_OBJECT
                 if (fp->argsobj)
                     ok &= js_PutArgsObject(cx, fp);
@@ -2296,23 +2274,12 @@
 
             /* Is this the first iteration ? */
             if (JSVAL_IS_VOID(rval)) {
-                /*
-                 * Yes, create a new JSObject to hold the iterator state.
-                 * Use NULL as the nominal parent in js_NewObject to ensure
-                 * that we use the correct scope chain lookup to try to find the
-                 * PropertyIterator constructor.
-                 */
-                propobj = js_NewObject(cx, &prop_iterator_class, NULL, NULL);
+                /* Yes, create a new JSObject to hold the iterator state */
+                propobj = js_NewObject(cx, &prop_iterator_class, NULL, obj);
                 if (!propobj) {
                     ok = JS_FALSE;
                     goto out;
                 }
-
-                /*
-                 * Now that we've resolved the object, use the PARENT slot to
-                 * store the object that we're iterating over.
-                 */
-                propobj->slots[JSSLOT_PARENT] = OBJECT_TO_JSVAL(obj);
                 propobj->slots[JSSLOT_ITER_STATE] = JSVAL_NULL;
 
                 /*
@@ -3410,12 +3377,17 @@
 #undef FAST_GLOBAL_INCREMENT_OP
 
           do_nonint_fast_global_incop:
+          {
+            const JSCodeSpec *cs = &js_CodeSpec[op];
+
             vp = sp++;
             SAVE_SP(fp);
             NONINT_INCREMENT_OP_MIDDLE();
             OBJ_SET_SLOT(cx, obj, slot, rval);
             STORE_OPND(-1, rtmp);
+            len = cs->length;
             break;
+          }
 
           case JSOP_GETPROP:
             /* Get an immediate atom naming the property. */
@@ -4572,7 +4544,8 @@
              */
             SAVE_SP(fp);
             obj2 = fp->scopeChain;
-            parent = js_NewObject(cx, &js_ObjectClass, NULL, obj2);
+            parent = js_ConstructObject(cx, &js_ObjectClass, NULL, obj2,
+                                        0, NULL);
             if (!parent) {
                 ok = JS_FALSE;
                 goto out;
@@ -4998,24 +4971,12 @@
             JS_ASSERT(JSVAL_IS_OBJECT(lval));
             obj = JSVAL_TO_OBJECT(lval);
 
+            /* Define obj[id] to contain rval and to be permanent. */
             SAVE_SP(fp);
-
-            /*
-             * It's possible for an evil script to substitute a random object
-             * for the new object. Check to make sure that we don't override a
-             * readonly property with the below OBJ_DEFINE_PROPERTY.
-             */
-            ok = OBJ_GET_ATTRIBUTES(cx, obj, id, NULL, &attrs);
+            ok = OBJ_DEFINE_PROPERTY(cx, obj, id, rval, NULL, NULL,
+                                     JSPROP_PERMANENT, NULL);
             if (!ok)
                 goto out;
-            if (!(attrs & (JSPROP_READONLY | JSPROP_PERMANENT |
-                           JSPROP_GETTER | JSPROP_SETTER))) {
-                /* Define obj[id] to contain rval and to be permanent. */
-                ok = OBJ_DEFINE_PROPERTY(cx, obj, id, rval, NULL, NULL,
-                                         JSPROP_PERMANENT, NULL);
-                if (!ok)
-                    goto out;
-            }
 
             /* Now that we're done with rval, pop it. */
             sp--;

CVSTrac 2.0.1