mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 969786: Record the introduction script in ScriptSourceObjects. r=sfink
This commit is contained in:
parent
5b59ee81f5
commit
d7f4619dde
@ -1269,6 +1269,31 @@ ScriptSourceObject::elementAttributeName() const
|
||||
return prop;
|
||||
}
|
||||
|
||||
void
|
||||
ScriptSourceObject::initIntroductionScript(JSScript *script)
|
||||
{
|
||||
JS_ASSERT(!getReservedSlot(INTRODUCTION_SCRIPT_SLOT).toPrivate());
|
||||
|
||||
// There is no equivalent of cross-compartment wrappers for scripts. If
|
||||
// the introduction script would be in a different compartment from the
|
||||
// compiled code, we would be creating a cross-compartment script
|
||||
// reference, which would be bogus. In that case, just don't bother to
|
||||
// retain the introduction script.
|
||||
if (script && script->compartment() == compartment())
|
||||
setReservedSlot(INTRODUCTION_SCRIPT_SLOT, PrivateValue(script));
|
||||
}
|
||||
|
||||
void
|
||||
ScriptSourceObject::trace(JSTracer *trc, JSObject *obj)
|
||||
{
|
||||
ScriptSourceObject *sso = static_cast<ScriptSourceObject *>(obj);
|
||||
|
||||
if (JSScript *script = sso->introductionScript()) {
|
||||
MarkScriptUnbarriered(trc, &script, "ScriptSourceObject introductionScript");
|
||||
sso->setReservedSlot(INTRODUCTION_SCRIPT_SLOT, PrivateValue(script));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ScriptSourceObject::finalize(FreeOp *fop, JSObject *obj)
|
||||
{
|
||||
@ -1287,7 +1312,11 @@ const Class ScriptSourceObject::class_ = {
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
ScriptSourceObject::finalize
|
||||
finalize,
|
||||
nullptr, /* call */
|
||||
nullptr, /* hasInstance */
|
||||
nullptr, /* construct */
|
||||
trace
|
||||
};
|
||||
|
||||
ScriptSourceObject *
|
||||
@ -1307,6 +1336,9 @@ ScriptSourceObject::create(ExclusiveContext *cx, ScriptSource *source,
|
||||
else
|
||||
sourceObject->initSlot(ELEMENT_PROPERTY_SLOT, UndefinedValue());
|
||||
|
||||
sourceObject->initSlot(INTRODUCTION_SCRIPT_SLOT, PrivateValue(nullptr));
|
||||
sourceObject->initIntroductionScript(options.introductionScript());
|
||||
|
||||
return sourceObject;
|
||||
}
|
||||
|
||||
|
@ -557,6 +557,7 @@ class ScriptSourceObject : public JSObject
|
||||
public:
|
||||
static const Class class_;
|
||||
|
||||
static void trace(JSTracer *trc, JSObject *obj);
|
||||
static void finalize(FreeOp *fop, JSObject *obj);
|
||||
static ScriptSourceObject *create(ExclusiveContext *cx, ScriptSource *source,
|
||||
const ReadOnlyCompileOptions &options);
|
||||
@ -571,11 +572,18 @@ class ScriptSourceObject : public JSObject
|
||||
void initElement(HandleObject element);
|
||||
const Value &elementAttributeName() const;
|
||||
|
||||
JSScript *introductionScript() const {
|
||||
void *untyped = getReservedSlot(INTRODUCTION_SCRIPT_SLOT).toPrivate();
|
||||
return static_cast<JSScript *>(untyped);
|
||||
}
|
||||
void initIntroductionScript(JSScript *script);
|
||||
|
||||
private:
|
||||
static const uint32_t SOURCE_SLOT = 0;
|
||||
static const uint32_t ELEMENT_SLOT = 1;
|
||||
static const uint32_t ELEMENT_PROPERTY_SLOT = 2;
|
||||
static const uint32_t RESERVED_SLOTS = 3;
|
||||
static const uint32_t INTRODUCTION_SCRIPT_SLOT = 3;
|
||||
static const uint32_t RESERVED_SLOTS = 4;
|
||||
};
|
||||
|
||||
enum GeneratorKind { NotGenerator, LegacyGenerator, StarGenerator };
|
||||
|
@ -177,8 +177,9 @@ ParseTask::ParseTask(ExclusiveContext *cx, JSObject *exclusiveContextGlobal, JSC
|
||||
JS::OffThreadCompileCallback callback, void *callbackData)
|
||||
: cx(cx), options(initCx), chars(chars), length(length),
|
||||
alloc(JSRuntime::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE), scopeChain(initCx, scopeChain),
|
||||
exclusiveContextGlobal(initCx, exclusiveContextGlobal), optionsElement(initCx), callback(callback),
|
||||
callbackData(callbackData), script(nullptr), errors(cx), overRecursed(false)
|
||||
exclusiveContextGlobal(initCx, exclusiveContextGlobal), optionsElement(initCx),
|
||||
optionsIntroductionScript(initCx), callback(callback), callbackData(callbackData),
|
||||
script(nullptr), errors(cx), overRecursed(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -192,6 +193,8 @@ ParseTask::init(JSContext *cx, const ReadOnlyCompileOptions &options)
|
||||
// point at while it's in the compilation's temporary compartment.
|
||||
optionsElement = this->options.element();
|
||||
this->options.setElement(nullptr);
|
||||
optionsIntroductionScript = this->options.introductionScript();
|
||||
this->options.setIntroductionScript(nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -211,6 +214,7 @@ ParseTask::finish()
|
||||
// was in the temporary compartment.
|
||||
ScriptSourceObject &sso = script->sourceObject()->as<ScriptSourceObject>();
|
||||
sso.initElement(optionsElement);
|
||||
sso.initIntroductionScript(optionsIntroductionScript);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -405,6 +405,7 @@ struct ParseTask
|
||||
// at that point would create cross-compartment references. Instead we
|
||||
// hold them here, and install them after merging the compartments.
|
||||
PersistentRootedObject optionsElement;
|
||||
PersistentRootedScript optionsIntroductionScript;
|
||||
|
||||
// Callback invoked off the main thread when the parse finishes.
|
||||
JS::OffThreadCompileCallback callback;
|
||||
|
Loading…
Reference in New Issue
Block a user