Bug 1067459 - Only install a small subset of the standard builtins in the self-hosting global. r=jorendorff

This commit is contained in:
Till Schneidereit
2014-09-16 10:01:09 -04:00
parent 4bc1651a64
commit ebd2949f9f
24 changed files with 323 additions and 169 deletions

View File

@@ -136,7 +136,8 @@ FinishObjectClassInit(JSContext *cx, JS::HandleObject ctor, JS::HandleObject pro
self->setOriginalEval(evalobj);
RootedObject intrinsicsHolder(cx);
if (cx->runtime()->isSelfHostingGlobal(self)) {
bool isSelfHostingGlobal = cx->runtime()->isSelfHostingGlobal(self);
if (isSelfHostingGlobal) {
intrinsicsHolder = self;
} else {
intrinsicsHolder = NewObjectWithGivenProto(cx, &JSObject::class_, proto, self,
@@ -158,8 +159,10 @@ FinishObjectClassInit(JSContext *cx, JS::HandleObject ctor, JS::HandleObject pro
* Define self-hosted functions after setting the intrinsics holder
* (which is needed to define self-hosted functions)
*/
if (!JS_DefineFunctions(cx, ctor, object_static_selfhosted_methods))
return false;
if (!isSelfHostingGlobal) {
if (!JS_DefineFunctions(cx, ctor, object_static_selfhosted_methods))
return false;
}
/*
* The global object should have |Object.prototype| as its [[Prototype]].