Bug 921454 - Add an option for explicitly forcing foreground finalization. r=jonco

This commit is contained in:
Bobby Holley 2013-10-04 13:29:36 +02:00
parent f8062f062d
commit 9a62ce9165
2 changed files with 12 additions and 2 deletions

View File

@ -353,7 +353,8 @@ SetProxyExtra(JSObject *obj, size_t n, const Value &extra)
class MOZ_STACK_CLASS ProxyOptions {
public:
ProxyOptions() : callable_(false),
singleton_(false)
singleton_(false),
forceForegroundFinalization_(false)
{}
bool callable() const { return callable_; }
@ -368,9 +369,18 @@ class MOZ_STACK_CLASS ProxyOptions {
return *this;
}
bool forceForegroundFinalization() const {
return forceForegroundFinalization_;
}
ProxyOptions &setForceForegroundFinalization(bool flag) {
forceForegroundFinalization_ = true;
return *this;
}
private:
bool callable_;
bool singleton_;
bool forceForegroundFinalization_;
};
JS_FRIEND_API(JSObject *)

View File

@ -43,7 +43,7 @@ ProxyObject::New(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, Tag
NewObjectKind newKind =
(clasp == &OuterWindowProxyObject::class_ || options.singleton()) ? SingletonObject : GenericObject;
gc::AllocKind allocKind = gc::GetGCObjectKind(clasp);
if (handler->finalizeInBackground(priv))
if (!options.forceForegroundFinalization() && handler->finalizeInBackground(priv))
allocKind = GetBackgroundAllocKind(allocKind);
RootedObject obj(cx, NewObjectWithGivenProto(cx, clasp, proto, parent, allocKind, newKind));
if (!obj)