Always try to eliminate branches if tree-shaking is enabled

This commit is contained in:
dcodeIO 2018-04-24 23:11:11 +02:00
parent 97e7158fff
commit 391db28fe2
38 changed files with 782 additions and 789 deletions

2
dist/asc.js vendored

File diff suppressed because one or more lines are too long

2
dist/asc.js.map vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
(module (module
(type $iiv (func (param i32 i32))) (type $iiv (func (param i32 i32)))
(type $F (func (result f64))) (type $F (func (result f64)))
(type $i (func (result i32)))
(type $v (func)) (type $v (func))
(type $iiFv (func (param i32 i32 f64))) (type $iiFv (func (param i32 i32 f64)))
(import "env" "RGB_ALIVE" (global $assembly/index/RGB_ALIVE i32)) (import "env" "RGB_ALIVE" (global $assembly/index/RGB_ALIVE i32))

View File

@ -1,5 +1,6 @@
(module (module
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $FF (func (param f64) (result f64))) (type $FF (func (param f64) (result f64)))
(type $Fi (func (param f64) (result i32))) (type $Fi (func (param f64) (result i32)))
(type $FFFF (func (param f64 f64 f64) (result f64))) (type $FFFF (func (param f64 f64 f64) (result f64)))

View File

@ -1,5 +1,8 @@
import "allocator/arena"; import "allocator/arena";
// From The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org
const SOLAR_MASS = 4.0 * Math.PI * Math.PI; const SOLAR_MASS = 4.0 * Math.PI * Math.PI;
const DAYS_PER_YEAR = 365.24; const DAYS_PER_YEAR = 365.24;
@ -79,9 +82,9 @@ function Neptune(): Body {
class NBodySystem { class NBodySystem {
bodies: Body[]; constructor(
public bodies: Body[]
constructor(bodies: Body[]) { ) {
var px = 0.0; var px = 0.0;
var py = 0.0; var py = 0.0;
var pz = 0.0; var pz = 0.0;
@ -93,16 +96,17 @@ class NBodySystem {
py += b.vy * m; py += b.vy * m;
pz += b.vz * m; pz += b.vz * m;
} }
this.bodies = bodies; bodies[0].offsetMomentum(px, py, pz);
this.bodies[0].offsetMomentum(px, py, pz);
} }
advance(dt: f64): void { advance(dt: f64): void {
var bodies = this.bodies; var bodies = this.bodies;
var size = bodies.length; var size: u32 = bodies.length;
// var buffer = changetype<usize>(bodies.buffer_);
for (let i = 0; i < size; ++i) { for (let i: u32 = 0; i < size; ++i) {
let bodyi = bodies[i]; let bodyi = bodies[i];
// let bodyi = load<Body>(buffer + i * sizeof<Body>(), 8);
let ix = bodyi.x; let ix = bodyi.x;
let iy = bodyi.y; let iy = bodyi.y;
@ -113,8 +117,10 @@ class NBodySystem {
let bivz = bodyi.vz; let bivz = bodyi.vz;
let bodyim = bodyi.mass; let bodyim = bodyi.mass;
for (let j = i + 1; j < size; ++j) { for (let j: u32 = i + 1; j < size; ++j) {
let bodyj = bodies[j]; let bodyj = bodies[j];
// let bodyj = load<Body>(buffer + j * sizeof<Body>(), 8);
let dx = ix - bodyj.x; let dx = ix - bodyj.x;
let dy = iy - bodyj.y; let dy = iy - bodyj.y;
let dz = iz - bodyj.z; let dz = iz - bodyj.z;
@ -148,9 +154,8 @@ class NBodySystem {
energy(): f64 { energy(): f64 {
var e = 0.0; var e = 0.0;
var bodies = this.bodies; var bodies = this.bodies;
var size = bodies.length;
for (let i = 0; i < size; ++i) { for (let i: u32 = 0, size: u32 = bodies.length; i < size; ++i) {
let bodyi = bodies[i]; let bodyi = bodies[i];
let ix = bodyi.x; let ix = bodyi.x;
@ -165,7 +170,7 @@ class NBodySystem {
e += 0.5 * bim * (vx * vx + vy * vy + vz * vz); e += 0.5 * bim * (vx * vx + vy * vy + vz * vz);
for (let j = i + 1; j < size; ++j) { for (let j: u32 = i + 1; j < size; ++j) {
let bodyj = bodies[j]; let bodyj = bodies[j];
let dx = ix - bodyj.x; let dx = ix - bodyj.x;
let dy = iy - bodyj.y; let dy = iy - bodyj.y;

View File

@ -679,40 +679,38 @@ function asmFunc(global, env, buffer) {
function assembly_index_NBodySystem_constructor($0, $1) { function assembly_index_NBodySystem_constructor($0, $1) {
$0 = $0 | 0; $0 = $0 | 0;
$1 = $1 | 0; $1 = $1 | 0;
var $2 = 0, $3 = 0, $5 = 0, $4 = 0.0, $6 = 0.0, $7 = 0.0, $8 = 0.0, $9 = 0, $9 = 0, $11 = 0, $12 = 0; var $2 = 0, $3 = 0, $4 = 0.0, $9 = 0, $5 = 0.0, $6 = 0.0, $7 = 0.0, $9 = 0, $8 = 0, $11 = 0, $12 = 0;
$2 = $1; $3 = $1;
$9 = HEAP32[($2 + 4 | 0) >> 2] | 0; $8 = HEAP32[($3 + 4 | 0) >> 2] | 0;
continue_0 : do { continue_0 : do {
if (($3 | 0) < ($9 | 0)) { if (($2 | 0) < ($8 | 0)) {
$2 = $3; $9 = $2;
$5 = $1; $3 = $1;
$5 = HEAPU32[$5 >> 2] | 0; $3 = HEAPU32[$3 >> 2] | 0;
if ($2 >>> 0 < ((HEAP32[$5 >> 2] | 0) >>> 2 | 0) >>> 0) $11 = HEAPU32[(($5 + ($2 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort(); if ($9 >>> 0 < ((HEAP32[$3 >> 2] | 0) >>> 2 | 0) >>> 0) $11 = HEAPU32[(($3 + ($9 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort();
$2 = $11; $3 = $11;
$4 = +HEAPF64[($2 + 48 | 0) >> 3]; $4 = +HEAPF64[($3 + 48 | 0) >> 3];
$6 = $6 + +HEAPF64[($2 + 24 | 0) >> 3] * $4; $5 = $5 + +HEAPF64[($3 + 24 | 0) >> 3] * $4;
$7 = $7 + +HEAPF64[($2 + 32 | 0) >> 3] * $4; $6 = $6 + +HEAPF64[($3 + 32 | 0) >> 3] * $4;
$8 = $8 + +HEAPF64[($2 + 40 | 0) >> 3] * $4; $7 = $7 + +HEAPF64[($3 + 40 | 0) >> 3] * $4;
$3 = $3 + 1 | 0; $2 = $2 + 1 | 0;
continue continue_0; continue continue_0;
} }
break continue_0; break continue_0;
} while (1); } while (1);
$2 = $1;
$2 = HEAPU32[$2 >> 2] | 0;
if (0 >>> 0 < ((HEAP32[$2 >> 2] | 0) >>> 2 | 0) >>> 0) $12 = HEAPU32[(($2 + 0 | 0) + 8 | 0) >> 2] | 0; else abort();
$2 = $12;
HEAPF64[($2 + 24 | 0) >> 3] = -$5 / 39.47841760435743;
HEAPF64[($2 + 32 | 0) >> 3] = -$6 / 39.47841760435743;
HEAPF64[($2 + 40 | 0) >> 3] = -$7 / 39.47841760435743;
if ($0) $9 = $0; else { if ($0) $9 = $0; else {
$3 = $lib_allocator_arena_allocate_memory(4 | 0) | 0; $2 = $lib_allocator_arena_allocate_memory(4 | 0) | 0;
HEAP32[$3 >> 2] = 0; HEAP32[$2 >> 2] = $1;
$0 = $3; $9 = $2;
$9 = $0;
} }
HEAP32[$9 >> 2] = $1; return $9 | 0;
$1 = HEAPU32[$0 >> 2] | 0;
$1 = HEAPU32[$1 >> 2] | 0;
if (0 >>> 0 < ((HEAP32[$1 >> 2] | 0) >>> 2 | 0) >>> 0) $12 = HEAPU32[(($1 + 0 | 0) + 8 | 0) >> 2] | 0; else abort();
$1 = $12;
HEAPF64[($1 + 24 | 0) >> 3] = -$6 / 39.47841760435743;
HEAPF64[($1 + 32 | 0) >> 3] = -$7 / 39.47841760435743;
HEAPF64[($1 + 40 | 0) >> 3] = -$8 / 39.47841760435743;
return $0 | 0;
} }
function assembly_index_init() { function assembly_index_init() {
@ -746,7 +744,7 @@ function asmFunc(global, env, buffer) {
$0 = $13; $0 = $13;
$14 = HEAP32[($0 + 4 | 0) >> 2] | 0; $14 = HEAP32[($0 + 4 | 0) >> 2] | 0;
continue_0 : do { continue_0 : do {
if (($6 | 0) < ($14 | 0)) { if ($6 >>> 0 < $14 >>> 0) {
$3 = $6; $3 = $6;
$0 = $13; $0 = $13;
$0 = HEAPU32[$0 >> 2] | 0; $0 = HEAPU32[$0 >> 2] | 0;
@ -761,7 +759,7 @@ function asmFunc(global, env, buffer) {
$18 = +HEAPF64[($0 + 48 | 0) >> 3]; $18 = +HEAPF64[($0 + 48 | 0) >> 3];
$3 = $6 + 1 | 0; $3 = $6 + 1 | 0;
continue_1 : do { continue_1 : do {
if (($3 | 0) < ($14 | 0)) { if ($3 >>> 0 < $14 >>> 0) {
$21 = $15; $21 = $15;
$19 = $3; $19 = $3;
$2 = $13; $2 = $13;
@ -807,7 +805,7 @@ function asmFunc(global, env, buffer) {
$0 = $4; $0 = $4;
$5 = HEAP32[($0 + 4 | 0) >> 2] | 0; $5 = HEAP32[($0 + 4 | 0) >> 2] | 0;
continue_0 : do { continue_0 : do {
if (($3 | 0) < ($5 | 0)) { if ($3 >>> 0 < $5 >>> 0) {
$2 = $3; $2 = $3;
$0 = $4; $0 = $4;
$0 = HEAPU32[$0 >> 2] | 0; $0 = HEAPU32[$0 >> 2] | 0;
@ -826,7 +824,7 @@ function asmFunc(global, env, buffer) {
$1 = $13 + .5 * $10 * ($15 + $1 * $1); $1 = $13 + .5 * $10 * ($15 + $1 * $1);
$0 = $3 + 1 | 0; $0 = $3 + 1 | 0;
continue_1 : do { continue_1 : do {
if (($0 | 0) < ($5 | 0)) { if ($0 >>> 0 < $5 >>> 0) {
$16 = $7; $16 = $7;
$11 = $0; $11 = $0;
$2 = $4; $2 = $4;

View File

@ -116,13 +116,13 @@ class NBodySystem {
} }
var system; var system;
function init() { function init() {
var bodies = new Array(); system = new NBodySystem([
bodies.push(Sun()); Sun(),
bodies.push(Jupiter()); Jupiter(),
bodies.push(Saturn()); Saturn(),
bodies.push(Uranus()); Uranus(),
bodies.push(Neptune()); Neptune()
system = new NBodySystem(bodies); ]);
} }
exports.init = init; exports.init = init;
function getBody(index) { function getBody(index) {

Binary file not shown.

View File

@ -2601,14 +2601,14 @@
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 f64) (local $4 f64)
(local $5 i32) (local $5 f64)
(local $6 f64) (local $6 f64)
(local $7 f64) (local $7 f64)
(local $8 f64) (local $8 i32)
(local $9 i32) (local $9 i32)
(set_local $9 (set_local $8
(i32.load offset=4 (i32.load offset=4
(tee_local $2 (tee_local $3
(get_local $1) (get_local $1)
) )
) )
@ -2616,23 +2616,23 @@
(loop $continue|0 (loop $continue|0
(if (if
(i32.lt_s (i32.lt_s
(get_local $3) (get_local $2)
(get_local $9) (get_local $8)
) )
(block (block
(set_local $4 (set_local $4
(f64.load offset=48 (f64.load offset=48
(tee_local $2 (tee_local $3
(if (result i32) (if (result i32)
(i32.lt_u (i32.lt_u
(tee_local $2 (tee_local $9
(get_local $3) (get_local $2)
) )
(i32.shr_u (i32.shr_u
(i32.load (i32.load
(tee_local $5 (tee_local $3
(i32.load (i32.load
(tee_local $5 (tee_local $3
(get_local $1) (get_local $1)
) )
) )
@ -2643,9 +2643,9 @@
) )
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $5) (get_local $3)
(i32.shl (i32.shl
(get_local $2) (get_local $9)
(i32.const 2) (i32.const 2)
) )
) )
@ -2655,12 +2655,23 @@
) )
) )
) )
(set_local $5
(f64.add
(get_local $5)
(f64.mul
(f64.load offset=24
(get_local $3)
)
(get_local $4)
)
)
)
(set_local $6 (set_local $6
(f64.add (f64.add
(get_local $6) (get_local $6)
(f64.mul (f64.mul
(f64.load offset=24 (f64.load offset=32
(get_local $2) (get_local $3)
) )
(get_local $4) (get_local $4)
) )
@ -2669,28 +2680,17 @@
(set_local $7 (set_local $7
(f64.add (f64.add
(get_local $7) (get_local $7)
(f64.mul
(f64.load offset=32
(get_local $2)
)
(get_local $4)
)
)
)
(set_local $8
(f64.add
(get_local $8)
(f64.mul (f64.mul
(f64.load offset=40 (f64.load offset=40
(get_local $2) (get_local $3)
) )
(get_local $4) (get_local $4)
) )
) )
) )
(set_local $3 (set_local $2
(i32.add (i32.add
(get_local $3) (get_local $2)
(i32.const 1) (i32.const 1)
) )
) )
@ -2698,39 +2698,17 @@
) )
) )
) )
(i32.store
(if (result i32)
(get_local $0)
(get_local $0)
(block (result i32)
(i32.store
(tee_local $3
(call $~lib/allocator/arena/allocate_memory
(i32.const 4)
)
)
(i32.const 0)
)
(tee_local $0
(get_local $3)
)
)
)
(get_local $1)
)
(f64.store offset=24 (f64.store offset=24
(tee_local $1 (tee_local $2
(if (result i32) (if (result i32)
(i32.lt_u (i32.lt_u
(i32.const 0) (i32.const 0)
(i32.shr_u (i32.shr_u
(i32.load (i32.load
(tee_local $1 (tee_local $2
(i32.load (i32.load
(tee_local $1 (tee_local $2
(i32.load (get_local $1)
(get_local $0)
)
) )
) )
) )
@ -2740,7 +2718,7 @@
) )
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $1) (get_local $2)
(i32.const 0) (i32.const 0)
) )
) )
@ -2749,13 +2727,22 @@
) )
(f64.div (f64.div
(f64.neg (f64.neg
(get_local $6) (get_local $5)
) )
(f64.const 39.47841760435743) (f64.const 39.47841760435743)
) )
) )
(f64.store offset=32 (f64.store offset=32
(get_local $1) (get_local $2)
(f64.div
(f64.neg
(get_local $6)
)
(f64.const 39.47841760435743)
)
)
(f64.store offset=40
(get_local $2)
(f64.div (f64.div
(f64.neg (f64.neg
(get_local $7) (get_local $7)
@ -2763,16 +2750,21 @@
(f64.const 39.47841760435743) (f64.const 39.47841760435743)
) )
) )
(f64.store offset=40 (if (result i32)
(get_local $1) (get_local $0)
(f64.div (get_local $0)
(f64.neg (block (result i32)
(get_local $8) (i32.store
(tee_local $2
(call $~lib/allocator/arena/allocate_memory
(i32.const 4)
)
)
(get_local $1)
) )
(f64.const 39.47841760435743) (get_local $2)
) )
) )
(get_local $0)
) )
(func $assembly/index/init (; 11 ;) (type $v) (func $assembly/index/init (; 11 ;) (type $v)
(local $0 i32) (local $0 i32)
@ -2933,7 +2925,7 @@
) )
(loop $continue|0 (loop $continue|0
(if (if
(i32.lt_s (i32.lt_u
(get_local $6) (get_local $6)
(get_local $14) (get_local $14)
) )
@ -3011,7 +3003,7 @@
) )
(loop $continue|1 (loop $continue|1
(if (if
(i32.lt_s (i32.lt_u
(get_local $3) (get_local $3)
(get_local $14) (get_local $14)
) )
@ -3267,7 +3259,7 @@
) )
(loop $continue|0 (loop $continue|0
(if (if
(i32.lt_s (i32.lt_u
(get_local $3) (get_local $3)
(get_local $5) (get_local $5)
) )
@ -3368,7 +3360,7 @@
) )
(loop $continue|1 (loop $continue|1
(if (if
(i32.lt_s (i32.lt_u
(get_local $0) (get_local $0)
(get_local $5) (get_local $5)
) )

File diff suppressed because it is too large Load Diff

View File

@ -1053,8 +1053,7 @@ export enum DecoratorKind {
OPERATOR, OPERATOR,
UNMANAGED, UNMANAGED,
SEALED, SEALED,
INLINE, INLINE
PRECOMPUTE
} }
/** Returns the decorator kind represented by the specified string. */ /** Returns the decorator kind represented by the specified string. */
@ -1065,7 +1064,6 @@ export function stringToDecoratorKind(str: string): DecoratorKind {
case "unmanaged": return DecoratorKind.UNMANAGED; case "unmanaged": return DecoratorKind.UNMANAGED;
case "sealed": return DecoratorKind.SEALED; case "sealed": return DecoratorKind.SEALED;
case "inline": return DecoratorKind.INLINE; case "inline": return DecoratorKind.INLINE;
case "precompute": return DecoratorKind.PRECOMPUTE;
default: return DecoratorKind.CUSTOM; default: return DecoratorKind.CUSTOM;
} }
} }

View File

@ -1634,21 +1634,30 @@ export class Compiler extends DiagnosticEmitter {
module module
); );
// Eliminate unnecesssary branches in generic contexts if the condition is constant
if ( if (
this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT) && !this.options.noTreeShaking ||
_BinaryenExpressionGetId(condExpr = this.precomputeExpressionRef(condExpr)) == ExpressionId.Const && this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT)
_BinaryenExpressionGetType(condExpr) == NativeType.I32
) { ) {
let ret: ExpressionRef; // Try to eliminate unnecesssary branches if the condition is constant
if (_BinaryenConstGetValueI32(condExpr)) { let condExprPrecomp = this.precomputeExpressionRef(condExpr);
ret = this.compileStatement(ifTrue); if (
} else if (ifFalse) { _BinaryenExpressionGetId(condExprPrecomp) == ExpressionId.Const &&
ret = this.compileStatement(ifFalse); _BinaryenExpressionGetType(condExprPrecomp) == NativeType.I32
} else { ) {
ret = module.createNop(); return _BinaryenConstGetValueI32(condExprPrecomp)
? this.compileStatement(ifTrue)
: ifFalse
? this.compileStatement(ifFalse)
: module.createNop();
// Otherwise recompile to the original and let the optimizer decide
} else /* if (condExpr != condExprPrecomp) <- not guaranteed */ {
condExpr = makeIsTrueish(
this.compileExpression(statement.condition, Type.i32, ConversionKind.NONE),
this.currentType,
module
);
} }
return ret;
} }
// Each arm initiates a branch // Each arm initiates a branch
@ -1992,14 +2001,25 @@ export class Compiler extends DiagnosticEmitter {
module module
); );
// Eliminate unnecesssary loops in generic contexts if the condition is constant
if ( if (
this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT) && !this.options.noTreeShaking ||
_BinaryenExpressionGetId(condExpr = this.precomputeExpressionRef(condExpr)) == ExpressionId.Const && this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT)
_BinaryenExpressionGetType(condExpr) == NativeType.I32
) { ) {
if (!_BinaryenConstGetValueI32(condExpr)) { // Try to eliminate unnecesssary loops if the condition is constant
return module.createNop(); let condExprPrecomp = this.precomputeExpressionRef(condExpr);
if (
_BinaryenExpressionGetId(condExprPrecomp) == ExpressionId.Const &&
_BinaryenExpressionGetType(condExprPrecomp) == NativeType.I32
) {
if (!_BinaryenConstGetValueI32(condExprPrecomp)) return module.createNop();
// Otherwise recompile to the original and let the optimizer decide
} else /* if (condExpr != condExprPrecomp) <- not guaranteed */ {
condExpr = makeIsTrueish(
this.compileExpression(statement.condition, Type.i32, ConversionKind.NONE),
this.currentType,
module
);
} }
} }
@ -6050,6 +6070,7 @@ export class Compiler extends DiagnosticEmitter {
compileTernaryExpression(expression: TernaryExpression, contextualType: Type): ExpressionRef { compileTernaryExpression(expression: TernaryExpression, contextualType: Type): ExpressionRef {
var ifThen = expression.ifThen; var ifThen = expression.ifThen;
var ifElse = expression.ifElse; var ifElse = expression.ifElse;
var currentFunction = this.currentFunction;
var condExpr = makeIsTrueish( var condExpr = makeIsTrueish(
this.compileExpression(expression.condition, Type.u32, ConversionKind.NONE), this.compileExpression(expression.condition, Type.u32, ConversionKind.NONE),
@ -6057,18 +6078,30 @@ export class Compiler extends DiagnosticEmitter {
this.module this.module
); );
// Eliminate unnecesssary branches in generic contexts if the condition is constant
if ( if (
this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT) && !this.options.noTreeShaking ||
_BinaryenExpressionGetId(condExpr = this.precomputeExpressionRef(condExpr)) == ExpressionId.Const && this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT)
_BinaryenExpressionGetType(condExpr) == NativeType.I32
) { ) {
return _BinaryenConstGetValueI32(condExpr) // Try to eliminate unnecesssary branches if the condition is constant
? this.compileExpression(ifThen, contextualType) let condExprPrecomp = this.precomputeExpressionRef(condExpr);
: this.compileExpression(ifElse, contextualType); if (
_BinaryenExpressionGetId(condExprPrecomp) == ExpressionId.Const &&
_BinaryenExpressionGetType(condExprPrecomp) == NativeType.I32
) {
return _BinaryenConstGetValueI32(condExprPrecomp)
? this.compileExpression(ifThen, contextualType)
: this.compileExpression(ifElse, contextualType);
// Otherwise recompile to the original and let the optimizer decide
} else /* if (condExpr != condExprPrecomp) <- not guaranteed */ {
condExpr = makeIsTrueish(
this.compileExpression(expression.condition, Type.u32, ConversionKind.NONE),
this.currentType,
this.module
);
}
} }
var currentFunction = this.currentFunction;
var ifThenExpr: ExpressionRef; var ifThenExpr: ExpressionRef;
var ifElseExpr: ExpressionRef; var ifElseExpr: ExpressionRef;
var ifThenType: Type; var ifThenType: Type;
@ -6891,3 +6924,8 @@ export function makeConditionalAllocate(compiler: Compiler, classInstance: Class
) )
); );
} }
export function isI32Const(expr: ExpressionRef): bool {
return _BinaryenExpressionGetId(expr) == ExpressionId.Const
&& _BinaryenExpressionGetType(expr) == NativeType.I32;
}

View File

@ -629,6 +629,7 @@ export class Program extends DiagnosticEmitter {
): void { ): void {
var name = declaration.name.text; var name = declaration.name.text;
var internalName = declaration.fileLevelInternalName; var internalName = declaration.fileLevelInternalName;
var decorators = declaration.decorators;
// static fields become global variables // static fields become global variables
if (declaration.is(CommonFlags.STATIC)) { if (declaration.is(CommonFlags.STATIC)) {
@ -655,7 +656,10 @@ export class Program extends DiagnosticEmitter {
name, name,
internalName, internalName,
Type.void, // resolved later on Type.void, // resolved later on
declaration declaration,
decorators
? this.filterDecorators(decorators, DecoratorFlags.NONE)
: DecoratorFlags.NONE
); );
staticField.parent = classPrototype; staticField.parent = classPrototype;
classPrototype.members.set(name, staticField); classPrototype.members.set(name, staticField);
@ -683,6 +687,7 @@ export class Program extends DiagnosticEmitter {
internalName, internalName,
declaration declaration
); );
if (decorators) this.filterDecorators(decorators, DecoratorFlags.NONE);
classPrototype.instanceMembers.set(name, instanceField); classPrototype.instanceMembers.set(name, instanceField);
// TBD: no need to mark as MODULE_EXPORT // TBD: no need to mark as MODULE_EXPORT
} }
@ -700,6 +705,7 @@ export class Program extends DiagnosticEmitter {
var decoratorFlags = DecoratorFlags.NONE; var decoratorFlags = DecoratorFlags.NONE;
if (decorators) { if (decorators) {
decoratorFlags = this.filterDecorators(decorators, decoratorFlags = this.filterDecorators(decorators,
DecoratorFlags.OPERATOR |
DecoratorFlags.INLINE DecoratorFlags.INLINE
); );
} }
@ -1548,6 +1554,7 @@ export class Program extends DiagnosticEmitter {
var declarations = statement.declarations; var declarations = statement.declarations;
for (let i = 0, k = declarations.length; i < k; ++i) { for (let i = 0, k = declarations.length; i < k; ++i) {
let declaration = declarations[i]; let declaration = declarations[i];
let decorators = declaration.decorators;
let internalName = declaration.fileLevelInternalName; let internalName = declaration.fileLevelInternalName;
if (this.elementsLookup.has(internalName)) { if (this.elementsLookup.has(internalName)) {
this.error( this.error(
@ -1562,7 +1569,12 @@ export class Program extends DiagnosticEmitter {
simpleName, simpleName,
internalName, internalName,
Type.void, // resolved later on Type.void, // resolved later on
declaration declaration,
decorators
? this.filterDecorators(decorators,
DecoratorFlags.GLOBAL
)
: DecoratorFlags.NONE
); );
global.parent = namespace; global.parent = namespace;
this.elementsLookup.set(internalName, global); this.elementsLookup.set(internalName, global);
@ -2274,6 +2286,8 @@ export enum DecoratorFlags {
NONE = 0, NONE = 0,
/** Is a program global. */ /** Is a program global. */
GLOBAL = 1 << 0, GLOBAL = 1 << 0,
/** Is an operator overload. */
OPERATOR = 1 << 1,
/** Is an unmanaged class. */ /** Is an unmanaged class. */
UNMANAGED = 1 << 2, UNMANAGED = 1 << 2,
/** Is a sealed class. */ /** Is a sealed class. */
@ -2285,6 +2299,7 @@ export enum DecoratorFlags {
export function decoratorKindToFlag(kind: DecoratorKind): DecoratorFlags { export function decoratorKindToFlag(kind: DecoratorKind): DecoratorFlags {
switch (kind) { switch (kind) {
case DecoratorKind.GLOBAL: return DecoratorFlags.GLOBAL; case DecoratorKind.GLOBAL: return DecoratorFlags.GLOBAL;
case DecoratorKind.OPERATOR: return DecoratorFlags.OPERATOR;
case DecoratorKind.UNMANAGED: return DecoratorFlags.UNMANAGED; case DecoratorKind.UNMANAGED: return DecoratorFlags.UNMANAGED;
case DecoratorKind.SEALED: return DecoratorFlags.SEALED; case DecoratorKind.SEALED: return DecoratorFlags.SEALED;
case DecoratorKind.INLINE: return DecoratorFlags.INLINE; case DecoratorKind.INLINE: return DecoratorFlags.INLINE;
@ -2453,10 +2468,12 @@ export class Global extends VariableLikeElement {
simpleName: string, simpleName: string,
internalName: string, internalName: string,
type: Type, type: Type,
declaration: VariableLikeDeclarationStatement | null declaration: VariableLikeDeclarationStatement | null,
decoratorFlags: DecoratorFlags
) { ) {
super(program, simpleName, internalName, type, declaration); super(program, simpleName, internalName, type, declaration);
this.flags = declaration ? declaration.flags : CommonFlags.NONE; this.flags = declaration ? declaration.flags : CommonFlags.NONE;
this.decoratorFlags = decoratorFlags;
this.type = type; // resolved later if `void` this.type = type; // resolved later if `void`
} }
} }

2
std/assembly.d.ts vendored
View File

@ -531,7 +531,7 @@ declare const Mathf: IMath<f32>;
/** Annotates an element as a program global. */ /** Annotates an element as a program global. */
declare function global(target: Function, propertyKey: string, descriptor: any): void; declare function global(target: Function, propertyKey: string, descriptor: any): void;
/** Annotates a method as an operator overload. */ /** Annotates a method as an operator overload for the specified `token`. */
declare function operator(token: string): (target: any, propertyKey: string, descriptor: any) => void; declare function operator(token: string): (target: any, propertyKey: string, descriptor: any) => void;
/** Annotates a class as being unmanaged with limited capabilities. */ /** Annotates a class as being unmanaged with limited capabilities. */

View File

@ -2,10 +2,6 @@ import {
TypedArray TypedArray
} from "./internal/typedarray"; } from "./internal/typedarray";
import {
storeUnsafeWithOffset
} from "./internal/arraybuffer";
export class Int8Array extends TypedArray<i8> { export class Int8Array extends TypedArray<i8> {
static readonly BYTES_PER_ELEMENT: usize = sizeof<i8>(); static readonly BYTES_PER_ELEMENT: usize = sizeof<i8>();

View File

@ -672,10 +672,10 @@
(loop $continue|0 (loop $continue|0
(if (if
;;@ ~lib/allocator/buddy.ts:381:9 ;;@ ~lib/allocator/buddy.ts:381:9
(i32.add (i32.ne
(get_local $1) (get_local $1)
;;@ ~lib/allocator/buddy.ts:381:18 ;;@ ~lib/allocator/buddy.ts:381:23
(i32.const 1) (i32.const -1)
) )
;;@ ~lib/allocator/buddy.ts:381:26 ;;@ ~lib/allocator/buddy.ts:381:26
(block (block

View File

@ -1,5 +1,6 @@
(module (module
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $HEAP_BASE i32 (i32.const 56)) (global $HEAP_BASE i32 (i32.const 56))

View File

@ -1,6 +1,7 @@
(module (module
(type $FFF (func (param f64 f64) (result f64))) (type $FFF (func (param f64 f64) (result f64)))
(type $F (func (result f64))) (type $F (func (result f64)))
(type $i (func (result i32)))
(type $FiF (func (param f64 i32) (result f64))) (type $FiF (func (param f64 i32) (result f64)))
(type $fff (func (param f32 f32) (result f32))) (type $fff (func (param f32 f32) (result f32)))
(type $fi (func (param f32) (result i32))) (type $fi (func (param f32) (result i32)))

View File

@ -1,5 +1,6 @@
(module (module
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $for/i (mut i32) (i32.const 0)) (global $for/i (mut i32) (i32.const 0))

View File

@ -1,5 +1,6 @@
(module (module
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $i (func (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))

View File

@ -126,50 +126,6 @@
(unreachable) (unreachable)
) )
) )
(if
(i32.ne
(tee_local $0
(i32.add
(tee_local $0
(i32.const 2)
)
(i32.const 1)
)
)
(i32.const 3)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 65)
(i32.const 2)
)
(unreachable)
)
)
(if
(i32.ne
(tee_local $0
(i32.add
(tee_local $0
(i32.const 3)
)
(i32.const 1)
)
)
(i32.const 4)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 66)
(i32.const 2)
)
(unreachable)
)
)
(if (if
(block (result i32) (block (result i32)
(set_global $~argc (set_global $~argc

View File

@ -223,20 +223,17 @@
(get_local $2) (get_local $2)
) )
(nop) (nop)
(if (block
(i32.const 1) (set_local $5
(block (get_local $3)
(set_local $5 )
(get_local $3) (set_local $6
) (get_local $5)
(set_local $6 )
(get_local $5) (set_local $4
) (i32.add
(set_local $4 (get_local $6)
(i32.add (i32.const 1)
(get_local $6)
(i32.const 1)
)
) )
) )
) )
@ -268,20 +265,17 @@
(get_local $4) (get_local $4)
) )
(nop) (nop)
(if (block
(i32.const 1) (set_local $6
(block (get_local $3)
(set_local $6 )
(get_local $3) (set_local $5
) (get_local $6)
(set_local $5 )
(get_local $6) (set_local $2
) (i32.add
(set_local $2 (get_local $5)
(i32.add (i32.const 1)
(get_local $5)
(i32.const 1)
)
) )
) )
) )

View File

@ -1,5 +1,6 @@
(module (module
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $FF (func (param f64) (result f64))) (type $FF (func (param f64) (result f64)))
(type $F (func (result f64))) (type $F (func (result f64)))
(type $Fi (func (param f64) (result i32))) (type $Fi (func (param f64) (result i32)))

View File

@ -1,5 +1,6 @@
(module (module
(type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32)))
(type $i (func (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))

View File

@ -1,5 +1,6 @@
(module (module
(type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32)))
(type $i (func (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))

View File

@ -1,5 +1,6 @@
(module (module
(type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32)))
(type $i (func (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))

View File

@ -1,5 +1,6 @@
(module (module
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $i (func (result i32)))
(global $HEAP_BASE i32 (i32.const 4)) (global $HEAP_BASE i32 (i32.const 4))
(memory $0 1) (memory $0 1)
(export "fib" (func $recursive/fib)) (export "fib" (func $recursive/fib))

View File

@ -1,6 +1,7 @@
(module (module
(type $FFF (func (param f64 f64) (result f64))) (type $FFF (func (param f64 f64) (result f64)))
(type $F (func (result f64))) (type $F (func (result f64)))
(type $i (func (result i32)))
(type $FiF (func (param f64 i32) (result f64))) (type $FiF (func (param f64 i32) (result f64)))
(type $fff (func (param f32 f32) (result f32))) (type $fff (func (param f32 f32) (result f32)))
(type $fi (func (param f32) (result i32))) (type $fi (func (param f32) (result i32)))
@ -8,7 +9,6 @@
(type $fif (func (param f32 i32) (result f32))) (type $fif (func (param f32 i32) (result f32)))
(type $Fi (func (param f64) (result i32))) (type $Fi (func (param f64) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iii (func (param i32 i32) (result i32))) (type $iii (func (param i32 i32) (result i32)))
(type $v (func)) (type $v (func))

View File

@ -3014,19 +3014,19 @@
(if (if
(i32.and (i32.and
(if (result i32) (if (result i32)
(tee_local $3 (tee_local $4
(i32.eqz (i32.eqz
(tee_local $4 (tee_local $3
(i32.load offset=4 (i32.load offset=4
(get_local $0) (get_local $0)
) )
) )
) )
) )
(get_local $3) (get_local $4)
(i32.ge_s (i32.ge_s
(get_local $2) (get_local $2)
(get_local $4) (get_local $3)
) )
) )
(i32.const 1) (i32.const 1)
@ -3042,9 +3042,9 @@
) )
(set_local $2 (set_local $2
(select (select
(tee_local $3 (tee_local $4
(i32.add (i32.add
(get_local $4) (get_local $3)
(get_local $2) (get_local $2)
) )
) )
@ -3052,13 +3052,13 @@
(i32.const 0) (i32.const 0)
) )
(i32.gt_s (i32.gt_s
(get_local $3) (get_local $4)
(get_local $2) (get_local $2)
) )
) )
) )
) )
(set_local $3 (set_local $0
(i32.load (i32.load
(get_local $0) (get_local $0)
) )
@ -3067,14 +3067,14 @@
(if (if
(i32.lt_s (i32.lt_s
(get_local $2) (get_local $2)
(get_local $4) (get_local $3)
) )
(block (block
(if (if
(i32.eq (i32.eq
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $3) (get_local $0)
(i32.shl (i32.shl
(get_local $2) (get_local $2)
(i32.const 2) (i32.const 2)
@ -3128,19 +3128,19 @@
(if (if
(i32.and (i32.and
(if (result i32) (if (result i32)
(tee_local $3 (tee_local $4
(i32.eqz (i32.eqz
(tee_local $4 (tee_local $3
(i32.load offset=4 (i32.load offset=4
(get_local $0) (get_local $0)
) )
) )
) )
) )
(get_local $3) (get_local $4)
(i32.ge_s (i32.ge_s
(get_local $2) (get_local $2)
(get_local $4) (get_local $3)
) )
) )
(i32.const 1) (i32.const 1)
@ -3156,9 +3156,9 @@
) )
(set_local $2 (set_local $2
(select (select
(tee_local $3 (tee_local $4
(i32.add (i32.add
(get_local $4) (get_local $3)
(get_local $2) (get_local $2)
) )
) )
@ -3166,13 +3166,13 @@
(i32.const 0) (i32.const 0)
) )
(i32.gt_s (i32.gt_s
(get_local $3) (get_local $4)
(get_local $2) (get_local $2)
) )
) )
) )
) )
(set_local $3 (set_local $0
(i32.load (i32.load
(get_local $0) (get_local $0)
) )
@ -3181,14 +3181,14 @@
(if (if
(i32.lt_s (i32.lt_s
(get_local $2) (get_local $2)
(get_local $4) (get_local $3)
) )
(block (block
(if (if
(i32.eq (i32.eq
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $3) (get_local $0)
(i32.shl (i32.shl
(get_local $2) (get_local $2)
(i32.const 2) (i32.const 2)

View File

@ -3589,19 +3589,19 @@
(block (block
(if (if
(i32.eq (i32.eq
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.4 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.5 (result i32)
(set_local $4 (set_local $5
(get_local $6) (get_local $6)
) )
(set_local $5 (set_local $4
(get_local $2) (get_local $2)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.4 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.5
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $4) (get_local $5)
(i32.shl (i32.shl
(get_local $5) (get_local $4)
(i32.const 2) (i32.const 2)
) )
) )
@ -3723,19 +3723,19 @@
(block (block
(if (if
(i32.eq (i32.eq
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.5 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.7 (result i32)
(set_local $4 (set_local $5
(get_local $6) (get_local $6)
) )
(set_local $5 (set_local $4
(get_local $2) (get_local $2)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.5 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.7
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $4) (get_local $5)
(i32.shl (i32.shl
(get_local $5) (get_local $4)
(i32.const 2) (i32.const 2)
) )
) )
@ -4023,19 +4023,19 @@
(i32.const 3) (i32.const 3)
) )
(call_indirect (type $iiii) (call_indirect (type $iiii)
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.6 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.9 (result i32)
(set_local $5 (set_local $6
(get_local $2) (get_local $2)
) )
(set_local $6 (set_local $5
(get_local $3) (get_local $3)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.6 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.9
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $5) (get_local $6)
(i32.shl (i32.shl
(get_local $6) (get_local $5)
(i32.const 2) (i32.const 2)
) )
) )
@ -4169,19 +4169,19 @@
(i32.const 3) (i32.const 3)
) )
(call_indirect (type $iiii) (call_indirect (type $iiii)
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.7 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.11 (result i32)
(set_local $5 (set_local $6
(get_local $2) (get_local $2)
) )
(set_local $6 (set_local $5
(get_local $3) (get_local $3)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.7 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.11
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $5) (get_local $6)
(i32.shl (i32.shl
(get_local $6) (get_local $5)
(i32.const 2) (i32.const 2)
) )
) )
@ -4309,19 +4309,19 @@
(i32.const 3) (i32.const 3)
) )
(call_indirect (type $iiii) (call_indirect (type $iiii)
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.8 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.13 (result i32)
(set_local $5 (set_local $6
(get_local $2) (get_local $2)
) )
(set_local $6 (set_local $5
(get_local $3) (get_local $3)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.8 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.13
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $5) (get_local $6)
(i32.shl (i32.shl
(get_local $6) (get_local $5)
(i32.const 2) (i32.const 2)
) )
) )
@ -4449,14 +4449,14 @@
(i32.const 3) (i32.const 3)
) )
(call_indirect (type $iiiv) (call_indirect (type $iiiv)
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.9 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.14 (result i32)
(set_local $5 (set_local $5
(get_local $2) (get_local $2)
) )
(set_local $6 (set_local $6
(get_local $3) (get_local $3)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.9 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.14
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $5) (get_local $5)
@ -4655,14 +4655,14 @@
(i32.const 3) (i32.const 3)
) )
(call_indirect (type $iiif) (call_indirect (type $iiif)
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.10 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.15 (result i32)
(set_local $10 (set_local $10
(get_local $2) (get_local $2)
) )
(set_local $11 (set_local $11
(get_local $6) (get_local $6)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.10 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.15
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $10) (get_local $10)
@ -4833,14 +4833,14 @@
(i32.const 3) (i32.const 3)
) )
(call_indirect (type $iiii) (call_indirect (type $iiii)
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.11 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.16 (result i32)
(set_local $10 (set_local $10
(get_local $2) (get_local $2)
) )
(set_local $11 (set_local $11
(get_local $6) (get_local $6)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.11 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.16
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $10) (get_local $10)
@ -4973,14 +4973,14 @@
(block (block
(block (block
(set_local $7 (set_local $7
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.12 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.17 (result i32)
(set_local $6 (set_local $6
(get_local $2) (get_local $2)
) )
(set_local $7 (set_local $7
(get_local $5) (get_local $5)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.12 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.17
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $6) (get_local $6)
@ -5142,14 +5142,14 @@
) )
(call_indirect (type $iiiii) (call_indirect (type $iiiii)
(get_local $3) (get_local $3)
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.13 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.18 (result i32)
(set_local $7 (set_local $7
(get_local $4) (get_local $4)
) )
(set_local $8 (set_local $8
(get_local $5) (get_local $5)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.13 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.18
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $7) (get_local $7)
@ -5257,14 +5257,14 @@
) )
(call_indirect (type $iiiii) (call_indirect (type $iiiii)
(get_local $3) (get_local $3)
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.14 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.19 (result i32)
(set_local $7 (set_local $7
(get_local $4) (get_local $4)
) )
(set_local $8 (set_local $8
(get_local $5) (get_local $5)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.14 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.19
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $7) (get_local $7)
@ -5388,14 +5388,14 @@
) )
(call_indirect (type $iiiii) (call_indirect (type $iiiii)
(get_local $3) (get_local $3)
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.15 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.20 (result i32)
(set_local $6 (set_local $6
(get_local $4) (get_local $4)
) )
(set_local $7 (set_local $7
(get_local $5) (get_local $5)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.15 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.20
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $6) (get_local $6)
@ -5486,14 +5486,14 @@
) )
(call_indirect (type $iiiii) (call_indirect (type $iiiii)
(get_local $3) (get_local $3)
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.16 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.21 (result i32)
(set_local $6 (set_local $6
(get_local $4) (get_local $4)
) )
(set_local $7 (set_local $7
(get_local $5) (get_local $5)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.16 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.21
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $6) (get_local $6)
@ -5882,14 +5882,14 @@
(block (block
(block (block
(set_local $6 (set_local $6
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.19 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.24 (result i32)
(set_local $5 (set_local $5
(get_local $2) (get_local $2)
) )
(set_local $6 (set_local $6
(get_local $3) (get_local $3)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.19 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.24
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $5) (get_local $5)
@ -5918,14 +5918,14 @@
(block (block
(block (block
(set_local $8 (set_local $8
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.20 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.25 (result i32)
(set_local $7 (set_local $7
(get_local $2) (get_local $2)
) )
(set_local $8 (set_local $8
(get_local $5) (get_local $5)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.20 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.25
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $7) (get_local $7)
@ -6154,14 +6154,14 @@
) )
) )
(set_local $10 (set_local $10
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.21 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.26 (result i32)
(set_local $9 (set_local $9
(get_local $5) (get_local $5)
) )
(set_local $10 (set_local $10
(get_local $8) (get_local $8)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.21 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.26
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $9) (get_local $9)
@ -6175,14 +6175,14 @@
) )
) )
(set_local $11 (set_local $11
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.22 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.27 (result i32)
(set_local $9 (set_local $9
(get_local $5) (get_local $5)
) )
(set_local $11 (set_local $11
(get_local $6) (get_local $6)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.22 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.27
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $9) (get_local $9)
@ -6315,14 +6315,14 @@
(block (block
(block (block
(set_local $10 (set_local $10
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.23 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.28 (result i32)
(set_local $11 (set_local $11
(get_local $5) (get_local $5)
) )
(set_local $10 (set_local $10
(i32.const 0) (i32.const 0)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.23 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.28
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $11) (get_local $11)
@ -6343,14 +6343,14 @@
(i32.const 0) (i32.const 0)
) )
(set_local $7 (set_local $7
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.24 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.29 (result i32)
(set_local $9 (set_local $9
(get_local $5) (get_local $5)
) )
(set_local $12 (set_local $12
(get_local $6) (get_local $6)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.24 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.29
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $9) (get_local $9)
@ -6452,14 +6452,14 @@
(block (block
(block (block
(set_local $10 (set_local $10
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.25 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.30 (result i32)
(set_local $7 (set_local $7
(get_local $5) (get_local $5)
) )
(set_local $12 (set_local $12
(i32.const 0) (i32.const 0)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.25 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.30
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $7) (get_local $7)
@ -6473,14 +6473,14 @@
) )
) )
(set_local $7 (set_local $7
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.26 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.31 (result i32)
(set_local $12 (set_local $12
(get_local $5) (get_local $5)
) )
(set_local $7 (set_local $7
(get_local $11) (get_local $11)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.26 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.31
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $12) (get_local $12)
@ -6613,14 +6613,14 @@
(get_local $4) (get_local $4)
) )
(set_local $14 (set_local $14
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.27 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.32 (result i32)
(set_local $6 (set_local $6
(get_local $5) (get_local $5)
) )
(set_local $8 (set_local $8
(i32.const 1) (i32.const 1)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.27 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.32
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $6) (get_local $6)
@ -6641,14 +6641,14 @@
(i32.const 1) (i32.const 1)
) )
(set_local $11 (set_local $11
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.28 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.33 (result i32)
(set_local $10 (set_local $10
(get_local $5) (get_local $5)
) )
(set_local $7 (set_local $7
(i32.const 0) (i32.const 0)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.28 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.33
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $10) (get_local $10)
@ -6731,14 +6731,14 @@
) )
(block (block
(set_local $5 (set_local $5
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.17 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.22 (result i32)
(set_local $4 (set_local $4
(get_local $3) (get_local $3)
) )
(set_local $5 (set_local $5
(i32.const 1) (i32.const 1)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.17 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.22
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $4) (get_local $4)
@ -6752,14 +6752,14 @@
) )
) )
(set_local $6 (set_local $6
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.18 (result i32) (block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.23 (result i32)
(set_local $4 (set_local $4
(get_local $3) (get_local $3)
) )
(set_local $6 (set_local $6
(i32.const 0) (i32.const 0)
) )
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.18 (br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.23
(i32.load offset=8 (i32.load offset=8
(i32.add (i32.add
(get_local $4) (get_local $4)

View File

@ -2,9 +2,10 @@
(type $F (func (result f64))) (type $F (func (result f64)))
(type $FF (func (param f64) (result f64))) (type $FF (func (param f64) (result f64)))
(type $f (func (result f32))) (type $f (func (result f32)))
(type $i (func (result i32)))
(type $I (func (result i64)))
(type $Fi (func (param f64) (result i32))) (type $Fi (func (param f64) (result i32)))
(type $FFF (func (param f64 f64) (result f64))) (type $FFF (func (param f64 f64) (result f64)))
(type $i (func (result i32)))
(type $FiF (func (param f64 i32) (result f64))) (type $FiF (func (param f64 i32) (result f64)))
(type $Ff (func (param f64) (result f32))) (type $Ff (func (param f64) (result f32)))
(global $std/libm/E f64 (f64.const 2.718281828459045)) (global $std/libm/E f64 (f64.const 2.718281828459045))

View File

@ -16,6 +16,7 @@
(type $fiffii (func (param f32 i32 f32 f32 i32) (result i32))) (type $fiffii (func (param f32 i32 f32 f32 i32) (result i32)))
(type $FF (func (param f64) (result f64))) (type $FF (func (param f64) (result f64)))
(type $ff (func (param f32) (result f32))) (type $ff (func (param f32) (result f32)))
(type $I (func (result i64)))
(type $FFFFii (func (param f64 f64 f64 f64 i32) (result i32))) (type $FFFFii (func (param f64 f64 f64 f64 i32) (result i32)))
(type $FFF (func (param f64 f64) (result f64))) (type $FFF (func (param f64 f64) (result f64)))
(type $ffffii (func (param f32 f32 f32 f32 i32) (result i32))) (type $ffffii (func (param f32 f32 f32 f32 i32) (result i32)))

View File

@ -2,8 +2,8 @@
(type $FFFi (func (param f64 f64 f64) (result i32))) (type $FFFi (func (param f64 f64 f64) (result i32)))
(type $FFF (func (param f64 f64) (result f64))) (type $FFF (func (param f64 f64) (result f64)))
(type $Fi (func (param f64) (result i32))) (type $Fi (func (param f64) (result i32)))
(type $FFi (func (param f64 f64) (result i32)))
(type $i (func (result i32))) (type $i (func (result i32)))
(type $FFi (func (param f64 f64) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $F (func (result f64))) (type $F (func (result f64)))
(type $fffi (func (param f32 f32 f32) (result i32))) (type $fffi (func (param f32 f32 f32) (result i32)))

View File

@ -58,10 +58,16 @@
(i32.and (i32.and
(if (result i32) (if (result i32)
(tee_local $1 (tee_local $1
(i32.const 1) (i32.eq
(i32.const 2)
(i32.const 2)
)
) )
(get_local $1) (get_local $1)
(i32.const 0) (i32.eq
(i32.const 2)
(i32.const 4)
)
) )
(i32.const 1) (i32.const 1)
) )
@ -215,10 +221,16 @@
(i32.and (i32.and
(if (result i32) (if (result i32)
(tee_local $1 (tee_local $1
(i32.const 1) (i32.eq
(i32.const 2)
(i32.const 2)
)
) )
(get_local $1) (get_local $1)
(i32.const 0) (i32.eq
(i32.const 2)
(i32.const 4)
)
) )
(i32.const 1) (i32.const 1)
) )
@ -930,10 +942,16 @@
(i32.and (i32.and
(if (result i32) (if (result i32)
(tee_local $1 (tee_local $1
(i32.const 0) (i32.eq
(i32.const 4)
(i32.const 2)
)
) )
(get_local $1) (get_local $1)
(i32.const 1) (i32.eq
(i32.const 4)
(i32.const 4)
)
) )
(i32.const 1) (i32.const 1)
) )
@ -1013,10 +1031,16 @@
(i32.and (i32.and
(if (result i32) (if (result i32)
(tee_local $1 (tee_local $1
(i32.const 0) (i32.eq
(i32.const 4)
(i32.const 2)
)
) )
(get_local $1) (get_local $1)
(i32.const 1) (i32.eq
(i32.const 4)
(i32.const 4)
)
) )
(i32.const 1) (i32.const 1)
) )

View File

@ -1,4 +1,5 @@
(module (module
(type $i (func (result i32)))
(type $v (func)) (type $v (func))
(global $ternary/a (mut i32) (i32.const 0)) (global $ternary/a (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 4)) (global $HEAP_BASE i32 (i32.const 4))
@ -7,54 +8,22 @@
(start $start) (start $start)
(func $start (; 0 ;) (type $v) (func $start (; 0 ;) (type $v)
(drop (drop
(if (result i32) (i32.const 1)
(i32.const 0)
(unreachable)
(i32.const 1)
)
) )
(drop (drop
(if (result i32) (i32.const 1)
(i32.const 1)
(i32.const 1)
(unreachable)
)
) )
(drop (drop
(if (result i32) (i32.const 1)
(if (result i32)
(i32.const 0)
(unreachable)
(i32.const 1)
)
(i32.const 1)
(unreachable)
)
) )
(set_global $ternary/a (set_global $ternary/a
(if (result i32) (i32.const 1)
(i32.const 0)
(unreachable)
(i32.const 1)
)
) )
(set_global $ternary/a (set_global $ternary/a
(if (result i32) (i32.const 1)
(i32.const 1)
(i32.const 1)
(unreachable)
)
) )
(set_global $ternary/a (set_global $ternary/a
(if (result i32) (i32.const 1)
(if (result i32)
(i32.const 0)
(unreachable)
(i32.const 1)
)
(i32.const 1)
(unreachable)
)
) )
) )
) )

View File

@ -1,4 +1,5 @@
(module (module
(type $i (func (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))