Bug 770999 - Add get() method to Handle<T> and Rooted<T> (r=bhackett)
authorBill McCloskey <wmccloskey@mozilla.com>
Wed, 04 Jul 2012 13:34:42 -0700
changeset 98365 2ecd5bbb52897c504f1a134966396a6cd62a1b4e
parent 98364 13897ce0f3a2a70e7b8a9d1cf6b1e939416fe6f8
child 98366 0690da7a7b86b54110698860492232756793f1eb
push id897
push usertim.taubert@gmx.de
push dateThu, 05 Jul 2012 13:27:11 +0000
treeherderfx-team@7209f9f14a7d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs770999
milestone16.0a1
Bug 770999 - Add get() method to Handle<T> and Rooted<T> (r=bhackett)
content/xbl/src/nsXBLBinding.cpp
dom/workers/WorkerScope.cpp
js/src/frontend/Parser.cpp
js/src/gc/Root.h
js/src/jsapi-tests/testLookup.cpp
js/src/jsarray.cpp
js/src/jscompartment.cpp
js/src/jscompartment.h
js/src/jsinfer.cpp
js/src/jsinterp.cpp
js/src/jsinterpinlines.h
js/src/jsiter.h
js/src/jsobj.cpp
js/src/json.cpp
js/src/jsproxy.cpp
js/src/jstypedarray.cpp
js/src/jsxml.cpp
js/src/methodjit/Compiler.cpp
js/src/vm/Debugger.cpp
js/src/vm/GlobalObject.cpp
js/src/vm/ObjectImpl.cpp
js/src/vm/RegExpObject.cpp
js/src/vm/ScopeObject.cpp
--- a/content/xbl/src/nsXBLBinding.cpp
+++ b/content/xbl/src/nsXBLBinding.cpp
@@ -374,20 +374,18 @@ XBLResolve(JSContext *cx, JSHandleObject
   if (!set) {
     return false;
   }
   js::SetFunctionNativeReserved(set, XBLPROTO_SLOT, JS::ObjectValue(*obj));
   js::SetFunctionNativeReserved(set, FIELD_SLOT,
                                 JS::StringValue(JSID_TO_STRING(id)));
 
   if (!::JS_DefinePropertyById(cx, obj, id, JS::UndefinedValue(),
-                               JS_DATA_TO_FUNC_PTR(JSPropertyOp,
-                                                   get.reference()),
-                               JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp,
-                                                   set.reference()),
+                               JS_DATA_TO_FUNC_PTR(JSPropertyOp, get.get()),
+                               JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, set.get()),
                                field->AccessorAttributes())) {
     return false;
   }
 
   objp.set(obj);
   return true;
 }
 
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -789,17 +789,17 @@ private:
   Resolve(JSContext* aCx, JSHandleObject aObj, JSHandleId aId, unsigned aFlags,
           JSMutableHandleObject aObjp)
   {
     JSBool resolved;
     if (!JS_ResolveStandardClass(aCx, aObj, aId, &resolved)) {
       return false;
     }
 
-    aObjp.set(resolved ? aObj.value() : NULL);
+    aObjp.set(resolved ? aObj.get() : NULL);
     return true;
   }
 
   static void
   Finalize(JSFreeOp* aFop, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == Class());
     DedicatedWorkerGlobalScope* scope =
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -2468,17 +2468,17 @@ CheckDestructuring(JSContext *cx, BindDa
     bool ok;
 
     if (left->isKind(PNK_ARRAYCOMP)) {
         parser->reportError(left, JSMSG_ARRAY_COMP_LEFTSIDE);
         return false;
     }
 
     Rooted<StaticBlockObject *> blockObj(cx);
-    blockObj = data && data->binder == BindLet ? data->let.blockObj.reference() : NULL;
+    blockObj = data && data->binder == BindLet ? data->let.blockObj.get() : NULL;
     uint32_t blockCountBefore = blockObj ? blockObj->slotCount() : 0;
 
     if (left->isKind(PNK_RB)) {
         for (ParseNode *pn = left->pn_head; pn; pn = pn->pn_next) {
             /* Nullary comma is an elision; binary comma is an expression.*/
             if (!pn->isArrayHole()) {
                 if (pn->isKind(PNK_RB) || pn->isKind(PNK_RC)) {
                     ok = CheckDestructuring(cx, data, pn, parser, false);
--- a/js/src/gc/Root.h
+++ b/js/src/gc/Root.h
@@ -101,20 +101,20 @@ class Handle
      * normal way to create a handle, and normally happens implicitly.
      */
     template <typename S>
     inline
     Handle(Rooted<S> &root,
            typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy = 0);
 
     const T *address() const { return ptr; }
-    T value() const { return *ptr; }
+    T get() const { return *ptr; }
 
-    operator T () const { return value(); }
-    T operator ->() const { return value(); }
+    operator T () const { return get(); }
+    T operator ->() const { return get(); }
 
   private:
     Handle() {}
 
     const T *ptr;
 };
 
 typedef Handle<JSObject*>    HandleObject;
@@ -141,22 +141,21 @@ class MutableHandle
 
     template <typename S>
     inline
     MutableHandle(Rooted<S> *root,
                   typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy = 0);
 
     void set(T v) { *ptr = v; }
 
-    const T *address() const { return ptr; }
-    T *address() { return ptr; }
-    T value() const { return *ptr; }
+    T *address() const { return ptr; }
+    T get() const { return *ptr; }
 
-    operator T () const { return value(); }
-    T operator ->() const { return value(); }
+    operator T () const { return get(); }
+    T operator ->() const { return get(); }
 
   private:
     MutableHandle() {}
 
     T *ptr;
 };
 
 typedef MutableHandle<JSObject*>    MutableHandleObject;
@@ -207,18 +206,18 @@ class Rooted
 #if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING)
     Rooted<T> *previous() { return prev; }
 #endif
 
     operator T () const { return ptr; }
     T operator ->() const { return ptr; }
     T * address() { return &ptr; }
     const T * address() const { return &ptr; }
-    T & reference() { return ptr; }
-    T raw() const { return ptr; }
+    T & get() { return ptr; }
+    const T & get() const { return ptr; }
 
     T & operator =(T value)
     {
         JS_ASSERT(!RootMethods<T>::poisoned(value));
         ptr = value;
         return ptr;
     }
 
--- a/js/src/jsapi-tests/testLookup.cpp
+++ b/js/src/jsapi-tests/testLookup.cpp
@@ -47,17 +47,17 @@ document_resolve(JSContext *cx, JSHandle
         return false;
     if (JSVAL_IS_STRING(v.value())) {
         JSString *str = JSVAL_TO_STRING(v.value());
         JSFlatString *flatStr = JS_FlattenString(cx, str);
         if (!flatStr)
             return false;
         if (JS_FlatStringEqualsAscii(flatStr, "all") && !(flags & JSRESOLVE_DETECTING)) {
             JSBool ok = JS_DefinePropertyById(cx, obj, id, JSVAL_TRUE, NULL, NULL, 0);
-            objp.set(ok ? obj.value() : NULL);
+            objp.set(ok ? obj.get() : NULL);
             return ok;
         }
     }
     objp.set(NULL);
     return true;
 }
 
 static JSClass document_class = {
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -132,18 +132,18 @@ js_GetLengthProperty(JSContext *cx, JSOb
             return true;
         }
     }
 
     RootedValue value(cx);
     if (!obj->getProperty(cx, cx->runtime->atomState.lengthAtom, value.address()))
         return false;
 
-    if (value.reference().isInt32()) {
-        *lengthp = uint32_t(value.reference().toInt32()); /* uint32_t cast does ToUint32_t */
+    if (value.get().isInt32()) {
+        *lengthp = uint32_t(value.get().toInt32()); /* uint32_t cast does ToUint32_t */
         return true;
     }
 
 
     return ToUint32(cx, value, (uint32_t *)lengthp);
 }
 
 namespace js {
@@ -2170,17 +2170,17 @@ SortComparatorFunction::operator()(const
 } /* namespace anonymous */
 
 JSBool
 js::array_sort(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     RootedValue fvalRoot(cx);
-    Value &fval = fvalRoot.reference();
+    Value &fval = fvalRoot.get();
 
     if (args.hasDefined(0)) {
         if (args[0].isPrimitive()) {
             JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_SORT_ARG);
             return false;
         }
         fval = args[0];     /* non-default compare function */
     } else {
--- a/js/src/jscompartment.cpp
+++ b/js/src/jscompartment.cpp
@@ -261,17 +261,17 @@ JSCompartment::wrap(JSContext *cx, Value
      * to the object.
      */
     RootedObject wrapper(cx, cx->runtime->wrapObjectCallback(cx, obj, proto, global, flags));
     if (!wrapper)
         return false;
 
     // We maintain the invariant that the key in the cross-compartment wrapper
     // map is always directly wrapped by the value.
-    JS_ASSERT(Wrapper::wrappedObject(wrapper) == &key.reference().toObject());
+    JS_ASSERT(Wrapper::wrappedObject(wrapper) == &key.get().toObject());
 
     vp->setObject(*wrapper);
 
     if (wrapper->getProto() != proto && !SetProto(cx, wrapper, proto, false))
         return false;
 
     if (!crossCompartmentWrappers.put(key, *vp))
         return false;
@@ -282,51 +282,51 @@ JSCompartment::wrap(JSContext *cx, Value
 }
 
 bool
 JSCompartment::wrap(JSContext *cx, JSString **strp)
 {
     RootedValue value(cx, StringValue(*strp));
     if (!wrap(cx, value.address()))
         return false;
-    *strp = value.reference().toString();
+    *strp = value.get().toString();
     return true;
 }
 
 bool
 JSCompartment::wrap(JSContext *cx, HeapPtrString *strp)
 {
     RootedValue value(cx, StringValue(*strp));
     if (!wrap(cx, value.address()))
         return false;
-    *strp = value.reference().toString();
+    *strp = value.get().toString();
     return true;
 }
 
 bool
 JSCompartment::wrap(JSContext *cx, JSObject **objp)
 {
     if (!*objp)
         return true;
     RootedValue value(cx, ObjectValue(**objp));
     if (!wrap(cx, value.address()))
         return false;
-    *objp = &value.reference().toObject();
+    *objp = &value.get().toObject();
     return true;
 }
 
 bool
 JSCompartment::wrapId(JSContext *cx, jsid *idp)
 {
     if (JSID_IS_INT(*idp))
         return true;
     RootedValue value(cx, IdToValue(*idp));
     if (!wrap(cx, value.address()))
         return false;
-    return ValueToId(cx, value.reference(), idp);
+    return ValueToId(cx, value.get(), idp);
 }
 
 bool
 JSCompartment::wrap(JSContext *cx, PropertyOp *propp)
 {
     Value v = CastAsObjectJsval(*propp);
     if (!wrap(cx, &v))
         return false;
--- a/js/src/jscompartment.h
+++ b/js/src/jscompartment.h
@@ -72,19 +72,19 @@ struct CrossCompartmentKey
       : kind(ObjectWrapper), debugger(NULL), wrapped(wrapped) {}
     CrossCompartmentKey(JSString *wrapped)
       : kind(StringWrapper), debugger(NULL), wrapped(wrapped) {}
     CrossCompartmentKey(Value wrapped)
       : kind(wrapped.isString() ? StringWrapper : ObjectWrapper),
         debugger(NULL),
         wrapped((js::gc::Cell *)wrapped.toGCThing()) {}
     CrossCompartmentKey(const RootedValue &wrapped)
-      : kind(wrapped.raw().isString() ? StringWrapper : ObjectWrapper),
+      : kind(wrapped.get().isString() ? StringWrapper : ObjectWrapper),
         debugger(NULL),
-        wrapped((js::gc::Cell *)wrapped.raw().toGCThing()) {}
+        wrapped((js::gc::Cell *)wrapped.get().toGCThing()) {}
     CrossCompartmentKey(Kind kind, JSObject *dbg, js::gc::Cell *wrapped)
       : kind(kind), debugger(dbg), wrapped(wrapped) {}
 };
 
 struct WrapperHasher
 {
     typedef CrossCompartmentKey Lookup;
 
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -2551,17 +2551,17 @@ TypeCompartment::fixObjectType(JSContext
      * is a type mismatch with previous objects of the same shape, use the
      * generic unknown type.
      */
     JS_ASSERT(obj->isObject());
 
     if (obj->slotSpan() == 0 || obj->inDictionaryMode())
         return;
 
-    ObjectTypeTable::AddPtr p = objectTypeTable->lookupForAdd(obj.raw());
+    ObjectTypeTable::AddPtr p = objectTypeTable->lookupForAdd(obj.get());
     const Shape *baseShape = obj->lastProperty();
 
     if (p) {
         /* The lookup ensures the shape matches, now check that the types match. */
         Type *types = p->value.types;
         for (unsigned i = 0; i < obj->slotSpan(); i++) {
             Type ntype = GetValueTypeForTable(cx, obj->getSlot(i));
             if (ntype != types[i]) {
@@ -2619,23 +2619,23 @@ TypeCompartment::fixObjectType(JSContext
             shape = shape->previous();
         }
 
         ObjectTableKey key;
         key.ids = ids;
         key.nslots = obj->slotSpan();
         key.nfixed = obj->numFixedSlots();
         key.proto = obj->getProto();
-        JS_ASSERT(ObjectTableKey::match(key, obj.raw()));
+        JS_ASSERT(ObjectTableKey::match(key, obj.get()));
 
         ObjectTableEntry entry;
         entry.object = objType;
         entry.types = types;
 
-        p = objectTypeTable->lookupForAdd(obj.raw());
+        p = objectTypeTable->lookupForAdd(obj.get());
         if (!objectTypeTable->add(p, key, entry)) {
             cx->compartment->types.setPendingNukeTypes(cx);
             return;
         }
 
         obj->setType(objType);
     }
 }
@@ -5701,17 +5701,17 @@ JSObject::getNewType(JSContext *cx, JSFu
 
     bool markUnknown = self->lastProperty()->hasObjectFlag(BaseShape::NEW_TYPE_UNKNOWN);
 
     RootedTypeObject type(cx);
     type = cx->compartment->types.newTypeObject(cx, NULL, JSProto_Object, self, markUnknown);
     if (!type)
         return NULL;
 
-    if (!table.relookupOrAdd(p, self, type.raw()))
+    if (!table.relookupOrAdd(p, self, type.get()))
         return NULL;
 
     if (!cx->typeInferenceEnabled())
         return type;
 
     AutoEnterTypeInference enter(cx);
 
     /*
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -162,23 +162,23 @@ js::OnUnknownMethod(JSContext *cx, Handl
     RootedValue idval(cx, idval_);
 
     RootedId id(cx, NameToId(cx->runtime->atomState.noSuchMethodAtom));
     RootedValue value(cx);
     if (!GetMethod(cx, obj, id, 0, value.address()))
         return false;
     TypeScript::MonitorUnknown(cx, cx->fp()->script(), cx->regs().pc);
 
-    if (value.reference().isPrimitive()) {
+    if (value.get().isPrimitive()) {
         *vp = value;
     } else {
 #if JS_HAS_XML_SUPPORT
         /* Extract the function name from function::name qname. */
-        if (idval.reference().isObject()) {
-            JSObject *obj = &idval.reference().toObject();
+        if (idval.get().isObject()) {
+            JSObject *obj = &idval.get().toObject();
             if (js_GetLocalNameFromFunctionQName(obj, id.address(), cx))
                 idval = IdToValue(id);
         }
 #endif
 
         JSObject *obj = NewObjectWithClassProto(cx, &js_NoSuchMethodClass, NULL, NULL);
         if (!obj)
             return false;
@@ -590,19 +590,19 @@ js::LooselyEqual(JSContext *cx, const Va
     RootedValue lvalue(cx, lval);
     RootedValue rvalue(cx, rval);
 
     if (!ToPrimitive(cx, lvalue.address()))
         return false;
     if (!ToPrimitive(cx, rvalue.address()))
         return false;
 
-    if (lvalue.reference().isString() && rvalue.reference().isString()) {
-        JSString *l = lvalue.reference().toString();
-        JSString *r = rvalue.reference().toString();
+    if (lvalue.get().isString() && rvalue.get().isString()) {
+        JSString *l = lvalue.get().toString();
+        JSString *r = rvalue.get().toString();
         return EqualStrings(cx, l, r, result);
     }
 
     double l, r;
     if (!ToNumber(cx, lvalue, &l) || !ToNumber(cx, rvalue, &r))
         return false;
     *result = (l == r);
     return true;
@@ -953,17 +953,17 @@ js::AssertValidPropertyCacheHit(JSContex
     RootedObject obj(cx);
     RootedObject pobj(cx);
     JSProperty *prop;
     JSBool ok;
 
     if (JOF_OPMODE(*pc) == JOF_NAME)
         ok = FindProperty(cx, name, start, &obj, &pobj, &prop);
     else
-        ok = baseops::LookupProperty(cx, start, name.reference(), &pobj, &prop);
+        ok = baseops::LookupProperty(cx, start, name, &pobj, &prop);
     JS_ASSERT(ok);
 
     if (cx->runtime->gcNumber != sample)
         JS_PROPERTY_CACHE(cx).restore(&savedEntry);
     JS_ASSERT(prop);
     JS_ASSERT(pobj == found);
 
     const Shape *shape = (Shape *) prop;
@@ -2354,17 +2354,17 @@ BEGIN_CASE(JSOP_GETPROP)
 BEGIN_CASE(JSOP_GETXPROP)
 BEGIN_CASE(JSOP_LENGTH)
 BEGIN_CASE(JSOP_CALLPROP)
 {
     RootedValue rval(cx);
     if (!GetPropertyOperation(cx, script, regs.pc, regs.sp[-1], rval.address()))
         goto error;
 
-    TypeScript::Monitor(cx, script, regs.pc, rval.reference());
+    TypeScript::Monitor(cx, script, regs.pc, rval);
 
     regs.sp[-1] = rval;
     assertSameCompartment(cx, regs.sp[-1]);
 }
 END_CASE(JSOP_GETPROP)
 
 BEGIN_CASE(JSOP_SETGNAME)
 BEGIN_CASE(JSOP_SETNAME)
--- a/js/src/jsinterpinlines.h
+++ b/js/src/jsinterpinlines.h
@@ -247,17 +247,17 @@ GetPropertyOperation(JSContext *cx, JSSc
 
     RootedObject obj(cx, ValueToObject(cx, lval));
     if (!obj)
         return false;
 
     PropertyCacheEntry *entry;
     Rooted<JSObject*> obj2(cx);
     PropertyName *name;
-    JS_PROPERTY_CACHE(cx).test(cx, pc, obj.reference(), obj2.reference(), entry, name);
+    JS_PROPERTY_CACHE(cx).test(cx, pc, obj.get(), obj2.get(), entry, name);
     if (!name) {
         AssertValidPropertyCacheHit(cx, obj, obj2, entry);
         if (!NativeGet(cx, obj, obj2, entry->prop, JSGET_CACHE_RESULT, vp))
             return false;
         return true;
     }
 
     RootedId id(cx, NameToId(name));
@@ -372,17 +372,17 @@ NameOperation(JSContext *cx, JSScript *s
      * before the global object.
      */
     if (js_CodeSpec[*pc].format & JOF_GNAME)
         obj = &obj->global();
 
     PropertyCacheEntry *entry;
     Rooted<JSObject*> obj2(cx);
     RootedPropertyName name(cx);
-    JS_PROPERTY_CACHE(cx).test(cx, pc, obj.reference(), obj2.reference(), entry, name.reference());
+    JS_PROPERTY_CACHE(cx).test(cx, pc, obj.get(), obj2.get(), entry, name.get());
     if (!name) {
         AssertValidPropertyCacheHit(cx, obj, obj2, entry);
         if (!NativeGet(cx, obj, obj2, entry->prop, 0, vp))
             return false;
         return true;
     }
 
     JSProperty *prop;
@@ -486,18 +486,18 @@ AddOperation(JSContext *cx, const Value 
         if (!js_ConcatenateXML(cx, &lhs.toObject(), &rhs.toObject(), res))
             return false;
         types::TypeScript::MonitorUnknown(cx);
     } else
 #endif
     {
         RootedValue lval_(cx, lhs);
         RootedValue rval_(cx, rhs);
-        Value &lval = lval_.reference();
-        Value &rval = rval_.reference();
+        Value &lval = lval_.get();
+        Value &rval = rval_.get();
 
         /*
          * If either operand is an object, any non-integer result must be
          * reported to inference.
          */
         bool lIsObject = lval.isObject(), rIsObject = rval.isObject();
 
         if (!ToPrimitive(cx, &lval))
@@ -543,52 +543,52 @@ AddOperation(JSContext *cx, const Value 
 
 static JS_ALWAYS_INLINE bool
 SubOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, Value *res)
 {
     double d1, d2;
     if (!ToNumber(cx, lhs, &d1) || !ToNumber(cx, rhs, &d2))
         return false;
     double d = d1 - d2;
-    if (!res->setNumber(d) && !(lhs.value().isDouble() || rhs.value().isDouble()))
+    if (!res->setNumber(d) && !(lhs.get().isDouble() || rhs.get().isDouble()))
         types::TypeScript::MonitorOverflow(cx);
     return true;
 }
 
 static JS_ALWAYS_INLINE bool
 MulOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, Value *res)
 {
     double d1, d2;
     if (!ToNumber(cx, lhs, &d1) || !ToNumber(cx, rhs, &d2))
         return false;
     double d = d1 * d2;
-    if (!res->setNumber(d) && !(lhs.value().isDouble() || rhs.value().isDouble()))
+    if (!res->setNumber(d) && !(lhs.get().isDouble() || rhs.get().isDouble()))
         types::TypeScript::MonitorOverflow(cx);
     return true;
 }
 
 static JS_ALWAYS_INLINE bool
 DivOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, Value *res)
 {
     double d1, d2;
     if (!ToNumber(cx, lhs, &d1) || !ToNumber(cx, rhs, &d2))
         return false;
     res->setNumber(NumberDiv(d1, d2));
 
-    if (d2 == 0 || (res->isDouble() && !(lhs.value().isDouble() || rhs.value().isDouble())))
+    if (d2 == 0 || (res->isDouble() && !(lhs.get().isDouble() || rhs.get().isDouble())))
         types::TypeScript::MonitorOverflow(cx);
     return true;
 }
 
 static JS_ALWAYS_INLINE bool
 ModOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, Value *res)
 {
     int32_t l, r;
-    if (lhs.value().isInt32() && rhs.value().isInt32() &&
-        (l = lhs.value().toInt32()) >= 0 && (r = rhs.value().toInt32()) > 0) {
+    if (lhs.get().isInt32() && rhs.get().isInt32() &&
+        (l = lhs.get().toInt32()) >= 0 && (r = rhs.get().toInt32()) > 0) {
         int32_t mod = l % r;
         res->setInt32(mod);
         return true;
     }
 
     double d1, d2;
     if (!ToNumber(cx, lhs, &d1) || !ToNumber(cx, rhs, &d2))
         return false;
@@ -773,18 +773,18 @@ SetObjectElementOperation(JSContext *cx,
 
     RootedValue tmp(cx, value);
     return obj->setGeneric(cx, obj, id, tmp.address(), strict);
 }
 
 #define RELATIONAL_OP(OP)                                                     \
     JS_BEGIN_MACRO                                                            \
         RootedValue lvalRoot(cx, lhs), rvalRoot(cx, rhs);                     \
-        Value &lval = lvalRoot.reference();                                   \
-        Value &rval = rvalRoot.reference();                                   \
+        Value &lval = lvalRoot.get();                                         \
+        Value &rval = rvalRoot.get();                                         \
         /* Optimize for two int-tagged operands (typical loop control). */    \
         if (lval.isInt32() && rval.isInt32()) {                               \
             *res = lval.toInt32() OP rval.toInt32();                          \
         } else {                                                              \
             if (!ToPrimitive(cx, JSTYPE_NUMBER, &lval))                       \
                 return false;                                                 \
             if (!ToPrimitive(cx, JSTYPE_NUMBER, &rval))                       \
                 return false;                                                 \
--- a/js/src/jsiter.h
+++ b/js/src/jsiter.h
@@ -241,34 +241,34 @@ class ForOfIterator {
     ForOfIterator &operator=(const ForOfIterator &) MOZ_DELETE;
 
   public:
     ForOfIterator(JSContext *cx, const Value &iterable)
         : cx(cx), iterator(cx, NULL), currentValue(cx), closed(false)
     {
         RootedValue iterv(cx, iterable);
         ok = ValueToIterator(cx, JSITER_FOR_OF, iterv.address());
-        iterator = ok ? &iterv.reference().toObject() : NULL;
+        iterator = ok ? &iterv.get().toObject() : NULL;
     }
 
     ~ForOfIterator() {
         if (!closed)
             close();
     }
 
     bool next() {
         JS_ASSERT(!closed);
         ok = ok && Next(cx, iterator, currentValue.address());
-        return ok && !currentValue.reference().isMagic(JS_NO_ITER_VALUE);
+        return ok && !currentValue.get().isMagic(JS_NO_ITER_VALUE);
     }
 
     Value &value() {
         JS_ASSERT(ok);
         JS_ASSERT(!closed);
-        return currentValue.reference();
+        return currentValue.get();
     }
 
     bool close() {
         JS_ASSERT(!closed);
         closed = true;
         if (!iterator)
             return false;
         bool throwing = cx->isExceptionPending();
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -162,17 +162,17 @@ MarkSharpObjects(JSContext *cx, HandleOb
 
     JSIdArray *ida;
 
     JSSharpObjectMap *map = &cx->sharpObjectMap;
     JS_ASSERT(map->depth >= 1);
     JSSharpInfo sharpid;
     JSSharpTable::Ptr p = map->table.lookup(obj);
     if (!p) {
-        if (!map->table.put(obj.value(), sharpid))
+        if (!map->table.put(obj.get(), sharpid))
             return false;
 
         ida = JS_Enumerate(cx, obj);
         if (!ida)
             return false;
 
         bool ok = true;
         RootedId id(cx);
@@ -182,18 +182,18 @@ MarkSharpObjects(JSContext *cx, HandleOb
             JSProperty *prop;
             ok = obj->lookupGeneric(cx, id, &obj2, &prop);
             if (!ok)
                 break;
             if (!prop)
                 continue;
             bool hasGetter, hasSetter;
             RootedValue valueRoot(cx), setterRoot(cx);
-            Value &value = valueRoot.reference();
-            Value &setter = setterRoot.reference();
+            Value &value = valueRoot.get();
+            Value &setter = setterRoot.get();
             if (obj2->isNative()) {
                 const Shape *shape = (Shape *) prop;
                 hasGetter = shape->hasGetterValue();
                 hasSetter = shape->hasSetterValue();
                 if (hasGetter)
                     value = shape->getterValue();
                 if (hasSetter)
                     setter = shape->setterValue();
@@ -289,17 +289,17 @@ js_EnterSharpObject(JSContext *cx, Handl
          * It's possible that the value of a property has changed from the
          * first time the object's properties are traversed (when the property
          * ids are entered into the hash table) to the second (when they are
          * converted to strings), i.e., the JSObject::getProperty() call is not
          * idempotent.
          */
         p = map->table.lookup(obj);
         if (!p) {
-            if (!map->table.put(obj.value(), sharpid))
+            if (!map->table.put(obj.get(), sharpid))
                 goto bad;
             goto out;
         }
         sharpid = p->value;
     }
 
     if (sharpid.isSharp || sharpid.hasGen)
         *alreadySeen = true;
@@ -4346,18 +4346,18 @@ js_FindClassObject(JSContext *cx, Handle
     RootedObject pobj(cx);
     if (!LookupPropertyWithFlags(cx, obj, id, 0, &pobj, &prop))
         return false;
     RootedValue v(cx, UndefinedValue());
     if (prop && pobj->isNative()) {
         shape = (Shape *) prop;
         if (shape->hasSlot()) {
             v = pobj->nativeGetSlot(shape->slot());
-            if (v.reference().isPrimitive())
-                v.reference().setUndefined();
+            if (v.get().isPrimitive())
+                v.get().setUndefined();
         }
     }
     vp.set(v);
     return true;
 }
 
 bool
 JSObject::allocSlot(JSContext *cx, uint32_t *slotp)
@@ -4775,17 +4775,17 @@ LookupPropertyWithFlagsInline(JSContext 
              * 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.value())
+                while ((proto = proto->getProto()) != objp)
                     JS_ASSERT(proto);
             }
 #endif
             return true;
         }
 
         current = proto;
     }
@@ -4942,17 +4942,17 @@ js::FindIdentifierBase(JSContext *cx, Ha
      * must not be passed a global object (i.e. one with null parent).
      */
     for (int scopeIndex = 0;
          obj->isGlobal() || IsCacheableNonGlobalScope(obj);
          scopeIndex++)
     {
         RootedObject pobj(cx);
         JSProperty *prop;
-        if (!LookupPropertyWithFlags(cx, obj, name.value(), cx->resolveFlags, &pobj, &prop))
+        if (!LookupPropertyWithFlags(cx, obj, name, cx->resolveFlags, &pobj, &prop))
             return NULL;
         if (prop) {
             if (!pobj->isNative()) {
                 JS_ASSERT(obj->isGlobal());
                 return obj;
             }
             JS_ASSERT_IF(obj->isScope(), pobj->getClass() == obj->getClass());
             JS_PROPERTY_CACHE(cx).fill(cx, scopeChain, scopeIndex, pobj, (Shape *) prop);
@@ -5849,22 +5849,22 @@ bool
 js::FindClassPrototype(JSContext *cx, HandleObject scopeobj, JSProtoKey protoKey,
                        MutableHandleObject protop, Class *clasp)
 {
     RootedValue v(cx);
     if (!js_FindClassObject(cx, scopeobj, protoKey, &v, clasp))
         return false;
 
     if (IsFunctionObject(v)) {
-        JSObject *ctor = &v.reference().toObject();
+        JSObject *ctor = &v.get().toObject();
         if (!ctor->getProperty(cx, cx->runtime->atomState.classPrototypeAtom, v.address()))
             return false;
     }
 
-    protop.set(v.reference().isObject() ? &v.reference().toObject() : NULL);
+    protop.set(v.get().isObject() ? &v.get().toObject() : NULL);
     return true;
 }
 
 /*
  * The first part of this function has been hand-expanded and optimized into
  * NewBuiltinClassInstance in jsobjinlines.h.
  */
 bool
--- a/js/src/json.cpp
+++ b/js/src/json.cpp
@@ -410,17 +410,17 @@ JO(JSContext *cx, HandleObject obj, Stri
          * handling boxed Number/String/Boolean objects; 3) filtering out
          * values which process to |undefined|, and 4) stringifying all values
          * which pass the filter.
          */
         id = propertyList[i];
         Value outputValue;
         if (!obj->getGeneric(cx, id, &outputValue))
             return false;
-        if (!PreprocessValue(cx, obj, id.reference(), &outputValue, scx))
+        if (!PreprocessValue(cx, obj, id.get(), &outputValue, scx))
             return false;
         if (IsFilteredValue(outputValue))
             continue;
 
         /* Output a comma unless this is the first member to write. */
         if (wroteMember && !scx->sb.append(','))
             return false;
         wroteMember = true;
@@ -581,17 +581,17 @@ Str(JSContext *cx, const Value &v, Strin
 }
 
 /* ES5 15.12.3. */
 JSBool
 js_Stringify(JSContext *cx, Value *vp, JSObject *replacer_, Value space_, StringBuffer &sb)
 {
     RootedObject replacer(cx, replacer_);
     RootedValue spaceRoot(cx, space_);
-    Value &space = spaceRoot.reference();
+    Value &space = spaceRoot.get();
 
     /* Step 4. */
     AutoIdVector propertyList(cx);
     if (replacer) {
         if (replacer->isCallable()) {
             /* Step 4a(i): use replacer to transform values.  */
         } else if (ObjectClassIs(*replacer, ESClass_Array, cx)) {
             /*
@@ -729,17 +729,17 @@ js_Stringify(JSContext *cx, Value *vp, J
         return false;
     }
 
     /* Step 11. */
     StringifyContext scx(cx, sb, gap, replacer, propertyList);
     if (!scx.init())
         return false;
 
-    if (!PreprocessValue(cx, wrapper, emptyId.reference(), vp, &scx))
+    if (!PreprocessValue(cx, wrapper, emptyId.get(), vp, &scx))
         return false;
     if (IsFilteredValue(*vp))
         return true;
 
     return Str(cx, *vp, &scx);
 }
 
 /* ES5 15.12.2 Walk. */
--- a/js/src/jsproxy.cpp
+++ b/js/src/jsproxy.cpp
@@ -786,32 +786,32 @@ ScriptedProxyHandler::getPropertyDescrip
                                             PropertyDescriptor *desc)
 {
     RootedId id(cx, id_);
     RootedObject proxy(cx, proxy_);
     RootedObject handler(cx, GetProxyHandlerObject(cx, proxy));
     RootedValue fval(cx), value(cx);
     return GetFundamentalTrap(cx, handler, ATOM(getPropertyDescriptor), fval.address()) &&
            Trap1(cx, handler, fval, id, value.address()) &&
-           ((value.reference().isUndefined() && IndicatePropertyNotFound(cx, desc)) ||
+           ((value.get().isUndefined() && IndicatePropertyNotFound(cx, desc)) ||
             (ReturnedValueMustNotBePrimitive(cx, proxy, ATOM(getPropertyDescriptor), value) &&
              ParsePropertyDescriptorObject(cx, proxy, id, value, desc)));
 }
 
 bool
 ScriptedProxyHandler::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id_, bool set,
                                                PropertyDescriptor *desc)
 {
     RootedId id(cx, id_);
     RootedObject proxy(cx, proxy_);
     RootedObject handler(cx, GetProxyHandlerObject(cx, proxy));
     RootedValue fval(cx), value(cx);
     return GetFundamentalTrap(cx, handler, ATOM(getOwnPropertyDescriptor), fval.address()) &&
            Trap1(cx, handler, fval, id, value.address()) &&
-           ((value.reference().isUndefined() && IndicatePropertyNotFound(cx, desc)) ||
+           ((value.get().isUndefined() && IndicatePropertyNotFound(cx, desc)) ||
             (ReturnedValueMustNotBePrimitive(cx, proxy, ATOM(getPropertyDescriptor), value) &&
              ParsePropertyDescriptorObject(cx, proxy, id, value, desc)));
 }
 
 bool
 ScriptedProxyHandler::defineProperty(JSContext *cx, JSObject *proxy, jsid id_,
                                      PropertyDescriptor *desc)
 {
--- a/js/src/jstypedarray.cpp
+++ b/js/src/jstypedarray.cpp
@@ -317,17 +317,17 @@ ArrayBufferObject::obj_lookupGeneric(JSC
      * Otherwise, if propp is non-null, the property
      * was found. Otherwise it was not
      * found so look in the prototype chain.
      */
     if (!delegateResult)
         return false;
 
     if (*propp != NULL) {
-        if (objp.value() == delegate)
+        if (objp == delegate)
             objp.set(obj);
         return true;
     }
 
     JSObject *proto = obj->getProto();
     if (!proto) {
         objp.set(NULL);
         *propp = NULL;
@@ -358,17 +358,17 @@ ArrayBufferObject::obj_lookupElement(JSC
      * Otherwise, if propp is non-null, the property
      * was found. Otherwise it was not
      * found so look in the prototype chain.
      */
     if (!delegate->lookupElement(cx, index, objp, propp))
         return false;
 
     if (*propp != NULL) {
-        if (objp.value() == delegate)
+        if (objp == delegate)
             objp.set(obj);
         return true;
     }
 
     if (JSObject *proto = obj->getProto())
         return proto->lookupElement(cx, index, objp, propp);
 
     objp.set(NULL);
--- a/js/src/jsxml.cpp
+++ b/js/src/jsxml.cpp
@@ -1661,21 +1661,21 @@ fail:
  */
 static JSBool
 GetXMLSetting(JSContext *cx, const char *name, jsval *vp)
 {
     RootedValue v(cx);
     RootedObject null(cx);
     if (!js_FindClassObject(cx, null, JSProto_XML, &v))
         return JS_FALSE;
-    if (v.reference().isPrimitive() || !v.reference().toObject().isFunction()) {
+    if (v.get().isPrimitive() || !v.get().toObject().isFunction()) {
         *vp = JSVAL_VOID;
         return JS_TRUE;
     }
-    return JS_GetProperty(cx, &v.reference().toObject(), name, vp);
+    return JS_GetProperty(cx, &v.get().toObject(), name, vp);
 }
 
 static JSBool
 GetBooleanXMLSetting(JSContext *cx, const char *name, JSBool *bp)
 {
     jsval v;
 
     return GetXMLSetting(cx, name, &v) && JS_ValueToBoolean(cx, v, bp);
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -5160,17 +5160,17 @@ mjit::Compiler::jsop_getprop_dispatch(Pr
      * the object being accessed. Return true if the CALLPROP has been fully
      * processed, false if no code was generated.
      */
     FrameEntry *top = frame.peek(-1);
     if (top->isNotType(JSVAL_TYPE_OBJECT))
         return false;
 
     RootedId id(cx, NameToId(name));
-    if (id.reference() != types::MakeTypeId(cx, id))
+    if (id.get() != types::MakeTypeId(cx, id))
         return false;
 
     types::TypeSet *pushedTypes = pushedTypeSet(0);
     if (pushedTypes->unknownObject() || pushedTypes->baseFlags() != 0)
         return false;
 
     /* Check every pushed value is a singleton. */
     for (unsigned i = 0; i < pushedTypes->getObjectCount(); i++) {
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -634,17 +634,17 @@ Debugger::wrapEnvironment(JSContext *cx,
     } else {
         /* Create a new Debugger.Environment for env. */
         JSObject *proto = &object->getReservedSlot(JSSLOT_DEBUG_ENV_PROTO).toObject();
         envobj = NewObjectWithGivenProto(cx, &DebuggerEnv_class, proto, NULL);
         if (!envobj)
             return false;
         envobj->setPrivate(env);
         envobj->setReservedSlot(JSSLOT_DEBUGENV_OWNER, ObjectValue(*object));
-        if (!environments.relookupOrAdd(p, env.value(), envobj)) {
+        if (!environments.relookupOrAdd(p, env, envobj)) {
             js_ReportOutOfMemory(cx);
             return false;
         }
 
         CrossCompartmentKey key(CrossCompartmentKey::DebuggerEnvironment, object, env);
         if (!object->compartment()->crossCompartmentWrappers.put(key, ObjectValue(*envobj))) {
             environments.remove(env);
             js_ReportOutOfMemory(cx);
@@ -1811,17 +1811,17 @@ Debugger::construct(JSContext *cx, unsig
      * the reserved slots are for hooks; they default to undefined.
      */
     RootedObject obj(cx, NewObjectWithGivenProto(cx, &Debugger::jsclass, proto, NULL));
     if (!obj)
         return false;
     for (unsigned slot = JSSLOT_DEBUG_PROTO_START; slot < JSSLOT_DEBUG_PROTO_STOP; slot++)
         obj->setReservedSlot(slot, proto->getReservedSlot(slot));
 
-    Debugger *dbg = cx->new_<Debugger>(cx, obj.reference());
+    Debugger *dbg = cx->new_<Debugger>(cx, obj.get());
     if (!dbg)
         return false;
     obj->setPrivate(dbg);
     if (!dbg->init(cx)) {
         cx->delete_(dbg);
         return false;
     }
 
@@ -3224,17 +3224,17 @@ DebuggerFrame_getArguments(JSContext *cx
             RootedFunction getobj(cx);
             getobj = js_NewFunction(cx, NULL, DebuggerArguments_getArg, 0, 0, global, NULL,
                                     JSFunction::ExtendedFinalizeKind);
             if (!getobj)
                 return false;
             id = INT_TO_JSID(i);
             if (!getobj ||
                 !DefineNativeProperty(cx, argsobj, id, UndefinedValue(),
-                                      JS_DATA_TO_FUNC_PTR(PropertyOp, getobj.reference()), NULL,
+                                      JS_DATA_TO_FUNC_PTR(PropertyOp, getobj.get()), NULL,
                                       JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_GETTER, 0, 0))
             {
                 return false;
             }
             getobj->setExtendedSlot(0, Int32Value(i));
         }
     } else {
         argsobj = NULL;
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -390,17 +390,17 @@ CreateBlankProto(JSContext *cx, Class *c
 JSObject *
 GlobalObject::createBlankPrototype(JSContext *cx, Class *clasp)
 {
     Rooted<GlobalObject*> self(cx, this);
     JSObject *objectProto = getOrCreateObjectPrototype(cx);
     if (!objectProto)
         return NULL;
 
-    return CreateBlankProto(cx, clasp, *objectProto, *self.reference());
+    return CreateBlankProto(cx, clasp, *objectProto, *self.get());
 }
 
 JSObject *
 GlobalObject::createBlankPrototypeInheriting(JSContext *cx, Class *clasp, JSObject &proto)
 {
     return CreateBlankProto(cx, clasp, proto, *this);
 }
 
--- a/js/src/vm/ObjectImpl.cpp
+++ b/js/src/vm/ObjectImpl.cpp
@@ -493,29 +493,29 @@ js::GetOwnProperty(JSContext *cx, Handle
                    PropDesc *desc)
 {
     NEW_OBJECT_REPRESENTATION_ONLY();
 
     JS_CHECK_RECURSION(cx, return false);
 
     Rooted<PropertyId> pid(cx, pid_);
 
-    if (static_cast<JSObject *>(obj.value())->isProxy()) {
+    if (static_cast<JSObject *>(obj.get())->isProxy()) {
         MOZ_NOT_REACHED("NYI: proxy [[GetOwnProperty]]");
         return false;
     }
 
     const Shape *shape = obj->nativeLookup(cx, pid);
     if (!shape) {
         /* Not found: attempt to resolve it. */
         Class *clasp = obj->getClass();
         JSResolveOp resolve = clasp->resolve;
         if (resolve != JS_ResolveStub) {
-            Rooted<jsid> id(cx, pid.reference().asId());
-            Rooted<JSObject*> robj(cx, static_cast<JSObject*>(obj.value()));
+            Rooted<jsid> id(cx, pid.get().asId());
+            Rooted<JSObject*> robj(cx, static_cast<JSObject*>(obj.get()));
             if (clasp->flags & JSCLASS_NEW_RESOLVE) {
                 Rooted<JSObject*> obj2(cx, NULL);
                 JSNewResolveOp op = reinterpret_cast<JSNewResolveOp>(resolve);
                 if (!op(cx, robj, id, resolveFlags, &obj2))
                     return false;
             } else {
                 if (!resolve(cx, robj, id))
                     return false;
--- a/js/src/vm/RegExpObject.cpp
+++ b/js/src/vm/RegExpObject.cpp
@@ -73,17 +73,17 @@ RegExpObjectBuilder::build(HandleAtom so
 }
 
 RegExpObject *
 RegExpObjectBuilder::build(HandleAtom source, RegExpFlag flags)
 {
     if (!getOrCreate())
         return NULL;
 
-    return reobj_->init(cx, source, flags) ? reobj_.raw() : NULL;
+    return reobj_->init(cx, source, flags) ? reobj_.get() : NULL;
 }
 
 RegExpObject *
 RegExpObjectBuilder::clone(Handle<RegExpObject *> other, Handle<RegExpObject *> proto)
 {
     if (!getOrCreateClone(proto))
         return NULL;
 
--- a/js/src/vm/ScopeObject.cpp
+++ b/js/src/vm/ScopeObject.cpp
@@ -1432,17 +1432,17 @@ DebugScopeObject::create(JSContext *cx, 
 {
     JSObject *obj = NewProxyObject(cx, &DebugScopeProxy::singleton, ObjectValue(scope),
                                    NULL /* proto */, &scope.global(),
                                    NULL /* call */, NULL /* construct */);
     if (!obj)
         return NULL;
 
     JS_ASSERT(!enclosing->isScope());
-    SetProxyExtra(obj, ENCLOSING_EXTRA, ObjectValue(*enclosing.value()));
+    SetProxyExtra(obj, ENCLOSING_EXTRA, ObjectValue(*enclosing));
 
     return &obj->asDebugScope();
 }
 
 ScopeObject &
 DebugScopeObject::scope() const
 {
     return GetProxyTargetObject(this)->asScope();