mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 880917 - Remove JS_SetVersion and version override machinery. r=luke
\o/
This commit is contained in:
parent
dc72ab031b
commit
4487e98c37
@ -125,38 +125,26 @@ JS::detail::CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl
|
||||
|
||||
/*
|
||||
* This class is a version-establishing barrier at the head of a VM entry or
|
||||
* re-entry. It ensures that:
|
||||
*
|
||||
* - |newVersion| is the starting (default) version used for the context.
|
||||
* - The starting version state is not an override.
|
||||
* - Overrides in the VM session are not propagated to the caller.
|
||||
* re-entry. It ensures that |newVersion| is the starting (default) version
|
||||
* used for the context.
|
||||
*/
|
||||
class AutoVersionAPI
|
||||
{
|
||||
JSContext * const cx;
|
||||
JSVersion oldDefaultVersion;
|
||||
bool oldHasVersionOverride;
|
||||
JSVersion oldVersionOverride;
|
||||
JSVersion newVersion;
|
||||
|
||||
public:
|
||||
AutoVersionAPI(JSContext *cx, JSVersion newVersion)
|
||||
: cx(cx),
|
||||
oldDefaultVersion(cx->getDefaultVersion()),
|
||||
oldHasVersionOverride(cx->isVersionOverridden()),
|
||||
oldVersionOverride(oldHasVersionOverride ? cx->findVersion() : JSVERSION_UNKNOWN)
|
||||
oldDefaultVersion(cx->getDefaultVersion())
|
||||
{
|
||||
this->newVersion = newVersion;
|
||||
cx->clearVersionOverride();
|
||||
cx->setDefaultVersion(newVersion);
|
||||
}
|
||||
|
||||
~AutoVersionAPI() {
|
||||
cx->setDefaultVersion(oldDefaultVersion);
|
||||
if (oldHasVersionOverride)
|
||||
cx->overrideVersion(oldVersionOverride);
|
||||
else
|
||||
cx->clearVersionOverride();
|
||||
}
|
||||
|
||||
/* The version that this scoped-entity establishes. */
|
||||
@ -1340,23 +1328,6 @@ JS_GetVersion(JSContext *cx)
|
||||
return VersionNumber(cx->findVersion());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSVersion)
|
||||
JS_SetVersion(JSContext *cx, JSVersion newVersion)
|
||||
{
|
||||
JS_ASSERT(VersionIsKnown(newVersion));
|
||||
JS_ASSERT(!VersionHasFlags(newVersion));
|
||||
JSVersion newVersionNumber = newVersion;
|
||||
|
||||
JSVersion oldVersion = cx->findVersion();
|
||||
JSVersion oldVersionNumber = VersionNumber(oldVersion);
|
||||
if (oldVersionNumber == newVersionNumber)
|
||||
return oldVersionNumber; /* No override actually occurs! */
|
||||
|
||||
VersionCopyFlags(&newVersion, oldVersion);
|
||||
cx->maybeOverrideVersion(newVersion);
|
||||
return oldVersionNumber;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_SetVersionForCompartment(JSCompartment *compartment, JSVersion version)
|
||||
{
|
||||
|
@ -1890,9 +1890,6 @@ JS_ContextIterator(JSRuntime *rt, JSContext **iterp);
|
||||
extern JS_PUBLIC_API(JSVersion)
|
||||
JS_GetVersion(JSContext *cx);
|
||||
|
||||
extern JS_PUBLIC_API(JSVersion)
|
||||
JS_SetVersion(JSContext *cx, JSVersion version);
|
||||
|
||||
// Mutate the version on the compartment. This is generally discouraged, but
|
||||
// necessary to support the version mutation in the js and xpc shell command
|
||||
// set.
|
||||
|
@ -1121,7 +1121,6 @@ js_HandleExecutionInterrupt(JSContext *cx)
|
||||
JSContext::JSContext(JSRuntime *rt)
|
||||
: ContextFriendFields(rt),
|
||||
defaultVersion(JSVERSION_DEFAULT),
|
||||
hasVersionOverride(false),
|
||||
throwing(false),
|
||||
exception(UndefinedValue()),
|
||||
options_(0),
|
||||
|
@ -1535,8 +1535,6 @@ struct JSContext : js::ContextFriendFields,
|
||||
private:
|
||||
/* See JSContext::findVersion. */
|
||||
JSVersion defaultVersion; /* script compilation version */
|
||||
JSVersion versionOverride; /* supercedes defaultVersion when valid */
|
||||
bool hasVersionOverride;
|
||||
|
||||
/* Exception state -- the exception member is a GC root by definition. */
|
||||
bool throwing; /* is there a pending exception? */
|
||||
@ -1646,50 +1644,15 @@ struct JSContext : js::ContextFriendFields,
|
||||
inline js::RegExpStatics *regExpStatics();
|
||||
|
||||
public:
|
||||
/*
|
||||
* The default script compilation version can be set iff there is no code running.
|
||||
* This typically occurs via the JSAPI right after a context is constructed.
|
||||
*/
|
||||
inline bool canSetDefaultVersion() const;
|
||||
|
||||
/* Force a version for future script compilation. */
|
||||
inline void overrideVersion(JSVersion newVersion);
|
||||
|
||||
/* Set the default script compilation version. */
|
||||
void setDefaultVersion(JSVersion version) {
|
||||
defaultVersion = version;
|
||||
}
|
||||
|
||||
void clearVersionOverride() { hasVersionOverride = false; }
|
||||
JSVersion getDefaultVersion() const { return defaultVersion; }
|
||||
bool isVersionOverridden() const { return hasVersionOverride; }
|
||||
|
||||
JSVersion getVersionOverride() const {
|
||||
JS_ASSERT(isVersionOverridden());
|
||||
return versionOverride;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the default version if possible; otherwise, force the version.
|
||||
* Return whether an override occurred.
|
||||
*/
|
||||
inline bool maybeOverrideVersion(JSVersion newVersion);
|
||||
|
||||
/*
|
||||
* If there is no code on the stack, turn the override version into the
|
||||
* default version.
|
||||
*/
|
||||
void maybeMigrateVersionOverride() {
|
||||
JS_ASSERT(stack.empty());
|
||||
if (JS_UNLIKELY(isVersionOverridden())) {
|
||||
defaultVersion = versionOverride;
|
||||
clearVersionOverride();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return:
|
||||
* - The override version, if there is an override version.
|
||||
* - The newest scripted frame's version, if there is such a frame.
|
||||
* - The version from the compartment.
|
||||
* - The default version.
|
||||
|
@ -468,9 +468,6 @@ CallSetter(JSContext *cx, HandleObject obj, HandleId id, StrictPropertyOp op, un
|
||||
inline JSVersion
|
||||
JSContext::findVersion() const
|
||||
{
|
||||
if (hasVersionOverride)
|
||||
return versionOverride;
|
||||
|
||||
if (JSScript *script = stack.currentScript(NULL, js::ContextStack::ALLOW_CROSS_COMPARTMENT))
|
||||
return script->getVersion();
|
||||
|
||||
@ -480,31 +477,6 @@ JSContext::findVersion() const
|
||||
return defaultVersion;
|
||||
}
|
||||
|
||||
inline bool
|
||||
JSContext::canSetDefaultVersion() const
|
||||
{
|
||||
return !stack.hasfp() && !hasVersionOverride;
|
||||
}
|
||||
|
||||
inline void
|
||||
JSContext::overrideVersion(JSVersion newVersion)
|
||||
{
|
||||
JS_ASSERT(!canSetDefaultVersion());
|
||||
versionOverride = newVersion;
|
||||
hasVersionOverride = true;
|
||||
}
|
||||
|
||||
inline bool
|
||||
JSContext::maybeOverrideVersion(JSVersion newVersion)
|
||||
{
|
||||
if (canSetDefaultVersion()) {
|
||||
setDefaultVersion(newVersion);
|
||||
return false;
|
||||
}
|
||||
overrideVersion(newVersion);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline js::LifoAlloc &
|
||||
JSContext::analysisLifoAlloc()
|
||||
{
|
||||
|
@ -833,9 +833,6 @@ ContextStack::popSegment()
|
||||
{
|
||||
space().seg_ = seg_->prevInMemory();
|
||||
seg_ = seg_->prevInContext();
|
||||
|
||||
if (!seg_)
|
||||
cx_->maybeMigrateVersionOverride();
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user