Bug 907937 - Inline jsval wrapping overload. r=billm

This thing is small enough now that it can be inlined. This is already a significant
win because primitive jsval wrapping is now entirely inlined.
This commit is contained in:
Bobby Holley 2013-08-22 12:40:31 -07:00
parent 1e989152b6
commit e6a0bd3c95
2 changed files with 27 additions and 28 deletions

View File

@ -202,33 +202,6 @@ JSCompartment::putWrapper(const CrossCompartmentKey &wrapped, const js::Value &w
return crossCompartmentWrappers.put(wrapped, wrapper);
}
bool
JSCompartment::wrap(JSContext *cx, MutableHandleValue vp, HandleObject existingArg)
{
JS_ASSERT_IF(existingArg, vp.isObject());
/* Only GC things have to be wrapped or copied. */
if (!vp.isMarkable())
return true;
/* Handle strings. */
if (vp.isString()) {
JSString *str = vp.toString();
if (!wrap(cx, &str))
return false;
vp.setString(str);
return true;
}
/* All that's left are objects. */
MOZ_ASSERT(vp.isObject());
RootedObject obj(cx, &vp.toObject());
if (!wrap(cx, &obj, existingArg))
return false;
vp.setObject(*obj);
return true;
}
bool
JSCompartment::wrap(JSContext *cx, JSString **strp)
{

View File

@ -281,7 +281,33 @@ struct JSCompartment
void markCrossCompartmentWrappers(JSTracer *trc);
void markAllCrossCompartmentWrappers(JSTracer *trc);
bool wrap(JSContext *cx, JS::MutableHandleValue vp, JS::HandleObject existing = js::NullPtr());
inline bool wrap(JSContext *cx, JS::MutableHandleValue vp,
JS::HandleObject existing = js::NullPtr())
{
JS_ASSERT_IF(existing, vp.isObject());
/* Only GC things have to be wrapped or copied. */
if (!vp.isMarkable())
return true;
/* Handle strings. */
if (vp.isString()) {
JSString *str = vp.toString();
if (!wrap(cx, &str))
return false;
vp.setString(str);
return true;
}
/* All that's left are objects. */
MOZ_ASSERT(vp.isObject());
JS::RootedObject obj(cx, &vp.toObject());
if (!wrap(cx, &obj, existing))
return false;
vp.setObject(*obj);
return true;
}
bool wrap(JSContext *cx, JSString **strp);
bool wrap(JSContext *cx, js::HeapPtrString *strp);
bool wrap(JSContext *cx, JS::MutableHandleObject obj,