Bug 1638446 - Change wasm start function to not pre-declare a valid ref.func index. r=lth
authorRyan Hunt <rhunt@eqrion.net>
Thu, 21 May 2020 18:41:34 +0000
changeset 531533 44d7d84902b45f915eff8e52eec572409efa31e0
parent 531532 edddd94f6da24b685987ed9243c616adc7807586
child 531534 f56a395fb0689ed86de46fa3c875008dee488bfa
push id37440
push userabutkovits@mozilla.com
push dateFri, 22 May 2020 09:43:16 +0000
treeherdermozilla-central@fbf71e4d2e21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1638446
milestone78.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 1638446 - Change wasm start function to not pre-declare a valid ref.func index. r=lth This was omitted from the original upstream spec-tests that changed validation to treat the whole module environment as pre-declaring ref.func indices, and added after our commit landed. Differential Revision: https://phabricator.services.mozilla.com/D75989
js/src/jit-test/tests/wasm/gc/ref-func.js
js/src/wasm/WasmValidate.cpp
--- a/js/src/jit-test/tests/wasm/gc/ref-func.js
+++ b/js/src/jit-test/tests/wasm/gc/ref-func.js
@@ -100,18 +100,18 @@ assertEq(validFuncRefText('(elem 0 (i32.
 assertEq(validFuncRefText('(elem funcref (ref.func $referenced))', 'funcref') instanceof WebAssembly.Instance, true);
 
 // reference function can be forward declared via globals
 assertEq(validFuncRefText('(global funcref (ref.func $referenced))', 'anyref') instanceof WebAssembly.Instance, true);
 
 // reference function can be forward declared via export
 assertEq(validFuncRefText('(export "referenced" (func $referenced))', 'anyref') instanceof WebAssembly.Instance, true);
 
-// reference function can be forward declared via start
-assertEq(validFuncRefText('(start $referenced)', 'anyref') instanceof WebAssembly.Instance, true);
+// reference function cannot be forward declared via start
+assertErrorMessage(() => validFuncRefText('(start $referenced)', 'anyref'), WebAssembly.CompileError, /function index is not declared in a section before the code section/);
 
 // Tests not expressible in the text format.
 
 // element segment with elemexpr can carry non-reference type, but this must be
 // rejected.
 
 assertErrorMessage(() => new WebAssembly.Module(
     moduleWithSections([generalElemSection([{ flag: PassiveElemExpr,
--- a/js/src/wasm/WasmValidate.cpp
+++ b/js/src/wasm/WasmValidate.cpp
@@ -2558,18 +2558,16 @@ static bool DecodeStartSection(Decoder& 
   if (!d.readVarU32(&funcIndex)) {
     return d.fail("failed to read start func index");
   }
 
   if (funcIndex >= env->numFuncs()) {
     return d.fail("unknown start function");
   }
 
-  env->validForRefFunc.setBit(funcIndex);
-
   const FuncType& funcType = *env->funcTypes[funcIndex];
   if (funcType.results().length() > 0) {
     return d.fail("start function must not return anything");
   }
 
   if (funcType.args().length()) {
     return d.fail("start function must be nullary");
   }