mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 784400 - Make standard builtins and the current global available to self-hosted code. r=bhackett
--HG-- extra : rebase_source : 19acba6e9b53127f917787036b0dfd672ea34edd
This commit is contained in:
parent
7a64c4d595
commit
e82a228562
@ -5023,6 +5023,13 @@ JS_DefineFunctions(JSContext *cx, JSObject *objArg, JSFunctionSpec *fs)
|
||||
fun->setExtendedSlot(0, PrivateValue(fs));
|
||||
}
|
||||
|
||||
/*
|
||||
* During creation of the self-hosting global, we ignore all
|
||||
* self-hosted functions.
|
||||
*/
|
||||
if (fs->selfHostedName && cx->runtime->isSelfHostedGlobal(cx->global()))
|
||||
return JS_TRUE;
|
||||
|
||||
fun = js_DefineFunction(cx, obj, id, fs->call.op, fs->nargs, flags, fs->selfHostedName);
|
||||
if (!fun)
|
||||
return JS_FALSE;
|
||||
|
@ -259,6 +259,12 @@ JSRuntime::initSelfHosting(JSContext *cx)
|
||||
return false;
|
||||
JS_SetGlobalObject(cx, selfHostedGlobal_);
|
||||
|
||||
AutoCompartment ac(cx, cx->global());
|
||||
RootedObject shg(cx, selfHostedGlobal_);
|
||||
|
||||
if (!JS_InitStandardClasses(cx, shg))
|
||||
return false;
|
||||
|
||||
const char *src = selfhosted::raw_sources;
|
||||
uint32_t srcLen = selfhosted::GetRawScriptsSize();
|
||||
|
||||
@ -266,7 +272,6 @@ JSRuntime::initSelfHosting(JSContext *cx)
|
||||
options.setFileAndLine("self-hosted", 1);
|
||||
options.setSelfHostingMode(true);
|
||||
|
||||
RootedObject shg(cx, selfHostedGlobal_);
|
||||
Value rv;
|
||||
/*
|
||||
* Set a temporary error reporter printing to stderr because it is too
|
||||
|
@ -441,6 +441,9 @@ struct JSRuntime : js::RuntimeFriendFields
|
||||
|
||||
bool initSelfHosting(JSContext *cx);
|
||||
void markSelfHostedGlobal(JSTracer *trc);
|
||||
bool isSelfHostedGlobal(js::HandleObject global) {
|
||||
return global == selfHostedGlobal_;
|
||||
}
|
||||
JSFunction *getSelfHostedFunction(JSContext *cx, const char *name);
|
||||
bool cloneSelfHostedValueById(JSContext *cx, jsid id, js::HandleObject holder, js::Value *vp);
|
||||
|
||||
|
@ -1514,6 +1514,7 @@ js_DefineFunction(JSContext *cx, HandleObject obj, HandleId id, Native native,
|
||||
kind);
|
||||
} else {
|
||||
JS_ASSERT(attrs & JSFUN_INTERPRETED);
|
||||
JS_ASSERT(!cx->runtime->isSelfHostedGlobal(cx->global()));
|
||||
fun = cx->runtime->getSelfHostedFunction(cx, selfHostedName);
|
||||
fun->initAtom(JSID_TO_ATOM(id));
|
||||
}
|
||||
|
@ -454,6 +454,14 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
|
||||
self->setIntrinsicsHolder(intrinsicsHolder);
|
||||
if (!JS_DefineFunctions(cx, intrinsicsHolder, intrinsic_functions))
|
||||
return NULL;
|
||||
/* Define a property 'global' with the current global as its value. */
|
||||
RootedValue global(cx, OBJECT_TO_JSVAL(self));
|
||||
if (!JSObject::defineProperty(cx, intrinsicsHolder, cx->runtime->atomState.globalAtom,
|
||||
global, JS_PropertyStub, JS_StrictPropertyStub,
|
||||
JSPROP_PERMANENT | JSPROP_READONLY))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* The global object should have |Object.prototype| as its [[Prototype]].
|
||||
|
Loading…
Reference in New Issue
Block a user