mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 989528 - Introduce a mechanism to explicitly enter a null compartment. r=luke
This commit is contained in:
parent
20f62f5f5a
commit
bae8ff964e
@ -984,6 +984,19 @@ JSAutoCompartment::~JSAutoCompartment()
|
||||
cx_->leaveCompartment(oldCompartment_);
|
||||
}
|
||||
|
||||
JSAutoNullCompartment::JSAutoNullCompartment(JSContext *cx)
|
||||
: cx_(cx),
|
||||
oldCompartment_(cx->compartment())
|
||||
{
|
||||
AssertHeapIsIdleOrIterating(cx_);
|
||||
cx_->enterNullCompartment();
|
||||
}
|
||||
|
||||
JSAutoNullCompartment::~JSAutoNullCompartment()
|
||||
{
|
||||
cx_->leaveCompartment(oldCompartment_);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_SetCompartmentPrivate(JSCompartment *compartment, void *data)
|
||||
{
|
||||
|
@ -1677,6 +1677,15 @@ class JS_PUBLIC_API(JSAutoCompartment)
|
||||
~JSAutoCompartment();
|
||||
};
|
||||
|
||||
class JS_PUBLIC_API(JSAutoNullCompartment)
|
||||
{
|
||||
JSContext *cx_;
|
||||
JSCompartment *oldCompartment_;
|
||||
public:
|
||||
JSAutoNullCompartment(JSContext *cx);
|
||||
~JSAutoNullCompartment();
|
||||
};
|
||||
|
||||
/* NB: This API is infallible; a nullptr return value does not indicate error. */
|
||||
extern JS_PUBLIC_API(JSCompartment *)
|
||||
JS_EnterCompartment(JSContext *cx, JSObject *target);
|
||||
|
@ -350,6 +350,7 @@ class ExclusiveContext : public ThreadSafeContext
|
||||
#endif
|
||||
|
||||
inline void enterCompartment(JSCompartment *c);
|
||||
inline void enterNullCompartment();
|
||||
inline void leaveCompartment(JSCompartment *oldCompartment);
|
||||
|
||||
void setWorkerThread(WorkerThread *workerThread);
|
||||
|
@ -407,6 +407,13 @@ js::ExclusiveContext::enterCompartment(JSCompartment *c)
|
||||
setCompartment(c);
|
||||
}
|
||||
|
||||
inline void
|
||||
js::ExclusiveContext::enterNullCompartment()
|
||||
{
|
||||
enterCompartmentDepth_++;
|
||||
setCompartment(nullptr);
|
||||
}
|
||||
|
||||
inline void
|
||||
js::ExclusiveContext::leaveCompartment(JSCompartment *oldCompartment)
|
||||
{
|
||||
@ -417,7 +424,8 @@ js::ExclusiveContext::leaveCompartment(JSCompartment *oldCompartment)
|
||||
// compartment.
|
||||
JSCompartment *startingCompartment = compartment_;
|
||||
setCompartment(oldCompartment);
|
||||
startingCompartment->leave();
|
||||
if (startingCompartment)
|
||||
startingCompartment->leave();
|
||||
}
|
||||
|
||||
inline void
|
||||
|
Loading…
Reference in New Issue
Block a user