mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-24 22:52:13 +00:00
Always try to eliminate branches if tree-shaking is enabled
This commit is contained in:
parent
97e7158fff
commit
391db28fe2
2
dist/asc.js
vendored
2
dist/asc.js
vendored
File diff suppressed because one or more lines are too long
2
dist/asc.js.map
vendored
2
dist/asc.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/assemblyscript.js
vendored
2
dist/assemblyscript.js
vendored
File diff suppressed because one or more lines are too long
2
dist/assemblyscript.js.map
vendored
2
dist/assemblyscript.js.map
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,7 @@
|
||||
(module
|
||||
(type $iiv (func (param i32 i32)))
|
||||
(type $F (func (result f64)))
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(type $iiFv (func (param i32 i32 f64)))
|
||||
(import "env" "RGB_ALIVE" (global $assembly/index/RGB_ALIVE i32))
|
||||
|
@ -1,5 +1,6 @@
|
||||
(module
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $FF (func (param f64) (result f64)))
|
||||
(type $Fi (func (param f64) (result i32)))
|
||||
(type $FFFF (func (param f64 f64 f64) (result f64)))
|
||||
|
@ -1,5 +1,8 @@
|
||||
import "allocator/arena";
|
||||
|
||||
// From The Computer Language Benchmarks Game
|
||||
// http://benchmarksgame.alioth.debian.org
|
||||
|
||||
const SOLAR_MASS = 4.0 * Math.PI * Math.PI;
|
||||
const DAYS_PER_YEAR = 365.24;
|
||||
|
||||
@ -79,9 +82,9 @@ function Neptune(): Body {
|
||||
|
||||
class NBodySystem {
|
||||
|
||||
bodies: Body[];
|
||||
|
||||
constructor(bodies: Body[]) {
|
||||
constructor(
|
||||
public bodies: Body[]
|
||||
) {
|
||||
var px = 0.0;
|
||||
var py = 0.0;
|
||||
var pz = 0.0;
|
||||
@ -93,16 +96,17 @@ class NBodySystem {
|
||||
py += b.vy * m;
|
||||
pz += b.vz * m;
|
||||
}
|
||||
this.bodies = bodies;
|
||||
this.bodies[0].offsetMomentum(px, py, pz);
|
||||
bodies[0].offsetMomentum(px, py, pz);
|
||||
}
|
||||
|
||||
advance(dt: f64): void {
|
||||
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 = load<Body>(buffer + i * sizeof<Body>(), 8);
|
||||
|
||||
let ix = bodyi.x;
|
||||
let iy = bodyi.y;
|
||||
@ -113,8 +117,10 @@ class NBodySystem {
|
||||
let bivz = bodyi.vz;
|
||||
|
||||
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 = load<Body>(buffer + j * sizeof<Body>(), 8);
|
||||
|
||||
let dx = ix - bodyj.x;
|
||||
let dy = iy - bodyj.y;
|
||||
let dz = iz - bodyj.z;
|
||||
@ -148,9 +154,8 @@ class NBodySystem {
|
||||
energy(): f64 {
|
||||
var e = 0.0;
|
||||
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 ix = bodyi.x;
|
||||
@ -165,7 +170,7 @@ class NBodySystem {
|
||||
|
||||
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 dx = ix - bodyj.x;
|
||||
let dy = iy - bodyj.y;
|
||||
|
@ -679,40 +679,38 @@ function asmFunc(global, env, buffer) {
|
||||
function assembly_index_NBodySystem_constructor($0, $1) {
|
||||
$0 = $0 | 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;
|
||||
$2 = $1;
|
||||
$9 = HEAP32[($2 + 4 | 0) >> 2] | 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;
|
||||
$3 = $1;
|
||||
$8 = HEAP32[($3 + 4 | 0) >> 2] | 0;
|
||||
continue_0 : do {
|
||||
if (($3 | 0) < ($9 | 0)) {
|
||||
$2 = $3;
|
||||
$5 = $1;
|
||||
$5 = HEAPU32[$5 >> 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();
|
||||
$2 = $11;
|
||||
$4 = +HEAPF64[($2 + 48 | 0) >> 3];
|
||||
$6 = $6 + +HEAPF64[($2 + 24 | 0) >> 3] * $4;
|
||||
$7 = $7 + +HEAPF64[($2 + 32 | 0) >> 3] * $4;
|
||||
$8 = $8 + +HEAPF64[($2 + 40 | 0) >> 3] * $4;
|
||||
$3 = $3 + 1 | 0;
|
||||
if (($2 | 0) < ($8 | 0)) {
|
||||
$9 = $2;
|
||||
$3 = $1;
|
||||
$3 = HEAPU32[$3 >> 2] | 0;
|
||||
if ($9 >>> 0 < ((HEAP32[$3 >> 2] | 0) >>> 2 | 0) >>> 0) $11 = HEAPU32[(($3 + ($9 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort();
|
||||
$3 = $11;
|
||||
$4 = +HEAPF64[($3 + 48 | 0) >> 3];
|
||||
$5 = $5 + +HEAPF64[($3 + 24 | 0) >> 3] * $4;
|
||||
$6 = $6 + +HEAPF64[($3 + 32 | 0) >> 3] * $4;
|
||||
$7 = $7 + +HEAPF64[($3 + 40 | 0) >> 3] * $4;
|
||||
$2 = $2 + 1 | 0;
|
||||
continue continue_0;
|
||||
}
|
||||
break continue_0;
|
||||
} 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 {
|
||||
$3 = $lib_allocator_arena_allocate_memory(4 | 0) | 0;
|
||||
HEAP32[$3 >> 2] = 0;
|
||||
$0 = $3;
|
||||
$9 = $0;
|
||||
$2 = $lib_allocator_arena_allocate_memory(4 | 0) | 0;
|
||||
HEAP32[$2 >> 2] = $1;
|
||||
$9 = $2;
|
||||
}
|
||||
HEAP32[$9 >> 2] = $1;
|
||||
$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;
|
||||
return $9 | 0;
|
||||
}
|
||||
|
||||
function assembly_index_init() {
|
||||
@ -746,7 +744,7 @@ function asmFunc(global, env, buffer) {
|
||||
$0 = $13;
|
||||
$14 = HEAP32[($0 + 4 | 0) >> 2] | 0;
|
||||
continue_0 : do {
|
||||
if (($6 | 0) < ($14 | 0)) {
|
||||
if ($6 >>> 0 < $14 >>> 0) {
|
||||
$3 = $6;
|
||||
$0 = $13;
|
||||
$0 = HEAPU32[$0 >> 2] | 0;
|
||||
@ -761,7 +759,7 @@ function asmFunc(global, env, buffer) {
|
||||
$18 = +HEAPF64[($0 + 48 | 0) >> 3];
|
||||
$3 = $6 + 1 | 0;
|
||||
continue_1 : do {
|
||||
if (($3 | 0) < ($14 | 0)) {
|
||||
if ($3 >>> 0 < $14 >>> 0) {
|
||||
$21 = $15;
|
||||
$19 = $3;
|
||||
$2 = $13;
|
||||
@ -807,7 +805,7 @@ function asmFunc(global, env, buffer) {
|
||||
$0 = $4;
|
||||
$5 = HEAP32[($0 + 4 | 0) >> 2] | 0;
|
||||
continue_0 : do {
|
||||
if (($3 | 0) < ($5 | 0)) {
|
||||
if ($3 >>> 0 < $5 >>> 0) {
|
||||
$2 = $3;
|
||||
$0 = $4;
|
||||
$0 = HEAPU32[$0 >> 2] | 0;
|
||||
@ -826,7 +824,7 @@ function asmFunc(global, env, buffer) {
|
||||
$1 = $13 + .5 * $10 * ($15 + $1 * $1);
|
||||
$0 = $3 + 1 | 0;
|
||||
continue_1 : do {
|
||||
if (($0 | 0) < ($5 | 0)) {
|
||||
if ($0 >>> 0 < $5 >>> 0) {
|
||||
$16 = $7;
|
||||
$11 = $0;
|
||||
$2 = $4;
|
||||
|
@ -116,13 +116,13 @@ class NBodySystem {
|
||||
}
|
||||
var system;
|
||||
function init() {
|
||||
var bodies = new Array();
|
||||
bodies.push(Sun());
|
||||
bodies.push(Jupiter());
|
||||
bodies.push(Saturn());
|
||||
bodies.push(Uranus());
|
||||
bodies.push(Neptune());
|
||||
system = new NBodySystem(bodies);
|
||||
system = new NBodySystem([
|
||||
Sun(),
|
||||
Jupiter(),
|
||||
Saturn(),
|
||||
Uranus(),
|
||||
Neptune()
|
||||
]);
|
||||
}
|
||||
exports.init = init;
|
||||
function getBody(index) {
|
||||
|
Binary file not shown.
@ -2601,14 +2601,14 @@
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 f64)
|
||||
(local $5 i32)
|
||||
(local $5 f64)
|
||||
(local $6 f64)
|
||||
(local $7 f64)
|
||||
(local $8 f64)
|
||||
(local $8 i32)
|
||||
(local $9 i32)
|
||||
(set_local $9
|
||||
(set_local $8
|
||||
(i32.load offset=4
|
||||
(tee_local $2
|
||||
(tee_local $3
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
@ -2616,23 +2616,23 @@
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $3)
|
||||
(get_local $9)
|
||||
(get_local $2)
|
||||
(get_local $8)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(f64.load offset=48
|
||||
(tee_local $2
|
||||
(tee_local $3
|
||||
(if (result i32)
|
||||
(i32.lt_u
|
||||
(tee_local $2
|
||||
(get_local $3)
|
||||
(tee_local $9
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.shr_u
|
||||
(i32.load
|
||||
(tee_local $5
|
||||
(tee_local $3
|
||||
(i32.load
|
||||
(tee_local $5
|
||||
(tee_local $3
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
@ -2643,9 +2643,9 @@
|
||||
)
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $3)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(get_local $9)
|
||||
(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
|
||||
(f64.add
|
||||
(get_local $6)
|
||||
(f64.mul
|
||||
(f64.load offset=24
|
||||
(get_local $2)
|
||||
(f64.load offset=32
|
||||
(get_local $3)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
@ -2669,28 +2680,17 @@
|
||||
(set_local $7
|
||||
(f64.add
|
||||
(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.load offset=40
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(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
|
||||
(tee_local $1
|
||||
(tee_local $2
|
||||
(if (result i32)
|
||||
(i32.lt_u
|
||||
(i32.const 0)
|
||||
(i32.shr_u
|
||||
(i32.load
|
||||
(tee_local $1
|
||||
(tee_local $2
|
||||
(i32.load
|
||||
(tee_local $1
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(tee_local $2
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2740,7 +2718,7 @@
|
||||
)
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
@ -2749,13 +2727,22 @@
|
||||
)
|
||||
(f64.div
|
||||
(f64.neg
|
||||
(get_local $6)
|
||||
(get_local $5)
|
||||
)
|
||||
(f64.const 39.47841760435743)
|
||||
)
|
||||
)
|
||||
(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.neg
|
||||
(get_local $7)
|
||||
@ -2763,16 +2750,21 @@
|
||||
(f64.const 39.47841760435743)
|
||||
)
|
||||
)
|
||||
(f64.store offset=40
|
||||
(get_local $1)
|
||||
(f64.div
|
||||
(f64.neg
|
||||
(get_local $8)
|
||||
(if (result i32)
|
||||
(get_local $0)
|
||||
(get_local $0)
|
||||
(block (result i32)
|
||||
(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)
|
||||
(local $0 i32)
|
||||
@ -2933,7 +2925,7 @@
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_s
|
||||
(i32.lt_u
|
||||
(get_local $6)
|
||||
(get_local $14)
|
||||
)
|
||||
@ -3011,7 +3003,7 @@
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_s
|
||||
(i32.lt_u
|
||||
(get_local $3)
|
||||
(get_local $14)
|
||||
)
|
||||
@ -3267,7 +3259,7 @@
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_s
|
||||
(i32.lt_u
|
||||
(get_local $3)
|
||||
(get_local $5)
|
||||
)
|
||||
@ -3368,7 +3360,7 @@
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_s
|
||||
(i32.lt_u
|
||||
(get_local $0)
|
||||
(get_local $5)
|
||||
)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1053,8 +1053,7 @@ export enum DecoratorKind {
|
||||
OPERATOR,
|
||||
UNMANAGED,
|
||||
SEALED,
|
||||
INLINE,
|
||||
PRECOMPUTE
|
||||
INLINE
|
||||
}
|
||||
|
||||
/** 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 "sealed": return DecoratorKind.SEALED;
|
||||
case "inline": return DecoratorKind.INLINE;
|
||||
case "precompute": return DecoratorKind.PRECOMPUTE;
|
||||
default: return DecoratorKind.CUSTOM;
|
||||
}
|
||||
}
|
||||
|
@ -1634,21 +1634,30 @@ export class Compiler extends DiagnosticEmitter {
|
||||
module
|
||||
);
|
||||
|
||||
// Eliminate unnecesssary branches in generic contexts if the condition is constant
|
||||
if (
|
||||
this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT) &&
|
||||
_BinaryenExpressionGetId(condExpr = this.precomputeExpressionRef(condExpr)) == ExpressionId.Const &&
|
||||
_BinaryenExpressionGetType(condExpr) == NativeType.I32
|
||||
!this.options.noTreeShaking ||
|
||||
this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT)
|
||||
) {
|
||||
let ret: ExpressionRef;
|
||||
if (_BinaryenConstGetValueI32(condExpr)) {
|
||||
ret = this.compileStatement(ifTrue);
|
||||
} else if (ifFalse) {
|
||||
ret = this.compileStatement(ifFalse);
|
||||
} else {
|
||||
ret = module.createNop();
|
||||
// Try to eliminate unnecesssary branches if the condition is constant
|
||||
let condExprPrecomp = this.precomputeExpressionRef(condExpr);
|
||||
if (
|
||||
_BinaryenExpressionGetId(condExprPrecomp) == ExpressionId.Const &&
|
||||
_BinaryenExpressionGetType(condExprPrecomp) == NativeType.I32
|
||||
) {
|
||||
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
|
||||
@ -1992,14 +2001,25 @@ export class Compiler extends DiagnosticEmitter {
|
||||
module
|
||||
);
|
||||
|
||||
// Eliminate unnecesssary loops in generic contexts if the condition is constant
|
||||
if (
|
||||
this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT) &&
|
||||
_BinaryenExpressionGetId(condExpr = this.precomputeExpressionRef(condExpr)) == ExpressionId.Const &&
|
||||
_BinaryenExpressionGetType(condExpr) == NativeType.I32
|
||||
!this.options.noTreeShaking ||
|
||||
this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT)
|
||||
) {
|
||||
if (!_BinaryenConstGetValueI32(condExpr)) {
|
||||
return module.createNop();
|
||||
// Try to eliminate unnecesssary loops if the condition is constant
|
||||
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 {
|
||||
var ifThen = expression.ifThen;
|
||||
var ifElse = expression.ifElse;
|
||||
var currentFunction = this.currentFunction;
|
||||
|
||||
var condExpr = makeIsTrueish(
|
||||
this.compileExpression(expression.condition, Type.u32, ConversionKind.NONE),
|
||||
@ -6057,18 +6078,30 @@ export class Compiler extends DiagnosticEmitter {
|
||||
this.module
|
||||
);
|
||||
|
||||
// Eliminate unnecesssary branches in generic contexts if the condition is constant
|
||||
if (
|
||||
this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT) &&
|
||||
_BinaryenExpressionGetId(condExpr = this.precomputeExpressionRef(condExpr)) == ExpressionId.Const &&
|
||||
_BinaryenExpressionGetType(condExpr) == NativeType.I32
|
||||
!this.options.noTreeShaking ||
|
||||
this.currentFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT)
|
||||
) {
|
||||
return _BinaryenConstGetValueI32(condExpr)
|
||||
? this.compileExpression(ifThen, contextualType)
|
||||
: this.compileExpression(ifElse, contextualType);
|
||||
// Try to eliminate unnecesssary branches if the condition is constant
|
||||
let condExprPrecomp = this.precomputeExpressionRef(condExpr);
|
||||
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 ifElseExpr: ExpressionRef;
|
||||
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;
|
||||
}
|
||||
|
@ -629,6 +629,7 @@ export class Program extends DiagnosticEmitter {
|
||||
): void {
|
||||
var name = declaration.name.text;
|
||||
var internalName = declaration.fileLevelInternalName;
|
||||
var decorators = declaration.decorators;
|
||||
|
||||
// static fields become global variables
|
||||
if (declaration.is(CommonFlags.STATIC)) {
|
||||
@ -655,7 +656,10 @@ export class Program extends DiagnosticEmitter {
|
||||
name,
|
||||
internalName,
|
||||
Type.void, // resolved later on
|
||||
declaration
|
||||
declaration,
|
||||
decorators
|
||||
? this.filterDecorators(decorators, DecoratorFlags.NONE)
|
||||
: DecoratorFlags.NONE
|
||||
);
|
||||
staticField.parent = classPrototype;
|
||||
classPrototype.members.set(name, staticField);
|
||||
@ -683,6 +687,7 @@ export class Program extends DiagnosticEmitter {
|
||||
internalName,
|
||||
declaration
|
||||
);
|
||||
if (decorators) this.filterDecorators(decorators, DecoratorFlags.NONE);
|
||||
classPrototype.instanceMembers.set(name, instanceField);
|
||||
// TBD: no need to mark as MODULE_EXPORT
|
||||
}
|
||||
@ -700,6 +705,7 @@ export class Program extends DiagnosticEmitter {
|
||||
var decoratorFlags = DecoratorFlags.NONE;
|
||||
if (decorators) {
|
||||
decoratorFlags = this.filterDecorators(decorators,
|
||||
DecoratorFlags.OPERATOR |
|
||||
DecoratorFlags.INLINE
|
||||
);
|
||||
}
|
||||
@ -1548,6 +1554,7 @@ export class Program extends DiagnosticEmitter {
|
||||
var declarations = statement.declarations;
|
||||
for (let i = 0, k = declarations.length; i < k; ++i) {
|
||||
let declaration = declarations[i];
|
||||
let decorators = declaration.decorators;
|
||||
let internalName = declaration.fileLevelInternalName;
|
||||
if (this.elementsLookup.has(internalName)) {
|
||||
this.error(
|
||||
@ -1562,7 +1569,12 @@ export class Program extends DiagnosticEmitter {
|
||||
simpleName,
|
||||
internalName,
|
||||
Type.void, // resolved later on
|
||||
declaration
|
||||
declaration,
|
||||
decorators
|
||||
? this.filterDecorators(decorators,
|
||||
DecoratorFlags.GLOBAL
|
||||
)
|
||||
: DecoratorFlags.NONE
|
||||
);
|
||||
global.parent = namespace;
|
||||
this.elementsLookup.set(internalName, global);
|
||||
@ -2274,6 +2286,8 @@ export enum DecoratorFlags {
|
||||
NONE = 0,
|
||||
/** Is a program global. */
|
||||
GLOBAL = 1 << 0,
|
||||
/** Is an operator overload. */
|
||||
OPERATOR = 1 << 1,
|
||||
/** Is an unmanaged class. */
|
||||
UNMANAGED = 1 << 2,
|
||||
/** Is a sealed class. */
|
||||
@ -2285,6 +2299,7 @@ export enum DecoratorFlags {
|
||||
export function decoratorKindToFlag(kind: DecoratorKind): DecoratorFlags {
|
||||
switch (kind) {
|
||||
case DecoratorKind.GLOBAL: return DecoratorFlags.GLOBAL;
|
||||
case DecoratorKind.OPERATOR: return DecoratorFlags.OPERATOR;
|
||||
case DecoratorKind.UNMANAGED: return DecoratorFlags.UNMANAGED;
|
||||
case DecoratorKind.SEALED: return DecoratorFlags.SEALED;
|
||||
case DecoratorKind.INLINE: return DecoratorFlags.INLINE;
|
||||
@ -2453,10 +2468,12 @@ export class Global extends VariableLikeElement {
|
||||
simpleName: string,
|
||||
internalName: string,
|
||||
type: Type,
|
||||
declaration: VariableLikeDeclarationStatement | null
|
||||
declaration: VariableLikeDeclarationStatement | null,
|
||||
decoratorFlags: DecoratorFlags
|
||||
) {
|
||||
super(program, simpleName, internalName, type, declaration);
|
||||
this.flags = declaration ? declaration.flags : CommonFlags.NONE;
|
||||
this.decoratorFlags = decoratorFlags;
|
||||
this.type = type; // resolved later if `void`
|
||||
}
|
||||
}
|
||||
|
2
std/assembly.d.ts
vendored
2
std/assembly.d.ts
vendored
@ -531,7 +531,7 @@ declare const Mathf: IMath<f32>;
|
||||
/** Annotates an element as a program global. */
|
||||
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;
|
||||
|
||||
/** Annotates a class as being unmanaged with limited capabilities. */
|
||||
|
@ -2,10 +2,6 @@ import {
|
||||
TypedArray
|
||||
} from "./internal/typedarray";
|
||||
|
||||
import {
|
||||
storeUnsafeWithOffset
|
||||
} from "./internal/arraybuffer";
|
||||
|
||||
export class Int8Array extends TypedArray<i8> {
|
||||
static readonly BYTES_PER_ELEMENT: usize = sizeof<i8>();
|
||||
|
||||
|
@ -672,10 +672,10 @@
|
||||
(loop $continue|0
|
||||
(if
|
||||
;;@ ~lib/allocator/buddy.ts:381:9
|
||||
(i32.add
|
||||
(i32.ne
|
||||
(get_local $1)
|
||||
;;@ ~lib/allocator/buddy.ts:381:18
|
||||
(i32.const 1)
|
||||
;;@ ~lib/allocator/buddy.ts:381:23
|
||||
(i32.const -1)
|
||||
)
|
||||
;;@ ~lib/allocator/buddy.ts:381:26
|
||||
(block
|
||||
|
@ -1,5 +1,6 @@
|
||||
(module
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $HEAP_BASE i32 (i32.const 56))
|
||||
|
@ -1,6 +1,7 @@
|
||||
(module
|
||||
(type $FFF (func (param f64 f64) (result f64)))
|
||||
(type $F (func (result f64)))
|
||||
(type $i (func (result i32)))
|
||||
(type $FiF (func (param f64 i32) (result f64)))
|
||||
(type $fff (func (param f32 f32) (result f32)))
|
||||
(type $fi (func (param f32) (result i32)))
|
||||
|
@ -1,5 +1,6 @@
|
||||
(module
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $for/i (mut i32) (i32.const 0))
|
||||
|
@ -1,5 +1,6 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
|
@ -126,50 +126,6 @@
|
||||
(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
|
||||
(block (result i32)
|
||||
(set_global $~argc
|
||||
|
@ -223,20 +223,17 @@
|
||||
(get_local $2)
|
||||
)
|
||||
(nop)
|
||||
(if
|
||||
(i32.const 1)
|
||||
(block
|
||||
(set_local $5
|
||||
(get_local $3)
|
||||
)
|
||||
(set_local $6
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.add
|
||||
(get_local $6)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(get_local $3)
|
||||
)
|
||||
(set_local $6
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.add
|
||||
(get_local $6)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -268,20 +265,17 @@
|
||||
(get_local $4)
|
||||
)
|
||||
(nop)
|
||||
(if
|
||||
(i32.const 1)
|
||||
(block
|
||||
(set_local $6
|
||||
(get_local $3)
|
||||
)
|
||||
(set_local $5
|
||||
(get_local $6)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(set_local $6
|
||||
(get_local $3)
|
||||
)
|
||||
(set_local $5
|
||||
(get_local $6)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -1,5 +1,6 @@
|
||||
(module
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $FF (func (param f64) (result f64)))
|
||||
(type $F (func (result f64)))
|
||||
(type $Fi (func (param f64) (result i32)))
|
||||
|
@ -1,5 +1,6 @@
|
||||
(module
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
|
@ -1,5 +1,6 @@
|
||||
(module
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
|
@ -1,5 +1,6 @@
|
||||
(module
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
|
@ -1,5 +1,6 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $i (func (result i32)))
|
||||
(global $HEAP_BASE i32 (i32.const 4))
|
||||
(memory $0 1)
|
||||
(export "fib" (func $recursive/fib))
|
||||
|
@ -1,6 +1,7 @@
|
||||
(module
|
||||
(type $FFF (func (param f64 f64) (result f64)))
|
||||
(type $F (func (result f64)))
|
||||
(type $i (func (result i32)))
|
||||
(type $FiF (func (param f64 i32) (result f64)))
|
||||
(type $fff (func (param f32 f32) (result f32)))
|
||||
(type $fi (func (param f32) (result i32)))
|
||||
@ -8,7 +9,6 @@
|
||||
(type $fif (func (param f32 i32) (result f32)))
|
||||
(type $Fi (func (param f64) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
|
@ -3014,19 +3014,19 @@
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.eqz
|
||||
(tee_local $4
|
||||
(tee_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
@ -3042,9 +3042,9 @@
|
||||
)
|
||||
(set_local $2
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
@ -3052,13 +3052,13 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(set_local $0
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
@ -3067,14 +3067,14 @@
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
@ -3128,19 +3128,19 @@
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.eqz
|
||||
(tee_local $4
|
||||
(tee_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
@ -3156,9 +3156,9 @@
|
||||
)
|
||||
(set_local $2
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
@ -3166,13 +3166,13 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(set_local $0
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
@ -3181,14 +3181,14 @@
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
|
@ -3589,19 +3589,19 @@
|
||||
(block
|
||||
(if
|
||||
(i32.eq
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.4 (result i32)
|
||||
(set_local $4
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.5 (result i32)
|
||||
(set_local $5
|
||||
(get_local $6)
|
||||
)
|
||||
(set_local $5
|
||||
(set_local $4
|
||||
(get_local $2)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.4
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.5
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(get_local $5)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(get_local $4)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
@ -3723,19 +3723,19 @@
|
||||
(block
|
||||
(if
|
||||
(i32.eq
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.5 (result i32)
|
||||
(set_local $4
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.7 (result i32)
|
||||
(set_local $5
|
||||
(get_local $6)
|
||||
)
|
||||
(set_local $5
|
||||
(set_local $4
|
||||
(get_local $2)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.5
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.7
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(get_local $5)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(get_local $4)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
@ -4023,19 +4023,19 @@
|
||||
(i32.const 3)
|
||||
)
|
||||
(call_indirect (type $iiii)
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.6 (result i32)
|
||||
(set_local $5
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.9 (result i32)
|
||||
(set_local $6
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $6
|
||||
(set_local $5
|
||||
(get_local $3)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.6
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.9
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $6)
|
||||
(i32.shl
|
||||
(get_local $6)
|
||||
(get_local $5)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
@ -4169,19 +4169,19 @@
|
||||
(i32.const 3)
|
||||
)
|
||||
(call_indirect (type $iiii)
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.7 (result i32)
|
||||
(set_local $5
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.11 (result i32)
|
||||
(set_local $6
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $6
|
||||
(set_local $5
|
||||
(get_local $3)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.7
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.11
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $6)
|
||||
(i32.shl
|
||||
(get_local $6)
|
||||
(get_local $5)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
@ -4309,19 +4309,19 @@
|
||||
(i32.const 3)
|
||||
)
|
||||
(call_indirect (type $iiii)
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.8 (result i32)
|
||||
(set_local $5
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.13 (result i32)
|
||||
(set_local $6
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $6
|
||||
(set_local $5
|
||||
(get_local $3)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.8
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.13
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $6)
|
||||
(i32.shl
|
||||
(get_local $6)
|
||||
(get_local $5)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
@ -4449,14 +4449,14 @@
|
||||
(i32.const 3)
|
||||
)
|
||||
(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
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $6
|
||||
(get_local $3)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.9
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.14
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
@ -4655,14 +4655,14 @@
|
||||
(i32.const 3)
|
||||
)
|
||||
(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
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $11
|
||||
(get_local $6)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.10
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.15
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $10)
|
||||
@ -4833,14 +4833,14 @@
|
||||
(i32.const 3)
|
||||
)
|
||||
(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
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $11
|
||||
(get_local $6)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.11
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.16
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $10)
|
||||
@ -4973,14 +4973,14 @@
|
||||
(block
|
||||
(block
|
||||
(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
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $7
|
||||
(get_local $5)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.12
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.17
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $6)
|
||||
@ -5142,14 +5142,14 @@
|
||||
)
|
||||
(call_indirect (type $iiiii)
|
||||
(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
|
||||
(get_local $4)
|
||||
)
|
||||
(set_local $8
|
||||
(get_local $5)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.13
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.18
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $7)
|
||||
@ -5257,14 +5257,14 @@
|
||||
)
|
||||
(call_indirect (type $iiiii)
|
||||
(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
|
||||
(get_local $4)
|
||||
)
|
||||
(set_local $8
|
||||
(get_local $5)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.14
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.19
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $7)
|
||||
@ -5388,14 +5388,14 @@
|
||||
)
|
||||
(call_indirect (type $iiiii)
|
||||
(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
|
||||
(get_local $4)
|
||||
)
|
||||
(set_local $7
|
||||
(get_local $5)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.15
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.20
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $6)
|
||||
@ -5486,14 +5486,14 @@
|
||||
)
|
||||
(call_indirect (type $iiiii)
|
||||
(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
|
||||
(get_local $4)
|
||||
)
|
||||
(set_local $7
|
||||
(get_local $5)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.16
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.21
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $6)
|
||||
@ -5882,14 +5882,14 @@
|
||||
(block
|
||||
(block
|
||||
(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
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $6
|
||||
(get_local $3)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.19
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.24
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
@ -5918,14 +5918,14 @@
|
||||
(block
|
||||
(block
|
||||
(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
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $8
|
||||
(get_local $5)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.20
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.25
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $7)
|
||||
@ -6154,14 +6154,14 @@
|
||||
)
|
||||
)
|
||||
(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
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $10
|
||||
(get_local $8)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.21
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.26
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $9)
|
||||
@ -6175,14 +6175,14 @@
|
||||
)
|
||||
)
|
||||
(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
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $11
|
||||
(get_local $6)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.22
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.27
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $9)
|
||||
@ -6315,14 +6315,14 @@
|
||||
(block
|
||||
(block
|
||||
(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
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $10
|
||||
(i32.const 0)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.23
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.28
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $11)
|
||||
@ -6343,14 +6343,14 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
(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
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $12
|
||||
(get_local $6)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.24
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.29
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $9)
|
||||
@ -6452,14 +6452,14 @@
|
||||
(block
|
||||
(block
|
||||
(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
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $12
|
||||
(i32.const 0)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.25
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.30
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $7)
|
||||
@ -6473,14 +6473,14 @@
|
||||
)
|
||||
)
|
||||
(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
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $7
|
||||
(get_local $11)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.26
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.31
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $12)
|
||||
@ -6613,14 +6613,14 @@
|
||||
(get_local $4)
|
||||
)
|
||||
(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
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $8
|
||||
(i32.const 1)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.27
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.32
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $6)
|
||||
@ -6641,14 +6641,14 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
(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
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $7
|
||||
(i32.const 0)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.28
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.33
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $10)
|
||||
@ -6731,14 +6731,14 @@
|
||||
)
|
||||
(block
|
||||
(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
|
||||
(get_local $3)
|
||||
)
|
||||
(set_local $5
|
||||
(i32.const 1)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.17
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.22
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
@ -6752,14 +6752,14 @@
|
||||
)
|
||||
)
|
||||
(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
|
||||
(get_local $3)
|
||||
)
|
||||
(set_local $6
|
||||
(i32.const 0)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.18
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.23
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
|
@ -2,9 +2,10 @@
|
||||
(type $F (func (result f64)))
|
||||
(type $FF (func (param f64) (result f64)))
|
||||
(type $f (func (result f32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $I (func (result i64)))
|
||||
(type $Fi (func (param f64) (result i32)))
|
||||
(type $FFF (func (param f64 f64) (result f64)))
|
||||
(type $i (func (result i32)))
|
||||
(type $FiF (func (param f64 i32) (result f64)))
|
||||
(type $Ff (func (param f64) (result f32)))
|
||||
(global $std/libm/E f64 (f64.const 2.718281828459045))
|
||||
|
@ -16,6 +16,7 @@
|
||||
(type $fiffii (func (param f32 i32 f32 f32 i32) (result i32)))
|
||||
(type $FF (func (param f64) (result f64)))
|
||||
(type $ff (func (param f32) (result f32)))
|
||||
(type $I (func (result i64)))
|
||||
(type $FFFFii (func (param f64 f64 f64 f64 i32) (result i32)))
|
||||
(type $FFF (func (param f64 f64) (result f64)))
|
||||
(type $ffffii (func (param f32 f32 f32 f32 i32) (result i32)))
|
||||
|
@ -2,8 +2,8 @@
|
||||
(type $FFFi (func (param f64 f64 f64) (result i32)))
|
||||
(type $FFF (func (param f64 f64) (result f64)))
|
||||
(type $Fi (func (param f64) (result i32)))
|
||||
(type $FFi (func (param f64 f64) (result i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $FFi (func (param f64 f64) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $F (func (result f64)))
|
||||
(type $fffi (func (param f32 f32 f32) (result i32)))
|
||||
|
@ -58,10 +58,16 @@
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.const 1)
|
||||
(i32.eq
|
||||
(i32.const 2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
(i32.eq
|
||||
(i32.const 2)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
@ -215,10 +221,16 @@
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.const 1)
|
||||
(i32.eq
|
||||
(i32.const 2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
(i32.eq
|
||||
(i32.const 2)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
@ -930,10 +942,16 @@
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.const 0)
|
||||
(i32.eq
|
||||
(i32.const 4)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
(i32.eq
|
||||
(i32.const 4)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
@ -1013,10 +1031,16 @@
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.const 0)
|
||||
(i32.eq
|
||||
(i32.const 4)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
(i32.eq
|
||||
(i32.const 4)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
|
@ -1,4 +1,5 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(global $ternary/a (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 4))
|
||||
@ -7,54 +8,22 @@
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(drop
|
||||
(if (result i32)
|
||||
(i32.const 0)
|
||||
(unreachable)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(drop
|
||||
(if (result i32)
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(drop
|
||||
(if (result i32)
|
||||
(if (result i32)
|
||||
(i32.const 0)
|
||||
(unreachable)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_global $ternary/a
|
||||
(if (result i32)
|
||||
(i32.const 0)
|
||||
(unreachable)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_global $ternary/a
|
||||
(if (result i32)
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_global $ternary/a
|
||||
(if (result i32)
|
||||
(if (result i32)
|
||||
(i32.const 0)
|
||||
(unreachable)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -1,4 +1,5 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user