summaryrefslogtreecommitdiffstats
path: root/devtools/client/shared/vendor/WasmParser.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/shared/vendor/WasmParser.js')
-rw-r--r--devtools/client/shared/vendor/WasmParser.js81
1 files changed, 67 insertions, 14 deletions
diff --git a/devtools/client/shared/vendor/WasmParser.js b/devtools/client/shared/vendor/WasmParser.js
index 68397b8eeb..efa5b9a4e6 100644
--- a/devtools/client/shared/vendor/WasmParser.js
+++ b/devtools/client/shared/vendor/WasmParser.js
@@ -29,7 +29,7 @@ var __extends = (this && this.__extends) || (function () {
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
-exports.bytesToString = exports.BinaryReader = exports.Int64 = exports.TagAttribute = exports.ElementMode = exports.DataMode = exports.BinaryReaderState = exports.NameType = exports.LinkingType = exports.RelocType = exports.RefType = exports.Type = exports.FuncDef = exports.FieldDef = exports.TypeKind = exports.ExternalKind = exports.OperatorCodeNames = exports.OperatorCode = exports.SectionCode = void 0;
+exports.bytesToString = exports.BinaryReader = exports.Int64 = exports.TagAttribute = exports.ElementMode = exports.DataMode = exports.BinaryReaderState = exports.NameType = exports.LinkingType = exports.RelocType = exports.CatchHandler = exports.CatchHandlerKind = exports.RefType = exports.Type = exports.FuncDef = exports.FieldDef = exports.TypeKind = exports.ExternalKind = exports.OperatorCodeNames = exports.OperatorCode = exports.SectionCode = void 0;
// See https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md
var WASM_MAGIC_NUMBER = 0x6d736100;
var WASM_SUPPORTED_EXPERIMENTAL_VERSION = 0xd;
@@ -64,7 +64,7 @@ var OperatorCode;
OperatorCode[OperatorCode["catch"] = 7] = "catch";
OperatorCode[OperatorCode["throw"] = 8] = "throw";
OperatorCode[OperatorCode["rethrow"] = 9] = "rethrow";
- OperatorCode[OperatorCode["unwind"] = 10] = "unwind";
+ OperatorCode[OperatorCode["throw_ref"] = 10] = "throw_ref";
OperatorCode[OperatorCode["end"] = 11] = "end";
OperatorCode[OperatorCode["br"] = 12] = "br";
OperatorCode[OperatorCode["br_if"] = 13] = "br_if";
@@ -82,6 +82,7 @@ var OperatorCode;
OperatorCode[OperatorCode["drop"] = 26] = "drop";
OperatorCode[OperatorCode["select"] = 27] = "select";
OperatorCode[OperatorCode["select_with_type"] = 28] = "select_with_type";
+ OperatorCode[OperatorCode["try_table"] = 31] = "try_table";
OperatorCode[OperatorCode["local_get"] = 32] = "local_get";
OperatorCode[OperatorCode["local_set"] = 33] = "local_set";
OperatorCode[OperatorCode["local_tee"] = 34] = "local_tee";
@@ -597,8 +598,8 @@ var OperatorCode;
OperatorCode[OperatorCode["f64x2_relaxed_min"] = 1036559] = "f64x2_relaxed_min";
OperatorCode[OperatorCode["f64x2_relaxed_max"] = 1036560] = "f64x2_relaxed_max";
OperatorCode[OperatorCode["i16x8_relaxed_q15mulr_s"] = 1036561] = "i16x8_relaxed_q15mulr_s";
- OperatorCode[OperatorCode["i16x8_dot_i8x16_i7x16_s"] = 1036562] = "i16x8_dot_i8x16_i7x16_s";
- OperatorCode[OperatorCode["i32x4_dot_i8x16_i7x16_add_s"] = 1036563] = "i32x4_dot_i8x16_i7x16_add_s";
+ OperatorCode[OperatorCode["i16x8_relaxed_dot_i8x16_i7x16_s"] = 1036562] = "i16x8_relaxed_dot_i8x16_i7x16_s";
+ OperatorCode[OperatorCode["i32x4_relaxed_dot_i8x16_i7x16_add_s"] = 1036563] = "i32x4_relaxed_dot_i8x16_i7x16_add_s";
// GC proposal.
OperatorCode[OperatorCode["struct_new"] = 64256] = "struct_new";
OperatorCode[OperatorCode["struct_new_default"] = 64257] = "struct_new_default";
@@ -643,7 +644,7 @@ exports.OperatorCodeNames = [
"catch",
"throw",
"rethrow",
- "unwind",
+ "throw_ref",
"end",
"br",
"br_if",
@@ -664,7 +665,7 @@ exports.OperatorCodeNames = [
"select",
undefined,
undefined,
- undefined,
+ "try_table",
"local.get",
"local.set",
"local.tee",
@@ -1187,8 +1188,8 @@ exports.OperatorCodeNames = [
"f64x2.relaxed_min",
"f64x2.relaxed_max",
"i16x8.relaxed_q15mulr_s",
- "i16x8.dot_i8x16_i7x16_s",
- "i32x4.dot_i8x16_i7x16_add_s",
+ "i16x8.relaxed_dot_i8x16_i7x16_s",
+ "i32x4.relaxed_dot_i8x16_i7x16_add_s",
].forEach(function (s, i) {
exports.OperatorCodeNames[0xfd000 | i] = s;
});
@@ -1297,9 +1298,9 @@ exports.OperatorCodeNames = [
"array.init_data",
"array.init_elem",
"ref.test",
- "ref.test null",
+ "ref.test",
+ "ref.cast",
"ref.cast",
- "ref.cast null",
"br_on_cast",
"br_on_cast_fail",
"any.convert_extern",
@@ -1328,6 +1329,7 @@ var TypeKind;
TypeKind[TypeKind["v128"] = -5] = "v128";
TypeKind[TypeKind["i8"] = -8] = "i8";
TypeKind[TypeKind["i16"] = -9] = "i16";
+ TypeKind[TypeKind["nullexnref"] = -12] = "nullexnref";
TypeKind[TypeKind["nullfuncref"] = -13] = "nullfuncref";
TypeKind[TypeKind["nullref"] = -15] = "nullref";
TypeKind[TypeKind["nullexternref"] = -14] = "nullexternref";
@@ -1338,6 +1340,7 @@ var TypeKind;
TypeKind[TypeKind["i31ref"] = -20] = "i31ref";
TypeKind[TypeKind["structref"] = -21] = "structref";
TypeKind[TypeKind["arrayref"] = -22] = "arrayref";
+ TypeKind[TypeKind["exnref"] = -23] = "exnref";
TypeKind[TypeKind["ref"] = -28] = "ref";
TypeKind[TypeKind["ref_null"] = -29] = "ref_null";
TypeKind[TypeKind["func"] = -32] = "func";
@@ -1388,6 +1391,7 @@ var Type = exports.Type = /** @class */ (function () {
// Convenience singletons.
Type.funcref = new Type(-16 /* TypeKind.funcref */);
Type.externref = new Type(-17 /* TypeKind.externref */);
+ Type.exnref = new Type(-23 /* TypeKind.exnref */);
return Type;
}());
var RefType = /** @class */ (function (_super) {
@@ -1411,6 +1415,19 @@ var RefType = /** @class */ (function (_super) {
return RefType;
}(Type));
exports.RefType = RefType;
+var CatchHandlerKind;
+(function (CatchHandlerKind) {
+ CatchHandlerKind[CatchHandlerKind["Catch"] = 0] = "Catch";
+ CatchHandlerKind[CatchHandlerKind["CatchRef"] = 1] = "CatchRef";
+ CatchHandlerKind[CatchHandlerKind["CatchAll"] = 2] = "CatchAll";
+ CatchHandlerKind[CatchHandlerKind["CatchAllRef"] = 3] = "CatchAllRef";
+})(CatchHandlerKind = exports.CatchHandlerKind || (exports.CatchHandlerKind = {}));
+var CatchHandler = /** @class */ (function () {
+ function CatchHandler() {
+ }
+ return CatchHandler;
+}());
+exports.CatchHandler = CatchHandler;
var RelocType;
(function (RelocType) {
RelocType[RelocType["FunctionIndex_LEB"] = 0] = "FunctionIndex_LEB";
@@ -1814,11 +1831,13 @@ var BinaryReader = /** @class */ (function () {
case -9 /* TypeKind.i16 */:
case -16 /* TypeKind.funcref */:
case -17 /* TypeKind.externref */:
+ case -23 /* TypeKind.exnref */:
case -18 /* TypeKind.anyref */:
case -19 /* TypeKind.eqref */:
case -20 /* TypeKind.i31ref */:
case -14 /* TypeKind.nullexternref */:
case -13 /* TypeKind.nullfuncref */:
+ case -12 /* TypeKind.nullexnref */:
case -21 /* TypeKind.structref */:
case -22 /* TypeKind.arrayref */:
case -15 /* TypeKind.nullref */:
@@ -1989,6 +2008,7 @@ var BinaryReader = /** @class */ (function () {
case -9 /* TypeKind.i16 */:
case -16 /* TypeKind.funcref */:
case -17 /* TypeKind.externref */:
+ case -23 /* TypeKind.exnref */:
case -18 /* TypeKind.anyref */:
case -19 /* TypeKind.eqref */:
this.result = {
@@ -2936,8 +2956,8 @@ var BinaryReader = /** @class */ (function () {
case 1036559 /* OperatorCode.f64x2_relaxed_min */:
case 1036560 /* OperatorCode.f64x2_relaxed_max */:
case 1036561 /* OperatorCode.i16x8_relaxed_q15mulr_s */:
- case 1036562 /* OperatorCode.i16x8_dot_i8x16_i7x16_s */:
- case 1036563 /* OperatorCode.i32x4_dot_i8x16_i7x16_add_s */:
+ case 1036562 /* OperatorCode.i16x8_relaxed_dot_i8x16_i7x16_s */:
+ case 1036563 /* OperatorCode.i32x4_relaxed_dot_i8x16_i7x16_add_s */:
break;
default:
this.error = new Error("Unknown operator: 0x".concat(code.toString(16).padStart(4, "0")));
@@ -3109,7 +3129,7 @@ var BinaryReader = /** @class */ (function () {
}
break;
}
- var code, blockType, selectType, refType, brDepth, brTable, relativeDepth, funcIndex, typeIndex, tableIndex, localIndex, globalIndex, tagIndex, memoryAddress, literal, reserved;
+ var code, blockType, selectType, refType, brDepth, brTable, tryTable, relativeDepth, funcIndex, typeIndex, tableIndex, localIndex, globalIndex, tagIndex, memoryAddress, literal, reserved;
if (this.state === 26 /* BinaryReaderState.INIT_EXPRESSION_OPERATOR */ &&
this._sectionId === 9 /* SectionCode.Element */ &&
isExternvalElementSegmentType(this._segmentType)) {
@@ -3171,6 +3191,38 @@ var BinaryReader = /** @class */ (function () {
case 8 /* OperatorCode.throw */:
tagIndex = this.readVarInt32();
break;
+ case 31 /* OperatorCode.try_table */:
+ blockType = this.readType();
+ var tableCount = this.readVarUint32();
+ if (!this.hasBytes(2 * tableCount)) {
+ // We need at least (2 * tableCount) bytes
+ this._pos = pos;
+ return false;
+ }
+ tryTable = [];
+ for (var i = 0; i < tableCount; i++) {
+ if (!this.hasVarIntBytes()) {
+ this._pos = pos;
+ return false;
+ }
+ var kind = this.readVarUint32();
+ var tagIndex;
+ if (kind == CatchHandlerKind.Catch ||
+ kind == CatchHandlerKind.CatchRef) {
+ if (!this.hasVarIntBytes()) {
+ this._pos = pos;
+ return false;
+ }
+ tagIndex = this.readVarUint32();
+ }
+ if (!this.hasVarIntBytes()) {
+ this._pos = pos;
+ return false;
+ }
+ var depth = this.readVarUint32();
+ tryTable.push({ kind: kind, depth: depth, tagIndex: tagIndex });
+ }
+ break;
case 208 /* OperatorCode.ref_null */:
refType = this.readHeapType();
break;
@@ -3278,7 +3330,6 @@ var BinaryReader = /** @class */ (function () {
case 0 /* OperatorCode.unreachable */:
case 1 /* OperatorCode.nop */:
case 5 /* OperatorCode.else */:
- case 10 /* OperatorCode.unwind */:
case 11 /* OperatorCode.end */:
case 15 /* OperatorCode.return */:
case 25 /* OperatorCode.catch_all */:
@@ -3415,6 +3466,7 @@ var BinaryReader = /** @class */ (function () {
case 209 /* OperatorCode.ref_is_null */:
case 212 /* OperatorCode.ref_as_non_null */:
case 211 /* OperatorCode.ref_eq */:
+ case 10 /* OperatorCode.throw_ref */:
break;
default:
this.error = new Error("Unknown operator: ".concat(code));
@@ -3430,6 +3482,7 @@ var BinaryReader = /** @class */ (function () {
srcType: undefined,
brDepth: brDepth,
brTable: brTable,
+ tryTable: tryTable,
relativeDepth: relativeDepth,
tableIndex: tableIndex,
funcIndex: funcIndex,