Bug 972087 - Don't store self-hosting name on clones of intrinsic functions. r=jorendorff

This commit is contained in:
Till Schneidereit 2014-02-28 16:04:37 +13:00
parent 4757cb31a4
commit 9dece28c31

View File

@ -1013,16 +1013,19 @@ CloneObject(JSContext *cx, JSObject *selfHostedObject, CloneMemory &clonedObject
RootedObject clone(cx);
if (selfHostedObject->is<JSFunction>()) {
JSFunction *selfHostedFunction = &selfHostedObject->as<JSFunction>();
bool hasName = selfHostedFunction->atom() != nullptr;
js::gc::AllocKind kind = hasName
bool needsName = selfHostedFunction->isInterpreted() &&
selfHostedFunction->atom() != nullptr;
js::gc::AllocKind kind = needsName
? JSFunction::ExtendedFinalizeKind
: selfHostedFunction->getAllocKind();
clone = CloneFunctionObject(cx, HandleFunction::fromMarkedLocation(&selfHostedFunction),
cx->global(), kind, TenuredObject);
// To be able to re-lazify the cloned function, its name in the
// self-hosting compartment has to be stored on the clone.
if (clone && hasName)
// To be able to re-lazify cloned interpreted functions, their name in
// the self-hosting compartment has to be stored on the clone.
if (clone && needsName) {
JS_ASSERT(clone->as<JSFunction>().isSelfHostedBuiltin());
clone->as<JSFunction>().setExtendedSlot(0, StringValue(selfHostedFunction->atom()));
}
} else if (selfHostedObject->is<RegExpObject>()) {
RegExpObject &reobj = selfHostedObject->as<RegExpObject>();
RootedAtom source(cx, reobj.getSource());