Bug 1510193 - don't use TypedObjects if not available and necessary. r=jorendorff
authorLars T Hansen <lhansen@mozilla.com>
Thu, 29 Nov 2018 10:10:02 +0100
changeset 508373 01648611837dfa623fa2b3f112ffd1baa8a0a746
parent 508372 7a7d0cec00a317f56a756ac1357ab3fed3af9bb1
child 508374 0d11eb20a6af24bb4d332cbbc7bacc4d6cebcc36
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1510193
milestone65.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 1510193 - don't use TypedObjects if not available and necessary. r=jorendorff We rely on TypedObjects for the experimental wasm GC feature, but that feature is Nightly-only and we should not be touching TypedObjects if we don't need them. Furthermore we should just fail to compile outright if wasm GC is enabled but TypedObjects are not.
js/src/wasm/WasmModule.cpp
--- a/js/src/wasm/WasmModule.cpp
+++ b/js/src/wasm/WasmModule.cpp
@@ -1107,16 +1107,17 @@ static bool CreateExportObject(JSContext
       return false;
     }
   }
 
   instanceObj->initExportsObj(*exportObj);
   return true;
 }
 
+#ifdef ENABLE_WASM_GC
 static bool MakeStructField(JSContext* cx, const ValType& v, bool isMutable,
                             const char* format, uint32_t fieldNo,
                             AutoIdVector* ids, AutoValueVector* fieldTypeObjs,
                             Vector<StructFieldProps>* fieldProps) {
   char buf[20];
   sprintf(buf, format, fieldNo);
   RootedString str(cx, JS_AtomizeAndPinString(cx, buf));
   if (!str) {
@@ -1167,20 +1168,34 @@ static bool MakeStructField(JSContext* c
   }
 
   if (!fieldProps->append(props)) {
     return false;
   }
 
   return true;
 }
+#endif
 
 bool Module::makeStructTypeDescrs(
     JSContext* cx,
     MutableHandle<StructTypeDescrVector> structTypeDescrs) const {
+  // This method must be a no-op if there are no structs.
+  if (structTypes().length() == 0) {
+    return true;
+  }
+
+#ifndef ENABLE_WASM_GC
+  MOZ_CRASH("Should not have seen any struct types");
+#else
+
+#ifndef ENABLE_BINARYDATA
+#error "GC types require TypedObject"
+#endif
+
   // Not just any prototype object will do, we must have the actual
   // StructTypePrototype.
   RootedObject typedObjectModule(
       cx, GlobalObject::getOrCreateTypedObjectModule(cx, cx->global()));
   if (!typedObjectModule) {
     return false;
   }
 
@@ -1247,16 +1262,17 @@ bool Module::makeStructTypeDescrs(
                                                   fieldTypeObjs, fieldProps));
 
     if (!structTypeDescr || !structTypeDescrs.append(structTypeDescr)) {
       return false;
     }
   }
 
   return true;
+#endif
 }
 
 bool Module::instantiate(JSContext* cx, Handle<FunctionVector> funcImports,
                          WasmTableObjectVector& tableImports,
                          HandleWasmMemoryObject memoryImport,
                          HandleValVector globalImportValues,
                          WasmGlobalObjectVector& globalObjs,
                          HandleObject instanceProto,