diff --git a/cli/asc.js b/cli/asc.js index ef26b5c99e..f3b48d7ec7 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -34,6 +34,11 @@ const fs = require("fs"); const path = require("path"); const process = require("process"); // ensure shim +process.exit = ((exit) => function(code) { + if (code) console.log(new Error("exit " + code.toString()).stack); + exit(code); +})(process.exit); + const utf8 = require("./util/utf8"); const colorsUtil = require("./util/colors"); const optionsUtil = require("./util/options"); diff --git a/lib/loader/index.js b/lib/loader/index.js index efbe88c10d..6f4d9fb6f3 100644 --- a/lib/loader/index.js +++ b/lib/loader/index.js @@ -81,16 +81,16 @@ function postInstantiate(extendedExports, instance) { const exports = instance.exports; const memory = exports.memory; const table = exports.table; - const new_ = exports["__new"]; - const retain = exports["__retain"]; - const rttiBase = exports["__rtti_base"] || ~0; // oob if not present + const __new = exports["__new"]; + const __retain = exports["__retain"]; + const __rtti_base = exports["__rtti_base"] || ~0; // oob if not present /** Gets the runtime type info for the given id. */ function getInfo(id) { const U32 = new Uint32Array(memory.buffer); - const count = U32[rttiBase >>> 2]; + const count = U32[__rtti_base >>> 2]; if ((id >>>= 0) >= count) throw Error(`invalid id: ${id}`); - return U32[(rttiBase + 4 >>> 2) + id * 2]; + return U32[(__rtti_base + 4 >>> 2) + id * 2]; } /** Gets and validate runtime type info for the given id for array like objects */ @@ -103,9 +103,9 @@ function postInstantiate(extendedExports, instance) { /** Gets the runtime base id for the given id. */ function getBase(id) { const U32 = new Uint32Array(memory.buffer); - const count = U32[rttiBase >>> 2]; + const count = U32[__rtti_base >>> 2]; if ((id >>>= 0) >= count) throw Error(`invalid id: ${id}`); - return U32[(rttiBase + 4 >>> 2) + id * 2 + 1]; + return U32[(__rtti_base + 4 >>> 2) + id * 2 + 1]; } /** Gets the runtime alignment of a collection's values. */ @@ -120,8 +120,9 @@ function postInstantiate(extendedExports, instance) { /** Allocates a new string in the module's memory and returns its retained pointer. */ function __newString(str) { + if (str == null) return 0; const length = str.length; - const ptr = new_(length << 1, STRING_ID); + const ptr = __new(length << 1, STRING_ID); const U16 = new Uint16Array(memory.buffer); for (var i = 0, p = ptr >>> 1; i < length; ++i) U16[p + i] = str.charCodeAt(i); return ptr; @@ -131,6 +132,7 @@ function postInstantiate(extendedExports, instance) { /** Reads a string from the module's memory by its pointer. */ function __getString(ptr) { + if (!ptr) return null; const buffer = memory.buffer; const id = new Uint32Array(buffer)[ptr + ID_OFFSET >>> 2]; if (id !== STRING_ID) throw Error(`not a string: ${ptr}`); @@ -163,14 +165,14 @@ function postInstantiate(extendedExports, instance) { const info = getArrayInfo(id); const align = getValueAlign(info); const length = values.length; - const buf = new_(length << align, info & STATICARRAY ? id : ARRAYBUFFER_ID); + const buf = __new(length << align, info & STATICARRAY ? id : ARRAYBUFFER_ID); let result; if (info & STATICARRAY) { result = buf; } else { - const arr = new_(info & ARRAY ? ARRAY_SIZE : ARRAYBUFFERVIEW_SIZE, id); + const arr = __new(info & ARRAY ? ARRAY_SIZE : ARRAYBUFFERVIEW_SIZE, id); const U32 = new Uint32Array(memory.buffer); - U32[arr + ARRAYBUFFERVIEW_BUFFER_OFFSET >>> 2] = retain(buf); + U32[arr + ARRAYBUFFERVIEW_BUFFER_OFFSET >>> 2] = __retain(buf); U32[arr + ARRAYBUFFERVIEW_DATASTART_OFFSET >>> 2] = buf; U32[arr + ARRAYBUFFERVIEW_DATALENGTH_OFFSET >>> 2] = length << align; if (info & ARRAY) U32[arr + ARRAY_LENGTH_OFFSET >>> 2] = length; @@ -178,7 +180,7 @@ function postInstantiate(extendedExports, instance) { } const view = getView(align, info & VAL_SIGNED, info & VAL_FLOAT); if (info & VAL_MANAGED) { - for (let i = 0; i < length; ++i) view[(buf >>> align) + i] = retain(values[i]); + for (let i = 0; i < length; ++i) view[(buf >>> align) + i] = __retain(values[i]); } else { view.set(values, buf >>> align); } @@ -267,7 +269,7 @@ function postInstantiate(extendedExports, instance) { function __instanceof(ptr, baseId) { const U32 = new Uint32Array(memory.buffer); let id = U32[ptr + ID_OFFSET >>> 2]; - if (id <= U32[rttiBase >>> 2]) { + if (id <= U32[__rtti_base >>> 2]) { do { if (id == baseId) return true; id = getBase(id); @@ -331,7 +333,6 @@ export async function instantiateStreaming(source, imports = {}) { /** Demangles an AssemblyScript module's exports to a friendly object structure. */ export function demangle(exports, extendedExports = {}) { - extendedExports = Object.create(extendedExports); const setArgumentsLength = exports["__argumentsLength"] ? length => { exports["__argumentsLength"].value = length; } : exports["__setArgumentsLength"] || exports["__setargc"] || (() => { /* nop */ }); diff --git a/lib/loader/umd/index.d.ts b/lib/loader/umd/index.d.ts index a940eccbc8..f1c27f20e8 100644 --- a/lib/loader/umd/index.d.ts +++ b/lib/loader/umd/index.d.ts @@ -1 +1 @@ -export * from ".."; +export * from "../index"; diff --git a/lib/loader/umd/index.js b/lib/loader/umd/index.js index cd4dfeac59..0dba9053a0 100644 --- a/lib/loader/umd/index.js +++ b/lib/loader/umd/index.js @@ -95,17 +95,19 @@ var loader = (function(exports) { const exports = instance.exports; const memory = exports.memory; const table = exports.table; - const new_ = exports["__new"]; - const retain = exports["__retain"]; - const rttiBase = exports["__rtti_base"] || ~0; // oob if not present + const __new = exports["__new"]; + const __retain = exports["__retain"]; + + const __rtti_base = exports["__rtti_base"] || ~0; // oob if not present /** Gets the runtime type info for the given id. */ + function getInfo(id) { const U32 = new Uint32Array(memory.buffer); - const count = U32[rttiBase >>> 2]; + const count = U32[__rtti_base >>> 2]; if ((id >>>= 0) >= count) throw Error(`invalid id: ${id}`); - return U32[(rttiBase + 4 >>> 2) + id * 2]; + return U32[(__rtti_base + 4 >>> 2) + id * 2]; } /** Gets and validate runtime type info for the given id for array like objects */ @@ -120,9 +122,9 @@ var loader = (function(exports) { function getBase(id) { const U32 = new Uint32Array(memory.buffer); - const count = U32[rttiBase >>> 2]; + const count = U32[__rtti_base >>> 2]; if ((id >>>= 0) >= count) throw Error(`invalid id: ${id}`); - return U32[(rttiBase + 4 >>> 2) + id * 2 + 1]; + return U32[(__rtti_base + 4 >>> 2) + id * 2 + 1]; } /** Gets the runtime alignment of a collection's values. */ @@ -139,8 +141,11 @@ var loader = (function(exports) { function __newString(str) { + if (str == null) return 0; const length = str.length; - const ptr = new_(length << 1, STRING_ID); + + const ptr = __new(length << 1, STRING_ID); + const U16 = new Uint16Array(memory.buffer); for (var i = 0, p = ptr >>> 1; i < length; ++i) U16[p + i] = str.charCodeAt(i); @@ -152,6 +157,7 @@ var loader = (function(exports) { /** Reads a string from the module's memory by its pointer. */ function __getString(ptr) { + if (!ptr) return null; const buffer = memory.buffer; const id = new Uint32Array(buffer)[ptr + ID_OFFSET >>> 2]; if (id !== STRING_ID) throw Error(`not a string: ${ptr}`); @@ -197,15 +203,18 @@ var loader = (function(exports) { const info = getArrayInfo(id); const align = getValueAlign(info); const length = values.length; - const buf = new_(length << align, info & STATICARRAY ? id : ARRAYBUFFER_ID); + + const buf = __new(length << align, info & STATICARRAY ? id : ARRAYBUFFER_ID); + let result; if (info & STATICARRAY) { result = buf; } else { - const arr = new_(info & ARRAY ? ARRAY_SIZE : ARRAYBUFFERVIEW_SIZE, id); + const arr = __new(info & ARRAY ? ARRAY_SIZE : ARRAYBUFFERVIEW_SIZE, id); + const U32 = new Uint32Array(memory.buffer); - U32[arr + ARRAYBUFFERVIEW_BUFFER_OFFSET >>> 2] = retain(buf); + U32[arr + ARRAYBUFFERVIEW_BUFFER_OFFSET >>> 2] = __retain(buf); U32[arr + ARRAYBUFFERVIEW_DATASTART_OFFSET >>> 2] = buf; U32[arr + ARRAYBUFFERVIEW_DATALENGTH_OFFSET >>> 2] = length << align; if (info & ARRAY) U32[arr + ARRAY_LENGTH_OFFSET >>> 2] = length; @@ -215,7 +224,7 @@ var loader = (function(exports) { const view = getView(align, info & VAL_SIGNED, info & VAL_FLOAT); if (info & VAL_MANAGED) { - for (let i = 0; i < length; ++i) view[(buf >>> align) + i] = retain(values[i]); + for (let i = 0; i < length; ++i) view[(buf >>> align) + i] = __retain(values[i]); } else { view.set(values, buf >>> align); } @@ -298,7 +307,7 @@ var loader = (function(exports) { const U32 = new Uint32Array(memory.buffer); let id = U32[ptr + ID_OFFSET >>> 2]; - if (id <= U32[rttiBase >>> 2]) { + if (id <= U32[__rtti_base >>> 2]) { do { if (id == baseId) return true; id = getBase(id); @@ -371,7 +380,6 @@ var loader = (function(exports) { function demangle(exports, extendedExports = {}) { - extendedExports = Object.create(extendedExports); const setArgumentsLength = exports["__argumentsLength"] ? length => { exports["__argumentsLength"].value = length; } : exports["__setArgumentsLength"] || exports["__setargc"] || (() => { diff --git a/lib/rtrace/umd/index.d.ts b/lib/rtrace/umd/index.d.ts index a940eccbc8..f1c27f20e8 100644 --- a/lib/rtrace/umd/index.d.ts +++ b/lib/rtrace/umd/index.d.ts @@ -1 +1 @@ -export * from ".."; +export * from "../index"; diff --git a/src/compiler.ts b/src/compiler.ts index 588ececa43..08d25afff7 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -459,11 +459,13 @@ export class Compiler extends DiagnosticEmitter { let signature = startFunctionInstance.signature; if (!startIsEmpty && explicitStart) { module.addGlobal(BuiltinNames.started, NativeType.I32, true, module.i32(0)); + startFunctionBody.unshift( + module.global_set(BuiltinNames.started, module.i32(1)) + ); startFunctionBody.unshift( module.if( module.global_get(BuiltinNames.started, NativeType.I32), - module.return(), - module.global_set(BuiltinNames.started, module.i32(1)) + module.return() ) ); } @@ -5354,7 +5356,7 @@ export class Compiler extends DiagnosticEmitter { case TypeKind.U32: { let instance = this.i32PowInstance; if (!instance) { - let prototype = this.program.lookupGlobal(CommonNames.ipow32); + let prototype = this.program.lookup(CommonNames.ipow32); if (!prototype) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -5380,7 +5382,7 @@ export class Compiler extends DiagnosticEmitter { case TypeKind.U64: { let instance = this.i64PowInstance; if (!instance) { - let prototype = this.program.lookupGlobal(CommonNames.ipow64); + let prototype = this.program.lookup(CommonNames.ipow64); if (!prototype) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -5401,7 +5403,7 @@ export class Compiler extends DiagnosticEmitter { let isWasm64 = this.options.isWasm64; let instance = isWasm64 ? this.i64PowInstance : this.i32PowInstance; if (!instance) { - let prototype = this.program.lookupGlobal(isWasm64 ? CommonNames.ipow64 : CommonNames.ipow32); + let prototype = this.program.lookup(isWasm64 ? CommonNames.ipow64 : CommonNames.ipow32); if (!prototype) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -5425,7 +5427,7 @@ export class Compiler extends DiagnosticEmitter { case TypeKind.F32: { let instance = this.f32PowInstance; if (!instance) { - let namespace = this.program.lookupGlobal(CommonNames.Mathf); + let namespace = this.program.lookup(CommonNames.Mathf); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -5454,7 +5456,7 @@ export class Compiler extends DiagnosticEmitter { case TypeKind.F64: { let instance = this.f64PowInstance; if (!instance) { - let namespace = this.program.lookupGlobal(CommonNames.Math); + let namespace = this.program.lookup(CommonNames.Math); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -5592,7 +5594,7 @@ export class Compiler extends DiagnosticEmitter { case TypeKind.F32: { let instance = this.f32ModInstance; if (!instance) { - let namespace = this.program.lookupGlobal(CommonNames.Mathf); + let namespace = this.program.lookup(CommonNames.Mathf); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -5620,7 +5622,7 @@ export class Compiler extends DiagnosticEmitter { case TypeKind.F64: { let instance = this.f64ModInstance; if (!instance) { - let namespace = this.program.lookupGlobal(CommonNames.Math); + let namespace = this.program.lookup(CommonNames.Math); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, diff --git a/src/glue/binaryen.d.ts b/src/glue/binaryen.d.ts index 1e358b91b5..8954c6f51b 100644 --- a/src/glue/binaryen.d.ts +++ b/src/glue/binaryen.d.ts @@ -851,6 +851,10 @@ export declare function _BinaryenFunctionGetParams(func: BinaryenFunctionRef): B export declare function _BinaryenFunctionGetResults(func: BinaryenFunctionRef): BinaryenType; export declare function _BinaryenFunctionGetNumVars(func: BinaryenFunctionRef): BinaryenIndex; export declare function _BinaryenFunctionGetVar(func: BinaryenFunctionRef, index: BinaryenIndex): BinaryenType; +export declare function _BinaryenFunctionGetNumLocals(func: BinaryenFunctionRef): BinaryenIndex; +export declare function _BinaryenFunctionHasLocalName(func: BinaryenFunctionRef, index: BinaryenIndex): bool; +export declare function _BinaryenFunctionGetLocalName(func: BinaryenFunctionRef, index: BinaryenIndex): BinaryenString; +export declare function _BinaryenFunctionSetLocalName(func: BinaryenFunctionRef, index: BinaryenIndex, name: BinaryenString): void; export declare function _BinaryenFunctionGetBody(func: BinaryenFunctionRef): BinaryenExpressionRef; export declare function _BinaryenFunctionSetBody(func: BinaryenFunctionRef, bodyExpr: BinaryenExpressionRef): void; export declare function _BinaryenFunctionOptimize(func: BinaryenFunctionRef, module: BinaryenModuleRef): void; diff --git a/src/program.ts b/src/program.ts index 4b7cec27b0..8cf6324e98 100644 --- a/src/program.ts +++ b/src/program.ts @@ -631,7 +631,9 @@ export class Program extends DiagnosticEmitter { /** Gets the standard `abort` instance, if not explicitly disabled. */ get abortInstance(): Function | null { - return this.lookupFunction(CommonNames.abort); + var prototype = this.lookup(CommonNames.abort); + if (!prototype || prototype.kind != ElementKind.FUNCTION_PROTOTYPE) return null; + return this.resolver.resolveFunction(prototype, null); } // Runtime interface @@ -1207,7 +1209,7 @@ export class Program extends DiagnosticEmitter { if (element) { file.ensureExport(exportName, element); } else { - let globalElement = this.lookupGlobal(localName); + let globalElement = this.lookup(localName); if (globalElement !== null && isDeclaredElement(globalElement.kind)) { // export { memory } file.ensureExport(exportName, globalElement); } else { @@ -1508,14 +1510,26 @@ export class Program extends DiagnosticEmitter { } } + /** Looks up the element of the specified name in the global scope. */ + lookup(name: string): Element | null { + var elements = this.elementsByName; + if (elements.has(name)) return assert(elements.get(name)); + return null; + } + /** Requires that a global library element of the specified kind is present and returns it. */ private require(name: string, kind: ElementKind): Element { - var element = this.lookupGlobal(name); + var element = this.lookup(name); if (!element) throw new Error("Missing standard library component: " + name); - if (element.kind != kind) throw Error("Invalid standard library component: " + name); + if (element.kind != kind) throw Error("Invalid standard library component kind: " + name); return element; } + /** Requires that a global variable is present and returns it. */ + private requireGlobal(name: string): Global { + return this.require(name, ElementKind.GLOBAL); + } + /** Requires that a non-generic global class is present and returns it. */ private requireClass(name: string): Class { var prototype = this.require(name, ElementKind.CLASS_PROTOTYPE); @@ -1524,13 +1538,6 @@ export class Program extends DiagnosticEmitter { return resolved; } - /** Obtains a non-generic global function and returns it. Returns `null` if it does not exist. */ - private lookupFunction(name: string): Function | null { - var prototype = this.lookupGlobal(name); - if (!prototype || prototype.kind != ElementKind.FUNCTION_PROTOTYPE) return null; - return this.resolver.resolveFunction(prototype, null); - } - /** Requires that a global function is present and returns it. */ private requireFunction(name: string, typeArguments: Type[] | null = null): Function { var prototype = this.require(name, ElementKind.FUNCTION_PROTOTYPE); @@ -1611,7 +1618,7 @@ export class Program extends DiagnosticEmitter { private registerWrapperClass(type: Type, className: string): void { var wrapperClasses = this.wrapperClasses; assert(!type.isInternalReference && !wrapperClasses.has(type)); - var element = assert(this.lookupGlobal(className)); + var element = assert(this.lookup(className)); assert(element.kind == ElementKind.CLASS_PROTOTYPE); var classElement = assert(this.resolver.resolveClass(element, null)); classElement.wrappedType = type; @@ -1679,20 +1686,6 @@ export class Program extends DiagnosticEmitter { return element; } - /** Looks up the element of the specified name in the global scope. */ - lookupGlobal(name: string): Element | null { - var elements = this.elementsByName; - if (elements.has(name)) return assert(elements.get(name)); - return null; - } - - /** Looks up the element of the specified name in the global scope. Errors if not present. */ - requireGlobal(name: string): Element { - var elements = this.elementsByName; - if (elements.has(name)) return assert(elements.get(name)); - throw new Error("missing global"); - } - /** Tries to locate a foreign file given its normalized path. */ private lookupForeignFile( /** Normalized path to the other file. */ @@ -2527,7 +2520,7 @@ export class Program extends DiagnosticEmitter { default: assert(false); // namespace member expected } } - if (original != element) copyMembers(original, element); // retain original parent + if (original != element) copyMembers(original, element); // keep original parent return element; } @@ -3055,7 +3048,7 @@ export class File extends Element { lookup(name: string): Element | null { var element = this.lookupInSelf(name); if (element) return element; - return this.program.lookupGlobal(name); + return this.program.lookup(name); } /** Ensures that an element is an export of this file. */ @@ -4341,8 +4334,7 @@ export class Class extends TypedElement { var program = this.program; var payloadSize = this.nextMemoryOffset + overhead; var blockSize = program.computeBlockSize(payloadSize, true); // excl. overhead - var totalSize = program.blockOverhead + blockSize; - var buffer = new Uint8Array(totalSize); + var buffer = new Uint8Array(program.blockOverhead + blockSize); var OBJECT = program.OBJECTInstance; OBJECT.writeField("mmInfo", blockSize, buffer, 0); OBJECT.writeField("gcInfo", 1, buffer, 0); // RC = 1 diff --git a/src/resolver.ts b/src/resolver.ts index c3ffdf6695..4de7b91840 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -1156,7 +1156,7 @@ export class Resolver extends DiagnosticEmitter { this.currentElementExpression = null; return element; } - if (element = this.program.lookupGlobal(name)) { + if (element = this.program.lookup(name)) { this.currentThisExpression = null; this.currentElementExpression = null; return element; diff --git a/tests/compiler/class-overloading.optimized.wat b/tests/compiler/class-overloading.optimized.wat index 66f96f06da..453d52ad9f 100644 --- a/tests/compiler/class-overloading.optimized.wat +++ b/tests/compiler/class-overloading.optimized.wat @@ -688,10 +688,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:class-overloading ) (func $class-overloading/A#a@virtual (param $0 i32) diff --git a/tests/compiler/class-overloading.untouched.wat b/tests/compiler/class-overloading.untouched.wat index 61c1c74ca0..2a930ce90f 100644 --- a/tests/compiler/class-overloading.untouched.wat +++ b/tests/compiler/class-overloading.untouched.wat @@ -1132,10 +1132,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:class-overloading ) (func $class-overloading/F#a (param $0 i32) (param $1 i32) diff --git a/tests/compiler/features/js-bigint-integration.optimized.wat b/tests/compiler/features/js-bigint-integration.optimized.wat index 205eca354a..b3f9d9fc1e 100644 --- a/tests/compiler/features/js-bigint-integration.optimized.wat +++ b/tests/compiler/features/js-bigint-integration.optimized.wat @@ -20,10 +20,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started global.get $features/js-bigint-integration/externalValue i64.const 9007199254740991 i64.ne diff --git a/tests/compiler/features/js-bigint-integration.untouched.wat b/tests/compiler/features/js-bigint-integration.untouched.wat index 0826c65673..51dcfc375b 100644 --- a/tests/compiler/features/js-bigint-integration.untouched.wat +++ b/tests/compiler/features/js-bigint-integration.untouched.wat @@ -47,10 +47,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:features/js-bigint-integration ) ) diff --git a/tests/compiler/features/mutable-globals.optimized.wat b/tests/compiler/features/mutable-globals.optimized.wat index ec2cb52728..cda319bf99 100644 --- a/tests/compiler/features/mutable-globals.optimized.wat +++ b/tests/compiler/features/mutable-globals.optimized.wat @@ -15,10 +15,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started global.get $features/mutable-globals/external i32.const 123 i32.ne diff --git a/tests/compiler/features/mutable-globals.untouched.wat b/tests/compiler/features/mutable-globals.untouched.wat index cb4be66177..870fa6a997 100644 --- a/tests/compiler/features/mutable-globals.untouched.wat +++ b/tests/compiler/features/mutable-globals.untouched.wat @@ -74,10 +74,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:features/mutable-globals ) ) diff --git a/tests/compiler/retain-release.optimized.wat b/tests/compiler/retain-release.optimized.wat index 511018c885..a8099f3ee2 100644 --- a/tests/compiler/retain-release.optimized.wat +++ b/tests/compiler/retain-release.optimized.wat @@ -245,10 +245,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started i32.const 1132 global.set $~lib/rt/stub/offset i32.const 0 diff --git a/tests/compiler/retain-release.untouched.wat b/tests/compiler/retain-release.untouched.wat index d844329b3d..3c30d43f74 100644 --- a/tests/compiler/retain-release.untouched.wat +++ b/tests/compiler/retain-release.untouched.wat @@ -850,10 +850,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:retain-release ) ) diff --git a/tests/compiler/retain-return.optimized.wat b/tests/compiler/retain-return.optimized.wat index 707b363fff..344d524fe2 100644 --- a/tests/compiler/retain-return.optimized.wat +++ b/tests/compiler/retain-return.optimized.wat @@ -952,10 +952,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $~lib/rt/pure/__new drop call $~lib/rt/pure/__new diff --git a/tests/compiler/retain-return.untouched.wat b/tests/compiler/retain-return.untouched.wat index 413e6498d0..be329e00c1 100644 --- a/tests/compiler/retain-return.untouched.wat +++ b/tests/compiler/retain-return.untouched.wat @@ -1681,10 +1681,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:retain-return ) (func $~lib/rt/tlsf/freeBlock (param $0 i32) (param $1 i32) diff --git a/tests/compiler/rt/finalize.optimized.wat b/tests/compiler/rt/finalize.optimized.wat index 328fcfbfe2..561545b506 100644 --- a/tests/compiler/rt/finalize.optimized.wat +++ b/tests/compiler/rt/finalize.optimized.wat @@ -1507,10 +1507,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:rt/finalize ) (func $~lib/rt/tlsf/freeBlock (param $0 i32) (param $1 i32) diff --git a/tests/compiler/rt/finalize.untouched.wat b/tests/compiler/rt/finalize.untouched.wat index 6d9c38c425..1c4f9d5b93 100644 --- a/tests/compiler/rt/finalize.untouched.wat +++ b/tests/compiler/rt/finalize.untouched.wat @@ -2109,10 +2109,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:rt/finalize ) (func $~lib/staticarray/StaticArray#__uget (param $0 i32) (param $1 i32) (result i32) diff --git a/tests/compiler/rt/instanceof.optimized.wat b/tests/compiler/rt/instanceof.optimized.wat index 8452b66c4b..85161cd681 100644 --- a/tests/compiler/rt/instanceof.optimized.wat +++ b/tests/compiler/rt/instanceof.optimized.wat @@ -408,10 +408,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:rt/instanceof ) ) diff --git a/tests/compiler/rt/instanceof.untouched.wat b/tests/compiler/rt/instanceof.untouched.wat index 6fa648a1b4..0f751cc27f 100644 --- a/tests/compiler/rt/instanceof.untouched.wat +++ b/tests/compiler/rt/instanceof.untouched.wat @@ -719,10 +719,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:rt/instanceof ) ) diff --git a/tests/compiler/rt/stub-realloc.optimized.wat b/tests/compiler/rt/stub-realloc.optimized.wat index ee222437c6..baf7db82b6 100644 --- a/tests/compiler/rt/stub-realloc.optimized.wat +++ b/tests/compiler/rt/stub-realloc.optimized.wat @@ -595,10 +595,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started i32.const 1196 global.set $~lib/rt/stub/startOffset i32.const 1196 diff --git a/tests/compiler/rt/stub-realloc.untouched.wat b/tests/compiler/rt/stub-realloc.untouched.wat index 72e9360d03..a03c5eb08d 100644 --- a/tests/compiler/rt/stub-realloc.untouched.wat +++ b/tests/compiler/rt/stub-realloc.untouched.wat @@ -1736,10 +1736,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started global.get $~lib/memory/__heap_base i32.const 4 i32.add diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index b804d00e96..13100f4a86 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -1624,10 +1624,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:std/symbol ) ) diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index 197e397106..cc2705015b 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -3571,10 +3571,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:std/symbol ) ) diff --git a/tests/compiler/std/trace.optimized.wat b/tests/compiler/std/trace.optimized.wat index 851c8ec865..2a0e521ca4 100644 --- a/tests/compiler/std/trace.optimized.wat +++ b/tests/compiler/std/trace.optimized.wat @@ -18,10 +18,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started i32.const 1056 i32.const 0 f64.const 0 diff --git a/tests/compiler/std/trace.untouched.wat b/tests/compiler/std/trace.untouched.wat index 816fe855e9..7896fe16d4 100644 --- a/tests/compiler/std/trace.untouched.wat +++ b/tests/compiler/std/trace.untouched.wat @@ -85,10 +85,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:std/trace ) ) diff --git a/tests/compiler/typeof.optimized.wat b/tests/compiler/typeof.optimized.wat index fd29a688f9..654f23567e 100644 --- a/tests/compiler/typeof.optimized.wat +++ b/tests/compiler/typeof.optimized.wat @@ -467,10 +467,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:typeof ) ) diff --git a/tests/compiler/typeof.untouched.wat b/tests/compiler/typeof.untouched.wat index 5dc2dc800b..889004ce47 100644 --- a/tests/compiler/typeof.untouched.wat +++ b/tests/compiler/typeof.untouched.wat @@ -732,10 +732,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:typeof ) ) diff --git a/tests/compiler/wasi/trace.optimized.wat b/tests/compiler/wasi/trace.optimized.wat index a71b5068ec..001b5f9c88 100644 --- a/tests/compiler/wasi/trace.optimized.wat +++ b/tests/compiler/wasi/trace.optimized.wat @@ -1864,10 +1864,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started i32.const 2076 global.set $~lib/rt/stub/offset i32.const 0 diff --git a/tests/compiler/wasi/trace.untouched.wat b/tests/compiler/wasi/trace.untouched.wat index ec26523ed6..d475094413 100644 --- a/tests/compiler/wasi/trace.untouched.wat +++ b/tests/compiler/wasi/trace.untouched.wat @@ -3697,10 +3697,9 @@ global.get $~started if return - else - i32.const 1 - global.set $~started end + i32.const 1 + global.set $~started call $start:wasi/trace ) )