mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1138390 - Wait for GC to finish if necessary in runOffThreadScript() r=terrence
This commit is contained in:
parent
71d94d71fd
commit
1184b19cd8
28
js/src/jit-test/tests/gc/bug-1138390.js
Normal file
28
js/src/jit-test/tests/gc/bug-1138390.js
Normal file
@ -0,0 +1,28 @@
|
||||
if (!("startgc" in this &&
|
||||
"offThreadCompileScript" in this &&
|
||||
"runOffThreadScript" in this))
|
||||
{
|
||||
quit();
|
||||
}
|
||||
|
||||
if (helperThreadCount() == 0)
|
||||
quit();
|
||||
|
||||
if ("gczeal" in this)
|
||||
gczeal(0);
|
||||
|
||||
// Start an incremental GC that includes the atoms zone
|
||||
startgc(0);
|
||||
var g = newGlobal();
|
||||
|
||||
// Start an off thread compilation that will not run until GC has finished
|
||||
if ("gcstate" in this)
|
||||
assertEq("mark", gcstate());
|
||||
g.offThreadCompileScript('23;', {});
|
||||
|
||||
// Wait for the compilation to finish, which must finish the GC first
|
||||
assertEq(23, g.runOffThreadScript());
|
||||
if ("gcstate" in this)
|
||||
assertEq("none", gcstate());
|
||||
|
||||
print("done");
|
@ -58,6 +58,7 @@
|
||||
|
||||
#include "builtin/TestingFunctions.h"
|
||||
#include "frontend/Parser.h"
|
||||
#include "gc/GCInternals.h"
|
||||
#include "jit/arm/Simulator-arm.h"
|
||||
#include "jit/Ion.h"
|
||||
#include "jit/JitcodeMap.h"
|
||||
@ -3581,13 +3582,17 @@ runOffThreadScript(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
JSRuntime *rt = cx->runtime();
|
||||
if (OffThreadParsingMustWaitForGC(rt))
|
||||
gc::AutoFinishGC finishgc(rt);
|
||||
|
||||
void *token = offThreadState.waitUntilDone(cx);
|
||||
if (!token) {
|
||||
JS_ReportError(cx, "called runOffThreadScript when no compilation is pending");
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedScript script(cx, JS::FinishOffThreadScript(cx, cx->runtime(), token));
|
||||
RootedScript script(cx, JS::FinishOffThreadScript(cx, rt, token));
|
||||
if (!script)
|
||||
return false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user