mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1274922 part 2 - Give the shell its own EnvironmentPreparer. r=jorendorff
This commit is contained in:
parent
8164408c7e
commit
4cbcb1c8f0
@ -178,6 +178,16 @@ struct ShellRuntime
|
||||
bool quitting;
|
||||
};
|
||||
|
||||
struct MOZ_STACK_CLASS EnvironmentPreparer : public js::ScriptEnvironmentPreparer {
|
||||
JSContext* cx;
|
||||
explicit EnvironmentPreparer(JSContext* cx)
|
||||
: cx(cx)
|
||||
{
|
||||
js::SetScriptEnvironmentPreparer(JS_GetRuntime(cx), this);
|
||||
}
|
||||
void invoke(JS::HandleObject scope, Closure& closure) override;
|
||||
};
|
||||
|
||||
// Shell state set once at startup.
|
||||
static bool enableCodeCoverage = false;
|
||||
static bool enableDisassemblyDumps = false;
|
||||
@ -496,6 +506,18 @@ SkipUTF8BOM(FILE* file)
|
||||
ungetc(ch1, file);
|
||||
}
|
||||
|
||||
void
|
||||
EnvironmentPreparer::invoke(HandleObject scope, Closure& closure)
|
||||
{
|
||||
MOZ_ASSERT(!JS_IsExceptionPending(cx));
|
||||
|
||||
AutoCompartment ac(cx, scope);
|
||||
if (!closure(cx))
|
||||
JS_ReportPendingException(cx);
|
||||
|
||||
MOZ_ASSERT(!JS_IsExceptionPending(cx));
|
||||
}
|
||||
|
||||
static void
|
||||
RunFile(JSContext* cx, const char* filename, FILE* file, bool compileOnly)
|
||||
{
|
||||
@ -2952,6 +2974,8 @@ WorkerMain(void* arg)
|
||||
JS::SetEnqueuePromiseJobCallback(rt, ShellEnqueuePromiseJobCallback);
|
||||
#endif // SPIDERMONKEY_PROMISE
|
||||
|
||||
EnvironmentPreparer environmentPreparer(cx);
|
||||
|
||||
JS::SetLargeAllocationFailureCallback(rt, my_LargeAllocFailCallback, (void*)cx);
|
||||
|
||||
do {
|
||||
@ -7441,6 +7465,8 @@ main(int argc, char** argv, char** envp)
|
||||
JS::SetEnqueuePromiseJobCallback(rt, ShellEnqueuePromiseJobCallback);
|
||||
#endif // SPIDERMONKEY_PROMISE
|
||||
|
||||
EnvironmentPreparer environmentPreparer(cx);
|
||||
|
||||
JS_SetGCParameter(rt, JSGC_MODE, JSGC_MODE_INCREMENTAL);
|
||||
|
||||
JS::SetLargeAllocationFailureCallback(rt, my_LargeAllocFailCallback, (void*)cx);
|
||||
|
Loading…
Reference in New Issue
Block a user