| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,7 @@ Last update: | |||
| 29 | 29 | - streams: https://github.com/web-platform-tests/wpt/tree/51750bc8d7/streams | |
| 30 | 30 | - url: https://github.com/web-platform-tests/wpt/tree/7c5c3cc125/url | |
| 31 | 31 | - user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing | |
| 32 | - - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/d8dbe6990b/wasm/jsapi | ||
| 32 | + - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi | ||
| 33 | 33 | - wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi | |
| 34 | 34 | - WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/188993d46b/WebCryptoAPI | |
| 35 | 35 | - webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,7 +76,7 @@ | |||
| 76 | 76 | "path": "user-timing" | |
| 77 | 77 | }, | |
| 78 | 78 | "wasm/jsapi": { | |
| 79 | - "commit": "d8dbe6990bed03ec03beee25069a9347d4c3d6d5", | ||
| 79 | + "commit": "cde25e7e3c3b9d2280eb088a3fb9da988793d255", | ||
| 80 | 80 | "path": "wasm/jsapi" | |
| 81 | 81 | }, | |
| 82 | 82 | "wasm/webapi": { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,11 +14,11 @@ promise_test(async () => { | |||
| 14 | 14 | const kWasmAnyRef = 0x6f; | |
| 15 | 15 | const kSig_v_r = makeSig([kWasmAnyRef], []); | |
| 16 | 16 | const builder = new WasmModuleBuilder(); | |
| 17 | - const except = builder.addException(kSig_v_r); | ||
| 17 | + const tagIndex = builder.addTag(kSig_v_r); | ||
| 18 | 18 | builder.addFunction("throw_param", kSig_v_r) | |
| 19 | 19 | .addBody([ | |
| 20 | 20 | kExprLocalGet, 0, | |
| 21 | - kExprThrow, except, | ||
| 21 | + kExprThrow, tagIndex, | ||
| 22 | 22 | ]) | |
| 23 | 23 | .exportFunc(); | |
| 24 | 24 | const buffer = builder.toBuffer(); | |
@@ -45,11 +45,11 @@ promise_test(async () => { | |||
| 45 | 45 | ||
| 46 | 46 | promise_test(async () => { | |
| 47 | 47 | const builder = new WasmModuleBuilder(); | |
| 48 | - const except = builder.addException(kSig_v_a); | ||
| 48 | + const tagIndex = builder.addTag(kSig_v_a); | ||
| 49 | 49 | builder.addFunction("throw_null", kSig_v_v) | |
| 50 | 50 | .addBody([ | |
| 51 | 51 | kExprRefNull, kWasmAnyFunc, | |
| 52 | - kExprThrow, except, | ||
| 52 | + kExprThrow, tagIndex, | ||
| 53 | 53 | ]) | |
| 54 | 54 | .exportFunc(); | |
| 55 | 55 | const buffer = builder.toBuffer(); | |
@@ -59,11 +59,11 @@ promise_test(async () => { | |||
| 59 | 59 | ||
| 60 | 60 | promise_test(async () => { | |
| 61 | 61 | const builder = new WasmModuleBuilder(); | |
| 62 | - const except = builder.addException(kSig_v_i); | ||
| 62 | + const tagIndex = builder.addTag(kSig_v_i); | ||
| 63 | 63 | builder.addFunction("throw_int", kSig_v_v) | |
| 64 | 64 | .addBody([ | |
| 65 | 65 | ...wasmI32Const(7), | |
| 66 | - kExprThrow, except, | ||
| 66 | + kExprThrow, tagIndex, | ||
| 67 | 67 | ]) | |
| 68 | 68 | .exportFunc(); | |
| 69 | 69 | const buffer = builder.toBuffer(); | |
@@ -74,12 +74,12 @@ promise_test(async () => { | |||
| 74 | 74 | promise_test(async () => { | |
| 75 | 75 | const builder = new WasmModuleBuilder(); | |
| 76 | 76 | const fnIndex = builder.addImport("module", "fn", kSig_v_v); | |
| 77 | - const except = builder.addException(kSig_v_r); | ||
| 77 | + const tagIndex= builder.addTag(kSig_v_r); | ||
| 78 | 78 | builder.addFunction("catch_exception", kSig_r_v) | |
| 79 | 79 | .addBody([ | |
| 80 | 80 | kExprTry, kWasmStmt, | |
| 81 | 81 | kExprCallFunction, fnIndex, | |
| 82 | - kExprCatch, except, | ||
| 82 | + kExprCatch, tagIndex, | ||
| 83 | 83 | kExprReturn, | |
| 84 | 84 | kExprEnd, | |
| 85 | 85 | kExprRefNull, kWasmAnyRef, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,8 +18,8 @@ test(() => { | |||
| 18 | 18 | }, "No arguments"); | |
| 19 | 19 | ||
| 20 | 20 | test(() => { | |
| 21 | - const argument = new WebAssembly.Tag({ parameters: [] }); | ||
| 22 | - assert_throws_js(TypeError, () => WebAssembly.Exception(argument)); | ||
| 21 | + const tag = new WebAssembly.Tag({ parameters: [] }); | ||
| 22 | + assert_throws_js(TypeError, () => WebAssembly.Exception(tag)); | ||
| 23 | 23 | }, "Calling"); | |
| 24 | 24 | ||
| 25 | 25 | test(() => { | |
@@ -53,10 +53,10 @@ test(() => { | |||
| 53 | 53 | ["i64", undefined], | |
| 54 | 54 | ]; | |
| 55 | 55 | for (const typeAndArg of typesAndArgs) { | |
| 56 | - const exn = new WebAssembly.Tag({ parameters: [typeAndArg[0]] }); | ||
| 56 | + const tag = new WebAssembly.Tag({ parameters: [typeAndArg[0]] }); | ||
| 57 | 57 | assert_throws_js( | |
| 58 | 58 | TypeError, | |
| 59 | - () => new WebAssembly.Exception(exn, typeAndArg[1]) | ||
| 59 | + () => new WebAssembly.Exception(tag, typeAndArg[1]) | ||
| 60 | 60 | ); | |
| 61 | 61 | } | |
| 62 | 62 | }, "Invalid exception argument"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,7 @@ test(() => { | |||
| 20 | 20 | test(() => { | |
| 21 | 21 | const tag = new WebAssembly.Tag({ parameters: [] }); | |
| 22 | 22 | const exn = new WebAssembly.Exception(tag, []); | |
| 23 | - assert_throws_js(TypeError, () => exn.getArg(tag, 1)); | ||
| 23 | + assert_throws_js(RangeError, () => exn.getArg(tag, 1)); | ||
| 24 | 24 | }, "Index out of bounds"); | |
| 25 | 25 | ||
| 26 | 26 | test(() => { | |
@@ -43,7 +43,7 @@ test(() => { | |||
| 43 | 43 | const tag = new WebAssembly.Tag({ parameters: [] }); | |
| 44 | 44 | const exn = new WebAssembly.Exception(tag, []); | |
| 45 | 45 | for (const value of outOfRangeValues) { | |
| 46 | - assert_throws_js(TypeError, () => exn.getArg(tag, value)); | ||
| 46 | + assert_throws_js(RangeError, () => exn.getArg(tag, value)); | ||
| 47 | 47 | } | |
| 48 | 48 | }, "Getting out-of-range argument"); | |
| 49 | 49 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,61 @@ | |||
| 1 | + // META: global=window,dedicatedworker,jsshell | ||
| 2 | + // META: script=/wasm/jsapi/assertions.js | ||
| 3 | + // META: script=/wasm/jsapi/wasm-module-builder.js | ||
| 4 | + | ||
| 5 | + test(() => { | ||
| 6 | + const tag = new WebAssembly.Tag({ parameters: ["i32"] }); | ||
| 7 | + const exn = new WebAssembly.Exception(tag, [42]); | ||
| 8 | + const exn_same_payload = new WebAssembly.Exception(tag, [42]); | ||
| 9 | + const exn_diff_payload = new WebAssembly.Exception(tag, [53]); | ||
| 10 | + | ||
| 11 | + const builder = new WasmModuleBuilder(); | ||
| 12 | + const jsfuncIndex = builder.addImport("module", "jsfunc", kSig_v_v); | ||
| 13 | + const tagIndex = builder.addImportedTag("module", "tag", kSig_v_i); | ||
| 14 | + const imports = { | ||
| 15 | + module: { | ||
| 16 | + jsfunc: function() { throw exn; }, | ||
| 17 | + tag: tag | ||
| 18 | + } | ||
| 19 | + }; | ||
| 20 | + | ||
| 21 | + builder | ||
| 22 | + .addFunction("catch_rethrow", kSig_v_v) | ||
| 23 | + .addBody([ | ||
| 24 | + kExprTry, kWasmStmt, | ||
| 25 | + kExprCallFunction, jsfuncIndex, | ||
| 26 | + kExprCatch, tagIndex, | ||
| 27 | + kExprDrop, | ||
| 28 | + kExprRethrow, 0x00, | ||
| 29 | + kExprEnd | ||
| 30 | + ]) | ||
| 31 | + .exportFunc(); | ||
| 32 | + | ||
| 33 | + builder | ||
| 34 | + .addFunction("catch_all_rethrow", kSig_v_v) | ||
| 35 | + .addBody([ | ||
| 36 | + kExprTry, kWasmStmt, | ||
| 37 | + kExprCallFunction, jsfuncIndex, | ||
| 38 | + kExprCatchAll, | ||
| 39 | + kExprRethrow, 0x00, | ||
| 40 | + kExprEnd | ||
| 41 | + ]) | ||
| 42 | + .exportFunc(); | ||
| 43 | + | ||
| 44 | + const buffer = builder.toBuffer(); | ||
| 45 | + WebAssembly.instantiate(buffer, imports).then(result => { | ||
| 46 | + try { | ||
| 47 | + result.instance.exports.catch_rethrow(); | ||
| 48 | + } catch (e) { | ||
| 49 | + assert_equals(e, exn); | ||
| 50 | + assert_not_equals(e, exn_same_payload); | ||
| 51 | + assert_not_equals(e, exn_diff_payload); | ||
| 52 | + } | ||
| 53 | + try { | ||
| 54 | + result.instance.exports.catch_all_rethrow(); | ||
| 55 | + } catch (e) { | ||
| 56 | + assert_equals(e, exn); | ||
| 57 | + assert_not_equals(e, exn_same_payload); | ||
| 58 | + assert_not_equals(e, exn_diff_payload); | ||
| 59 | + } | ||
| 60 | + }); | ||
| 61 | + }, "Identity check"); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,8 +3,8 @@ | |||
| 3 | 3 | test(() => { | |
| 4 | 4 | const argument = { parameters: [] }; | |
| 5 | 5 | const tag = new WebAssembly.Tag(argument); | |
| 6 | - const exception = new WebAssembly.Exception(tag, []); | ||
| 7 | - assert_class_string(exception, "WebAssembly.Exception"); | ||
| 6 | + const exn = new WebAssembly.Exception(tag, []); | ||
| 7 | + assert_class_string(exn, "WebAssembly.Exception"); | ||
| 8 | 8 | }, "Object.prototype.toString on an Exception"); | |
| 9 | 9 | ||
| 10 | 10 | test(() => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,7 +65,7 @@ let kElementSectionCode = 9; // Elements section | |||
| 65 | 65 | let kCodeSectionCode = 10; // Function code | |
| 66 | 66 | let kDataSectionCode = 11; // Data segments | |
| 67 | 67 | let kDataCountSectionCode = 12; // Data segment count (between Element & Code) | |
| 68 | - let kExceptionSectionCode = 13; // Exception section (between Global & Export) | ||
| 68 | + let kTagSectionCode = 13; // Tag section (between Memory & Global) | ||
| 69 | 69 | ||
| 70 | 70 | // Name section types | |
| 71 | 71 | let kModuleNameCode = 0; | |
@@ -104,13 +104,13 @@ let kExternalFunction = 0; | |||
| 104 | 104 | let kExternalTable = 1; | |
| 105 | 105 | let kExternalMemory = 2; | |
| 106 | 106 | let kExternalGlobal = 3; | |
| 107 | - let kExternalException = 4; | ||
| 107 | + let kExternalTag = 4; | ||
| 108 | 108 | ||
| 109 | 109 | let kTableZero = 0; | |
| 110 | 110 | let kMemoryZero = 0; | |
| 111 | 111 | let kSegmentZero = 0; | |
| 112 | 112 | ||
| 113 | - let kExceptionAttribute = 0; | ||
| 113 | + let kTagAttribute = 0; | ||
| 114 | 114 | ||
| 115 | 115 | // Useful signatures | |
| 116 | 116 | let kSig_i_i = makeSig([kWasmI32], [kWasmI32]); | |
@@ -681,15 +681,15 @@ class WasmModuleBuilder { | |||
| 681 | 681 | this.exports = []; | |
| 682 | 682 | this.globals = []; | |
| 683 | 683 | this.tables = []; | |
| 684 | - this.exceptions = []; | ||
| 684 | + this.tags = []; | ||
| 685 | 685 | this.functions = []; | |
| 686 | 686 | this.element_segments = []; | |
| 687 | 687 | this.data_segments = []; | |
| 688 | 688 | this.explicit = []; | |
| 689 | 689 | this.num_imported_funcs = 0; | |
| 690 | 690 | this.num_imported_globals = 0; | |
| 691 | 691 | this.num_imported_tables = 0; | |
| 692 | - this.num_imported_exceptions = 0; | ||
| 692 | + this.num_imported_tags = 0; | ||
| 693 | 693 | return this; | |
| 694 | 694 | } | |
| 695 | 695 | ||
@@ -752,10 +752,10 @@ class WasmModuleBuilder { | |||
| 752 | 752 | return table; | |
| 753 | 753 | } | |
| 754 | 754 | ||
| 755 | - addException(type) { | ||
| 755 | + addTag(type) { | ||
| 756 | 756 | let type_index = (typeof type) == "number" ? type : this.addType(type); | |
| 757 | - let except_index = this.exceptions.length + this.num_imported_exceptions; | ||
| 758 | - this.exceptions.push(type_index); | ||
| 757 | + let except_index = this.tags.length + this.num_imported_tags; | ||
| 758 | + this.tags.push(type_index); | ||
| 759 | 759 | return except_index; | |
| 760 | 760 | } | |
| 761 | 761 | ||
@@ -804,14 +804,14 @@ class WasmModuleBuilder { | |||
| 804 | 804 | return this.num_imported_tables++; | |
| 805 | 805 | } | |
| 806 | 806 | ||
| 807 | - addImportedException(module, name, type) { | ||
| 808 | - if (this.exceptions.length != 0) { | ||
| 809 | - throw new Error('Imported exceptions must be declared before local ones'); | ||
| 807 | + addImportedTag(module, name, type) { | ||
| 808 | + if (this.tags.length != 0) { | ||
| 809 | + throw new Error('Imported tags must be declared before local ones'); | ||
| 810 | 810 | } | |
| 811 | 811 | let type_index = (typeof type) == "number" ? type : this.addType(type); | |
| 812 | - let o = {module: module, name: name, kind: kExternalException, type: type_index}; | ||
| 812 | + let o = {module: module, name: name, kind: kExternalTag, type: type_index}; | ||
| 813 | 813 | this.imports.push(o); | |
| 814 | - return this.num_imported_exceptions++; | ||
| 814 | + return this.num_imported_tags++; | ||
| 815 | 815 | } | |
| 816 | 816 | ||
| 817 | 817 | addExport(name, index) { | |
@@ -938,8 +938,8 @@ class WasmModuleBuilder { | |||
| 938 | 938 | section.emit_u8(has_max ? 1 : 0); // flags | |
| 939 | 939 | section.emit_u32v(imp.initial); // initial | |
| 940 | 940 | if (has_max) section.emit_u32v(imp.maximum); // maximum | |
| 941 | - } else if (imp.kind == kExternalException) { | ||
| 942 | - section.emit_u32v(kExceptionAttribute); | ||
| 941 | + } else if (imp.kind == kExternalTag) { | ||
| 942 | + section.emit_u32v(kTagAttribute); | ||
| 943 | 943 | section.emit_u32v(imp.type); | |
| 944 | 944 | } else { | |
| 945 | 945 | throw new Error("unknown/unsupported import kind " + imp.kind); | |
@@ -1036,13 +1036,13 @@ class WasmModuleBuilder { | |||
| 1036 | 1036 | }); | |
| 1037 | 1037 | } | |
| 1038 | 1038 | ||
| 1039 | - // Add exceptions. | ||
| 1040 | - if (wasm.exceptions.length > 0) { | ||
| 1041 | - if (debug) print("emitting exceptions @ " + binary.length); | ||
| 1042 | - binary.emit_section(kExceptionSectionCode, section => { | ||
| 1043 | - section.emit_u32v(wasm.exceptions.length); | ||
| 1044 | - for (let type of wasm.exceptions) { | ||
| 1045 | - section.emit_u32v(kExceptionAttribute); | ||
| 1039 | + // Add tags. | ||
| 1040 | + if (wasm.tags.length > 0) { | ||
| 1041 | + if (debug) print("emitting tags @ " + binary.length); | ||
| 1042 | + binary.emit_section(kTagSectionCode, section => { | ||
| 1043 | + section.emit_u32v(wasm.tags.length); | ||
| 1044 | + for (let type of wasm.tags) { | ||
| 1045 | + section.emit_u32v(kTagAttribute); | ||
| 1046 | 1046 | section.emit_u32v(type); | |
| 1047 | 1047 | } | |
| 1048 | 1048 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments