-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[js-api] Update basic and identity tests for exnref #316
Conversation
This updates `basic.tentative.any.js` and `identity.tentative.any.js` tests to use the new instructions (`try_table` and `throw_ref`). In addition to converting existing tests to use the new instruction while maintaining the semantics, I added a new test in `basic.tentative.any.js` that makes use of all four `catch` clause variants to show all catch clauses works well in JS API tests. These new tests reauire `--js-flags=--experimental-wasm-exnref` argument to chrome, which is not currently supported in WPT out of the box. I've instead confirmed these run with chrome web tests infrastructure (https://chromium.googlesource.com/chromium/src/+/HEAD/docs/testing/web_tests.md#Running-Web-Tests).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added wasm instruction-equivalent of the programs for readability.
@@ -73,7 +73,7 @@ promise_test(async () => { | |||
promise_test(async () => { | |||
const builder = new WasmModuleBuilder(); | |||
const fnIndex = builder.addImport("module", "fn", kSig_v_v); | |||
const tagIndex= builder.addTag(kSig_v_r); | |||
const tagIndex = builder.addTag(kSig_v_r); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by fix
kExprBlock, kWasmVoid, | ||
kExprBlock, kExternRefCode, | ||
kExprTryTable, kWasmVoid, 1, | ||
kCatchNoRef, tagIndexExternref, 0, | ||
kExprCallFunction, fnIndex, | ||
kExprEnd, | ||
kExprBr, 1, | ||
kExprEnd, | ||
kExprReturn, | ||
kExprEnd, | ||
kExprRefNull, kExternRefCode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to
block $outer
block $catch_dest (result externref)
try_table (catch $tag-externref $catch_dest)
call $fn
end
br $outer
end
return
end
ref.null extern
kExprBlock, kWasmVoid, | ||
kExprBlock, kExnRefCode, | ||
kExprTryTable, kWasmVoid, 1, | ||
kCatchAllRef, 0, | ||
kExprCallFunction, fnIndex, | ||
kExprEnd, | ||
kExprBr, 1, | ||
kExprEnd, | ||
kExprThrowRef, | ||
kExprEnd, | ||
kExprRefNull, kExternRefCode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to
block $outer
block $catch_all_ref_dest (result exnref)
try_table (catch_all_ref $catch_all_ref_dest)
call $fn
end
br $outer
end
throw_ref
end
ref.null extern
kExprBlock, kWasmVoid, | ||
kExprBlock, kExnRefCode, | ||
kExprBlock, sig_ie_v, | ||
kExprBlock, kWasmVoid, | ||
kExprBlock, kWasmI32, | ||
kExprTryTable, kWasmVoid, 4, | ||
kCatchNoRef, tagIndexI32, 0, | ||
kCatchAllNoRef, 1, | ||
kCatchRef, tagIndexI32, 2, | ||
kCatchAllRef, 3, | ||
kExprCallFunction, fnIndex, | ||
kExprEnd, | ||
kExprBr, 4, | ||
kExprEnd, | ||
kExprReturn, | ||
kExprEnd, | ||
kExprBr, 2, | ||
kExprEnd, | ||
kExprDrop, | ||
kExprDrop, | ||
kExprBr, 1, | ||
kExprEnd, | ||
kExprDrop, | ||
kExprEnd, | ||
kExprI32Const, 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to
block $outer
block $catch_all_ref_dest (result exnref)
block $catch_ref_dest (result i32 exnref)
block $catch_all_dest
block $catch_dest (result i32)
try_table (catch $tag-i32 $catch_dest) (catch_all $catch_all_dest) (catch_ref $tag-i32 $catch_ref_dest) (catch_all_ref $catch_all_ref_dest)
call $fn
end
br $outer
end
return
end
br $outer
end
drop
drop
br $outer
end
drop
end
i32.const 0
kExprBlock, kWasmVoid, | ||
kExprBlock, sig_ie_v, | ||
kExprTryTable, kWasmVoid, 1, | ||
kCatchRef, jsTagIndex, 0, | ||
kExprCallFunction, throwJSTagExnIndex, | ||
kExprEnd, | ||
kExprBr, 1, | ||
kExprEnd, | ||
kExprThrowRef, | ||
kExprEnd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to
block $outer
block $catch_ref_dest (result i32 exnref)
try_table (catch_ref $js_tag $catch_ref_dest)
call $throw_js_tag_exn
end
br $outer
end
throw_ref
end
kExprBlock, kWasmVoid, | ||
kExprBlock, sig_ie_v, | ||
kExprTryTable, kWasmVoid, 1, | ||
kCatchRef, wasmTagIndex, 0, | ||
kExprCallFunction, throwWasmTagExnIndex, | ||
kExprEnd, | ||
kExprBr, 1, | ||
kExprEnd, | ||
kExprThrowRef, | ||
kExprEnd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to
block $outer
block $catch_ref_dest (result i32 exnref)
try_table (catch_ref $wasm_tag $catch_ref_dest)
call $throw_wasm_tag_exn
end
br $outer
end
throw_ref
end
kExprBlock, kWasmVoid, | ||
kExprBlock, kExnRefCode, | ||
kExprTryTable, kWasmVoid, 1, | ||
kCatchAllRef, 0, | ||
kExprCallFunction, throwJSTagExnIndex, | ||
kExprEnd, | ||
kExprBr, 1, | ||
kExprEnd, | ||
kExprThrowRef, | ||
kExprEnd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to
block $outer
block $catch_all_ref_dest (result exnref)
try_table (catch_all_ref $js_tag $catch_all_ref_dest)
call $throw_js_tag_exn
end
br $outer
end
throw_ref
end
kExprBlock, kWasmVoid, | ||
kExprBlock, kExnRefCode, | ||
kExprTryTable, kWasmVoid, 1, | ||
kCatchAllRef, 0, | ||
kExprCallFunction, throwWasmTagExnIndex, | ||
kExprEnd, | ||
kExprBr, 1, | ||
kExprEnd, | ||
kExprThrowRef, | ||
kExprEnd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to
block $outer
block $catch_all_ref_dest (result exnref)
try_table (catch_all_ref $wasm_tag $catch_all_ref_dest)
call $throw_wasm_tag_exn
end
br $outer
end
throw_ref
end
kExprBlock, kWasmVoid, | ||
kExprBlock, kWasmI32, | ||
kExprTryTable, kWasmVoid, 1, | ||
kCatchNoRef, jsTagIndex, 0, | ||
kExprCallFunction, throwJSTagExnIndex, | ||
kExprEnd, | ||
kExprBr, 1, | ||
kExprEnd, | ||
kExprReturn, | ||
kExprEnd | ||
kExprEnd, | ||
kExprI32Const, 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to
block $outer
block $catch_dest (result i32)
try_table (catch $js_tag $catch_dest)
call $throw_js_tag_exn
end
br $outer
end
return
end
i32.const 0
kExprBlock, kWasmVoid, | ||
kExprBlock, kWasmI32, | ||
kExprTryTable, kWasmVoid, 1, | ||
kCatchNoRef, jsTagIndex, 0, | ||
kExprCallFunction, throwJSTagExnIndex, | ||
kExprEnd, | ||
kExprBr, 1, | ||
kExprEnd, | ||
kExprThrow, jsTagIndex, | ||
kExprEnd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to
block $outer
block $catch_dest (result i32)
try_table (catch $js_tag $catch_dest)
call $throw_js_tag_exn
end
br $outer
end
throw $js_tag
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I have not reviewed the changed wasm code.
Co-authored-by: Ms2ger <[email protected]>
This updates
basic.tentative.any.js
andidentity.tentative.any.js
tests to use the new instructions (try_table
andthrow_ref
). In addition to converting existing tests to use the new instruction while maintaining the semantics, I added a new test inbasic.tentative.any.js
that makes use of all fourcatch
clause variants to show all catch clauses works well in JS API tests.These new tests reauire
--js-flags=--experimental-wasm-exnref
argument to chrome, which is not currently supported in WPT out of the box. I've instead confirmed these run with chrome web tests infrastructure (https://chromium.googlesource.com/chromium/src/+/HEAD/docs/testing/web_tests.md#Running-Web-Tests).