mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-13 23:11:41 +00:00
Better resolve infrastructure; Instance fields
This commit is contained in:
@ -58,7 +58,8 @@ glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
|
||||
module.interpret();
|
||||
console.log(chalk.default.green("interpret OK"));
|
||||
try {
|
||||
var wasmModule = new WebAssembly.Module(module.toBinary());
|
||||
var binary = module.toBinary();
|
||||
var wasmModule = new WebAssembly.Module(binary);
|
||||
var wasmInstance = new WebAssembly.Instance(wasmModule, {
|
||||
env: {
|
||||
externalFunc: function() {},
|
||||
|
@ -63,6 +63,33 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load16_s offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load8_s offset=6
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.store16 offset=4
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.store8 offset=6
|
||||
(get_local $0)
|
||||
(i32.const 3)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
|
@ -65,6 +65,33 @@
|
||||
(f32.const 2)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load16_s offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load8_s offset=6
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.store16 offset=4
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.store8 offset=6
|
||||
(get_local $0)
|
||||
(i32.const 3)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $start (; 5 ;) (type $v)
|
||||
|
@ -20,6 +20,14 @@ export function test(animal: Animal<f64>): Animal<f64> {
|
||||
animal.instanceAdd(1, 2);
|
||||
animal.instanceSub<f32>(1, 2);
|
||||
|
||||
animal.one;
|
||||
animal.two;
|
||||
animal.three;
|
||||
|
||||
animal.one = 0 + 1;
|
||||
animal.two = 1 + 1;
|
||||
animal.three = 1 + 1 + 1;
|
||||
|
||||
var ptr = changetype<usize>(animal);
|
||||
var cls = changetype<Animal<f64>>(ptr);
|
||||
return cls;
|
||||
|
@ -76,6 +76,45 @@
|
||||
(f32.const 2)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load16_s offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load8_s offset=6
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(i32.add
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.store16 offset=4
|
||||
(get_local $0)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=6
|
||||
(get_local $0)
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(get_local $0)
|
||||
|
4
tests/compiler/empty.optimized.wast
Normal file
4
tests/compiler/empty.optimized.wast
Normal file
@ -0,0 +1,4 @@
|
||||
(module
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
)
|
0
tests/compiler/empty.ts
Normal file
0
tests/compiler/empty.ts
Normal file
54
tests/compiler/empty.wast
Normal file
54
tests/compiler/empty.wast
Normal file
@ -0,0 +1,54 @@
|
||||
(module
|
||||
(global $HEAP_BASE i32 (i32.const 4))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
)
|
||||
(;
|
||||
[program.elements]
|
||||
GLOBAL: NaN
|
||||
GLOBAL: Infinity
|
||||
FUNCTION_PROTOTYPE: isNaN
|
||||
FUNCTION_PROTOTYPE: isFinite
|
||||
FUNCTION_PROTOTYPE: clz
|
||||
FUNCTION_PROTOTYPE: ctz
|
||||
FUNCTION_PROTOTYPE: popcnt
|
||||
FUNCTION_PROTOTYPE: rotl
|
||||
FUNCTION_PROTOTYPE: rotr
|
||||
FUNCTION_PROTOTYPE: abs
|
||||
FUNCTION_PROTOTYPE: max
|
||||
FUNCTION_PROTOTYPE: min
|
||||
FUNCTION_PROTOTYPE: ceil
|
||||
FUNCTION_PROTOTYPE: floor
|
||||
FUNCTION_PROTOTYPE: copysign
|
||||
FUNCTION_PROTOTYPE: nearest
|
||||
FUNCTION_PROTOTYPE: reinterpret
|
||||
FUNCTION_PROTOTYPE: sqrt
|
||||
FUNCTION_PROTOTYPE: trunc
|
||||
FUNCTION_PROTOTYPE: load
|
||||
FUNCTION_PROTOTYPE: store
|
||||
FUNCTION_PROTOTYPE: sizeof
|
||||
FUNCTION_PROTOTYPE: select
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
FUNCTION_PROTOTYPE: i16
|
||||
FUNCTION_PROTOTYPE: i32
|
||||
FUNCTION_PROTOTYPE: i64
|
||||
FUNCTION_PROTOTYPE: u8
|
||||
FUNCTION_PROTOTYPE: u16
|
||||
FUNCTION_PROTOTYPE: u32
|
||||
FUNCTION_PROTOTYPE: u64
|
||||
FUNCTION_PROTOTYPE: bool
|
||||
FUNCTION_PROTOTYPE: f32
|
||||
FUNCTION_PROTOTYPE: f64
|
||||
FUNCTION_PROTOTYPE: isize
|
||||
FUNCTION_PROTOTYPE: usize
|
||||
GLOBAL: HEAP_BASE
|
||||
[program.exports]
|
||||
|
||||
;)
|
@ -1,8 +1,10 @@
|
||||
(module
|
||||
(type $FFF (func (param f64 f64) (result f64)))
|
||||
(type $fff (func (param f32 f32) (result f32)))
|
||||
(type $v (func))
|
||||
(memory $0 1)
|
||||
(export "fmod" (func $fmod/fmod))
|
||||
(export "fmodf" (func $fmod/fmodf))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $fmod/fmod (; 0 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
|
||||
@ -391,8 +393,374 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(func $fmod/fmodf (; 1 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 f32)
|
||||
(set_local $4
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(tee_local $2
|
||||
(i32.reinterpret/f32
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 23)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(set_local $6
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(tee_local $5
|
||||
(i32.reinterpret/f32
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i32.const 23)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
(i32.and
|
||||
(get_local $2)
|
||||
(i32.const -2147483648)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(if (result i32)
|
||||
(if (result i32)
|
||||
(tee_local $3
|
||||
(i32.eqz
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(tee_local $3
|
||||
(f32.ne
|
||||
(tee_local $8
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.eq
|
||||
(get_local $4)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f32.div
|
||||
(f32.mul
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(f32.mul
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(if (result i32)
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $2)
|
||||
(i32.const 8388607)
|
||||
)
|
||||
(i32.const 8388608)
|
||||
)
|
||||
(block (result i32)
|
||||
(set_local $3
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 9)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(get_local $3)
|
||||
(i32.const 31)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.sub
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $5
|
||||
(if (result i32)
|
||||
(get_local $6)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $5)
|
||||
(i32.const 8388607)
|
||||
)
|
||||
(i32.const 8388608)
|
||||
)
|
||||
(block (result i32)
|
||||
(set_local $3
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.const 9)
|
||||
)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(get_local $3)
|
||||
(i32.const 31)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $6
|
||||
(i32.sub
|
||||
(get_local $6)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $6)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue|2
|
||||
(if
|
||||
(i32.gt_s
|
||||
(get_local $4)
|
||||
(get_local $6)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(tee_local $3
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
(i32.const 31)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.sub
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(tee_local $3
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
(i32.const 31)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue|3
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(get_local $2)
|
||||
(i32.const 23)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.sub
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(f32.reinterpret/i32
|
||||
(i32.or
|
||||
(tee_local $2
|
||||
(if (result i32)
|
||||
(i32.gt_s
|
||||
(get_local $4)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.or
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 8388608)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $4)
|
||||
(i32.const 23)
|
||||
)
|
||||
)
|
||||
(i32.shr_u
|
||||
(get_local $2)
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 2 ;) (type $v)
|
||||
(local $0 f64)
|
||||
(local $1 f32)
|
||||
(if
|
||||
(f64.eq
|
||||
(tee_local $0
|
||||
@ -445,5 +813,57 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f32.eq
|
||||
(tee_local $1
|
||||
(call $fmod/fmodf
|
||||
(f32.const 1)
|
||||
(f32.const nan:0x400000)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f32.ne
|
||||
(call $fmod/fmodf
|
||||
(f32.const 1.5)
|
||||
(f32.const 1)
|
||||
)
|
||||
(f32.const 0.5)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(f32.lt
|
||||
(f32.sub
|
||||
(call $fmod/fmodf
|
||||
(f32.const 9.199999809265137)
|
||||
(f32.const 2)
|
||||
)
|
||||
(f32.const 1.2000000476837158)
|
||||
)
|
||||
(f32.const 1.1920928955078125e-07)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(f32.lt
|
||||
(f32.sub
|
||||
(call $fmod/fmodf
|
||||
(f32.const 9.199999809265137)
|
||||
(f32.const 3.700000047683716)
|
||||
)
|
||||
(f32.const 1.7999999523162842)
|
||||
)
|
||||
(f32.const 1.1920928955078125e-07)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -14,6 +14,7 @@ export function fmod(x: f64, y: f64): f64 {
|
||||
return x;
|
||||
}
|
||||
|
||||
// normalize x and y
|
||||
if (!ex) {
|
||||
for (var i = ux << 12; !(i >> 63); i <<= 1)
|
||||
--ex;
|
||||
@ -31,6 +32,7 @@ export function fmod(x: f64, y: f64): f64 {
|
||||
uy |= 1 << 52;
|
||||
}
|
||||
|
||||
// x mod y
|
||||
for (; ex > ey; ex--) {
|
||||
i = ux - uy;
|
||||
if (!(i >> 63)) {
|
||||
@ -49,6 +51,7 @@ export function fmod(x: f64, y: f64): f64 {
|
||||
for (; !(ux >> 52); ux <<= 1)
|
||||
--ex;
|
||||
|
||||
// scale result
|
||||
if (ex > 0) {
|
||||
ux -= 1 << 52;
|
||||
ux |= <u64>ex << 52;
|
||||
@ -63,3 +66,72 @@ assert(isNaN<f64>(fmod(1, NaN)));
|
||||
assert(fmod(1.5, 1.0) == 0.5); // exactly 0.5 (as in C)
|
||||
assert(fmod(9.2, 2.0) - 1.2 < f64.EPSILON); // not exactly 1.2 (as in C)
|
||||
assert(fmod(9.2, 3.7) - 1.8 < f64.EPSILON); // not exactly 1.8 (as in C)
|
||||
|
||||
export function fmodf(x: f32, y: f32): f32 {
|
||||
// the following is based on musl's implementation of fmodf
|
||||
var ux = reinterpret<f32,u32>(x);
|
||||
var uy = reinterpret<f32,u32>(y);
|
||||
var ex = <i32>(ux >> 23 & 0xff);
|
||||
var ey = <i32>(uy >> 23 & 0xff);
|
||||
var sx = ux & 0x80000000;
|
||||
|
||||
if (uy << 1 == 0 || isNaN<f32>(y) || ex == 0xff)
|
||||
return (x * y) / (x * y);
|
||||
if (ux << 1 <= uy << 1) {
|
||||
if (ux << 1 == uy << 1)
|
||||
return 0 * x;
|
||||
return x;
|
||||
}
|
||||
|
||||
// normalize x and y
|
||||
if (!ex) {
|
||||
for (var i = ux << 9; !(i >> 31); i <<= 1)
|
||||
--ex;
|
||||
ux <<= -ex + 1;
|
||||
} else {
|
||||
ux &= -1 >> 9;
|
||||
ux |= 1 << 23;
|
||||
}
|
||||
if (!ey) {
|
||||
for (i = uy << 9; !(i >> 31); i <<= 1)
|
||||
--ey;
|
||||
uy <<= -ey + 1;
|
||||
} else {
|
||||
uy &= -1 >> 9;
|
||||
uy |= 1 << 23;
|
||||
}
|
||||
|
||||
// x mod y
|
||||
for (; ex > ey; --ex) {
|
||||
i = ux - uy;
|
||||
if (!(i >> 31)) {
|
||||
if (!i)
|
||||
return 0 * x;
|
||||
ux = i;
|
||||
}
|
||||
ux <<= 1;
|
||||
}
|
||||
i = ux - uy;
|
||||
if (!(i >> 31)) {
|
||||
if (!i)
|
||||
return 0 * x;
|
||||
ux = i;
|
||||
}
|
||||
for (; !(ux >> 23); ux <<= 1)
|
||||
--ex;
|
||||
|
||||
// scale result
|
||||
if (ex > 0) {
|
||||
ux -= 1 << 23;
|
||||
ux |= <u32>ex << 23;
|
||||
} else {
|
||||
ux >>= -ex + 1;
|
||||
}
|
||||
ux |= sx;
|
||||
return reinterpret<i32,f32>(ux);
|
||||
}
|
||||
|
||||
assert(isNaN<f32>(fmodf(1, NaN)));
|
||||
assert(fmodf(1.5, 1.0) == 0.5);
|
||||
assert(fmodf(9.2, 2.0) - 1.2 < f32.EPSILON);
|
||||
assert(fmodf(9.2, 3.7) - 1.8 < f32.EPSILON);
|
||||
|
@ -1,10 +1,13 @@
|
||||
(module
|
||||
(type $FFF (func (param f64 f64) (result f64)))
|
||||
(type $fff (func (param f32 f32) (result f32)))
|
||||
(type $v (func))
|
||||
(global $f64.EPSILON f64 (f64.const 2.220446049250313e-16))
|
||||
(global $f32.EPSILON f32 (f32.const 1.1920928955078125e-07))
|
||||
(global $HEAP_BASE i32 (i32.const 4))
|
||||
(memory $0 1)
|
||||
(export "fmod" (func $fmod/fmod))
|
||||
(export "fmodf" (func $fmod/fmodf))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $fmod/fmod (; 0 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
|
||||
@ -481,8 +484,456 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(func $fmod/fmodf (; 1 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 f32)
|
||||
(local $8 i32)
|
||||
(local $9 i32)
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.reinterpret/f32
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(i32.reinterpret/f32
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $2)
|
||||
(i32.const 23)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $3)
|
||||
(i32.const 23)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $6
|
||||
(i32.and
|
||||
(get_local $2)
|
||||
(i32.const -2147483648)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(if (result i32)
|
||||
(tee_local $8
|
||||
(if (result i32)
|
||||
(tee_local $8
|
||||
(i32.eq
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(get_local $8)
|
||||
(f32.ne
|
||||
(tee_local $7
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $8)
|
||||
(i32.eq
|
||||
(get_local $4)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f32.div
|
||||
(f32.mul
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(f32.mul
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $4)
|
||||
)
|
||||
(block
|
||||
(block $break|0
|
||||
(block
|
||||
(set_local $9
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 9)
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(get_local $9)
|
||||
(i32.const 31)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.sub
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $9
|
||||
(i32.shl
|
||||
(get_local $9)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.and
|
||||
(get_local $2)
|
||||
(i32.shr_u
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 9)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.or
|
||||
(get_local $2)
|
||||
(i32.shl
|
||||
(i32.const 1)
|
||||
(i32.const 23)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $5)
|
||||
)
|
||||
(block
|
||||
(block $break|1
|
||||
(set_local $9
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 9)
|
||||
)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(get_local $9)
|
||||
(i32.const 31)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(i32.sub
|
||||
(get_local $5)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $9
|
||||
(i32.shl
|
||||
(get_local $9)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $5)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(i32.and
|
||||
(get_local $3)
|
||||
(i32.shr_u
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 9)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.or
|
||||
(get_local $3)
|
||||
(i32.shl
|
||||
(i32.const 1)
|
||||
(i32.const 23)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|2
|
||||
(nop)
|
||||
(loop $continue|2
|
||||
(if
|
||||
(i32.gt_s
|
||||
(get_local $4)
|
||||
(get_local $5)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(set_local $9
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(get_local $9)
|
||||
(i32.const 31)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $9)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $9)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.sub
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $9
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(get_local $9)
|
||||
(i32.const 31)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $9)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $9)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|3
|
||||
(nop)
|
||||
(loop $continue|3
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.shr_u
|
||||
(get_local $2)
|
||||
(i32.const 23)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.sub
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.gt_s
|
||||
(get_local $4)
|
||||
(i32.const 0)
|
||||
)
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.shl
|
||||
(i32.const 1)
|
||||
(i32.const 23)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.or
|
||||
(get_local $2)
|
||||
(i32.shl
|
||||
(get_local $4)
|
||||
(i32.const 23)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shr_u
|
||||
(get_local $2)
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.or
|
||||
(get_local $2)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f32.reinterpret/i32
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 2 ;) (type $v)
|
||||
(local $0 f64)
|
||||
(local $1 f32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(f64.ne
|
||||
@ -539,6 +990,62 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(f32.ne
|
||||
(tee_local $1
|
||||
(call $fmod/fmodf
|
||||
(f32.const 1)
|
||||
(f32.const nan:0x400000)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(f32.eq
|
||||
(call $fmod/fmodf
|
||||
(f32.const 1.5)
|
||||
(f32.const 1)
|
||||
)
|
||||
(f32.const 0.5)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(f32.lt
|
||||
(f32.sub
|
||||
(call $fmod/fmodf
|
||||
(f32.const 9.199999809265137)
|
||||
(f32.const 2)
|
||||
)
|
||||
(f32.const 1.2000000476837158)
|
||||
)
|
||||
(f32.const 1.1920928955078125e-07)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(f32.lt
|
||||
(f32.sub
|
||||
(call $fmod/fmodf
|
||||
(f32.const 9.199999809265137)
|
||||
(f32.const 3.700000047683716)
|
||||
)
|
||||
(f32.const 1.7999999523162842)
|
||||
)
|
||||
(f32.const 1.1920928955078125e-07)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
@ -588,6 +1095,8 @@
|
||||
FUNCTION_PROTOTYPE: usize
|
||||
GLOBAL: HEAP_BASE
|
||||
FUNCTION_PROTOTYPE: fmod/fmod
|
||||
FUNCTION_PROTOTYPE: fmod/fmodf
|
||||
[program.exports]
|
||||
FUNCTION_PROTOTYPE: fmod/fmod
|
||||
FUNCTION_PROTOTYPE: fmod/fmodf
|
||||
;)
|
||||
|
@ -2,7 +2,6 @@
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(global $namespace/Outer.Inner.aVar (mut i32) (i32.const 0))
|
||||
(global $namespace/Joined.THREE i32 (i32.const 3))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
@ -17,7 +16,7 @@
|
||||
(drop
|
||||
(block (result i32)
|
||||
(block $__inlined_func$namespace/Joined.anotherFunc (result i32)
|
||||
(get_global $namespace/Joined.THREE)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -2,7 +2,6 @@
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(global $namespace/Outer.Inner.aVar (mut i32) (i32.const 0))
|
||||
(global $namespace/Joined.THREE i32 (i32.const 3))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
@ -10,7 +9,7 @@
|
||||
(get_global $namespace/Outer.Inner.aVar)
|
||||
)
|
||||
(func $namespace/Joined.anotherFunc (; 1 ;) (type $i) (result i32)
|
||||
(get_global $namespace/Joined.THREE)
|
||||
(i32.const 3)
|
||||
)
|
||||
(func $start (; 2 ;) (type $v)
|
||||
(drop
|
||||
|
@ -16,7 +16,7 @@
|
||||
)
|
||||
(func $namespace/Joined.anotherFunc (; 1 ;) (type $i) (result i32)
|
||||
(return
|
||||
(get_global $namespace/Joined.THREE)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(func $start (; 2 ;) (type $v)
|
||||
@ -27,7 +27,7 @@
|
||||
(call $namespace/Outer.Inner.aFunc)
|
||||
)
|
||||
(drop
|
||||
(get_global $namespace/Outer.Inner.anEnum.ONE)
|
||||
(i32.const 1)
|
||||
)
|
||||
(drop
|
||||
(call $namespace/Joined.anotherFunc)
|
||||
|
Reference in New Issue
Block a user