Remove the start decorator in favor of a command line option

This commit is contained in:
dcode 2019-06-05 18:52:04 +02:00
parent dfe04d08e4
commit eaea26b7ae
44 changed files with 3676 additions and 3228 deletions

View File

@ -441,6 +441,7 @@ exports.main = function main(argv, options, callback) {
assemblyscript.setImportMemory(compilerOptions, args.importMemory); assemblyscript.setImportMemory(compilerOptions, args.importMemory);
assemblyscript.setSharedMemory(compilerOptions, args.sharedMemory); assemblyscript.setSharedMemory(compilerOptions, args.sharedMemory);
assemblyscript.setImportTable(compilerOptions, args.importTable); assemblyscript.setImportTable(compilerOptions, args.importTable);
assemblyscript.setExplicitStart(compilerOptions, args.explicitStart);
assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0); assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);
assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null); assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);
assemblyscript.setOptimizeLevelHints(compilerOptions, optimizeLevel, shrinkLevel); assemblyscript.setOptimizeLevelHints(compilerOptions, optimizeLevel, shrinkLevel);

View File

@ -129,6 +129,11 @@
"type": "b", "type": "b",
"default": false "default": false
}, },
"explicitStart": {
"description": "Exports an explicit start function to be called manually.",
"type": "b",
"default": false
},
"lib": { "lib": {
"description": [ "description": [
"Adds one or multiple paths to custom library components and", "Adds one or multiple paths to custom library components and",

View File

@ -100,6 +100,9 @@ Besides demangling classes exported from your entry file to a handy object struc
var value = module.F64[ptr >>> 3]; var value = module.F64[ptr >>> 3];
``` ```
* **__start**(): `void`<br />
Explicit start function if the `--explicit-start` option is used. Must be called before any other exports if present.
* **__allocString**(str: `string`): `number`<br /> * **__allocString**(str: `string`): `number`<br />
Allocates a new string in the module's memory and returns a reference (pointer) to it. Allocates a new string in the module's memory and returns a reference (pointer) to it.

View File

@ -43,6 +43,8 @@ interface ASUtil {
readonly F32: Float32Array; readonly F32: Float32Array;
/** A 64-bit float view on the memory. */ /** A 64-bit float view on the memory. */
readonly F64: Float64Array; readonly F64: Float64Array;
/** Explicit start function, if requested. */
__start(): void;
/** Allocates a new string in the module's memory and returns a reference (pointer) to it. */ /** Allocates a new string in the module's memory and returns a reference (pointer) to it. */
__allocString(str: string): number; __allocString(str: string): number;
/** Reads (copies) the value of a string from the module's memory. */ /** Reads (copies) the value of a string from the module's memory. */

View File

@ -1184,7 +1184,6 @@ export enum DecoratorKind {
EXTERNAL, EXTERNAL,
BUILTIN, BUILTIN,
LAZY, LAZY,
START,
UNSAFE UNSAFE
} }
@ -1221,7 +1220,6 @@ export function decoratorNameToKind(name: Expression): DecoratorKind {
} }
case CharCode.s: { case CharCode.s: {
if (nameStr == "sealed") return DecoratorKind.SEALED; if (nameStr == "sealed") return DecoratorKind.SEALED;
if (nameStr == "start") return DecoratorKind.START;
break; break;
} }
case CharCode.u: { case CharCode.u: {

View File

@ -193,6 +193,8 @@ export class Options {
importTable: bool = false; importTable: bool = false;
/** If true, generates information necessary for source maps. */ /** If true, generates information necessary for source maps. */
sourceMap: bool = false; sourceMap: bool = false;
/** If true, generates an explicit start function. */
explicitStart: bool = false;
/** Static memory start offset. */ /** Static memory start offset. */
memoryBase: i32 = 0; memoryBase: i32 = 0;
/** Global aliases. */ /** Global aliases. */
@ -366,10 +368,21 @@ export class Compiler extends DiagnosticEmitter {
} }
} }
// compile the start function if not empty or called by main // compile the start function if not empty or explicitly requested
var hasExplicitStart = program.explicitStartFunction !== null; var startIsEmpty = !startFunctionBody.length;
if (startFunctionBody.length || hasExplicitStart) { var explicitStart = options.explicitStart;
if (!startIsEmpty || explicitStart) {
let signature = startFunctionInstance.signature; let signature = startFunctionInstance.signature;
if (!startIsEmpty && explicitStart) {
module.addGlobal(BuiltinSymbols.started, NativeType.I32, true, module.i32(0));
startFunctionBody.unshift(
module.if(
module.global_get(BuiltinSymbols.started, NativeType.I32),
module.return(),
module.global_set(BuiltinSymbols.started, module.i32(1))
)
);
}
let funcRef = module.addFunction( let funcRef = module.addFunction(
startFunctionInstance.internalName, startFunctionInstance.internalName,
this.ensureFunctionType( this.ensureFunctionType(
@ -381,7 +394,8 @@ export class Compiler extends DiagnosticEmitter {
module.block(null, startFunctionBody) module.block(null, startFunctionBody)
); );
startFunctionInstance.finalize(module, funcRef); startFunctionInstance.finalize(module, funcRef);
if (!hasExplicitStart) module.setStart(funcRef); if (!explicitStart) module.setStart(funcRef);
else module.addFunctionExport(startFunctionInstance.internalName, "__start");
} }
// compile runtime features // compile runtime features
@ -1149,23 +1163,6 @@ export class Compiler extends DiagnosticEmitter {
} }
} }
// make the main function call `start` implicitly, but only once
if (instance.prototype == this.program.explicitStartFunction) {
module.addGlobal(BuiltinSymbols.started, NativeType.I32, true, module.i32(0));
stmts.unshift(
module.if(
module.unary(
UnaryOp.EqzI32,
module.global_get(BuiltinSymbols.started, NativeType.I32)
),
module.block(null, [
module.call("start", null, NativeType.None),
module.global_set(BuiltinSymbols.started, module.i32(1))
])
)
);
}
// make constructors return their instance pointer // make constructors return their instance pointer
if (instance.is(CommonFlags.CONSTRUCTOR)) { if (instance.is(CommonFlags.CONSTRUCTOR)) {
let nativeSizeType = this.options.nativeSizeType; let nativeSizeType = this.options.nativeSizeType;

View File

@ -99,6 +99,11 @@ export function setGlobalAlias(options: Options, name: string, alias: string): v
globalAliases.set(name, alias); globalAliases.set(name, alias);
} }
/** Sets the `explicitStart` option. */
export function setExplicitStart(options: Options, explicitStart: bool): void {
options.explicitStart = explicitStart;
}
/** Sign extension operations. */ /** Sign extension operations. */
export const FEATURE_SIGN_EXTENSION = Feature.SIGN_EXTENSION; export const FEATURE_SIGN_EXTENSION = Feature.SIGN_EXTENSION;
/** Mutable global imports and exports. */ /** Mutable global imports and exports. */

View File

@ -321,8 +321,6 @@ export class Program extends DiagnosticEmitter {
nativeSource: Source; nativeSource: Source;
/** Special native code file. */ /** Special native code file. */
nativeFile: File; nativeFile: File;
/** Explicitly annotated start function. */
explicitStartFunction: FunctionPrototype | null = null;
// lookup maps // lookup maps
@ -1663,11 +1661,6 @@ export class Program extends DiagnosticEmitter {
validDecorators |= DecoratorFlags.GLOBAL; validDecorators |= DecoratorFlags.GLOBAL;
} }
} }
if (!declaration.is(CommonFlags.GENERIC)) {
if (parent.kind == ElementKind.FILE && (<File>parent).source.isEntry) {
validDecorators |= DecoratorFlags.START;
}
}
var element = new FunctionPrototype( var element = new FunctionPrototype(
name, name,
parent, parent,
@ -1675,14 +1668,6 @@ export class Program extends DiagnosticEmitter {
this.checkDecorators(declaration.decorators, validDecorators) this.checkDecorators(declaration.decorators, validDecorators)
); );
if (!parent.add(name, element)) return null; if (!parent.add(name, element)) return null;
if (element.hasDecorator(DecoratorFlags.START)) {
if (this.explicitStartFunction) {
this.error(
DiagnosticCode.Module_cannot_have_multiple_start_functions,
assert(findDecorator(DecoratorKind.START, declaration.decorators)).range
);
} else this.explicitStartFunction = element;
}
return element; return element;
} }
@ -1921,10 +1906,8 @@ export enum DecoratorFlags {
BUILTIN = 1 << 8, BUILTIN = 1 << 8,
/** Is compiled lazily. */ /** Is compiled lazily. */
LAZY = 1 << 9, LAZY = 1 << 9,
/** Is the explicit start function. */
START = 1 << 10,
/** Is considered unsafe code. */ /** Is considered unsafe code. */
UNSAFE = 1 << 11 UNSAFE = 1 << 10
} }
/** Translates a decorator kind to the respective decorator flag. */ /** Translates a decorator kind to the respective decorator flag. */
@ -1941,7 +1924,6 @@ export function decoratorKindToFlag(kind: DecoratorKind): DecoratorFlags {
case DecoratorKind.EXTERNAL: return DecoratorFlags.EXTERNAL; case DecoratorKind.EXTERNAL: return DecoratorFlags.EXTERNAL;
case DecoratorKind.BUILTIN: return DecoratorFlags.BUILTIN; case DecoratorKind.BUILTIN: return DecoratorFlags.BUILTIN;
case DecoratorKind.LAZY: return DecoratorFlags.LAZY; case DecoratorKind.LAZY: return DecoratorFlags.LAZY;
case DecoratorKind.START: return DecoratorFlags.START;
case DecoratorKind.UNSAFE: return DecoratorFlags.UNSAFE; case DecoratorKind.UNSAFE: return DecoratorFlags.UNSAFE;
default: return DecoratorFlags.NONE; default: return DecoratorFlags.NONE;
} }

View File

@ -351,10 +351,9 @@ function testInstantiate(basename, binaryBuffer, name) {
"var": 3 "var": 3
} }
}).exports; }).exports;
if (exports.main) { if (exports.__start) {
console.log(colorsUtil.white(" [main]")); console.log(colorsUtil.white(" [start]"));
let code = exports.main(); exports.__start();
console.log(colorsUtil.white(" [exit " + code + "]\n"));
} }
}); });
let leakCount = rtr.check(); let leakCount = rtr.check();

View File

@ -1,5 +0,0 @@
{
"asc_flags": [
"--runtime none"
]
}

View File

@ -1,23 +0,0 @@
(module
(type $FUNCSIG$v (func))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(memory $0 0)
(global $main/code (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(export "memory" (memory $0))
(export "main" (func $main/main))
(func $main/main (; 0 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
global.get $~lib/started
i32.eqz
if
i32.const 1
global.set $main/code
i32.const 1
global.set $~lib/started
end
global.get $main/code
)
(func $null (; 1 ;) (type $FUNCSIG$v)
nop
)
)

View File

@ -1,7 +0,0 @@
var code = 0;
code = 1;
@start
export function main(argc: i32, argv: usize): i32 {
return code;
}

View File

@ -1,30 +0,0 @@
(module
(type $FUNCSIG$v (func))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(memory $0 0)
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $main/code (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(export "memory" (memory $0))
(export "main" (func $main/main))
(func $start:main (; 0 ;) (type $FUNCSIG$v)
i32.const 1
global.set $main/code
)
(func $main/main (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
global.get $~lib/started
i32.eqz
if
call $start
i32.const 1
global.set $~lib/started
end
global.get $main/code
)
(func $start (; 2 ;) (type $FUNCSIG$v)
call $start:main
)
(func $null (; 3 ;) (type $FUNCSIG$v)
)
)

View File

@ -33,9 +33,8 @@
(global $~lib/rt/pure/CUR (mut i32) (i32.const 0)) (global $~lib/rt/pure/CUR (mut i32) (i32.const 0))
(global $~lib/rt/pure/END (mut i32) (i32.const 0)) (global $~lib/rt/pure/END (mut i32) (i32.const 0))
(global $~lib/rt/pure/ROOTS (mut i32) (i32.const 0)) (global $~lib/rt/pure/ROOTS (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "main" (func $retain-release-sanity/main)) (start $start)
(func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -2601,14 +2600,8 @@
call $~lib/rt/pure/__release call $~lib/rt/pure/__release
call $~lib/rt/pure/__collect call $~lib/rt/pure/__collect
) )
(func $retain-release-sanity/main (; 42 ;) (type $FUNCSIG$v) (func $start (; 42 ;) (type $FUNCSIG$v)
global.get $~lib/started call $start:retain-release-sanity
i32.eqz
if
call $start:retain-release-sanity
i32.const 1
global.set $~lib/started
end
) )
(func $~lib/rt/pure/__visit (; 43 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/rt/pure/__visit (; 43 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0 local.get $0

View File

@ -1,4 +1,3 @@
@start export function main(): void {}
{ {
let arr: i32[] = new Array<i32>(3); let arr: i32[] = new Array<i32>(3);
arr.push(123); arr.push(123);

View File

@ -36,11 +36,10 @@
(global $~lib/rt/pure/END (mut i32) (i32.const 0)) (global $~lib/rt/pure/END (mut i32) (i32.const 0))
(global $~lib/rt/pure/ROOTS (mut i32) (i32.const 0)) (global $~lib/rt/pure/ROOTS (mut i32) (i32.const 0))
(global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/rt/__rtti_base i32 (i32.const 680)) (global $~lib/rt/__rtti_base i32 (i32.const 680))
(global $~lib/heap/__heap_base i32 (i32.const 748)) (global $~lib/heap/__heap_base i32 (i32.const 748))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "main" (func $retain-release-sanity/main)) (start $start)
(func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -4537,22 +4536,13 @@
end end
call $~lib/rt/pure/__collect call $~lib/rt/pure/__collect
) )
(func $retain-release-sanity/main (; 48 ;) (type $FUNCSIG$v) (func $start (; 48 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start
i32.const 1
global.set $~lib/started
end
)
(func $start (; 49 ;) (type $FUNCSIG$v)
call $start:retain-release-sanity call $start:retain-release-sanity
) )
(func $~lib/array/Array<i32>#__visit_impl (; 50 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/Array<i32>#__visit_impl (; 49 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
nop nop
) )
(func $~lib/rt/pure/__visit (; 51 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/rt/pure/__visit (; 50 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
local.get $0 local.get $0
@ -4706,7 +4696,7 @@
end end
end end
) )
(func $~lib/array/Array<~lib/string/String>#__visit_impl (; 52 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/Array<~lib/string/String>#__visit_impl (; 51 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -4744,7 +4734,7 @@
end end
end end
) )
(func $~lib/array/Array<~lib/array/Array<~lib/string/String>>#__visit_impl (; 53 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/Array<~lib/array/Array<~lib/string/String>>#__visit_impl (; 52 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -4782,7 +4772,7 @@
end end
end end
) )
(func $~lib/rt/__visit_members (; 54 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/rt/__visit_members (; 53 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
block $block$4$break block $block$4$break
block block
@ -4896,6 +4886,6 @@
end end
unreachable unreachable
) )
(func $null (; 55 ;) (type $FUNCSIG$v) (func $null (; 54 ;) (type $FUNCSIG$v)
) )
) )

View File

@ -1,5 +1,6 @@
{ {
"asc_flags": [ "asc_flags": [
"--runtime none" "--runtime none",
"--explicitStart"
] ]
} }

View File

@ -17,6 +17,8 @@
(global $retain-release/glo (mut i32) (i32.const 0)) (global $retain-release/glo (mut i32) (i32.const 0))
(global $retain-release/TARGET (mut i32) (i32.const 0)) (global $retain-release/TARGET (mut i32) (i32.const 0))
(global $~lib/argc (mut i32) (i32.const 0)) (global $~lib/argc (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(export "__start" (func $start))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "returnRef" (func $retain-release/returnRef)) (export "returnRef" (func $retain-release/returnRef))
(export "receiveRef" (func $retain-release/receiveRef)) (export "receiveRef" (func $retain-release/receiveRef))
@ -52,7 +54,6 @@
(export "provideRefIndirect" (func $retain-release/provideRefIndirect)) (export "provideRefIndirect" (func $retain-release/provideRefIndirect))
(export "receiveRefIndirect" (func $retain-release/receiveRefIndirect)) (export "receiveRefIndirect" (func $retain-release/receiveRefIndirect))
(export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirect)) (export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirect))
(start $start)
(func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -206,6 +207,13 @@
) )
(func $start (; 15 ;) (type $FUNCSIG$v) (func $start (; 15 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
global.get $~lib/started
if
return
else
i32.const 1
global.set $~lib/started
end
i32.const 96 i32.const 96
global.set $~lib/rt/stub/startOffset global.set $~lib/rt/stub/startOffset
global.get $~lib/rt/stub/startOffset global.get $~lib/rt/stub/startOffset

View File

@ -17,7 +17,9 @@
(global $retain-release/glo (mut i32) (i32.const 0)) (global $retain-release/glo (mut i32) (i32.const 0))
(global $retain-release/TARGET (mut i32) (i32.const 0)) (global $retain-release/TARGET (mut i32) (i32.const 0))
(global $~lib/argc (mut i32) (i32.const 0)) (global $~lib/argc (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/heap/__heap_base i32 (i32.const 92)) (global $~lib/heap/__heap_base i32 (i32.const 92))
(export "__start" (func $start))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "returnRef" (func $retain-release/returnRef)) (export "returnRef" (func $retain-release/returnRef))
(export "receiveRef" (func $retain-release/receiveRef)) (export "receiveRef" (func $retain-release/receiveRef))
@ -53,7 +55,6 @@
(export "provideRefIndirect" (func $retain-release/provideRefIndirect)) (export "provideRefIndirect" (func $retain-release/provideRefIndirect))
(export "receiveRefIndirect" (func $retain-release/receiveRefIndirect)) (export "receiveRefIndirect" (func $retain-release/receiveRefIndirect))
(export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirectDrop)) (export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirectDrop))
(start $start)
(func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -666,6 +667,13 @@
call $~lib/rt/stub/__release call $~lib/rt/stub/__release
) )
(func $start (; 41 ;) (type $FUNCSIG$v) (func $start (; 41 ;) (type $FUNCSIG$v)
global.get $~lib/started
if
return
else
i32.const 1
global.set $~lib/started
end
call $start:retain-release call $start:retain-release
) )
(func $null (; 42 ;) (type $FUNCSIG$v) (func $null (; 42 ;) (type $FUNCSIG$v)

View File

@ -1,5 +1,6 @@
{ {
"asc_flags": [ "asc_flags": [
"--runtime none" "--runtime none",
"--explicitStart"
] ]
} }

View File

@ -20,8 +20,8 @@
(global $rt/instanceof/nullCat i32 (i32.const 0)) (global $rt/instanceof/nullCat i32 (i32.const 0))
(global $rt/instanceof/nullBlackcat i32 (i32.const 0)) (global $rt/instanceof/nullBlackcat i32 (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0)) (global $~lib/started (mut i32) (i32.const 0))
(export "__start" (func $start))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "main" (func $rt/instanceof/main))
(func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32) (local $1 i32)
(local $2 i32) (local $2 i32)
@ -531,14 +531,15 @@
unreachable unreachable
end end
) )
(func $rt/instanceof/main (; 7 ;) (type $FUNCSIG$v) (func $start (; 7 ;) (type $FUNCSIG$v)
global.get $~lib/started global.get $~lib/started
i32.eqz
if if
call $start:rt/instanceof return
else
i32.const 1 i32.const 1
global.set $~lib/started global.set $~lib/started
end end
call $start:rt/instanceof
) )
(func $null (; 8 ;) (type $FUNCSIG$v) (func $null (; 8 ;) (type $FUNCSIG$v)
nop nop

View File

@ -49,5 +49,3 @@ assert(!(nullCat instanceof BlackCat)); // dynamic false
assert(!(nullBlackcat instanceof Animal)); // static false assert(!(nullBlackcat instanceof Animal)); // static false
assert(!(nullBlackcat instanceof Cat)); // dynamic false assert(!(nullBlackcat instanceof Cat)); // dynamic false
assert(!(nullBlackcat instanceof BlackCat)); // dynamic false assert(!(nullBlackcat instanceof BlackCat)); // dynamic false
@start export function main(): void {}

View File

@ -24,8 +24,8 @@
(global $~lib/started (mut i32) (i32.const 0)) (global $~lib/started (mut i32) (i32.const 0))
(global $~lib/rt/__rtti_base i32 (i32.const 56)) (global $~lib/rt/__rtti_base i32 (i32.const 56))
(global $~lib/heap/__heap_base i32 (i32.const 108)) (global $~lib/heap/__heap_base i32 (i32.const 108))
(export "__start" (func $start))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "main" (func $rt/instanceof/main))
(func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -719,18 +719,16 @@
unreachable unreachable
end end
) )
(func $rt/instanceof/main (; 9 ;) (type $FUNCSIG$v) (func $start (; 9 ;) (type $FUNCSIG$v)
global.get $~lib/started global.get $~lib/started
i32.eqz
if if
call $start return
else
i32.const 1 i32.const 1
global.set $~lib/started global.set $~lib/started
end end
)
(func $start (; 10 ;) (type $FUNCSIG$v)
call $start:rt/instanceof call $start:rt/instanceof
) )
(func $null (; 11 ;) (type $FUNCSIG$v) (func $null (; 10 ;) (type $FUNCSIG$v)
) )
) )

View File

@ -1,6 +1,7 @@
{ {
"asc_flags": [ "asc_flags": [
"--runtime full", "--runtime half",
"--explicitStart",
"--use ASC_RTRACE=1" "--use ASC_RTRACE=1"
] ]
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,6 @@
import { Array } from "array"; import { Array } from "array";
import { COMPARATOR } from "util/sort"; import { COMPARATOR } from "util/sort";
@start export function main(): void {}
// Obtains the internal capacity of an array from its backing buffer. // Obtains the internal capacity of an array from its backing buffer.
function internalCapacity<T>(array: Array<T>): i32 { function internalCapacity<T>(array: Array<T>): i32 {
// the memory region used by the backing buffer might still be larger in that the ArrayBuffer // the memory region used by the backing buffer might still be larger in that the ArrayBuffer

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
{ {
"asc_flags": [ "asc_flags": [
"--runtime half", "--runtime half",
"--explicitStart",
"--use ASC_RTRACE=1" "--use ASC_RTRACE=1"
] ]
} }

View File

@ -193,9 +193,9 @@
(global $~lib/util/number/_frc_pow (mut i64) (i64.const 0)) (global $~lib/util/number/_frc_pow (mut i64) (i64.const 0))
(global $~lib/util/number/_exp_pow (mut i32) (i32.const 0)) (global $~lib/util/number/_exp_pow (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0)) (global $~lib/started (mut i32) (i32.const 0))
(export "__start" (func $start))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "getString" (func $std/string/getString)) (export "getString" (func $std/string/getString))
(export "main" (func $std/string/main))
(func $~lib/string/String#get:length (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $~lib/string/String#get:length (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0 local.get $0
i32.const 16 i32.const 16
@ -8925,14 +8925,15 @@
global.get $std/string/str global.get $std/string/str
call $~lib/rt/pure/__retain call $~lib/rt/pure/__retain
) )
(func $std/string/main (; 75 ;) (type $FUNCSIG$v) (func $start (; 75 ;) (type $FUNCSIG$v)
global.get $~lib/started global.get $~lib/started
i32.eqz
if if
call $start:std/string return
else
i32.const 1 i32.const 1
global.set $~lib/started global.set $~lib/started
end end
call $start:std/string
) )
(func $~lib/rt/pure/markGray (; 76 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/pure/markGray (; 76 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32) (local $1 i32)

View File

@ -310,5 +310,3 @@ export function getString(): string {
// Unleak globals // Unleak globals
__release(changetype<usize>(str)); __release(changetype<usize>(str));
@start export function main(): void {}

View File

@ -211,9 +211,9 @@
(global $~lib/started (mut i32) (i32.const 0)) (global $~lib/started (mut i32) (i32.const 0))
(global $~lib/rt/__rtti_base i32 (i32.const 7032)) (global $~lib/rt/__rtti_base i32 (i32.const 7032))
(global $~lib/heap/__heap_base i32 (i32.const 7100)) (global $~lib/heap/__heap_base i32 (i32.const 7100))
(export "__start" (func $start))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "getString" (func $std/string/getString)) (export "getString" (func $std/string/getString))
(export "main" (func $std/string/main))
(func $~lib/string/String#get:length (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $~lib/string/String#get:length (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0 local.get $0
i32.const 16 i32.const 16
@ -12141,19 +12141,17 @@
global.get $std/string/str global.get $std/string/str
call $~lib/rt/pure/__retain call $~lib/rt/pure/__retain
) )
(func $std/string/main (; 84 ;) (type $FUNCSIG$v) (func $start (; 84 ;) (type $FUNCSIG$v)
global.get $~lib/started global.get $~lib/started
i32.eqz
if if
call $start return
else
i32.const 1 i32.const 1
global.set $~lib/started global.set $~lib/started
end end
)
(func $start (; 85 ;) (type $FUNCSIG$v)
call $start:std/string call $start:std/string
) )
(func $~lib/rt/pure/markGray (; 86 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/pure/markGray (; 85 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32) (local $1 i32)
local.get $0 local.get $0
i32.load offset=4 i32.load offset=4
@ -12180,7 +12178,7 @@
call $~lib/rt/__visit_members call $~lib/rt/__visit_members
end end
) )
(func $~lib/rt/pure/scanBlack (; 87 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/pure/scanBlack (; 86 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0 local.get $0
local.get $0 local.get $0
i32.load offset=4 i32.load offset=4
@ -12197,7 +12195,7 @@
i32.const 4 i32.const 4
call $~lib/rt/__visit_members call $~lib/rt/__visit_members
) )
(func $~lib/rt/pure/scan (; 88 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/pure/scan (; 87 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32) (local $1 i32)
local.get $0 local.get $0
i32.load offset=4 i32.load offset=4
@ -12234,7 +12232,7 @@
end end
end end
) )
(func $~lib/rt/pure/collectWhite (; 89 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/pure/collectWhite (; 88 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32) (local $1 i32)
local.get $0 local.get $0
i32.load offset=4 i32.load offset=4
@ -12272,7 +12270,7 @@
call $~lib/rt/tlsf/freeBlock call $~lib/rt/tlsf/freeBlock
end end
) )
(func $~lib/rt/pure/__visit (; 90 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/rt/pure/__visit (; 89 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
local.get $0 local.get $0
@ -12426,7 +12424,7 @@
end end
end end
) )
(func $~lib/array/Array<~lib/string/String>#__visit_impl (; 91 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/Array<~lib/string/String>#__visit_impl (; 90 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -12464,19 +12462,19 @@
end end
end end
) )
(func $~lib/array/Array<i32>#__visit_impl (; 92 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/Array<i32>#__visit_impl (; 91 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
nop nop
) )
(func $~lib/array/Array<u32>#__visit_impl (; 93 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/Array<u32>#__visit_impl (; 92 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
nop nop
) )
(func $~lib/array/Array<u64>#__visit_impl (; 94 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/Array<u64>#__visit_impl (; 93 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
nop nop
) )
(func $~lib/array/Array<i16>#__visit_impl (; 95 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/Array<i16>#__visit_impl (; 94 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
nop nop
) )
(func $~lib/rt/__visit_members (; 96 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/rt/__visit_members (; 95 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
block $block$4$break block $block$4$break
block block
@ -12626,6 +12624,6 @@
end end
unreachable unreachable
) )
(func $null (; 97 ;) (type $FUNCSIG$v) (func $null (; 96 ;) (type $FUNCSIG$v)
) )
) )

View File

@ -1,5 +1,6 @@
{ {
"asc_flags": [ "asc_flags": [
"--runtime none" "--runtime none",
"--explicitStart"
] ]
} }

View File

@ -12,8 +12,8 @@
(data (i32.const 240) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00f\00i\00v\00e\00_\00i\00n\00t") (data (i32.const 240) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00f\00i\00v\00e\00_\00i\00n\00t")
(data (i32.const 272) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00f\00i\00v\00e\00_\00d\00b\00l") (data (i32.const 272) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00f\00i\00v\00e\00_\00d\00b\00l")
(global $~lib/started (mut i32) (i32.const 0)) (global $~lib/started (mut i32) (i32.const 0))
(export "__start" (func $start))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "main" (func $std/trace/main))
(func $start:std/trace (; 1 ;) (type $FUNCSIG$v) (func $start:std/trace (; 1 ;) (type $FUNCSIG$v)
i32.const 24 i32.const 24
i32.const 0 i32.const 0
@ -80,14 +80,15 @@
f64.const 5.5 f64.const 5.5
call $~lib/builtins/trace call $~lib/builtins/trace
) )
(func $std/trace/main (; 2 ;) (type $FUNCSIG$v) (func $start (; 2 ;) (type $FUNCSIG$v)
global.get $~lib/started global.get $~lib/started
i32.eqz
if if
call $start:std/trace return
else
i32.const 1 i32.const 1
global.set $~lib/started global.set $~lib/started
end end
call $start:std/trace
) )
(func $null (; 3 ;) (type $FUNCSIG$v) (func $null (; 3 ;) (type $FUNCSIG$v)
nop nop

View File

@ -6,6 +6,3 @@ trace("three_int", 3, 1, 2, 3);
trace("four_int", 4, 1, 2, 3, 4); trace("four_int", 4, 1, 2, 3, 4);
trace("five_int", 5, 1, 2, 3, 4, 5); trace("five_int", 5, 1, 2, 3, 4, 5);
trace("five_dbl", 5, 1.1, 2.2, 3.3, 4.4, 5.5); trace("five_dbl", 5, 1.1, 2.2, 3.3, 4.4, 5.5);
@start
export function main(): void {}

View File

@ -14,8 +14,8 @@
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $~lib/started (mut i32) (i32.const 0)) (global $~lib/started (mut i32) (i32.const 0))
(export "__start" (func $start))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "main" (func $std/trace/main))
(func $start:std/trace (; 1 ;) (type $FUNCSIG$v) (func $start:std/trace (; 1 ;) (type $FUNCSIG$v)
i32.const 24 i32.const 24
i32.const 0 i32.const 0
@ -82,18 +82,16 @@
f64.const 5.5 f64.const 5.5
call $~lib/builtins/trace call $~lib/builtins/trace
) )
(func $std/trace/main (; 2 ;) (type $FUNCSIG$v) (func $start (; 2 ;) (type $FUNCSIG$v)
global.get $~lib/started global.get $~lib/started
i32.eqz
if if
call $start return
else
i32.const 1 i32.const 1
global.set $~lib/started global.set $~lib/started
end end
)
(func $start (; 3 ;) (type $FUNCSIG$v)
call $start:std/trace call $start:std/trace
) )
(func $null (; 4 ;) (type $FUNCSIG$v) (func $null (; 3 ;) (type $FUNCSIG$v)
) )
) )

View File

@ -1,6 +1,7 @@
{ {
"asc_flags": [ "asc_flags": [
"--runtime half", "--runtime half",
"--explicitStart",
"--use ASC_RTRACE=1" "--use ASC_RTRACE=1"
] ]
} }

View File

@ -87,8 +87,8 @@
(global $std/typedarray/forEachValues i32 (i32.const 1112)) (global $std/typedarray/forEachValues i32 (i32.const 1112))
(global $std/typedarray/testArrayReverseValues i32 (i32.const 1480)) (global $std/typedarray/testArrayReverseValues i32 (i32.const 1480))
(global $~lib/started (mut i32) (i32.const 0)) (global $~lib/started (mut i32) (i32.const 0))
(export "__start" (func $start))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "main" (func $std/typedarray/main))
(func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -15524,14 +15524,15 @@
global.get $std/typedarray/testArrayReverseValues global.get $std/typedarray/testArrayReverseValues
call $~lib/rt/pure/__release call $~lib/rt/pure/__release
) )
(func $std/typedarray/main (; 285 ;) (type $FUNCSIG$v) (func $start (; 285 ;) (type $FUNCSIG$v)
global.get $~lib/started global.get $~lib/started
i32.eqz
if if
call $start:std/typedarray return
else
i32.const 1 i32.const 1
global.set $~lib/started global.set $~lib/started
end end
call $start:std/typedarray
) )
(func $~lib/rt/pure/markGray (; 286 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/pure/markGray (; 286 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32) (local $1 i32)

View File

@ -491,8 +491,6 @@ testArrayReverse<Uint64Array, u64>();
testArrayReverse<Float32Array, f32>(); testArrayReverse<Float32Array, f32>();
testArrayReverse<Float64Array, f64>(); testArrayReverse<Float64Array, f64>();
@start export function main(): void {}
// Unleak globals // Unleak globals
__release(changetype<usize>(forEachValues)); __release(changetype<usize>(forEachValues));

View File

@ -104,8 +104,8 @@
(global $~lib/started (mut i32) (i32.const 0)) (global $~lib/started (mut i32) (i32.const 0))
(global $~lib/rt/__rtti_base i32 (i32.const 1688)) (global $~lib/rt/__rtti_base i32 (i32.const 1688))
(global $~lib/heap/__heap_base i32 (i32.const 1820)) (global $~lib/heap/__heap_base i32 (i32.const 1820))
(export "__start" (func $start))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "main" (func $std/typedarray/main))
(func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -23151,25 +23151,23 @@
global.get $std/typedarray/testArrayReverseValues global.get $std/typedarray/testArrayReverseValues
call $~lib/rt/pure/__release call $~lib/rt/pure/__release
) )
(func $std/typedarray/main (; 393 ;) (type $FUNCSIG$v) (func $start (; 393 ;) (type $FUNCSIG$v)
global.get $~lib/started global.get $~lib/started
i32.eqz
if if
call $start return
else
i32.const 1 i32.const 1
global.set $~lib/started global.set $~lib/started
end end
)
(func $start (; 394 ;) (type $FUNCSIG$v)
call $start:std/typedarray call $start:std/typedarray
) )
(func $~lib/array/Array<i8>#__visit_impl (; 395 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/Array<i8>#__visit_impl (; 394 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
nop nop
) )
(func $~lib/array/Array<i32>#__visit_impl (; 396 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/Array<i32>#__visit_impl (; 395 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
nop nop
) )
(func $~lib/rt/pure/markGray (; 397 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/pure/markGray (; 396 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32) (local $1 i32)
local.get $0 local.get $0
i32.load offset=4 i32.load offset=4
@ -23196,7 +23194,7 @@
call $~lib/rt/__visit_members call $~lib/rt/__visit_members
end end
) )
(func $~lib/rt/pure/scanBlack (; 398 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/pure/scanBlack (; 397 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0 local.get $0
local.get $0 local.get $0
i32.load offset=4 i32.load offset=4
@ -23213,7 +23211,7 @@
i32.const 4 i32.const 4
call $~lib/rt/__visit_members call $~lib/rt/__visit_members
) )
(func $~lib/rt/pure/scan (; 399 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/pure/scan (; 398 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32) (local $1 i32)
local.get $0 local.get $0
i32.load offset=4 i32.load offset=4
@ -23250,7 +23248,7 @@
end end
end end
) )
(func $~lib/rt/pure/collectWhite (; 400 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/pure/collectWhite (; 399 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32) (local $1 i32)
local.get $0 local.get $0
i32.load offset=4 i32.load offset=4
@ -23288,7 +23286,7 @@
call $~lib/rt/tlsf/freeBlock call $~lib/rt/tlsf/freeBlock
end end
) )
(func $~lib/rt/pure/__visit (; 401 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/rt/pure/__visit (; 400 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
local.get $0 local.get $0
@ -23442,7 +23440,7 @@
end end
end end
) )
(func $~lib/rt/__visit_members (; 402 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/rt/__visit_members (; 401 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
block $block$4$break block $block$4$break
block block
@ -23538,6 +23536,6 @@
end end
unreachable unreachable
) )
(func $null (; 403 ;) (type $FUNCSIG$v) (func $null (; 402 ;) (type $FUNCSIG$v)
) )
) )

View File

@ -1 +1 @@
@start export function main(): void {} export { __free };

View File

@ -27,6 +27,7 @@ fetch("untouched.wasm").then(result =>
}) })
).then(result => { ).then(result => {
exports = result.instance.exports; exports = result.instance.exports;
if (exports.__start) exports.__start();
U32 = new Uint32Array(exports.memory.buffer); U32 = new Uint32Array(exports.memory.buffer);
var first = exports.__alloc(255); var first = exports.__alloc(255);
exports.__free(first); exports.__free(first);

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff