Bug 1478616 - Wasm, trace Ref as well as Anyref global and Val. r=bbouvier
authorLars T Hansen <lhansen@mozilla.com>
Thu, 26 Jul 2018 15:50:56 +0200
changeset 823536 55e008024f2463901dde8375b88046fe02920eb2
parent 823535 a4f36dad7af522083a839e073e9a0991c783c3ce
child 823537 e713a94f6e551b1e7bff74841faacbfdaae3057e
push id117712
push userrwood@mozilla.com
push dateFri, 27 Jul 2018 15:10:54 +0000
reviewersbbouvier
bugs1478616
milestone63.0a1
Bug 1478616 - Wasm, trace Ref as well as Anyref global and Val. r=bbouvier
js/src/wasm/WasmInstance.cpp
js/src/wasm/WasmTypes.cpp
--- a/js/src/wasm/WasmInstance.cpp
+++ b/js/src/wasm/WasmInstance.cpp
@@ -719,20 +719,20 @@ Instance::tracePrivate(JSTracer* trc)
         TraceNullableEdge(trc, &funcImportTls(fi).obj, "wasm import");
 
     for (const SharedTable& table : tables_)
         table->trace(trc);
 
 #ifdef ENABLE_WASM_GC
     for (const GlobalDesc& global : code().metadata().globals) {
         // Indirect anyref global get traced by the owning WebAssembly.Global.
-        if (global.type() != ValType::AnyRef || global.isConstant() || global.isIndirect())
+        if (!global.type().isRefOrAnyRef() || global.isConstant() || global.isIndirect())
             continue;
         GCPtrObject* obj = (GCPtrObject*)(globalData() + global.offset());
-        TraceNullableEdge(trc, obj, "wasm anyref global");
+        TraceNullableEdge(trc, obj, "wasm ref/anyref global");
     }
 #endif
 
     TraceNullableEdge(trc, &memory_, "wasm buffer");
 }
 
 void
 Instance::trace(JSTracer* trc)
--- a/js/src/wasm/WasmTypes.cpp
+++ b/js/src/wasm/WasmTypes.cpp
@@ -102,18 +102,18 @@ Val::writePayload(uint8_t* dst) const
         return;
     }
     MOZ_CRASH("unexpected Val type");
 }
 
 void
 Val::trace(JSTracer* trc)
 {
-    if (type_.isValid() && type_ == ValType::AnyRef && u.ptr_)
-        TraceManuallyBarrieredEdge(trc, &u.ptr_, "wasm anyref global");
+    if (type_.isValid() && type_.isRefOrAnyRef() && u.ptr_)
+        TraceManuallyBarrieredEdge(trc, &u.ptr_, "wasm ref/anyref global");
 }
 
 bool
 wasm::IsRoundingFunction(SymbolicAddress callee, jit::RoundingMode* mode)
 {
     switch (callee) {
       case SymbolicAddress::FloorD:
       case SymbolicAddress::FloorF: