Skip to content

Commit

Permalink
Backout 1c5a8d617bff (bug 765990), 617cb36ead59, b3067d05a76a (bug 76…
Browse files Browse the repository at this point in the history
…0995), 79f9a61a1e43 (bug 426163) for bustage
  • Loading branch information
Ed Morley committed Jun 21, 2012
1 parent 7eb690c commit 141bb38
Show file tree
Hide file tree
Showing 47 changed files with 469 additions and 712 deletions.
4 changes: 2 additions & 2 deletions dom/base/nsDOMWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1825,13 +1825,13 @@ nsDOMWindowUtils::GetParent(const JS::Value& aObject,
return NS_ERROR_XPC_BAD_CONVERT_JS;
}

JS::Rooted<JSObject*> parent(aCx, JS_GetParent(JSVAL_TO_OBJECT(aObject)));
JSObject* parent = JS_GetParent(JSVAL_TO_OBJECT(aObject));
*aParent = OBJECT_TO_JSVAL(parent);

// Outerize if necessary.
if (parent) {
if (JSObjectOp outerize = js::GetObjectClass(parent)->ext.outerObject) {
*aParent = OBJECT_TO_JSVAL(outerize(aCx, parent));
*aParent = OBJECT_TO_JSVAL(outerize(aCx, JS::RootedObject(aCx, parent)));
}
}

Expand Down
8 changes: 4 additions & 4 deletions js/src/builtin/MapObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ JSFunctionSpec MapObject::methods[] = {
JSObject *
MapObject::initClass(JSContext *cx, JSObject *obj)
{
Rooted<GlobalObject*> global(cx, &obj->asGlobal());
return InitClass(cx, global, &class_, JSProto_Map, construct, methods);
return InitClass(cx, Rooted<GlobalObject*>(cx, &obj->asGlobal()),
&class_, JSProto_Map, construct, methods);
}

void
Expand Down Expand Up @@ -348,8 +348,8 @@ JSFunctionSpec SetObject::methods[] = {
JSObject *
SetObject::initClass(JSContext *cx, JSObject *obj)
{
Rooted<GlobalObject*> global(cx, &obj->asGlobal());
return InitClass(cx, global, &class_, JSProto_Set, construct, methods);
return InitClass(cx, Rooted<GlobalObject*>(cx, &obj->asGlobal()),
&class_, JSProto_Set, construct, methods);
}

void
Expand Down
20 changes: 8 additions & 12 deletions js/src/builtin/RegExp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class RegExpMatchBuilder
JSContext * const cx;
RootedObject array;

bool setProperty(Handle<PropertyName*> name, Value v) {
return !!baseops::DefineProperty(cx, array, name, &v,
bool setProperty(JSAtom *name, Value v) {
return !!baseops::DefineProperty(cx, array, RootedId(cx, AtomToId(name)), &v,
JS_PropertyStub, JS_StrictPropertyStub, JSPROP_ENUMERATE);
}

Expand All @@ -38,14 +38,12 @@ class RegExpMatchBuilder
}

bool setIndex(int index) {
Rooted<PropertyName*> name(cx, cx->runtime->atomState.indexAtom);
return setProperty(name, Int32Value(index));
return setProperty(cx->runtime->atomState.indexAtom, Int32Value(index));
}

bool setInput(JSString *str) {
JS_ASSERT(str);
Rooted<PropertyName*> name(cx, cx->runtime->atomState.inputAtom);
return setProperty(name, StringValue(str));
return setProperty(cx->runtime->atomState.inputAtom, StringValue(str));
}
};

Expand Down Expand Up @@ -196,8 +194,8 @@ CompileRegExpObject(JSContext *cx, RegExpObjectBuilder &builder, CallArgs args)
{
if (args.length() == 0) {
RegExpStatics *res = cx->regExpStatics();
Rooted<PropertyName*> empty(cx, cx->runtime->emptyString);
RegExpObject *reobj = builder.build(empty, res->getFlags());
RegExpObject *reobj = builder.build(RootedAtom(cx, cx->runtime->emptyString),
res->getFlags());
if (!reobj)
return false;
args.rval() = ObjectValue(*reobj);
Expand Down Expand Up @@ -244,8 +242,7 @@ CompileRegExpObject(JSContext *cx, RegExpObjectBuilder &builder, CallArgs args)
if (!sourceObj.getProperty(cx, cx->runtime->atomState.sourceAtom, &v))
return false;

Rooted<JSAtom*> sourceAtom(cx, &v.toString()->asAtom());
RegExpObject *reobj = builder.build(sourceAtom, flags);
RegExpObject *reobj = builder.build(RootedAtom(cx, &v.toString()->asAtom()), flags);
if (!reobj)
return false;

Expand Down Expand Up @@ -465,8 +462,7 @@ js_InitRegExpClass(JSContext *cx, JSObject *obj)
proto->setPrivate(NULL);

RegExpObjectBuilder builder(cx, &proto->asRegExp());
Rooted<PropertyName*> empty(cx, cx->runtime->emptyString);
if (!builder.build(empty, RegExpFlag(0)))
if (!builder.build(RootedAtom(cx, cx->runtime->emptyString), RegExpFlag(0)))
return NULL;

if (!DefinePropertiesAndBrand(cx, proto, NULL, regexp_methods))
Expand Down
4 changes: 2 additions & 2 deletions js/src/frontend/BytecodeEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5614,8 +5614,8 @@ EmitObject(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)

if (obj) {
JS_ASSERT(!obj->inDictionaryMode());
Rooted<jsid> id(cx, AtomToId(pn3->pn_atom));
if (!DefineNativeProperty(cx, obj, id, UndefinedValue(), NULL, NULL,
if (!DefineNativeProperty(cx, obj, RootedId(cx, AtomToId(pn3->pn_atom)),
UndefinedValue(), NULL, NULL,
JSPROP_ENUMERATE, 0, 0))
{
return false;
Expand Down
9 changes: 4 additions & 5 deletions js/src/frontend/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,7 @@ BindLocalVariable(JSContext *cx, TreeContext *tc, ParseNode *pn, BindingKind kin
JS_ASSERT(kind == VARIABLE || kind == CONSTANT);

unsigned index = tc->sc->bindings.numVars();
Rooted<JSAtom*> atom(cx, pn->pn_atom);
if (!tc->sc->bindings.add(cx, atom, kind))
if (!tc->sc->bindings.add(cx, RootedAtom(cx, pn->pn_atom), kind))
return false;

if (!pn->pn_cookie.set(cx, tc->staticLevel, index))
Expand Down Expand Up @@ -605,7 +604,7 @@ Parser::functionBody(FunctionBodyType type)
if (!CheckStrictParameters(context, this))
return NULL;

Rooted<PropertyName*> arguments(context, context->runtime->atomState.argumentsAtom);
Rooted<PropertyName*> const arguments(context, context->runtime->atomState.argumentsAtom);

/*
* Non-top-level functions use JSOP_DEFFUN which is a dynamic scope
Expand Down Expand Up @@ -6852,8 +6851,8 @@ Parser::primaryExpr(TokenKind tt, bool afterDoubleDot)
pn->pn_xflags |= PNX_NONCONST;

/* NB: Getter function in { get x(){} } is unnamed. */
Rooted<PropertyName*> funName(context, NULL);
pn2 = functionDef(funName, op == JSOP_GETTER ? Getter : Setter, Expression);
pn2 = functionDef(RootedPropertyName(context, NULL),
op == JSOP_GETTER ? Getter : Setter, Expression);
if (!pn2)
return NULL;
TokenPos pos = {begin, pn2->pn_pos.end};
Expand Down
13 changes: 11 additions & 2 deletions js/src/gc/Root.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Handle
* Construct a handle from an explicitly rooted location. This is the
* normal way to create a handle, and normally happens implicitly.
*/
template <typename S> inline Handle(Rooted<S> &root);
template <typename S> inline Handle(const Rooted<S> &root);

const T *address() const { return ptr; }
T value() const { return *ptr; }
Expand Down Expand Up @@ -163,6 +163,15 @@ class Rooted
Rooted(JSContext *cx) { init(cx, RootMethods<T>::initial()); }
Rooted(JSContext *cx, T initial) { init(cx, initial); }

/*
* This method is only necessary due to an obscure C++98 requirement (that
* there be an accessible, usable copy constructor when passing a temporary
* to an implicitly-called constructor for use with a const-ref parameter).
* (Head spinning yet?) We can remove this when we build the JS engine
* with -std=c++11.
*/
operator Handle<T> () const { return Handle<T>(*this); }

~Rooted()
{
#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING)
Expand Down Expand Up @@ -208,7 +217,7 @@ class Rooted

template<typename T> template <typename S>
inline
Handle<T>::Handle(Rooted<S> &root)
Handle<T>::Handle(const Rooted<S> &root)
{
testAssign<S>();
ptr = reinterpret_cast<const T *>(root.address());
Expand Down
Loading

0 comments on commit 141bb38

Please sign in to comment.