Revised implicit type conversions; Initial function expression compilation

This commit is contained in:
dcodeIO
2018-02-28 01:48:01 +01:00
parent bda6cb9792
commit d4c00eaba3
36 changed files with 940 additions and 1754 deletions

View File

@ -63,34 +63,28 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $8
(i32.and
(if (result i32)
(i32.ne
(tee_local $8
(i64.eq
(i64.shl
(get_local $3)
(i64.const 1)
)
(i64.const 0)
)
(tee_local $8
(i32.and
(if (result i32)
(tee_local $8
(i64.eq
(i64.shl
(get_local $3)
(i64.const 1)
)
(i32.const 0)
)
(get_local $8)
(f64.ne
(tee_local $7
(get_local $1)
)
(get_local $7)
(i64.const 0)
)
)
(i32.const 1)
(get_local $8)
(f64.ne
(tee_local $7
(get_local $1)
)
(get_local $7)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $8)
(i32.eq
@ -517,34 +511,28 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $8
(i32.and
(if (result i32)
(i32.ne
(tee_local $8
(i32.eq
(i32.shl
(get_local $3)
(i32.const 1)
)
(i32.const 0)
)
(tee_local $8
(i32.and
(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)
)
)
(i32.const 1)
(get_local $8)
(f32.ne
(tee_local $7
(get_local $1)
)
(get_local $7)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $8)
(i32.eq

View File

@ -0,0 +1,15 @@
(module
(type $ii (func (param i32) (result i32)))
(type $v (func))
(table 3 3 anyfunc)
(elem (i32.const 0) $start~anonymous|0 $start~anonymous|0 $start~someName|2)
(memory $0 1)
(export "memory" (memory $0))
(start $start~someName|2)
(func $start~anonymous|0 (; 0 ;) (type $ii) (param $0 i32) (result i32)
(get_local $0)
)
(func $start~someName|2 (; 1 ;) (type $v)
(nop)
)
)

View File

@ -0,0 +1,11 @@
var f1 = function(a: i32): i32 {
return a;
};
f1;
var f2 = (a: i32): i32 => {
return a;
};
f2;
var f3 = function someName(): void {
};
f3;

View File

@ -0,0 +1,36 @@
(module
(type $ii (func (param i32) (result i32)))
(type $v (func))
(global $function-expression/f1 (mut i32) (i32.const 0))
(global $function-expression/f2 (mut i32) (i32.const 1))
(global $function-expression/f3 (mut i32) (i32.const 2))
(global $HEAP_BASE i32 (i32.const 4))
(table 3 3 anyfunc)
(elem (i32.const 0) $start~anonymous|0 $start~anonymous|1 $start~someName|2)
(memory $0 1)
(export "memory" (memory $0))
(start $start)
(func $start~anonymous|0 (; 0 ;) (type $ii) (param $0 i32) (result i32)
(return
(get_local $0)
)
)
(func $start~anonymous|1 (; 1 ;) (type $ii) (param $0 i32) (result i32)
(return
(get_local $0)
)
)
(func $start~someName|2 (; 2 ;) (type $v)
)
(func $start (; 3 ;) (type $v)
(drop
(get_global $function-expression/f1)
)
(drop
(get_global $function-expression/f2)
)
(drop
(get_global $function-expression/f3)
)
)
)

View File

@ -229,14 +229,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $9
(i32.lt_s
(get_local $8)
(i32.const 2)
)
(tee_local $9
(i32.lt_s
(get_local $8)
(i32.const 2)
)
(i32.const 0)
)
(get_local $9)
(i32.gt_s

View File

@ -16,10 +16,7 @@
(local $1 f64)
(drop
(if (result i32)
(i32.ne
(i32.const 0)
(i32.const 0)
)
(i32.const 0)
(unreachable)
(i32.const 0)
)
@ -36,10 +33,7 @@
)
(drop
(if (result i32)
(i32.ne
(i32.const 1)
(i32.const 0)
)
(i32.const 1)
(i32.const 1)
(unreachable)
)
@ -56,18 +50,12 @@
)
(drop
(if (result i32)
(i32.ne
(tee_local $0
(if (result i32)
(i32.ne
(i32.const 1)
(i32.const 0)
)
(i32.const 2)
(i32.const 1)
)
(tee_local $0
(if (result i32)
(i32.const 1)
(i32.const 2)
(i32.const 1)
)
(i32.const 0)
)
(get_local $0)
(unreachable)
@ -94,10 +82,7 @@
)
(set_global $logical/i
(if (result i32)
(i32.ne
(i32.const 1)
(i32.const 0)
)
(i32.const 1)
(i32.const 2)
(i32.const 1)
)
@ -121,10 +106,7 @@
)
(set_global $logical/i
(if (result i32)
(i32.ne
(i32.const 0)
(i32.const 0)
)
(i32.const 0)
(i32.const 0)
(i32.const 1)
)

View File

@ -24,10 +24,7 @@
(loop $continue|0
(if
(if (result i32)
(i32.ne
(get_local $2)
(i32.const 0)
)
(get_local $2)
(i32.rem_u
(get_local $1)
(i32.const 4)

View File

@ -1,4 +1,4 @@
function test(a: i32, b: i32): void {
function test(a: u32, b: u32): void {
// signed
assert(<i8>(a + b) == <i8>(<i8>a + <i8>b));

View File

@ -111,10 +111,7 @@
(loop $continue|0
(if
(if (result i32)
(i32.ne
(get_local $2)
(i32.const 0)
)
(get_local $2)
(i32.rem_u
(get_local $1)
(i32.const 4)
@ -1959,34 +1956,28 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $8
(i32.and
(if (result i32)
(i32.ne
(tee_local $8
(i64.eq
(i64.shl
(get_local $3)
(i64.const 1)
)
(i64.const 0)
)
(tee_local $8
(i32.and
(if (result i32)
(tee_local $8
(i64.eq
(i64.shl
(get_local $3)
(i64.const 1)
)
(i32.const 0)
)
(get_local $8)
(f64.ne
(tee_local $7
(get_local $1)
)
(get_local $7)
(i64.const 0)
)
)
(i32.const 1)
(get_local $8)
(f64.ne
(tee_local $7
(get_local $1)
)
(get_local $7)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $8)
(i32.eq
@ -2413,34 +2404,28 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $8
(i32.and
(if (result i32)
(i32.ne
(tee_local $8
(i32.eq
(i32.shl
(get_local $3)
(i32.const 1)
)
(i32.const 0)
)
(tee_local $8
(i32.and
(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)
)
)
(i32.const 1)
(get_local $8)
(f32.ne
(tee_local $7
(get_local $1)
)
(get_local $7)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $8)
(i32.eq
@ -4161,10 +4146,7 @@
)
(drop
(if (result i32)
(i32.ne
(i32.const 0)
(i32.const 0)
)
(i32.const 0)
(unreachable)
(i32.const 0)
)
@ -4181,10 +4163,7 @@
)
(drop
(if (result i32)
(i32.ne
(i32.const 1)
(i32.const 0)
)
(i32.const 1)
(i32.const 1)
(unreachable)
)
@ -4201,18 +4180,12 @@
)
(drop
(if (result i32)
(i32.ne
(tee_local $0
(if (result i32)
(i32.ne
(i32.const 1)
(i32.const 0)
)
(i32.const 2)
(i32.const 1)
)
(tee_local $0
(if (result i32)
(i32.const 1)
(i32.const 2)
(i32.const 1)
)
(i32.const 0)
)
(get_local $0)
(unreachable)
@ -4239,10 +4212,7 @@
)
(set_global $logical/i
(if (result i32)
(i32.ne
(i32.const 1)
(i32.const 0)
)
(i32.const 1)
(i32.const 2)
(i32.const 1)
)
@ -4266,10 +4236,7 @@
)
(set_global $logical/i
(if (result i32)
(i32.ne
(i32.const 0)
(i32.const 0)
)
(i32.const 0)
(i32.const 0)
(i32.const 1)
)

View File

@ -61,14 +61,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $4
(i32.gt_u
(get_local $2)
(get_local $3)
)
(tee_local $4
(i32.gt_u
(get_local $2)
(get_local $3)
)
(i32.const 0)
)
(i32.lt_s
(grow_memory
@ -476,10 +473,7 @@
(loop $continue|0
(if
(if (result i32)
(i32.ne
(get_local $2)
(i32.const 0)
)
(get_local $2)
(i32.and
(get_local $1)
(i32.const 3)
@ -2279,17 +2273,14 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $3
(i32.le_u
(i32.add
(get_local $1)
(get_local $2)
)
(get_local $0)
(tee_local $3
(i32.le_u
(i32.add
(get_local $1)
(get_local $2)
)
(get_local $0)
)
(i32.const 0)
)
(get_local $3)
(i32.le_u
@ -2607,10 +2598,7 @@
(loop $continue|0
(if
(if (result i32)
(i32.ne
(get_local $2)
(i32.const 0)
)
(get_local $2)
(i32.eq
(i32.load8_u
(get_local $0)

View File

@ -62,14 +62,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $4
(i32.gt_u
(get_local $2)
(get_local $3)
)
(tee_local $4
(i32.gt_u
(get_local $2)
(get_local $3)
)
(i32.const 0)
)
(i32.lt_s
(grow_memory
@ -135,10 +132,7 @@
(loop $continue|0
(if
(if (result i32)
(i32.ne
(get_local $2)
(i32.const 0)
)
(get_local $2)
(i32.and
(get_local $1)
(i32.const 3)
@ -1938,17 +1932,14 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $3
(i32.le_u
(i32.add
(get_local $1)
(get_local $2)
)
(get_local $0)
(tee_local $3
(i32.le_u
(i32.add
(get_local $1)
(get_local $2)
)
(get_local $0)
)
(i32.const 0)
)
(get_local $3)
(i32.le_u

View File

@ -53,14 +53,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $4
(i32.gt_u
(get_local $2)
(get_local $3)
)
(tee_local $4
(i32.gt_u
(get_local $2)
(get_local $3)
)
(i32.const 0)
)
(i32.lt_s
(grow_memory

View File

@ -16,29 +16,23 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 2)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -62,14 +56,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 2)
)
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 2)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -137,44 +128,35 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 2)
(i32.const 2)
)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 1)
)
(i32.const 1)
)
(get_local $1)
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 2)
(i32.const 4)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 2)
(i32.const 4)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -311,29 +293,23 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 2)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -357,14 +333,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 2)
)
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 2)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -456,44 +429,35 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 2)
(i32.const 2)
)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 2)
(i32.const 1)
)
(i32.const 1)
)
(get_local $1)
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 2)
(i32.const 4)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 2)
(i32.const 4)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -636,29 +600,23 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -682,14 +640,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -737,44 +692,35 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
(i32.const 1)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 4)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -905,29 +851,23 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -951,14 +891,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -1008,44 +945,35 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
(i32.const 1)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 4)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -1176,29 +1104,23 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 2)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 8)
(i32.const 2)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -1222,14 +1144,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 2)
)
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 2)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -1277,44 +1196,35 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 8)
(i32.const 2)
)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 1)
)
(i32.const 1)
)
(get_local $1)
(i32.eq
(i32.const 8)
(i32.const 2)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 8)
(i32.const 4)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 8)
(i32.const 4)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -1445,29 +1355,23 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 2)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 8)
(i32.const 2)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -1491,14 +1395,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 2)
)
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 2)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -1546,44 +1447,35 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 8)
(i32.const 2)
)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 8)
(i32.const 1)
)
(i32.const 1)
)
(get_local $1)
(i32.eq
(i32.const 8)
(i32.const 2)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 8)
(i32.const 4)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 8)
(i32.const 4)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -1714,29 +1606,23 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -1760,14 +1646,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -1815,44 +1698,35 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
(i32.const 1)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 4)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -1983,29 +1857,23 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -2029,14 +1897,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 2)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
@ -2084,44 +1949,35 @@
(i32.eqz
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.and
(if (result i32)
(i32.ne
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.and
(if (result i32)
(tee_local $1
(i32.eq
(i32.const 4)
(i32.const 1)
)
(i32.const 1)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 2)
)
)
(i32.const 0)
)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 4)
(i32.const 1)
)
)
(i32.const 1)
(get_local $1)
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(i32.const 1)
)
(i32.const 0)
)
(get_local $1)
(i32.eq

View File

@ -2193,9 +2193,7 @@
(get_local $2)
(i32.const 1)
)
(i32.load offset=8
(get_local $0)
)
(get_local $3)
)
(call "$(lib)/memory/move_memory"
(i32.add
@ -2221,9 +2219,7 @@
)
(i32.sub
(i32.sub
(i32.load offset=8
(get_local $0)
)
(get_local $3)
(get_local $2)
)
(i32.const 1)

View File

@ -59,14 +59,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $4
(i32.gt_u
(get_local $2)
(get_local $3)
)
(tee_local $4
(i32.gt_u
(get_local $2)
(get_local $3)
)
(i32.const 0)
)
(i32.lt_s
(grow_memory
@ -132,10 +129,7 @@
(loop $continue|0
(if
(if (result i32)
(i32.ne
(get_local $2)
(i32.const 0)
)
(get_local $2)
(i32.and
(get_local $1)
(i32.const 3)
@ -1935,17 +1929,14 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $3
(i32.le_u
(i32.add
(get_local $1)
(get_local $2)
)
(get_local $0)
(tee_local $3
(i32.le_u
(i32.add
(get_local $1)
(get_local $2)
)
(get_local $0)
)
(i32.const 0)
)
(get_local $3)
(i32.le_u
@ -2506,9 +2497,7 @@
(get_local $2)
(i32.const 1)
)
(i32.load offset=8
(get_local $0)
)
(get_local $3)
)
(call "$(lib)/memory/move_memory"
(i32.add
@ -2534,9 +2523,7 @@
)
(i32.sub
(i32.sub
(i32.load offset=8
(get_local $0)
)
(get_local $3)
(get_local $2)
)
(i32.const 1)

View File

@ -114,10 +114,7 @@
(loop $continue|0
(if
(if (result i32)
(i32.ne
(get_local $2)
(i32.const 0)
)
(get_local $2)
(i32.eq
(i32.load8_u
(get_local $0)
@ -635,14 +632,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $6
(i32.eq
(get_local $4)
(i32.const 48)
)
(tee_local $6
(i32.eq
(get_local $4)
(i32.const 48)
)
(i32.const 0)
)
(i32.gt_s
(get_local $2)
@ -771,14 +765,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $6
(i32.lt_s
(get_local $1)
(i32.const 2)
)
(tee_local $6
(i32.lt_s
(get_local $1)
(i32.const 2)
)
(i32.const 0)
)
(get_local $6)
(i32.gt_s
@ -821,14 +812,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $6
(i32.ge_s
(get_local $4)
(i32.const 48)
)
(tee_local $6
(i32.ge_s
(get_local $4)
(i32.const 48)
)
(i32.const 0)
)
(i32.le_s
(get_local $4)
@ -847,14 +835,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $6
(i32.ge_s
(get_local $4)
(i32.const 65)
)
(tee_local $6
(i32.ge_s
(get_local $4)
(i32.const 65)
)
(i32.const 0)
)
(i32.le_s
(get_local $4)
@ -876,14 +861,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $6
(i32.ge_s
(get_local $4)
(i32.const 97)
)
(tee_local $6
(i32.ge_s
(get_local $4)
(i32.const 97)
)
(i32.const 0)
)
(i32.le_s
(get_local $4)
@ -1119,14 +1101,11 @@
(if
(i32.and
(if (result i32)
(i32.ne
(tee_local $6
(i32.eq
(get_local $3)
(i32.const 69)
)
(tee_local $6
(i32.eq
(get_local $3)
(i32.const 69)
)
(i32.const 0)
)
(get_local $6)
(i32.eq

View File

@ -1,327 +0,0 @@
(module
(type $ii (func (param i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $iiv (func (param i32 i32)))
(type $iiiv (func (param i32 i32 i32)))
(type $iv (func (param i32)))
(type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 4) "\07\00\00\00t\00l\00s\00f\00.\00t\00s")
(export "control$construct" (func $tlsf/control$construct))
(export "memory" (memory $0))
(start $start)
(func $tlsf/fls (; 1 ;) (type $ii) (param $0 i32) (result i32)
(select
(i32.sub
(i32.const 31)
(i32.clz
(get_local $0)
)
)
(i32.const -1)
(get_local $0)
)
)
(func $tlsf/ffs (; 2 ;) (type $ii) (param $0 i32) (result i32)
(select
(i32.ctz
(get_local $0)
)
(i32.const -1)
(get_local $0)
)
)
(func $tlsf/block$set_next_free (; 3 ;) (type $iiv) (param $0 i32) (param $1 i32)
(i32.store
(i32.add
(get_local $0)
(i32.const 8)
)
(get_local $1)
)
)
(func $tlsf/block$set_prev_free (; 4 ;) (type $iiv) (param $0 i32) (param $1 i32)
(i32.store
(i32.add
(get_local $0)
(i32.const 12)
)
(get_local $1)
)
)
(func $tlsf/control$set_fl_bitmap (; 5 ;) (type $iiv) (param $0 i32) (param $1 i32)
(i32.store
(i32.add
(get_local $0)
(i32.const 16)
)
(get_local $1)
)
)
(func $tlsf/control$set_sl_bitmap (; 6 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(if
(i32.ge_u
(get_local $1)
(i32.const 23)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 162)
(i32.const 2)
)
(unreachable)
)
)
(i32.store
(i32.add
(i32.add
(get_local $0)
(i32.const 20)
)
(i32.shl
(get_local $1)
(i32.const 2)
)
)
(get_local $2)
)
)
(func $tlsf/control$set_block (; 7 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(if
(i32.ge_u
(get_local $1)
(i32.const 23)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 173)
(i32.const 2)
)
(unreachable)
)
)
(if
(i32.ge_u
(get_local $2)
(i32.const 32)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 174)
(i32.const 2)
)
(unreachable)
)
)
(i32.store
(i32.add
(i32.add
(get_local $0)
(i32.const 112)
)
(i32.shl
(i32.add
(i32.shl
(get_local $1)
(i32.const 5)
)
(get_local $2)
)
(i32.const 2)
)
)
(get_local $3)
)
)
(func $tlsf/control$construct (; 8 ;) (type $iv) (param $0 i32)
(local $1 i32)
(local $2 i32)
(call $tlsf/block$set_next_free
(get_local $0)
(get_local $0)
)
(call $tlsf/block$set_prev_free
(get_local $0)
(get_local $0)
)
(call $tlsf/control$set_fl_bitmap
(get_local $0)
(i32.const 0)
)
(loop $continue|0
(if
(i32.lt_u
(get_local $1)
(i32.const 23)
)
(block
(call $tlsf/control$set_sl_bitmap
(get_local $0)
(get_local $1)
(i32.const 0)
)
(set_local $2
(i32.const 0)
)
(loop $continue|1
(if
(i32.lt_u
(get_local $2)
(i32.const 32)
)
(block
(call $tlsf/control$set_block
(get_local $0)
(get_local $1)
(get_local $2)
(get_local $0)
)
(set_local $2
(i32.add
(get_local $2)
(i32.const 1)
)
)
(br $continue|1)
)
)
)
(set_local $1
(i32.add
(get_local $1)
(i32.const 1)
)
)
(br $continue|0)
)
)
)
)
(func $start (; 9 ;) (type $v)
(if
(i32.ne
(call $tlsf/fls
(i32.const 0)
)
(i32.const -1)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 10)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $tlsf/fls
(i32.const 1)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 11)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $tlsf/fls
(i32.const -2147483640)
)
(i32.const 31)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 12)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $tlsf/fls
(i32.const 2147483647)
)
(i32.const 30)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 13)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $tlsf/ffs
(i32.const 0)
)
(i32.const -1)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 20)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $tlsf/ffs
(i32.const 1)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 21)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $tlsf/ffs
(i32.const -2147483648)
)
(i32.const 31)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 22)
(i32.const 0)
)
(unreachable)
)
)
(call $tlsf/control$construct
(i32.load
(i32.const 4)
)
)
)
)

View File

@ -1,190 +0,0 @@
// An unfinished implementation of tlsf in low-level AssemblyScript.
// Useful as a compiler test in this state, but nothing more.
// based upon: https://github.com/mattconte/tlsf/blob/master/tlsf.c (BSD)
/** Finds the index of the least bit set. */
function fls(word: u32): i32 {
return !word ? -1: 31 - clz<i32>(word);
}
assert(fls(0) == -1);
assert(fls(1) == 0);
assert(fls(0x80000008) == 31);
assert(fls(0x7FFFFFFF) == 30);
/** Finds the index of the first bit set. */
function ffs(word: u32): i32 {
return !word ? -1 : ctz<i32>(word);
}
assert(ffs(0) == -1);
assert(ffs(1) == 0);
assert(ffs(0x80000000) == 31);
// Align allocated blocks to 8 bytes so that any native type is aligned
const ALIGN_SIZE_LOG2: i32 = 3;
const ALIGN_SIZE: i32 = 1 << ALIGN_SIZE_LOG2;
assert(ALIGN_SIZE == 8);
// Define bitmap constants
const SL_INDEX_COUNT_LOG2: i32 = 5;
const FL_INDEX_MAX: i32 = 30;
const SL_INDEX_COUNT: i32 = 1 << SL_INDEX_COUNT_LOG2;
const FL_INDEX_SHIFT: i32 = SL_INDEX_COUNT_LOG2 + ALIGN_SIZE_LOG2;
const FL_INDEX_COUNT: i32 = FL_INDEX_MAX - FL_INDEX_SHIFT + 1;
const SMALL_BLOCK_SIZE: i32 = 1 << FL_INDEX_SHIFT;
// struct block_header_t {
// struct block_header_t* prev_phys_block;
// size_t tagged_size;
// struct block_header_t* next_free;
// struct block_header_t* prev_free;
// }
const BLOCK$PREV_PHYS_BLOCK_OFFSET: usize = 0;
const BLOCK$TAGGED_SIZE_OFFSET: usize = BLOCK$PREV_PHYS_BLOCK_OFFSET + sizeof<usize>();
const BLOCK$NEXT_FREE_OFFSET: usize = BLOCK$TAGGED_SIZE_OFFSET + sizeof<usize>();
const BLOCK$PREV_FREE_OFFSET: usize = BLOCK$NEXT_FREE_OFFSET + sizeof<usize>();
const BLOCK$SIZE: usize = BLOCK$PREV_FREE_OFFSET + sizeof<usize>();
const BLOCK_HEADER_FREE_BIT: u32 = 1 << 0;
const BLOCK_HEADER_PREV_FREE_BIT: u32 = 1 << 1;
const BLOCK_OVERHEAD: usize = sizeof<usize>();
const BLOCK_START_OFFSET: usize = BLOCK$TAGGED_SIZE_OFFSET + sizeof<usize>();
const BLOCK_SIZE_MIN: usize = BLOCK$SIZE - BLOCK_OVERHEAD;
const BLOCK_SIZE_MAX: usize = 1 << (<usize>FL_INDEX_MAX);
function block$get_prev_phys_block(block: usize): usize {
return load<usize>(block + BLOCK$PREV_PHYS_BLOCK_OFFSET);
}
function block$set_prev_phys_block(block: usize, value: usize): void {
store<usize>(block + BLOCK$PREV_PHYS_BLOCK_OFFSET, value);
}
function block$get_tagged_size(block: usize): usize {
return load<usize>(block + BLOCK$TAGGED_SIZE_OFFSET);
}
function block$set_tagged_size(block: usize, value: usize): void {
store<usize>(block + BLOCK$TAGGED_SIZE_OFFSET, value);
}
function block_size(block: usize): usize {
return block$get_tagged_size(block) & ~(BLOCK_HEADER_FREE_BIT | BLOCK_HEADER_PREV_FREE_BIT);
}
function block_set_size(block: usize, value: usize): void {
store<usize>(block + BLOCK$TAGGED_SIZE_OFFSET, value | (block$get_tagged_size(block) & (BLOCK_HEADER_FREE_BIT | BLOCK_HEADER_PREV_FREE_BIT)));
}
function block$get_next_free(block: usize): usize {
return load<usize>(block + BLOCK$NEXT_FREE_OFFSET);
}
function block$set_next_free(block: usize, value: usize): void {
store<usize>(block + BLOCK$NEXT_FREE_OFFSET, value);
}
function block$get_prev_free(block: usize): usize {
return load<usize>(block + BLOCK$PREV_FREE_OFFSET);
}
function block$set_prev_free(block: usize, value: usize): void {
store<usize>(block + BLOCK$PREV_FREE_OFFSET, value);
}
function block_is_last(block: usize): bool {
return block_size(block) == 0;
}
function block_is_free(block: usize): bool {
return (block$get_tagged_size(block) & BLOCK_HEADER_FREE_BIT) != 0;
}
function block_set_free(block: usize): void {
store<usize>(block + BLOCK$TAGGED_SIZE_OFFSET, block$get_tagged_size(block) | BLOCK_HEADER_FREE_BIT);
}
function block_set_used(block: usize): void {
store<usize>(block + BLOCK$TAGGED_SIZE_OFFSET, block$get_tagged_size(block) & ~BLOCK_HEADER_FREE_BIT);
}
function block_is_prev_free(block: usize): bool {
return (block$get_tagged_size(block) & BLOCK_HEADER_PREV_FREE_BIT) != 0;
}
function block_set_prev_free(block: usize): void {
store<usize>(block + BLOCK$TAGGED_SIZE_OFFSET, block$get_tagged_size(block) | BLOCK_HEADER_PREV_FREE_BIT);
}
function block_set_prev_used(block: usize): void {
store<usize>(block + BLOCK$TAGGED_SIZE_OFFSET, block$get_tagged_size(block) & ~BLOCK_HEADER_PREV_FREE_BIT);
}
function block_from_ptr(ptr: usize): usize {
return ptr - BLOCK_START_OFFSET;
}
function block_to_ptr(block: usize): usize {
return block + BLOCK_START_OFFSET;
}
// struct control_t {
// block_header_t block_null;
// unsigned int fl_bitmap;
// unsigned int sl_bitmap[FL_INDEX_COUNT];
// block_header_t* blocks[FL_INDEX_COUNT][SL_INDEX_COUNT];
// }
const CONTROL$FL_BITMAP_OFFSET: usize = BLOCK$SIZE;
const CONTROL$SL_BITMAP_OFFSET: usize = CONTROL$FL_BITMAP_OFFSET + sizeof<u32>();
const CONTROL$BLOCKS_OFFSET: usize = CONTROL$SL_BITMAP_OFFSET + FL_INDEX_COUNT * sizeof<u32>();
const CONTROL$SIZE: usize = CONTROL$BLOCKS_OFFSET + FL_INDEX_COUNT * SL_INDEX_COUNT * sizeof<u32>();
function control$get_fl_bitmap(ptr: usize): u32 {
return load<u32>(ptr + CONTROL$FL_BITMAP_OFFSET);
}
function control$set_fl_bitmap(ptr: usize, value: u32): void {
store<u32>(ptr + CONTROL$FL_BITMAP_OFFSET, value);
}
function control$get_sl_bitmap(ptr: usize, flIndex: usize): u32 {
assert(flIndex < FL_INDEX_COUNT);
return load<u32>(ptr + CONTROL$SL_BITMAP_OFFSET + flIndex * sizeof<u32>());
}
function control$set_sl_bitmap(ptr: usize, flIndex: usize, value: u32): void {
assert(flIndex < FL_INDEX_COUNT);
store<u32>(ptr + CONTROL$SL_BITMAP_OFFSET + flIndex * sizeof<u32>(), value);
}
function control$get_block(ptr: usize, flIndex: usize, slIndex: usize): usize {
assert(flIndex < FL_INDEX_COUNT);
assert(slIndex < SL_INDEX_COUNT);
return load<usize>(ptr + CONTROL$BLOCKS_OFFSET + (flIndex * SL_INDEX_COUNT + slIndex) * sizeof<usize>());
}
function control$set_block(ptr: usize, flIndex: usize, slIndex: usize, value: usize): void {
assert(flIndex < FL_INDEX_COUNT);
assert(slIndex < SL_INDEX_COUNT);
store<usize>(ptr + CONTROL$BLOCKS_OFFSET + (flIndex * SL_INDEX_COUNT + slIndex) * sizeof<usize>(), value);
}
/* Clear structure and point all empty lists at the null block. */
export function control$construct(ptr: usize): void {
block$set_next_free(ptr, ptr);
block$set_prev_free(ptr, ptr);
control$set_fl_bitmap(ptr, 0);
for (var flIndex: usize = 0; flIndex < FL_INDEX_COUNT; ++flIndex) {
control$set_sl_bitmap(ptr, flIndex, 0);
for (var slIndex: usize = 0; slIndex < SL_INDEX_COUNT; ++slIndex)
control$set_block(ptr, flIndex, slIndex, ptr);
}
}
control$construct(load<usize>(sizeof<usize>())); // get HEAP_OFFSET and initialize there

View File

@ -1,412 +0,0 @@
(module
(type $ii (func (param i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $iiv (func (param i32 i32)))
(type $iiiv (func (param i32 i32 i32)))
(type $iv (func (param i32)))
(type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $tlsf/ALIGN_SIZE_LOG2 i32 (i32.const 3))
(global $tlsf/ALIGN_SIZE i32 (i32.const 8))
(global $tlsf/SL_INDEX_COUNT_LOG2 i32 (i32.const 5))
(global $tlsf/FL_INDEX_MAX i32 (i32.const 30))
(global $tlsf/SL_INDEX_COUNT i32 (i32.const 32))
(global $tlsf/FL_INDEX_SHIFT i32 (i32.const 8))
(global $tlsf/FL_INDEX_COUNT i32 (i32.const 23))
(global $tlsf/SMALL_BLOCK_SIZE i32 (i32.const 256))
(global $tlsf/BLOCK$PREV_PHYS_BLOCK_OFFSET i32 (i32.const 0))
(global $tlsf/BLOCK$TAGGED_SIZE_OFFSET i32 (i32.const 4))
(global $tlsf/BLOCK$NEXT_FREE_OFFSET i32 (i32.const 8))
(global $tlsf/BLOCK$PREV_FREE_OFFSET i32 (i32.const 12))
(global $tlsf/BLOCK$SIZE i32 (i32.const 16))
(global $tlsf/BLOCK_HEADER_FREE_BIT i32 (i32.const 1))
(global $tlsf/BLOCK_HEADER_PREV_FREE_BIT i32 (i32.const 2))
(global $tlsf/BLOCK_OVERHEAD i32 (i32.const 4))
(global $tlsf/BLOCK_START_OFFSET i32 (i32.const 8))
(global $tlsf/BLOCK_SIZE_MIN i32 (i32.const 12))
(global $tlsf/BLOCK_SIZE_MAX i32 (i32.const 1073741824))
(global $tlsf/CONTROL$FL_BITMAP_OFFSET i32 (i32.const 16))
(global $tlsf/CONTROL$SL_BITMAP_OFFSET i32 (i32.const 20))
(global $tlsf/CONTROL$BLOCKS_OFFSET i32 (i32.const 112))
(global $tlsf/CONTROL$SIZE i32 (i32.const 3056))
(global $HEAP_BASE i32 (i32.const 24))
(memory $0 1)
(data (i32.const 4) "\07\00\00\00t\00l\00s\00f\00.\00t\00s\00")
(export "control$construct" (func $tlsf/control$construct))
(export "memory" (memory $0))
(start $start)
(func $tlsf/fls (; 1 ;) (type $ii) (param $0 i32) (result i32)
(return
(if (result i32)
(i32.eqz
(get_local $0)
)
(i32.const -1)
(i32.sub
(i32.const 31)
(i32.clz
(get_local $0)
)
)
)
)
)
(func $tlsf/ffs (; 2 ;) (type $ii) (param $0 i32) (result i32)
(return
(if (result i32)
(i32.eqz
(get_local $0)
)
(i32.const -1)
(i32.ctz
(get_local $0)
)
)
)
)
(func $tlsf/block$set_next_free (; 3 ;) (type $iiv) (param $0 i32) (param $1 i32)
(i32.store
(i32.add
(get_local $0)
(i32.const 8)
)
(get_local $1)
)
)
(func $tlsf/block$set_prev_free (; 4 ;) (type $iiv) (param $0 i32) (param $1 i32)
(i32.store
(i32.add
(get_local $0)
(i32.const 12)
)
(get_local $1)
)
)
(func $tlsf/control$set_fl_bitmap (; 5 ;) (type $iiv) (param $0 i32) (param $1 i32)
(i32.store
(i32.add
(get_local $0)
(i32.const 16)
)
(get_local $1)
)
)
(func $tlsf/control$set_sl_bitmap (; 6 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(if
(i32.eqz
(i32.lt_u
(get_local $1)
(i32.const 23)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 162)
(i32.const 2)
)
(unreachable)
)
)
(i32.store
(i32.add
(i32.add
(get_local $0)
(i32.const 20)
)
(i32.mul
(get_local $1)
(i32.const 4)
)
)
(get_local $2)
)
)
(func $tlsf/control$set_block (; 7 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(if
(i32.eqz
(i32.lt_u
(get_local $1)
(i32.const 23)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 173)
(i32.const 2)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.lt_u
(get_local $2)
(i32.const 32)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 174)
(i32.const 2)
)
(unreachable)
)
)
(i32.store
(i32.add
(i32.add
(get_local $0)
(i32.const 112)
)
(i32.mul
(i32.add
(i32.mul
(get_local $1)
(i32.const 32)
)
(get_local $2)
)
(i32.const 4)
)
)
(get_local $3)
)
)
(func $tlsf/control$construct (; 8 ;) (type $iv) (param $0 i32)
(local $1 i32)
(local $2 i32)
(call $tlsf/block$set_next_free
(get_local $0)
(get_local $0)
)
(call $tlsf/block$set_prev_free
(get_local $0)
(get_local $0)
)
(call $tlsf/control$set_fl_bitmap
(get_local $0)
(i32.const 0)
)
(block $break|0
(set_local $1
(i32.const 0)
)
(loop $continue|0
(if
(i32.lt_u
(get_local $1)
(i32.const 23)
)
(block
(block
(call $tlsf/control$set_sl_bitmap
(get_local $0)
(get_local $1)
(i32.const 0)
)
(block $break|1
(set_local $2
(i32.const 0)
)
(loop $continue|1
(if
(i32.lt_u
(get_local $2)
(i32.const 32)
)
(block
(call $tlsf/control$set_block
(get_local $0)
(get_local $1)
(get_local $2)
(get_local $0)
)
(set_local $2
(i32.add
(get_local $2)
(i32.const 1)
)
)
(br $continue|1)
)
)
)
)
)
(set_local $1
(i32.add
(get_local $1)
(i32.const 1)
)
)
(br $continue|0)
)
)
)
)
)
(func $start (; 9 ;) (type $v)
(if
(i32.eqz
(i32.eq
(call $tlsf/fls
(i32.const 0)
)
(i32.const -1)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 10)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(call $tlsf/fls
(i32.const 1)
)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 11)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(call $tlsf/fls
(i32.const -2147483640)
)
(i32.const 31)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 12)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(call $tlsf/fls
(i32.const 2147483647)
)
(i32.const 30)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 13)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(call $tlsf/ffs
(i32.const 0)
)
(i32.const -1)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 20)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(call $tlsf/ffs
(i32.const 1)
)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 21)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(call $tlsf/ffs
(i32.const -2147483648)
)
(i32.const 31)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 22)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 8)
(i32.const 8)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 29)
(i32.const 0)
)
(unreachable)
)
)
(call $tlsf/control$construct
(i32.load
(i32.const 4)
)
)
)
)

View File

@ -219,22 +219,19 @@
(loop $continue|3
(if
(if (result i32)
(i32.ne
(tee_local $0
(block (result i32)
(set_local $0
(get_global $while/n)
)
(set_global $while/n
(i32.sub
(get_local $0)
(i32.const 1)
)
)
(get_local $0)
(tee_local $0
(block (result i32)
(set_local $0
(get_global $while/n)
)
(set_global $while/n
(i32.sub
(get_local $0)
(i32.const 1)
)
)
(get_local $0)
)
(i32.const 0)
)
(block (result i32)
(set_global $while/m