Bug 1455611: Prevent calling setGcZeal with --wasm-gc and wasm frames on the stack; r=jonco
authorBenjamin Bouvier <benj@benj.me>
Wed, 25 Apr 2018 12:22:42 +0200
changeset 471725 8c74001d3808e8b385c60da11f6ca99053bd816b
parent 471724 417514d1ff3429cb266037937b330a9e0c9b641b
child 471726 d7dd8b0d2473d38abcc425e583c377eac734d14c
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1455611
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1455611: Prevent calling setGcZeal with --wasm-gc and wasm frames on the stack; r=jonco
js/src/gc/GC.cpp
js/src/jit-test/tests/wasm/gc/block-gczeal.js
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -1065,16 +1065,31 @@ static const mozilla::EnumSet<ZealMode> 
     ZealMode::YieldBeforeSweepingShapeTrees
 };
 
 void
 GCRuntime::setZeal(uint8_t zeal, uint32_t frequency)
 {
     MOZ_ASSERT(zeal <= unsigned(ZealMode::Limit));
 
+#ifdef ENABLE_WASM_GC
+    // If we run with wasm-gc enabled and there's wasm frames on the stack,
+    // then GCs are suppressed and we should not allow to set the GC zeal,
+    // which presupposes that GC can be run right away.
+    // TODO (bug 1456824) This is temporary and should be removed once proper
+    // GC support is implemented.
+    JSContext* cx = rt->mainContextFromOwnThread();
+    if (cx->options().wasmGc()) {
+        for (FrameIter iter(cx); !iter.done(); ++iter) {
+            if (iter.isWasm())
+                return;
+        }
+    }
+#endif
+
     if (verifyPreData)
         VerifyBarriers(rt, PreBarrierVerifier);
 
     if (zeal == 0) {
         if (hasZealMode(ZealMode::GenerationalGC)) {
             evictNursery(JS::gcreason::DEBUG_GC);
             nursery().leaveZealMode();
         }
@@ -3992,17 +4007,17 @@ class MOZ_RAII js::gc::AutoRunParallelTa
 
     void run() override {
         func_(runtime());
     }
 };
 
 void
 GCRuntime::purgeRuntimeForMinorGC()
-{ 
+{
     // If external strings become nursery allocable, remember to call
     // zone->externalStringCache().purge() (and delete this assert.)
     MOZ_ASSERT(!IsNurseryAllocable(AllocKind::EXTERNAL_STRING));
 
     for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next())
         zone->functionToStringCache().purge();
 
     rt->caches().purgeForMinorGC(rt);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/gc/block-gczeal.js
@@ -0,0 +1,11 @@
+wasmEvalText(`(module
+    (import "global" "func" (result i32))
+    (func (export "func_0") (result i32)
+     call 0 ;; calls the import, which is func #0
+    )
+)`, { global: {
+    func() {
+        gczeal(7,6);
+        gczeal();
+    }
+} }).exports.func_0();