bug 627016 - remove JSProperty out param from DefineNativeProperty. r=jorendorff
authorIgor Bukanov <igor@mir2.org>
Fri, 21 Jan 2011 14:10:16 +0100
changeset 69497 787c58add0d204006391d61890b86253b58aad55
parent 69496 5ff15fe83e16733ae14b70f2fb676c5628de4ee6
child 69498 d406a64628e3f6b5f21aca1c3739c87f1478fe7c
push idunknown
push userunknown
push dateunknown
reviewersjorendorff
bugs627016
milestone6.0a1
bug 627016 - remove JSProperty out param from DefineNativeProperty. r=jorendorff
js/src/jsapi.cpp
js/src/jsarray.cpp
js/src/jsbuiltins.cpp
js/src/jsdbgapi.cpp
js/src/jsemit.cpp
js/src/jsexn.cpp
js/src/jsfun.cpp
js/src/jsinterp.cpp
js/src/jsobj.cpp
js/src/jsobj.h
js/src/json.cpp
js/src/jsonparser.cpp
js/src/jsparse.cpp
js/src/jspropertycache.cpp
js/src/jspropertycache.h
js/src/jsstr.cpp
js/src/jstracer.cpp
js/src/jstypedarray.cpp
js/src/methodjit/FastOps.cpp
js/src/methodjit/MethodJIT.cpp
js/src/methodjit/StubCalls.cpp
js/src/shell/js.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3252,17 +3252,17 @@ JS_LookupPropertyWithFlagsById(JSContext
                                JSObject **objp, jsval *vp)
 {
     JSBool ok;
     JSProperty *prop;
 
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, obj, id);
     ok = obj->isNative()
-         ? js_LookupPropertyWithFlags(cx, obj, id, flags, objp, &prop) >= 0
+         ? LookupPropertyWithFlags(cx, obj, id, flags, objp, &prop)
          : obj->lookupProperty(cx, id, objp, &prop);
     return ok && LookupResult(cx, obj, *objp, id, prop, Valueify(vp));
 }
 
 JS_PUBLIC_API(JSBool)
 JS_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, const char *name, uintN flags, jsval *vp)
 {
     JSObject *obj2;
@@ -3355,18 +3355,18 @@ DefinePropertyById(JSContext *cx, JSObje
                             ? JS_FUNC_TO_DATA_PTR(JSObject *, getter)
                             : NULL,
                             (attrs & JSPROP_SETTER)
                             ? JS_FUNC_TO_DATA_PTR(JSObject *, setter)
                             : NULL);
 
     JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_DECLARING);
     if (flags != 0 && obj->isNative()) {
-        return !!js_DefineNativeProperty(cx, obj, id, value, getter, setter,
-                                         attrs, flags, tinyid, NULL);
+        return !!DefineNativeProperty(cx, obj, id, value, getter, setter,
+                                      attrs, flags, tinyid);
     }
     return obj->defineProperty(cx, id, value, getter, setter, attrs);
 }
 
 JS_PUBLIC_API(JSBool)
 JS_DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value,
                       JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs)
 {
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -795,18 +795,17 @@ array_getProperty(JSContext *cx, JSObjec
 
         JSObject *proto = obj->getProto();
         if (!proto) {
             vp->setUndefined();
             return JS_TRUE;
         }
 
         vp->setUndefined();
-        if (js_LookupPropertyWithFlags(cx, proto, id, cx->resolveFlags,
-                                       &obj2, &prop) < 0)
+        if (!LookupPropertyWithFlags(cx, proto, id, cx->resolveFlags, &obj2, &prop))
             return JS_FALSE;
 
         if (prop && obj2->isNative()) {
             shape = (const Shape *) prop;
             if (!js_NativeGet(cx, obj, obj2, shape, JSGET_METHOD_BARRIER, vp))
                 return JS_FALSE;
         }
         return JS_TRUE;
--- a/js/src/jsbuiltins.cpp
+++ b/js/src/jsbuiltins.cpp
@@ -247,17 +247,17 @@ HasProperty(JSContext* cx, JSObject* obj
             return JS_NEITHER;
         Class* clasp = pobj->getClass();
         if (clasp->resolve != JS_ResolveStub && clasp != &js_StringClass)
             return JS_NEITHER;
     }
 
     JSObject* obj2;
     JSProperty* prop;
-    if (js_LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop) < 0)
+    if (!LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop))
         return JS_NEITHER;
     return prop != NULL;
 }
 
 JSBool FASTCALL
 js_HasNamedProperty(JSContext* cx, JSObject* obj, JSString* idstr)
 {
     JSAtom *atom = js_AtomizeString(cx, idstr, 0);
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -1094,21 +1094,20 @@ JS_SetWatchPoint(JSContext *cx, JSObject
         return false;
     const Shape *shape = (Shape *) prop;
     JSRuntime *rt = cx->runtime;
     if (!shape) {
         /* Check for a deleted symbol watchpoint, which holds its property. */
         JSWatchPoint *wp = FindWatchPoint(rt, obj, propid);
         if (!wp) {
             /* Make a new property in obj so we can watch for the first set. */
-            if (!js_DefineNativeProperty(cx, obj, propid, UndefinedValue(), NULL, NULL,
-                                         JSPROP_ENUMERATE, 0, 0, &prop)) {
+            shape = DefineNativeProperty(cx, obj, propid, UndefinedValue(), NULL, NULL,
+                                         JSPROP_ENUMERATE, 0, 0);
+            if (!shape)
                 return false;
-            }
-            shape = (Shape *) prop;
         }
     } else if (pobj != obj) {
         /* Clone the prototype property so we can watch the right object. */
         AutoValueRooter valroot(cx);
         PropertyOp getter;
         StrictPropertyOp setter;
         uintN attrs, flags;
         intN shortid;
@@ -1136,22 +1135,20 @@ JS_SetWatchPoint(JSContext *cx, JSObject
             }
             getter = NULL;
             setter = NULL;
             flags = 0;
             shortid = 0;
         }
 
         /* Recall that obj is native, whether or not pobj is native. */
-        if (!js_DefineNativeProperty(cx, obj, propid, valroot.value(),
-                                     getter, setter, attrs, flags,
-                                     shortid, &prop)) {
+        shape = DefineNativeProperty(cx, obj, propid, valroot.value(), getter, setter,
+                                     attrs, flags, shortid);
+        if (!shape)
             return false;
-        }
-        shape = (Shape *) prop;
     }
 
     /*
      * At this point, prop/shape exists in obj, obj is locked, and we must
      * unlock the object before returning.
      */
     DBG_LOCK(rt);
     JSWatchPoint *wp = LockedFindWatchPoint(rt, obj, propid);
--- a/js/src/jsemit.cpp
+++ b/js/src/jsemit.cpp
@@ -4482,20 +4482,20 @@ JSParseNode::getConstantValue(JSContext 
                 else if (!js_InternNonIntElementId(cx, obj, idvalue, &id))
                     return false;
                 if (!obj->defineProperty(cx, id, value, NULL, NULL, JSPROP_ENUMERATE))
                     return false;
             } else {
                 JS_ASSERT(pnid->pn_type == TOK_NAME ||
                           pnid->pn_type == TOK_STRING);
                 jsid id = ATOM_TO_JSID(pnid->pn_atom);
-                if (!((pnid->pn_atom == cx->runtime->atomState.protoAtom)
-                      ? js_SetPropertyHelper(cx, obj, id, 0, &value, strictChecks)
-                      : js_DefineNativeProperty(cx, obj, id, value, NULL, NULL,
-                                                JSPROP_ENUMERATE, 0, 0, NULL, 0))) {
+                if ((pnid->pn_atom == cx->runtime->atomState.protoAtom)
+                    ? !js_SetPropertyHelper(cx, obj, id, 0, &value, strictChecks)
+                    : !DefineNativeProperty(cx, obj, id, value, NULL, NULL,
+                                            JSPROP_ENUMERATE, 0, 0)) {
                     return false;
                 }
             }
         }
 
         vp->setObject(*obj);
         return true;
       }
@@ -6983,20 +6983,20 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
                         obj = NULL;
                     op = JSOP_INITPROP;
                     if (lambda)
                         ++slowMethodInits;
                 }
 
                 if (obj) {
                     JS_ASSERT(!obj->inDictionaryMode());
-                    if (!js_DefineNativeProperty(cx, obj, ATOM_TO_JSID(pn3->pn_atom),
-                                                 UndefinedValue(), NULL, NULL,
-                                                 JSPROP_ENUMERATE, 0, 0, NULL)) {
-                        return JS_FALSE;
+                    if (!DefineNativeProperty(cx, obj, ATOM_TO_JSID(pn3->pn_atom),
+                                              UndefinedValue(), NULL, NULL,
+                                              JSPROP_ENUMERATE, 0, 0)) {
+                        return false;
                     }
                     if (obj->inDictionaryMode())
                         obj = NULL;
                 }
 
                 EMIT_INDEX_OP(op, ALE_INDEX(ale));
             }
         }
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -1038,28 +1038,24 @@ js_InitExceptionClasses(JSContext *cx, J
             return NULL;
         JS_ASSERT(proto->privateData == NULL);
 
         if (i == JSEXN_ERR)
             error_proto = proto;
 
         /* Add properties to the prototype. */
         JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_DECLARING);
-        if (!js_DefineNativeProperty(cx, proto, nameId, StringValue(atom),
-                                     PropertyStub, StrictPropertyStub,
-                                     0, 0, 0, NULL) ||
-            !js_DefineNativeProperty(cx, proto, messageId, empty,
-                                     PropertyStub, StrictPropertyStub,
-                                     0, 0, 0, NULL) ||
-            !js_DefineNativeProperty(cx, proto, fileNameId, empty,
-                                     PropertyStub, StrictPropertyStub,
-                                     JSPROP_ENUMERATE, 0, 0, NULL) ||
-            !js_DefineNativeProperty(cx, proto, lineNumberId, Valueify(JSVAL_ZERO),
-                                     PropertyStub, StrictPropertyStub,
-                                     JSPROP_ENUMERATE, 0, 0, NULL)) {
+        if (!DefineNativeProperty(cx, proto, nameId, StringValue(atom),
+                                  PropertyStub, StrictPropertyStub, 0, 0, 0) ||
+            !DefineNativeProperty(cx, proto, messageId, empty,
+                                  PropertyStub, StrictPropertyStub, 0, 0, 0) ||
+            !DefineNativeProperty(cx, proto, fileNameId, empty,
+                                  PropertyStub, StrictPropertyStub, JSPROP_ENUMERATE, 0, 0) ||
+            !DefineNativeProperty(cx, proto, lineNumberId, Valueify(JSVAL_ZERO),
+                                  PropertyStub, StrictPropertyStub, JSPROP_ENUMERATE, 0, 0)) {
             return NULL;
         }
     }
 
     return error_proto;
 }
 
 const JSErrorFormatString*
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -1031,21 +1031,19 @@ CreateFunCallObject(JSContext *cx, Stack
      * For a named function expression Call's parent points to an environment
      * object holding function's name.
      */
     if (JSAtom *lambdaName = (fp->fun()->flags & JSFUN_LAMBDA) ? fp->fun()->atom : NULL) {
         scopeChain = NewDeclEnvObject(cx, fp);
         if (!scopeChain)
             return NULL;
 
-        if (!js_DefineNativeProperty(cx, scopeChain, ATOM_TO_JSID(lambdaName),
-                                     ObjectValue(fp->callee()),
-                                     CalleeGetter, NULL,
-                                     JSPROP_PERMANENT | JSPROP_READONLY,
-                                     0, 0, NULL)) {
+        if (!DefineNativeProperty(cx, scopeChain, ATOM_TO_JSID(lambdaName),
+                                  ObjectValue(fp->callee()), CalleeGetter, NULL,
+                                  JSPROP_PERMANENT | JSPROP_READONLY, 0, 0)) {
             return NULL;
         }
     }
 
     JSObject *callobj = NewCallObject(cx, fp->script(), *scopeChain, &fp->callee());
     if (!callobj)
         return NULL;
 
@@ -1363,20 +1361,20 @@ call_resolve(JSContext *cx, JSObject *ob
      * Resolve arguments so that we never store a particular Call object's
      * arguments object reference in a Call prototype's |arguments| slot.
      *
      * Include JSPROP_ENUMERATE for consistency with all other Call object
      * properties; see js::Bindings::add and js::Interpret's JSOP_DEFFUN
      * rebinding-Call-property logic.
      */
     if (callee && id == ATOM_TO_JSID(cx->runtime->atomState.argumentsAtom)) {
-        if (!js_DefineNativeProperty(cx, obj, id, UndefinedValue(),
-                                     GetCallArguments, SetCallArguments,
-                                     JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_ENUMERATE,
-                                     0, 0, NULL, JSDNP_DONT_PURGE)) {
+        if (!DefineNativeProperty(cx, obj, id, UndefinedValue(),
+                                  GetCallArguments, SetCallArguments,
+                                  JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_ENUMERATE,
+                                  0, 0, DNP_DONT_PURGE)) {
             return false;
         }
         *objp = obj;
         return true;
     }
 
     /* Control flow reaches here only if id was not resolved. */
     return true;
@@ -1785,35 +1783,33 @@ fun_resolve(JSContext *cx, JSObject *obj
         if (!ResolveInterpretedFunctionPrototype(cx, obj))
             return false;
         *objp = obj;
         return true;
     }
 
     if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
         JS_ASSERT(!IsInternalFunctionObject(obj));
-        if (!js_DefineNativeProperty(cx, obj, id, Int32Value(fun->nargs),
-                                     PropertyStub, StrictPropertyStub,
-                                     JSPROP_PERMANENT | JSPROP_READONLY, 0, 0, NULL)) {
+        if (!DefineNativeProperty(cx, obj, id, Int32Value(fun->nargs),
+                                  PropertyStub, StrictPropertyStub,
+                                  JSPROP_PERMANENT | JSPROP_READONLY, 0, 0)) {
             return false;
         }
         *objp = obj;
         return true;
     }
 
     for (uintN i = 0; i < JS_ARRAY_LENGTH(lazyFunctionDataProps); i++) {
         const LazyFunctionDataProp *lfp = &lazyFunctionDataProps[i];
 
         if (JSID_IS_ATOM(id, OFFSET_TO_ATOM(cx->runtime, lfp->atomOffset))) {
             JS_ASSERT(!IsInternalFunctionObject(obj));
-
-            if (!js_DefineNativeProperty(cx, obj, id, UndefinedValue(),
-                                         fun_getProperty, StrictPropertyStub,
-                                         lfp->attrs, Shape::HAS_SHORTID,
-                                         lfp->tinyid, NULL)) {
+            if (!DefineNativeProperty(cx, obj, id, UndefinedValue(),
+                                      fun_getProperty, StrictPropertyStub,
+                                      lfp->attrs, Shape::HAS_SHORTID, lfp->tinyid)) {
                 return false;
             }
             *objp = obj;
             return true;
         }
     }
 
     for (uintN i = 0; i < JS_ARRAY_LENGTH(poisonPillProps); i++) {
@@ -1831,20 +1827,18 @@ fun_resolve(JSContext *cx, JSObject *obj
                 getter = CastAsPropertyOp(throwTypeError);
                 setter = CastAsStrictPropertyOp(throwTypeError);
                 attrs |= JSPROP_GETTER | JSPROP_SETTER;
             } else {
                 getter = fun_getProperty;
                 setter = StrictPropertyStub;
             }
 
-            if (!js_DefineNativeProperty(cx, obj, id, UndefinedValue(),
-                                         getter, setter,
-                                         attrs, Shape::HAS_SHORTID,
-                                         p.tinyid, NULL)) {
+            if (!DefineNativeProperty(cx, obj, id, UndefinedValue(), getter, setter,
+                                      attrs, Shape::HAS_SHORTID, p.tinyid)) {
                 return false;
             }
             *objp = obj;
             return true;
         }
     }
 
     return true;
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -2133,17 +2133,17 @@ IteratorNext(JSContext *cx, JSObject *it
 namespace js {
 
 JS_REQUIRES_STACK JS_NEVER_INLINE bool
 Interpret(JSContext *cx, StackFrame *entryFrame, uintN inlineCallCount, InterpMode interpMode)
 {
 #ifdef MOZ_TRACEVIS
     TraceVisStateObj tvso(cx, S_INTERP);
 #endif
-    JSAutoResolveFlags rf(cx, JSRESOLVE_INFER);
+    JSAutoResolveFlags rf(cx, RESOLVE_INFER);
 
 # ifdef DEBUG
     /*
      * We call this macro from BEGIN_CASE in threaded interpreters,
      * and before entering the switch in non-threaded interpreters.
      * However, reaching such points doesn't mean we've actually
      * fetched an OP from the instruction stream: some opcodes use
      * 'op=x; DO_OP()' to let another opcode's implementation finish
@@ -4356,21 +4356,21 @@ BEGIN_CASE(JSOP_SETMETHOD)
         } else {
             JS_ASSERT(atom);
         }
 
         jsid id = ATOM_TO_JSID(atom);
         if (entry && JS_LIKELY(!obj->getOps()->setProperty)) {
             uintN defineHow;
             if (op == JSOP_SETMETHOD)
-                defineHow = JSDNP_CACHE_RESULT | JSDNP_SET_METHOD;
+                defineHow = DNP_CACHE_RESULT | DNP_SET_METHOD;
             else if (op == JSOP_SETNAME)
-                defineHow = JSDNP_CACHE_RESULT | JSDNP_UNQUALIFIED;
+                defineHow = DNP_CACHE_RESULT | DNP_UNQUALIFIED;
             else
-                defineHow = JSDNP_CACHE_RESULT;
+                defineHow = DNP_CACHE_RESULT;
             if (!js_SetPropertyHelper(cx, obj, id, defineHow, &rval, script->strictModeCode))
                 goto error;
         } else {
             if (!obj->setProperty(cx, id, &rval, script->strictModeCode))
                 goto error;
             ABORT_RECORDING(cx, "Non-native set");
         }
     } while (0);
@@ -5239,18 +5239,18 @@ BEGIN_CASE(JSOP_DEFVAR)
          * As attrs includes readonly, CheckRedeclaration can succeed only
          * if prop does not exist.
          */
         shouldDefine = true;
     }
 
     /* Bind a variable only if it's not yet defined. */
     if (shouldDefine &&
-        !js_DefineNativeProperty(cx, obj, id, UndefinedValue(),
-                                 PropertyStub, StrictPropertyStub, attrs, 0, 0, NULL)) {
+        !DefineNativeProperty(cx, obj, id, UndefinedValue(), PropertyStub, StrictPropertyStub,
+                              attrs, 0, 0)) {
         goto error;
     }
 }
 END_CASE(JSOP_DEFVAR)
 
 BEGIN_CASE(JSOP_DEFFUN)
 {
     /*
@@ -5845,23 +5845,22 @@ BEGIN_CASE(JSOP_INITMETHOD)
         PCMETER(JS_PROPERTY_CACHE(cx).inipcmisses++);
 
         /* Get the immediate property name into id. */
         JSAtom *atom;
         LOAD_ATOM(0, atom);
         jsid id = ATOM_TO_JSID(atom);
 
         uintN defineHow = (op == JSOP_INITMETHOD)
-                          ? JSDNP_CACHE_RESULT | JSDNP_SET_METHOD
-                          : JSDNP_CACHE_RESULT;
-        if (!(JS_UNLIKELY(atom == cx->runtime->atomState.protoAtom)
-              ? js_SetPropertyHelper(cx, obj, id, defineHow, &rval, script->strictModeCode)
-              : js_DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
-                                        JSPROP_ENUMERATE, 0, 0, NULL,
-                                        defineHow))) {
+                          ? DNP_CACHE_RESULT | DNP_SET_METHOD
+                          : DNP_CACHE_RESULT;
+        if (JS_UNLIKELY(atom == cx->runtime->atomState.protoAtom)
+            ? !js_SetPropertyHelper(cx, obj, id, defineHow, &rval, script->strictModeCode)
+            : !DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
+                                    JSPROP_ENUMERATE, 0, 0, defineHow)) {
             goto error;
         }
     }
 
     /* Common tail for property cache hit and miss cases. */
     regs.sp--;
 }
 END_CASE(JSOP_INITPROP);
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -3114,17 +3114,17 @@ js_InferFlags(JSContext *cx, uintN defau
  * ObjectOps and Class for with-statement stack objects.
  */
 static JSBool
 with_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
                     JSProperty **propp)
 {
     /* Fixes bug 463997 */
     uintN flags = cx->resolveFlags;
-    if (flags == JSRESOLVE_INFER)
+    if (flags == RESOLVE_INFER)
         flags = js_InferFlags(cx, flags);
     flags |= JSRESOLVE_WITH;
     JSAutoResolveFlags rf(cx, flags);
     return obj->getProto()->lookupProperty(cx, id, objp, propp);
 }
 
 static JSBool
 with_GetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
@@ -4258,57 +4258,55 @@ js_FindClassObject(JSContext *cx, JSObje
         do {
             obj = start;
             start = obj->getParent();
         } while (start);
     } else {
         obj = cx->globalObject;
         if (!obj) {
             vp->setUndefined();
-            return JS_TRUE;
+            return true;
         }
     }
 
     OBJ_TO_INNER_OBJECT(cx, obj);
     if (!obj)
-        return JS_FALSE;
+        return false;
 
     if (protoKey != JSProto_Null) {
         JS_ASSERT(JSProto_Null < protoKey);
         JS_ASSERT(protoKey < JSProto_LIMIT);
         if (!js_GetClassObject(cx, obj, protoKey, &cobj))
-            return JS_FALSE;
+            return false;
         if (cobj) {
             vp->setObject(*cobj);
             return JS_TRUE;
         }
         id = ATOM_TO_JSID(cx->runtime->atomState.classAtoms[protoKey]);
     } else {
         JSAtom *atom = js_Atomize(cx, clasp->name, strlen(clasp->name), 0);
         if (!atom)
             return false;
         id = ATOM_TO_JSID(atom);
     }
 
     JS_ASSERT(obj->isNative());
-    if (js_LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_CLASSNAME,
-                                   &pobj, &prop) < 0) {
-        return JS_FALSE;
-    }
+    if (!LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_CLASSNAME, &pobj, &prop))
+        return false;
     Value v = UndefinedValue();
     if (prop && pobj->isNative()) {
         shape = (Shape *) prop;
         if (pobj->containsSlot(shape->slot)) {
             v = pobj->nativeGetSlot(shape->slot);
             if (v.isPrimitive())
                 v.setUndefined();
         }
     }
     *vp = v;
-    return JS_TRUE;
+    return true;
 }
 
 JSObject *
 js_ConstructObject(JSContext *cx, Class *clasp, JSObject *proto, JSObject *parent,
                    uintN argc, Value *argv)
 {
     AutoArrayRooter argtvr(cx, argc, argv);
 
@@ -4613,18 +4611,17 @@ js_ChangeNativePropertyAttrs(JSContext *
 
     return obj->changeProperty(cx, shape, attrs, mask, getter, setter);
 }
 
 JSBool
 js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *value,
                   PropertyOp getter, StrictPropertyOp setter, uintN attrs)
 {
-    return js_DefineNativeProperty(cx, obj, id, *value, getter, setter, attrs,
-                                   0, 0, NULL);
+    return !!DefineNativeProperty(cx, obj, id, *value, getter, setter, attrs, 0, 0);
 }
 
 /*
  * Backward compatibility requires allowing addProperty hooks to mutate the
  * nominal initial value of a slotful property, while GC safety wants that
  * value to be stored before the call-out through the hook.  Optimize to do
  * both while saving cycles for classes that stub their addProperty hook.
  */
@@ -4639,106 +4636,104 @@ CallAddPropertyHook(JSContext *cx, Class
         if (*vp != nominal) {
             if (obj->containsSlot(shape->slot))
                 obj->nativeSetSlot(shape->slot, *vp);
         }
     }
     return true;
 }
 
-JSBool
-js_DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, const Value &value,
-                        PropertyOp getter, StrictPropertyOp setter, uintN attrs,
-                        uintN flags, intN shortid, JSProperty **propp,
-                        uintN defineHow /* = 0 */)
-{
-    JS_ASSERT((defineHow & ~(JSDNP_CACHE_RESULT | JSDNP_DONT_PURGE | JSDNP_SET_METHOD)) == 0);
+namespace js {
+
+const Shape *
+DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, const Value &value,
+                     PropertyOp getter, StrictPropertyOp setter, uintN attrs,
+                     uintN flags, intN shortid, uintN defineHow /* = 0 */)
+{
+    JS_ASSERT((defineHow & ~(DNP_CACHE_RESULT | DNP_DONT_PURGE | DNP_SET_METHOD)) == 0);
     LeaveTraceIfGlobalObject(cx, obj);
 
     /* Convert string indices to integers if appropriate. */
     id = js_CheckForStringIndex(id);
 
     /*
      * If defining a getter or setter, we must check for its counterpart and
      * update the attributes and property ops.  A getter or setter is really
      * only half of a property.
      */
     const Shape *shape = NULL;
     if (attrs & (JSPROP_GETTER | JSPROP_SETTER)) {
         JSObject *pobj;
         JSProperty *prop;
 
         /*
-         * If JS_THREADSAFE and id is found, js_LookupProperty returns with
-         * shape non-null and pobj locked.  If pobj == obj, the property is
-         * already in obj and obj has its own (mutable) scope.  So if we are
-         * defining a getter whose setter was already defined, or vice versa,
-         * finish the job via obj->changeProperty, and refresh the property
-         * cache line for (obj, id) to map shape.
+         * If we are defining a getter whose setter was already defined, or
+         * vice versa, finish the job via obj->changeProperty, and refresh the
+         * property cache line for (obj, id) to map shape.
          */
         if (!js_LookupProperty(cx, obj, id, &pobj, &prop))
-            return JS_FALSE;
-        shape = (Shape *) prop;
-        if (shape && pobj == obj && shape->isAccessorDescriptor()) {
-            shape = obj->changeProperty(cx, shape, attrs,
-                                        JSPROP_GETTER | JSPROP_SETTER,
-                                        (attrs & JSPROP_GETTER)
-                                        ? getter
-                                        : shape->getter(),
-                                        (attrs & JSPROP_SETTER)
-                                        ? setter
-                                        : shape->setter());
-
-            if (!shape)
-                return false;
-        } else if (prop) {
-            prop = NULL;
-            shape = NULL;
+            return NULL;
+        if (prop && pobj == obj) {
+            shape = (const Shape *) prop;
+            if (shape->isAccessorDescriptor()) {
+                shape = obj->changeProperty(cx, shape, attrs,
+                                            JSPROP_GETTER | JSPROP_SETTER,
+                                            (attrs & JSPROP_GETTER)
+                                            ? getter
+                                            : shape->getter(),
+                                            (attrs & JSPROP_SETTER)
+                                            ? setter
+                                            : shape->setter());
+                if (!shape)
+                    return NULL;
+            } else {
+                shape = NULL;
+            }
         }
     }
 
     /*
      * Purge the property cache of any properties named by id that are about
      * to be shadowed in obj's scope chain unless it is known a priori that it
      * is not possible. We do this before locking obj to avoid nesting locks.
      */
-    if (!(defineHow & JSDNP_DONT_PURGE))
+    if (!(defineHow & DNP_DONT_PURGE))
         js_PurgeScopeChain(cx, obj, id);
 
     /*
      * Check whether a readonly property or setter is being defined on a known
      * prototype object. See the comment in jscntxt.h before protoHazardShape's
      * member declaration.
      */
     if (obj->isDelegate() && (attrs & (JSPROP_READONLY | JSPROP_SETTER)))
         cx->runtime->protoHazardShape = js_GenerateShape(cx);
 
     /* Use the object's class getter and setter by default. */
     Class *clasp = obj->getClass();
-    if (!(defineHow & JSDNP_SET_METHOD)) {
+    if (!(defineHow & DNP_SET_METHOD)) {
         if (!getter && !(attrs & JSPROP_GETTER))
             getter = clasp->getProperty;
         if (!setter && !(attrs & JSPROP_SETTER))
             setter = clasp->setProperty;
     }
 
     /* Get obj's own scope if it has one, or create a new one for obj. */
     if (!obj->ensureClassReservedSlots(cx))
-        return false;
+        return NULL;
 
     /*
      * Make a local copy of value, in case a method barrier needs to update the
      * value to define, and just so addProperty can mutate its inout parameter.
      */
     Value valueCopy = value;
     bool adding = false;
 
     if (!shape) {
         /* Add a new property, or replace an existing one of the same id. */
-        if (defineHow & JSDNP_SET_METHOD) {
+        if (defineHow & DNP_SET_METHOD) {
             JS_ASSERT(clasp == &js_ObjectClass);
             JS_ASSERT(IsFunctionObject(value));
             JS_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
             JS_ASSERT(!getter && !setter);
 
             JSObject *funobj = &value.toObject();
             if (FUN_OBJECT(GET_FUNCTION_PRIVATE(cx, funobj)) == funobj) {
                 flags |= Shape::METHOD;
@@ -4762,27 +4757,27 @@ js_DefineNativeProperty(JSContext *cx, J
                  * the joined function object value as the getter object for
                  * the redefined property. The joined function object cannot
                  * yet have leaked, so only an internal code path could attempt
                  * such a thing. Any such path would be a bug to fix.
                  */
                 JS_ASSERT(existingShape->getter() != getter);
 
                 if (!obj->methodReadBarrier(cx, *existingShape, &valueCopy))
-                    return false;
+                    return NULL;
             }
         } else {
             adding = true;
         }
 
         uint32 oldShape = obj->shape();
         shape = obj->putProperty(cx, id, getter, setter, SHAPE_INVALID_SLOT,
                                  attrs, flags, shortid);
         if (!shape)
-            return false;
+            return NULL;
 
         /*
          * If shape is a joined method, the above call to putProperty suffices
          * to update the object's shape id if need be (because the shape's hash
          * identity includes the method value).
          *
          * But if scope->branded(), the object's shape id may not have changed
          * and we may be overwriting a cached function-valued property (note
@@ -4798,38 +4793,36 @@ js_DefineNativeProperty(JSContext *cx, J
 
     /* Store valueCopy before calling addProperty, in case the latter GC's. */
     if (obj->containsSlot(shape->slot))
         obj->nativeSetSlot(shape->slot, valueCopy);
 
     /* XXXbe called with lock held */
     if (!CallAddPropertyHook(cx, clasp, obj, shape, &valueCopy)) {
         obj->removeProperty(cx, id);
-        return false;
-    }
-
-    if (defineHow & JSDNP_CACHE_RESULT) {
+        return NULL;
+    }
+
+    if (defineHow & DNP_CACHE_RESULT) {
         JS_ASSERT_NOT_ON_TRACE(cx);
         if (adding) {
-            JS_PROPERTY_CACHE(cx).fill(cx, obj, 0, 0, obj, shape, true);
+            JS_PROPERTY_CACHE(cx).fill(cx, obj, 0, obj, shape, true);
             TRACE_1(AddProperty, obj);
         }
     }
-    if (propp)
-        *propp = (JSProperty *) shape;
-    return true;
+    return shape;
 
 #ifdef JS_TRACER
-  error: // TRACE_1 jumps here on error.
+  error:
+    /* TRACE_1 jumps here on error. */
+    return NULL;
 #endif
-    return false;
-}
-
-#define SCOPE_DEPTH_ACCUM(bs,val)                                             \
-    JS_SCOPE_DEPTH_METERING(JS_BASIC_STATS_ACCUM(bs, val))
+}
+
+} /* namespace js */
 
 /*
  * Call obj's resolve hook.
  *
  * cx, start, id, and flags are the parameters initially passed to the ongoing
  * lookup; objp and propp are its out parameters. obj is an object along
  * start's prototype chain.
  *
@@ -4868,17 +4861,17 @@ CallResolveOp(JSContext *cx, JSObject *s
         return true;
     }
     *recursedp = false;
 
     *propp = NULL;
 
     if (clasp->flags & JSCLASS_NEW_RESOLVE) {
         JSNewResolveOp newresolve = reinterpret_cast<JSNewResolveOp>(resolve);
-        if (flags == JSRESOLVE_INFER)
+        if (flags == RESOLVE_INFER)
             flags = js_InferFlags(cx, 0);
         JSObject *obj2 = (clasp->flags & JSCLASS_NEW_RESOLVE_GETS_START) ? start : NULL;
         if (!newresolve(cx, obj, id, flags, &obj2))
             return false;
 
         /*
          * We trust the new style resolve hook to set obj2 to NULL when
          * the id cannot be resolved. But, when obj2 is not null, we do
@@ -4904,161 +4897,164 @@ CallResolveOp(JSContext *cx, JSObject *s
             *objp = obj;
             *propp = (JSProperty *) shape;
         }
     }
 
     return true;
 }
 
-static JS_ALWAYS_INLINE int
-js_LookupPropertyWithFlagsInline(JSContext *cx, JSObject *obj, jsid id, uintN flags,
-                                 JSObject **objp, JSProperty **propp)
+#define SCOPE_DEPTH_ACCUM(bs,val) JS_SCOPE_DEPTH_METERING(JS_BASIC_STATS_ACCUM(bs, val))
+
+static JS_ALWAYS_INLINE bool
+LookupPropertyWithFlagsInline(JSContext *cx, JSObject *obj, jsid id, uintN flags,
+                              JSObject **objp, JSProperty **propp)
 {
     /* We should not get string indices which aren't already integers here. */
     JS_ASSERT(id == js_CheckForStringIndex(id));
 
     /* Search scopes starting with obj and following the prototype link. */
     JSObject *start = obj;
-    int protoIndex;
-    for (protoIndex = 0; ; protoIndex++) {
+#ifdef JS_SCOPE_DEPTH_METER
+    int protoIndex = 0;
+#endif
+    for (; ; JS_SCOPE_DEPTH_METERING(protoIndex++)) {
         const Shape *shape = obj->nativeLookup(id);
         if (shape) {
             SCOPE_DEPTH_ACCUM(&cx->runtime->protoLookupDepthStats, protoIndex);
             *objp = obj;
             *propp = (JSProperty *) shape;
-            return protoIndex;
+            return true;
         }
 
         /* Try obj's class resolve hook if id was not found in obj's scope. */
-        if (!shape && obj->getClass()->resolve != JS_ResolveStub) {
+        if (obj->getClass()->resolve != JS_ResolveStub) {
             bool recursed;
             if (!CallResolveOp(cx, start, obj, id, flags, objp, propp, &recursed))
-                return -1;
+                return false;
             if (recursed)
                 break;
             if (*propp) {
-                /* Recalculate protoIndex in case it was resolved on some other object. */
-                protoIndex = 0;
-                for (JSObject *proto = start; proto && proto != *objp; proto = proto->getProto())
-                    protoIndex++;
+                /*
+                 * For stats we do not recalculate protoIndex even if it was
+                 * resolved on some other object.
+                 */
                 SCOPE_DEPTH_ACCUM(&cx->runtime->protoLookupDepthStats, protoIndex);
-                return protoIndex;
+                return true;
             }
         }
 
         JSObject *proto = obj->getProto();
         if (!proto)
             break;
         if (!proto->isNative()) {
             if (!proto->lookupProperty(cx, id, objp, propp))
-                return -1;
+                return false;
 #ifdef DEBUG
             /*
              * Non-native objects must have either non-native lookup results,
              * or else native results from the non-native's prototype chain.
              *
              * See StackFrame::getValidCalleeObject, where we depend on this
              * fact to force a prototype-delegated joined method accessed via
              * arguments.callee through the delegating |this| object's method
              * read barrier.
              */
             if (*propp && (*objp)->isNative()) {
                 while ((proto = proto->getProto()) != *objp)
                     JS_ASSERT(proto);
             }
 #endif
-            return protoIndex + 1;
+            return true;
         }
 
         obj = proto;
     }
 
     *objp = NULL;
     *propp = NULL;
-    return protoIndex;
+    return true;
 }
 
 JS_FRIEND_API(JSBool)
 js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
                   JSProperty **propp)
 {
     /* Convert string indices to integers if appropriate. */
     id = js_CheckForStringIndex(id);
 
-    return js_LookupPropertyWithFlagsInline(cx, obj, id, cx->resolveFlags, objp, propp) >= 0;
-}
-
-int
-js_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN flags,
-                           JSObject **objp, JSProperty **propp)
+    return LookupPropertyWithFlagsInline(cx, obj, id, cx->resolveFlags, objp, propp);
+}
+
+namespace js {
+
+bool
+LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN flags,
+                        JSObject **objp, JSProperty **propp)
 {
     /* Convert string indices to integers if appropriate. */
     id = js_CheckForStringIndex(id);
 
-    return js_LookupPropertyWithFlagsInline(cx, obj, id, flags, objp, propp);
-}
+    return LookupPropertyWithFlagsInline(cx, obj, id, flags, objp, propp);
+}
+
+} /* namespace js */
 
 PropertyCacheEntry *
 js_FindPropertyHelper(JSContext *cx, jsid id, JSBool cacheResult,
                       JSObject **objp, JSObject **pobjp, JSProperty **propp)
 {
     JSObject *scopeChain, *obj, *parent, *pobj;
     PropertyCacheEntry *entry;
-    int scopeIndex, protoIndex;
+    int scopeIndex;
     JSProperty *prop;
 
     JS_ASSERT_IF(cacheResult, !JS_ON_TRACE(cx));
     scopeChain = &js_GetTopStackFrame(cx)->scopeChain();
 
     /* Scan entries on the scope chain that we can cache across. */
     entry = JS_NO_PROP_CACHE_FILL;
     obj = scopeChain;
     parent = obj->getParent();
     for (scopeIndex = 0;
          parent
          ? IsCacheableNonGlobalScope(obj)
          : !obj->getOps()->lookupProperty;
          ++scopeIndex) {
-        protoIndex =
-            js_LookupPropertyWithFlags(cx, obj, id, cx->resolveFlags,
-                                       &pobj, &prop);
-        if (protoIndex < 0)
+        if (!LookupPropertyWithFlags(cx, obj, id, cx->resolveFlags, &pobj, &prop))
             return NULL;
 
         if (prop) {
 #ifdef DEBUG
             if (parent) {
                 Class *clasp = obj->getClass();
                 JS_ASSERT(pobj->isNative());
                 JS_ASSERT(pobj->getClass() == clasp);
                 if (clasp == &js_BlockClass) {
                     /*
-                     * A block instance on the scope chain is immutable and it
-                     * shares its shapes with its compile-time prototype.
+                     * A block instance on the scope chain is immutable and
+                     * shares its shape with the compile-time prototype. Thus
+                     * we cannot find any property on the prototype.
                      */
-                    JS_ASSERT(pobj == obj);
                     JS_ASSERT(pobj->isClonedBlock());
-                    JS_ASSERT(protoIndex == 0);
                 } else {
                     /* Call and DeclEnvClass objects have no prototypes. */
                     JS_ASSERT(!obj->getProto());
-                    JS_ASSERT(protoIndex == 0);
                 }
+                JS_ASSERT(pobj == obj);
             } else {
                 JS_ASSERT(obj->isNative());
             }
 #endif
             /*
              * We must check if pobj is native as a global object can have
              * non-native prototype.
              */
             if (cacheResult && pobj->isNative()) {
-                entry = JS_PROPERTY_CACHE(cx).fill(cx, scopeChain, scopeIndex,
-                                                   protoIndex, pobj,
+                entry = JS_PROPERTY_CACHE(cx).fill(cx, scopeChain, scopeIndex, pobj,
                                                    (Shape *) prop);
             }
             SCOPE_DEPTH_ACCUM(&cx->runtime->scopeSearchDepthStats, scopeIndex);
             goto out;
         }
 
         if (!parent) {
             pobj = NULL;
@@ -5128,30 +5124,26 @@ js_FindIdentifierBase(JSContext *cx, JSO
      * The test order here matters because IsCacheableNonGlobalScope
      * must not be passed a global object (i.e. one with null parent).
      */
     for (int scopeIndex = 0;
          !obj->getParent() || IsCacheableNonGlobalScope(obj);
          scopeIndex++) {
         JSObject *pobj;
         JSProperty *prop;
-        int protoIndex = js_LookupPropertyWithFlags(cx, obj, id,
-                                                    cx->resolveFlags,
-                                                    &pobj, &prop);
-        if (protoIndex < 0)
+        if (!LookupPropertyWithFlags(cx, obj, id, cx->resolveFlags, &pobj, &prop))
             return NULL;
         if (prop) {
             if (!pobj->isNative()) {
                 JS_ASSERT(!obj->getParent());
                 return obj;
             }
             JS_ASSERT_IF(obj->getParent(), pobj->getClass() == obj->getClass());
             DebugOnly<PropertyCacheEntry*> entry =
-                JS_PROPERTY_CACHE(cx).fill(cx, scopeChain, scopeIndex, protoIndex, pobj,
-                                           (Shape *) prop);
+                JS_PROPERTY_CACHE(cx).fill(cx, scopeChain, scopeIndex, pobj, (Shape *) prop);
             JS_ASSERT(entry);
             return obj;
         }
 
         JSObject *parent = obj->getParent();
         if (!parent)
             return obj;
         obj = parent;
@@ -5293,33 +5285,30 @@ js_NativeSet(JSContext *cx, JSObject *ob
 }
 
 static JS_ALWAYS_INLINE bool
 js_GetPropertyHelperWithShapeInline(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id,
                                     uintN getHow, Value *vp,
                                     const Shape **shapeOut, JSObject **holderOut)
 {
     JSObject *aobj, *obj2;
-    int protoIndex;
     JSProperty *prop;
     const Shape *shape;
 
     JS_ASSERT_IF(getHow & JSGET_CACHE_RESULT, !JS_ON_TRACE(cx));
 
     *shapeOut = NULL;
 
     /* Convert string indices to integers if appropriate. */
     id = js_CheckForStringIndex(id);
 
     aobj = js_GetProtoIfDenseArray(obj);
-    /* This call site is hot -- use the always-inlined variant of js_LookupPropertyWithFlags(). */
-    protoIndex = js_LookupPropertyWithFlagsInline(cx, aobj, id, cx->resolveFlags,
-                                                  &obj2, &prop);
-    if (protoIndex < 0)
-        return JS_FALSE;
+    /* This call site is hot -- use the always-inlined variant of LookupPropertyWithFlags(). */
+    if (!LookupPropertyWithFlagsInline(cx, aobj, id, cx->resolveFlags, &obj2, &prop))
+        return false;
 
     *holderOut = obj2;
 
     if (!prop) {
         vp->setUndefined();
 
         if (!CallJSPropertyOp(cx, obj->getClass()->getProperty, obj, id, vp))
             return JS_FALSE;
@@ -5352,17 +5341,17 @@ js_GetPropertyHelperWithShapeInline(JSCo
                 /*
                  * XXX do not warn about missing __iterator__ as the function
                  * may be called from JS_GetMethodById. See bug 355145.
                  */
                 if (JSID_IS_ATOM(id, cx->runtime->atomState.iteratorAtom))
                     return JS_TRUE;
 
                 /* Do not warn about tests like (obj[prop] == undefined). */
-                if (cx->resolveFlags == JSRESOLVE_INFER) {
+                if (cx->resolveFlags == RESOLVE_INFER) {
                     LeaveTrace(cx);
                     pc += js_CodeSpec[op].length;
                     if (Detecting(cx, pc))
                         return JS_TRUE;
                 } else if (cx->resolveFlags & JSRESOLVE_DETECTING) {
                     return JS_TRUE;
                 }
 
@@ -5385,17 +5374,17 @@ js_GetPropertyHelperWithShapeInline(JSCo
                : obj2->getProperty(cx, id, vp);
     }
 
     shape = (Shape *) prop;
     *shapeOut = shape;
 
     if (getHow & JSGET_CACHE_RESULT) {
         JS_ASSERT_NOT_ON_TRACE(cx);
-        JS_PROPERTY_CACHE(cx).fill(cx, aobj, 0, protoIndex, obj2, shape);
+        JS_PROPERTY_CACHE(cx).fill(cx, aobj, 0, obj2, shape);
     }
 
     /* This call site is hot -- use the always-inlined variant of js_NativeGet(). */
     if (!js_NativeGetInline(cx, receiver, obj, obj2, shape, getHow, vp))
         return JS_FALSE;
 
     return JS_TRUE;
 }
@@ -5431,17 +5420,17 @@ js_GetProperty(JSContext *cx, JSObject *
     return js_GetPropertyHelperInline(cx, obj, receiver, id, JSGET_METHOD_BARRIER, vp);
 }
 
 JSBool
 js::GetPropertyDefault(JSContext *cx, JSObject *obj, jsid id, const Value &def, Value *vp)
 {
     JSProperty *prop;
     JSObject *obj2;
-    if (js_LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop) < 0)
+    if (!LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop))
         return false;
 
     if (!prop) {
         *vp = def;
         return true;
     }
 
     return js_GetProperty(cx, obj2, id, vp);
@@ -5520,39 +5509,35 @@ JSObject::callMethod(JSContext *cx, jsid
     return js_GetMethod(cx, this, id, JSGET_NO_METHOD_BARRIER, &fval) &&
            ExternalInvoke(cx, ObjectValue(*this), fval, argc, argv, vp);
 }
 
 JSBool
 js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow,
                      Value *vp, JSBool strict)
 {
-    int protoIndex;
     JSObject *pobj;
     JSProperty *prop;
     const Shape *shape;
     uintN attrs, flags;
     intN shortid;
     Class *clasp;
     PropertyOp getter;
     StrictPropertyOp setter;
     bool added;
 
-    JS_ASSERT((defineHow &
-               ~(JSDNP_CACHE_RESULT | JSDNP_SET_METHOD | JSDNP_UNQUALIFIED)) == 0);
-    if (defineHow & JSDNP_CACHE_RESULT)
+    JS_ASSERT((defineHow & ~(DNP_CACHE_RESULT | DNP_SET_METHOD | DNP_UNQUALIFIED)) == 0);
+    if (defineHow & DNP_CACHE_RESULT)
         JS_ASSERT_NOT_ON_TRACE(cx);
 
     /* Convert string indices to integers if appropriate. */
     id = js_CheckForStringIndex(id);
 
-    protoIndex = js_LookupPropertyWithFlags(cx, obj, id, cx->resolveFlags,
-                                            &pobj, &prop);
-    if (protoIndex < 0)
-        return JS_FALSE;
+    if (!LookupPropertyWithFlags(cx, obj, id, cx->resolveFlags, &pobj, &prop))
+        return false;
     if (prop) {
         if (!pobj->isNative()) {
             if (pobj->isProxy()) {
                 AutoPropertyDescriptorRooter pd(cx);
                 if (!JSProxy::getPropertyDescriptor(cx, pobj, id, true, &pd))
                     return false;
 
                 if ((pd.attrs & (JSPROP_SHARED | JSPROP_SHADOWABLE)) == JSPROP_SHARED) {
@@ -5571,17 +5556,17 @@ js_SetPropertyHelper(JSContext *cx, JSOb
 
             prop = NULL;
         }
     } else {
         /* We should never add properties to lexical blocks.  */
         JS_ASSERT(!obj->isBlock());
 
         if (!obj->getParent() &&
-            (defineHow & JSDNP_UNQUALIFIED) &&
+            (defineHow & DNP_UNQUALIFIED) &&
             !js_CheckUndeclaredVarAssignment(cx, JSID_TO_STRING(id))) {
             return JS_FALSE;
         }
     }
     shape = (Shape *) prop;
 
     /*
      * Now either shape is null, meaning id was not found in obj or one of its
@@ -5615,18 +5600,18 @@ js_SetPropertyHelper(JSContext *cx, JSOb
         }
 
         attrs = shape->attributes();
         if (pobj != obj) {
             /*
              * We found id in a prototype object: prepare to share or shadow.
              */
             if (!shape->shadowable()) {
-                if (defineHow & JSDNP_CACHE_RESULT)
-                    JS_PROPERTY_CACHE(cx).fill(cx, obj, 0, protoIndex, pobj, shape);
+                if (defineHow & DNP_CACHE_RESULT)
+                    JS_PROPERTY_CACHE(cx).fill(cx, obj, 0, pobj, shape);
 
                 if (shape->hasDefaultSetter() && !shape->hasGetterValue())
                     return JS_TRUE;
 
                 return shape->set(cx, obj, strict, vp);
             }
 
             /*
@@ -5640,17 +5625,17 @@ js_SetPropertyHelper(JSContext *cx, JSOb
              *
              * A subset of slotless shared properties is the set of properties
              * with shortids, which must be preserved too. An old API requires
              * that the property's getter and setter receive the shortid, not
              * id, when they are called on the shadowing property that we are
              * about to create in obj.
              */
             if (!shape->hasSlot()) {
-                defineHow &= ~JSDNP_SET_METHOD;
+                defineHow &= ~DNP_SET_METHOD;
                 if (shape->hasShortID()) {
                     flags = Shape::HAS_SHORTID;
                     shortid = shape->shortid;
                 }
                 attrs &= ~JSPROP_SHARED;
                 getter = shape->getter();
                 setter = shape->setter();
             } else {
@@ -5663,17 +5648,17 @@ js_SetPropertyHelper(JSContext *cx, JSOb
              * needed member values.
              */
             shape = NULL;
         }
 
         JS_ASSERT_IF(shape && shape->isMethod(), pobj->hasMethodBarrier());
         JS_ASSERT_IF(shape && shape->isMethod(),
                      pobj->getSlot(shape->slot).toObject() == shape->methodObject());
-        if (shape && (defineHow & JSDNP_SET_METHOD)) {
+        if (shape && (defineHow & DNP_SET_METHOD)) {
             /*
              * JSOP_SETMETHOD is assigning to an existing own property. If it
              * is an identical method property, do nothing. Otherwise downgrade
              * to ordinary assignment. Either way, do not fill the property
              * cache, as the interpreter has no fast path for these unusual
              * cases.
              */
             bool identical = shape->isMethod() && shape->methodObject() == vp->toObject();
@@ -5715,54 +5700,54 @@ js_SetPropertyHelper(JSContext *cx, JSOb
         /* Find or make a property descriptor with the right heritage. */
         if (!obj->ensureClassReservedSlots(cx))
             return JS_FALSE;
 
         /*
          * Check for Object class here to avoid defining a method on a class
          * with magic resolve, addProperty, getProperty, etc. hooks.
          */
-        if ((defineHow & JSDNP_SET_METHOD) && obj->canHaveMethodBarrier()) {
+        if ((defineHow & DNP_SET_METHOD) && obj->canHaveMethodBarrier()) {
             JS_ASSERT(IsFunctionObject(*vp));
             JS_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
 
             JSObject *funobj = &vp->toObject();
             JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
             if (fun == funobj) {
                 flags |= Shape::METHOD;
                 getter = CastAsPropertyOp(funobj);
             }
         }
 
         shape = obj->putProperty(cx, id, getter, setter, SHAPE_INVALID_SLOT,
                                  attrs, flags, shortid);
         if (!shape)
             return JS_FALSE;
 
-        if (defineHow & JSDNP_CACHE_RESULT)
+        if (defineHow & DNP_CACHE_RESULT)
             TRACE_1(AddProperty, obj);
 
         /*
          * Initialize the new property value (passed to setter) to undefined.
          * Note that we store before calling addProperty, to match the order
-         * in js_DefineNativeProperty.
+         * in DefineNativeProperty.
          */
         if (obj->containsSlot(shape->slot))
             obj->nativeSetSlot(shape->slot, UndefinedValue());
 
         /* XXXbe called with obj locked */
         if (!CallAddPropertyHook(cx, clasp, obj, shape, vp)) {
             obj->removeProperty(cx, id);
             return JS_FALSE;
         }
         added = true;
     }
 
-    if (defineHow & JSDNP_CACHE_RESULT)
-        JS_PROPERTY_CACHE(cx).fill(cx, obj, 0, 0, obj, shape, added);
+    if (defineHow & DNP_CACHE_RESULT)
+        JS_PROPERTY_CACHE(cx).fill(cx, obj, 0, obj, shape, added);
 
     return js_NativeSet(cx, obj, shape, added, strict, vp);
 
 #ifdef JS_TRACER
   error: // TRACE_1 jumps here in case of error.
     return JS_FALSE;
 #endif
 }
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -204,20 +204,19 @@ MeterEntryCount(uintN count);
 } /* namespace js */
 
 enum {
     INVALID_SHAPE = 0x8fffffff,
     SHAPELESS = 0xffffffff
 };
 
 /*
- * Unlike js_DefineNativeProperty, propp must be non-null. On success, and if
- * id was found, return true with *objp non-null and with a property of *objp
- * stored in *propp. If successful but id was not found, return true with both
- * *objp and *propp null.
+ * On success, and if id was found, return true with *objp non-null and with a
+ * property of *objp stored in *propp. If successful but id was not found,
+ * return true with both *objp and *propp null.
  */
 extern JS_FRIEND_API(JSBool)
 js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
                   JSProperty **propp);
 
 extern JSBool
 js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, const js::Value *value,
                   js::PropertyOp getter, js::StrictPropertyOp setter, uintN attrs);
@@ -1565,58 +1564,53 @@ extern const js::Shape *
 js_ChangeNativePropertyAttrs(JSContext *cx, JSObject *obj,
                              const js::Shape *shape, uintN attrs, uintN mask,
                              js::PropertyOp getter, js::StrictPropertyOp setter);
 
 extern JSBool
 js_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id,
                      const js::Value &descriptor, JSBool *bp);
 
+extern JS_FRIEND_DATA(js::Class) js_CallClass;
+extern JS_FRIEND_DATA(js::Class) js_DeclEnvClass;
+
+namespace js {
+
 /*
  * Flags for the defineHow parameter of js_DefineNativeProperty.
  */
-const uintN JSDNP_CACHE_RESULT = 1; /* an interpreter call from JSOP_INITPROP */
-const uintN JSDNP_DONT_PURGE   = 2; /* suppress js_PurgeScopeChain */
-const uintN JSDNP_SET_METHOD   = 4; /* js_{DefineNativeProperty,SetPropertyHelper}
+const uintN DNP_CACHE_RESULT = 1;   /* an interpreter call from JSOP_INITPROP */
+const uintN DNP_DONT_PURGE   = 2;   /* suppress js_PurgeScopeChain */
+const uintN DNP_SET_METHOD   = 4;   /* DefineNativeProperty,js_SetPropertyHelper
                                        must pass the js::Shape::METHOD
                                        flag on to JSObject::{add,put}Property */
-const uintN JSDNP_UNQUALIFIED  = 8; /* Unqualified property set.  Only used in
+const uintN DNP_UNQUALIFIED  = 8;   /* Unqualified property set.  Only used in
                                        the defineHow argument of
                                        js_SetPropertyHelper. */
 
 /*
- * On error, return false.  On success, if propp is non-null, return true with
- * obj locked and with a held property in *propp; if propp is null, return true
- * but release obj's lock first.
+ * Return successfully added or changed shape or NULL on error.
  */
-extern JSBool
-js_DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, const js::Value &value,
-                        js::PropertyOp getter, js::StrictPropertyOp setter, uintN attrs,
-                        uintN flags, intN shortid, JSProperty **propp,
-                        uintN defineHow = 0);
+extern const Shape *
+DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, const js::Value &value,
+                     PropertyOp getter, StrictPropertyOp setter, uintN attrs,
+                     uintN flags, intN shortid, uintN defineHow = 0);
 
 /*
- * Specialized subroutine that allows caller to preset JSRESOLVE_* flags and
- * returns the index along the prototype chain in which *propp was found, or
- * the last index if not found, or -1 on error.
+ * Specialized subroutine that allows caller to preset JSRESOLVE_* flags.
  */
-extern int
-js_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN flags,
-                           JSObject **objp, JSProperty **propp);
+extern bool
+LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN flags,
+                        JSObject **objp, JSProperty **propp);
 
 /*
  * Constant to pass to js_LookupPropertyWithFlags to infer bits from current
  * bytecode.
  */
-static const uintN JSRESOLVE_INFER = 0xffff;
-
-extern JS_FRIEND_DATA(js::Class) js_CallClass;
-extern JS_FRIEND_DATA(js::Class) js_DeclEnvClass;
-
-namespace js {
+static const uintN RESOLVE_INFER = 0xffff;
 
 /*
  * We cache name lookup results only for the global object or for native
  * non-global objects without prototype or with prototype that never mutates,
  * see bug 462734 and bug 487039.
  */
 static inline bool
 IsCacheableNonGlobalScope(JSObject *obj)
--- a/js/src/json.cpp
+++ b/js/src/json.cpp
@@ -772,18 +772,18 @@ js_Stringify(JSContext *cx, Value *vp, J
 
     /* Step 9. */
     JSObject *wrapper = NewBuiltinClassInstance(cx, &js_ObjectClass);
     if (!wrapper)
         return false;
 
     /* Step 10. */
     jsid emptyId = ATOM_TO_JSID(cx->runtime->atomState.emptyAtom);
-    if (!js_DefineNativeProperty(cx, wrapper, emptyId, *vp, PropertyStub, StrictPropertyStub,
-                                 JSPROP_ENUMERATE, 0, 0, NULL))
+    if (!DefineNativeProperty(cx, wrapper, emptyId, *vp, PropertyStub, StrictPropertyStub,
+                              JSPROP_ENUMERATE, 0, 0))
     {
         return false;
     }
 
     /* Step 11. */
     StringifyContext scx(cx, sb, gap, replacer, propertyList);
     if (!scx.init())
         return false;
@@ -874,19 +874,18 @@ Walk(JSContext *cx, JSObject *holder, js
 
                 if (newElement.isUndefined()) {
                     /* Step 2b(ii)(2). */
                     if (!js_DeleteProperty(cx, obj, id, &newElement, false))
                         return false;
                 } else {
                     /* Step 2b(ii)(3). */
                     JS_ASSERT(obj->isNative());
-                    if (!js_DefineNativeProperty(cx, obj, id, newElement, PropertyStub,
-                                                 StrictPropertyStub, JSPROP_ENUMERATE, 0, 0,
-                                                 NULL))
+                    if (!DefineNativeProperty(cx, obj, id, newElement, PropertyStub,
+                                              StrictPropertyStub, JSPROP_ENUMERATE, 0, 0))
                     {
                         return false;
                     }
                 }
             }
         }
     }
 
--- a/js/src/jsonparser.cpp
+++ b/js/src/jsonparser.cpp
@@ -533,19 +533,19 @@ JSONSourceParser::parse(Value *vp)
         switch (state) {
           case FinishObjectMember: {
             Value v = valueStack.popCopy();
             /*
              * NB: Relies on js_DefineNativeProperty performing
              *     js_CheckForStringIndex.
              */
             jsid propid = ATOM_TO_JSID(&valueStack.popCopy().toString()->asAtom());
-            if (!js_DefineNativeProperty(cx, &valueStack.back().toObject(), propid, v,
-                                         PropertyStub, StrictPropertyStub, JSPROP_ENUMERATE,
-                                         0, 0, NULL))
+            if (!DefineNativeProperty(cx, &valueStack.back().toObject(), propid, v,
+                                      PropertyStub, StrictPropertyStub, JSPROP_ENUMERATE,
+                                      0, 0))
             {
                 return false;
             }
             token = advanceAfterProperty();
             if (token == ObjectClose)
                 break;
             if (token != Comma) {
                 if (token == OOM)
--- a/js/src/jsparse.cpp
+++ b/js/src/jsparse.cpp
@@ -1194,25 +1194,21 @@ Compiler::defineGlobals(JSContext *cx, G
              * No need to check for redeclarations or anything, global
              * optimizations only take place if the property is not defined.
              */
             rval.setObject(*fun);
         } else {
             rval.setUndefined();
         }
 
-        JSProperty *prop;
-
-        if (!js_DefineNativeProperty(cx, globalObj, id, rval, PropertyStub, StrictPropertyStub,
-                                     JSPROP_ENUMERATE | JSPROP_PERMANENT, 0, 0, &prop)) {
+        const Shape *shape =
+            DefineNativeProperty(cx, globalObj, id, rval, PropertyStub, StrictPropertyStub,
+                                 JSPROP_ENUMERATE | JSPROP_PERMANENT, 0, 0);
+        if (!shape)
             return false;
-        }
-
-        JS_ASSERT(prop);
-        const Shape *shape = (const Shape *)prop;
         def.knownSlot = shape->slot;
     }
 
     js::Vector<JSScript *, 16, ContextAllocPolicy> worklist(cx);
     if (!worklist.append(script))
         return false;
 
     /*
@@ -4376,21 +4372,21 @@ CheckDestructuring(JSContext *cx, BindDa
      *
      * Note that we add such a property even if the block has locals due to
      * later let declarations in it. We optimize for code simplicity here,
      * not the fastest runtime performance with empty [] or {}.
      */
     if (data &&
         data->binder == BindLet &&
         OBJ_BLOCK_COUNT(cx, tc->blockChain()) == 0 &&
-        !js_DefineNativeProperty(cx, tc->blockChain(),
-                                 ATOM_TO_JSID(cx->runtime->atomState.emptyAtom),
-                                 UndefinedValue(), NULL, NULL,
-                                 JSPROP_ENUMERATE | JSPROP_PERMANENT,
-                                 Shape::HAS_SHORTID, 0, NULL)) {
+        !DefineNativeProperty(cx, tc->blockChain(),
+                              ATOM_TO_JSID(cx->runtime->atomState.emptyAtom),
+                              UndefinedValue(), NULL, NULL,
+                              JSPROP_ENUMERATE | JSPROP_PERMANENT,
+                              Shape::HAS_SHORTID, 0)) {
         return false;
     }
 
     return true;
 }
 
 /*
  * Extend the pn_pos.end source coordinate of each name in a destructuring
--- a/js/src/jspropertycache.cpp
+++ b/js/src/jspropertycache.cpp
@@ -44,18 +44,18 @@
 #include "jsobjinlines.h"
 #include "jspropertycacheinlines.h"
 
 using namespace js;
 
 JS_STATIC_ASSERT(sizeof(PCVal) == sizeof(jsuword));
 
 JS_REQUIRES_STACK PropertyCacheEntry *
-PropertyCache::fill(JSContext *cx, JSObject *obj, uintN scopeIndex, uintN protoIndex,
-                    JSObject *pobj, const Shape *shape, JSBool adding)
+PropertyCache::fill(JSContext *cx, JSObject *obj, uintN scopeIndex, JSObject *pobj,
+                    const Shape *shape, JSBool adding)
 {
     jsbytecode *pc;
     jsuword kshape, vshape;
     JSOp op;
     const JSCodeSpec *cs;
     PCVal vword;
     PropertyCacheEntry *entry;
 
@@ -83,52 +83,44 @@ PropertyCache::fill(JSContext *cx, JSObj
     if (adding && obj->inDictionaryMode()) {
         PCMETER(add2dictfills++);
         return JS_NO_PROP_CACHE_FILL;
     }
 
     /*
      * Check for overdeep scope and prototype chain. Because resolve, getter,
      * and setter hooks can change the prototype chain using JS_SetPrototype
-     * after js_LookupPropertyWithFlags has returned the nominal protoIndex,
-     * we have to validate protoIndex if it is non-zero. If it is zero, then
-     * we know thanks to the pobj->nativeContains test above, combined with the
-     * fact that obj == pobj, that protoIndex is invariant.
+     * after LookupPropertyWithFlags has returned, we calculate the protoIndex
+     * here and not in LookupPropertyWithFlags.
      *
      * The scopeIndex can't be wrong. We require JS_SetParent calls to happen
      * before any running script might consult a parent-linked scope chain. If
      * this requirement is not satisfied, the fill in progress will never hit,
      * but vcap vs. scope shape tests ensure nothing malfunctions.
      */
-    JS_ASSERT_IF(scopeIndex == 0 && protoIndex == 0, obj == pobj);
-
-    if (protoIndex != 0) {
-        JSObject *tmp = obj;
+    JS_ASSERT_IF(obj == pobj, scopeIndex == 0);
 
-        for (uintN i = 0; i != scopeIndex; i++)
-            tmp = tmp->getParent();
-        JS_ASSERT(tmp != pobj);
+    JSObject *tmp = obj;
+    for (uintN i = 0; i != scopeIndex; i++)
+        tmp = tmp->getParent();
 
-        protoIndex = 1;
-        for (;;) {
-            tmp = tmp->getProto();
+    uintN protoIndex = 0;
+    while (tmp != pobj) {
+        tmp = tmp->getProto();
 
-            /*
-             * We cannot cache properties coming from native objects behind
-             * non-native ones on the prototype chain. The non-natives can
-             * mutate in arbitrary way without changing any shapes.
-             */
-            if (!tmp || !tmp->isNative()) {
-                PCMETER(noprotos++);
-                return JS_NO_PROP_CACHE_FILL;
-            }
-            if (tmp == pobj)
-                break;
-            ++protoIndex;
+        /*
+         * We cannot cache properties coming from native objects behind
+         * non-native ones on the prototype chain. The non-natives can
+         * mutate in arbitrary way without changing any shapes.
+         */
+        if (!tmp || !tmp->isNative()) {
+            PCMETER(noprotos++);
+            return JS_NO_PROP_CACHE_FILL;
         }
+        ++protoIndex;
     }
 
     if (scopeIndex > PCVCAP_SCOPEMASK || protoIndex > PCVCAP_PROTOMASK) {
         PCMETER(longchains++);
         return JS_NO_PROP_CACHE_FILL;
     }
 
     /*
--- a/js/src/jspropertycache.h
+++ b/js/src/jspropertycache.h
@@ -266,18 +266,18 @@ class PropertyCache
      * Fill property cache entry for key cx->fp->pc, optimized value word
      * computed from obj and shape, and entry capability forged from 24-bit
      * obj->shape(), 4-bit scopeIndex, and 4-bit protoIndex.
      *
      * Return the filled cache entry or JS_NO_PROP_CACHE_FILL if caching was
      * not possible.
      */
     JS_REQUIRES_STACK PropertyCacheEntry *fill(JSContext *cx, JSObject *obj, uintN scopeIndex,
-                                               uintN protoIndex, JSObject *pobj,
-                                               const js::Shape *shape, JSBool adding = false);
+                                               JSObject *pobj, const js::Shape *shape,
+                                               JSBool adding = false);
 
     void purge(JSContext *cx);
     void purgeForScript(JSContext *cx, JSScript *script);
 
     /* Restore an entry that may have been purged during a GC. */
     void restore(PropertyCacheEntry *entry);
 };
 
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -2076,17 +2076,17 @@ FindReplaceLength(JSContext *cx, RegExpS
             atom = js_AtomizeString(cx, str, 0);
             if (!atom)
                 return false;
         }
         jsid id = ATOM_TO_JSID(atom);
 
         JSObject *holder;
         JSProperty *prop = NULL;
-        if (js_LookupPropertyWithFlags(cx, base, id, JSRESOLVE_QUALIFIED, &holder, &prop) < 0)
+        if (!LookupPropertyWithFlags(cx, base, id, JSRESOLVE_QUALIFIED, &holder, &prop))
             return false;
 
         /* Only handle the case where the property exists and is on this object. */
         if (prop && holder == base) {
             Shape *shape = (Shape *) prop;
             if (shape->slot != SHAPE_INVALID_SLOT && shape->hasDefaultGetter()) {
                 Value value = base->getSlot(shape->slot);
                 if (value.isString()) {
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -9515,32 +9515,27 @@ TraceRecorder::test_property_cache(JSObj
             /* js_FindPropertyHelper can reenter the interpreter and kill |this|. */
             if (!localtm.recorder)
                 return ARECORD_ABORTED;
 
             if (entry == JS_NO_PROP_CACHE_FILL)
                 RETURN_STOP_A("cannot cache name");
         } else {
             TraceMonitor &localtm = *traceMonitor;
-            int protoIndex = js_LookupPropertyWithFlags(cx, aobj, id,
-                                                        cx->resolveFlags,
-                                                        &obj2, &prop);
-
-            if (protoIndex < 0)
-                RETURN_ERROR_A("error in js_LookupPropertyWithFlags");
-
-            /* js_LookupPropertyWithFlags can reenter the interpreter and kill |this|. */
+            if (!LookupPropertyWithFlags(cx, aobj, id, cx->resolveFlags, &obj2, &prop))
+                RETURN_ERROR_A("error in LookupPropertyWithFlags");
+
+            /* LookupPropertyWithFlags can reenter the interpreter and kill |this|. */
             if (!localtm.recorder)
                 return ARECORD_ABORTED;
 
             if (prop) {
                 if (!obj2->isNative())
                     RETURN_STOP_A("property found on non-native object");
-                entry = JS_PROPERTY_CACHE(cx).fill(cx, aobj, 0, protoIndex, obj2,
-                                                   (Shape*) prop);
+                entry = JS_PROPERTY_CACHE(cx).fill(cx, aobj, 0, obj2, (Shape*) prop);
                 JS_ASSERT(entry);
                 if (entry == JS_NO_PROP_CACHE_FILL)
                     entry = NULL;
             }
 
         }
 
         if (!prop) {
--- a/js/src/jstypedarray.cpp
+++ b/js/src/jstypedarray.cpp
@@ -537,17 +537,17 @@ class TypedArrayTemplate
 
             JSObject *proto = obj->getProto();
             if (!proto) {
                 vp->setUndefined();
                 return true;
             }
 
             vp->setUndefined();
-            if (js_LookupPropertyWithFlags(cx, proto, id, cx->resolveFlags, &obj2, &prop) < 0)
+            if (!LookupPropertyWithFlags(cx, proto, id, cx->resolveFlags, &obj2, &prop))
                 return false;
 
             if (prop) {
                 if (obj2->isNative()) {
                     shape = (Shape *) prop;
                     if (!js_NativeGet(cx, obj, obj2, shape, JSGET_METHOD_BARRIER, vp))
                         return false;
                 }
--- a/js/src/methodjit/FastOps.cpp
+++ b/js/src/methodjit/FastOps.cpp
@@ -1804,21 +1804,21 @@ mjit::Compiler::jsop_initprop()
         masm.move(ImmPtr(atom), Registers::ArgReg1);
         INLINE_STUBCALL(stubs::InitProp);
         return;
     }
 
     JSObject *holder;
     JSProperty *prop = NULL;
 #ifdef DEBUG
-    int res =
+    bool res =
 #endif
-    js_LookupPropertyWithFlags(cx, baseobj, ATOM_TO_JSID(atom),
-                               JSRESOLVE_QUALIFIED, &holder, &prop);
-    JS_ASSERT(res >= 0 && prop && holder == baseobj);
+    LookupPropertyWithFlags(cx, baseobj, ATOM_TO_JSID(atom),
+                            JSRESOLVE_QUALIFIED, &holder, &prop);
+    JS_ASSERT(res && prop && holder == baseobj);
 
     RegisterID objReg = frame.copyDataIntoReg(obj);
     masm.loadPtr(Address(objReg, offsetof(JSObject, slots)), objReg);
 
     /* Perform the store. */
     Shape *shape = (Shape *) prop;
     frame.storeTo(fe, Address(objReg, shape->slot * sizeof(Value)));
     frame.freeReg(objReg);
--- a/js/src/methodjit/MethodJIT.cpp
+++ b/js/src/methodjit/MethodJIT.cpp
@@ -676,17 +676,17 @@ mjit::EnterMethodJIT(JSContext *cx, Stac
 #endif
 
     JS_ASSERT(cx->fp() == fp);
     FrameRegs &oldRegs = cx->regs();
 
     JSBool ok;
     {
         AssertCompartmentUnchanged pcc(cx);
-        JSAutoResolveFlags rf(cx, JSRESOLVE_INFER);
+        JSAutoResolveFlags rf(cx, RESOLVE_INFER);
         ok = JaegerTrampoline(cx, fp, code, stackLimit);
     }
 
     /* Undo repointRegs in SetVMFrameRegs. */
     cx->stack.repointRegs(&oldRegs);
     JS_ASSERT(fp == cx->fp());
 
     /* The trampoline wrote the return value but did not set the HAS_RVAL flag. */
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -247,21 +247,21 @@ stubs::SetName(VMFrame &f, JSAtom *origA
             JS_ASSERT(atom);
         }
 
         jsid id = ATOM_TO_JSID(atom);
         if (entry && JS_LIKELY(!obj->getOps()->setProperty)) {
             uintN defineHow;
             JSOp op = JSOp(*f.regs.pc);
             if (op == JSOP_SETMETHOD)
-                defineHow = JSDNP_CACHE_RESULT | JSDNP_SET_METHOD;
+                defineHow = DNP_CACHE_RESULT | DNP_SET_METHOD;
             else if (op == JSOP_SETNAME)
-                defineHow = JSDNP_CACHE_RESULT | JSDNP_UNQUALIFIED;
+                defineHow = DNP_CACHE_RESULT | DNP_UNQUALIFIED;
             else
-                defineHow = JSDNP_CACHE_RESULT;
+                defineHow = DNP_CACHE_RESULT;
             if (!js_SetPropertyHelper(cx, obj, id, defineHow, &rval, strict))
                 THROW();
         } else {
             if (!obj->setProperty(cx, id, &rval, strict))
                 THROW();
         }
     } while (0);
 
@@ -2104,23 +2104,22 @@ InitPropOrMethod(VMFrame &f, JSAtom *ato
         obj->nativeSetSlot(slot, rval);
     } else {
         PCMETER(JS_PROPERTY_CACHE(cx).inipcmisses++);
 
         /* Get the immediate property name into id. */
         jsid id = ATOM_TO_JSID(atom);
 
         uintN defineHow = (op == JSOP_INITMETHOD)
-                          ? JSDNP_CACHE_RESULT | JSDNP_SET_METHOD
-                          : JSDNP_CACHE_RESULT;
-        if (!(JS_UNLIKELY(atom == cx->runtime->atomState.protoAtom)
-              ? js_SetPropertyHelper(cx, obj, id, defineHow, &rval, false)
-              : js_DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
-                                        JSPROP_ENUMERATE, 0, 0, NULL,
-                                        defineHow))) {
+                          ? DNP_CACHE_RESULT | DNP_SET_METHOD
+                          : DNP_CACHE_RESULT;
+        if (JS_UNLIKELY(atom == cx->runtime->atomState.protoAtom)
+            ? !js_SetPropertyHelper(cx, obj, id, defineHow, &rval, false)
+            : !DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
+                                    JSPROP_ENUMERATE, 0, 0, defineHow)) {
             THROW();
         }
     }
 }
 
 void JS_FASTCALL
 stubs::InitProp(VMFrame &f, JSAtom *atom)
 {
@@ -2591,18 +2590,18 @@ stubs::DefVarOrConst(VMFrame &f, JSAtom 
          * As attrs includes readonly, CheckRedeclaration can succeed only
          * if prop does not exist.
          */
         shouldDefine = true;
     }
 
     /* Bind a variable only if it's not yet defined. */
     if (shouldDefine && 
-        !js_DefineNativeProperty(cx, obj, id, UndefinedValue(), PropertyStub, StrictPropertyStub,
-                                     attrs, 0, 0, NULL)) {
+        !DefineNativeProperty(cx, obj, id, UndefinedValue(), PropertyStub, StrictPropertyStub,
+                              attrs, 0, 0)) {
         THROW();
     }
 }
 
 void JS_FASTCALL
 stubs::SetConst(VMFrame &f, JSAtom *atom)
 {
     JSContext *cx = f.cx;
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -3716,17 +3716,17 @@ CopyProperty(JSContext *cx, JSObject *ob
 {
     JSProperty *prop;
     PropertyDescriptor desc;
     uintN propFlags = 0;
     JSObject *obj2;
 
     *objp = NULL;
     if (referent->isNative()) {
-        if (js_LookupPropertyWithFlags(cx, referent, id, lookupFlags, &obj2, &prop) < 0)
+        if (!LookupPropertyWithFlags(cx, referent, id, lookupFlags, &obj2, &prop))
             return false;
         if (obj2 != referent)
             return true;
 
         const Shape *shape = (Shape *) prop;
         if (shape->isMethod()) {
             shape = referent->methodReadBarrier(cx, *shape, &desc.value);
             if (!shape)
@@ -3763,19 +3763,18 @@ CopyProperty(JSContext *cx, JSObject *ob
         }
         desc.attrs &= JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
         desc.getter = PropertyStub;
         desc.setter = StrictPropertyStub;
         desc.shortid = 0;
     }
 
     *objp = obj;
-    return js_DefineNativeProperty(cx, obj, id, desc.value,
-                                   desc.getter, desc.setter, desc.attrs, propFlags,
-                                   desc.shortid, &prop);
+    return !!DefineNativeProperty(cx, obj, id, desc.value, desc.getter, desc.setter,
+                                  desc.attrs, propFlags, desc.shortid);
 }
 
 static JSBool
 resolver_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
 {
     jsval v;
     JS_ALWAYS_TRUE(JS_GetReservedSlot(cx, obj, 0, &v));
     return CopyProperty(cx, obj, JSVAL_TO_OBJECT(v), id, flags, objp);