https://bugs.webkit.org/show_bug.cgi?id=186794
<rdar://problem/
41140257>
Reviewed by Keith Miller.
JSTests:
* wasm/Builder.js:
(const._normalizeFunctionSignature):
* wasm/function-tests/void-argument-type-should-be-a-validation-error.js: Added.
(getBinary):
* wasm/self-test/test_BuilderJSON.js:
Source/JavaScriptCore:
* wasm/WasmModuleParser.cpp:
(JSC::Wasm::ModuleParser::parseType):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232970
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2018-06-19 Saam Barati <sbarati@apple.com>
+
+ Wasm: Any function argument of type Void should be a validation error
+ https://bugs.webkit.org/show_bug.cgi?id=186794
+ <rdar://problem/41140257>
+
+ Reviewed by Keith Miller.
+
+ * wasm/Builder.js:
+ (const._normalizeFunctionSignature):
+ * wasm/function-tests/void-argument-type-should-be-a-validation-error.js: Added.
+ (getBinary):
+ * wasm/self-test/test_BuilderJSON.js:
+
2018-06-18 Keith Miller <keith_miller@apple.com>
Properly zero unused property storage offsets
const _normalizeFunctionSignature = (params, ret) => {
assert.isArray(params);
for (const p of params)
- assert.truthy(WASM.isValidValueType(p), `Type parameter ${p} needs a valid value type`);
+ assert.truthy(WASM.isValidValueType(p) || p === "void", `Type parameter ${p} needs a valid value type`);
if (typeof(ret) === "undefined")
ret = "void";
assert.isNotArray(ret, `Multiple return values not supported by WebAssembly yet`);
--- /dev/null
+import * as assert from '../assert.js';
+import Builder from '../Builder.js';
+
+function getBinary(params) {
+ const builder = (new Builder())
+ builder.Type().End()
+ .Function().End()
+ .Memory().InitialMaxPages(1, 1).End()
+ .Export()
+ .Function("callFunc")
+ .End()
+ .Code()
+ .Function("callFunc", { params, ret: "void" })
+ .Return()
+ .End()
+ .End();
+ return builder.WebAssembly().get();
+}
+
+assert.throws(() => new WebAssembly.Module(getBinary(["i32", "void"])), WebAssembly.CompileError, "WebAssembly.Module doesn't parse at byte 15 / 47: can't get 1th argument Type");
+assert.throws(() => new WebAssembly.Module(getBinary(["void"])), WebAssembly.CompileError, "WebAssembly.Module doesn't parse at byte 14 / 46: can't get 0th argument Type");
+assert.throws(() => new WebAssembly.Module(getBinary(["i32", "void", "i32"])), WebAssembly.CompileError, "WebAssembly.Module doesn't parse at byte 15 / 48: can't get 1th argument Type");
})();
(function InvalidFunctionParameters() {
- for (let invalid of ["", "void", "bool", "any", "struct", 0, 3.14, undefined, [], {}]) {
+ for (let invalid of ["", "bool", "any", "struct", 0, 3.14, undefined, [], {}]) {
const c = (new Builder()).Code();
assert.throws(() => c.Function({ params: [invalid] }), Error, `Expected truthy: Type parameter ${invalid} needs a valid value type`);
}
+2018-06-19 Saam Barati <sbarati@apple.com>
+
+ Wasm: Any function argument of type Void should be a validation error
+ https://bugs.webkit.org/show_bug.cgi?id=186794
+ <rdar://problem/41140257>
+
+ Reviewed by Keith Miller.
+
+ * wasm/WasmModuleParser.cpp:
+ (JSC::Wasm::ModuleParser::parseType):
+
2018-06-18 Keith Miller <keith_miller@apple.com>
JSImmutableButterfly should assert m_header is adjacent to the data
for (unsigned i = 0; i < argumentCount; ++i) {
Type argumentType;
- WASM_PARSER_FAIL_IF(!parseResultType(argumentType), "can't get ", i, "th argument Type");
+ WASM_PARSER_FAIL_IF(!parseValueType(argumentType), "can't get ", i, "th argument Type");
signature->argument(i) = argumentType;
}