Control flow evaluator; Support for block-level let/const variables

This commit is contained in:
dcodeIO
2018-01-18 23:34:12 +01:00
parent 1c4b0ddc57
commit 7be4f9fabb
54 changed files with 3285 additions and 13138 deletions

View File

@ -2159,13 +2159,13 @@
(if
(i32.le_s
(tee_local $3
(if (result i32)
(get_local $2)
(select
(i32.shl
(get_local $2)
(i32.const 1)
)
(i32.const 1)
(get_local $2)
)
)
(i32.load offset=4
@ -2655,9 +2655,6 @@
(local $1 i32)
(local $2 i32)
(local $3 i32)
(set_local $1
(i32.const 0)
)
(set_local $2
(i32.sub
(i32.load offset=8

View File

@ -30,10 +30,8 @@
(i32.const 0)
)
)
(block
(set_local $1
(current_memory)
)
(set_local $1
(current_memory)
)
(if
(i32.gt_u
@ -82,10 +80,8 @@
(unreachable)
)
)
(block
(set_local $4
(get_global $std:heap/HEAP_OFFSET)
)
(set_local $4
(get_global $std:heap/HEAP_OFFSET)
)
(if
(i32.and
@ -2220,20 +2216,22 @@
(if
(get_local $2)
(block
(i32.store8
(i32.add
(get_local $0)
(tee_local $2
(i32.sub
(get_local $2)
(i32.const 1)
(block
(i32.store8
(i32.add
(get_local $0)
(tee_local $2
(i32.sub
(get_local $2)
(i32.const 1)
)
)
)
)
(i32.load8_u
(i32.add
(get_local $1)
(get_local $2)
(i32.load8_u
(i32.add
(get_local $1)
(get_local $2)
)
)
)
)
@ -2260,13 +2258,11 @@
)
(unreachable)
)
(block
(set_local $2
(call $std:heap/allocate_memory
(i32.mul
(get_local $1)
(i32.const 4)
)
(set_local $2
(call $std:heap/allocate_memory
(i32.mul
(get_local $1)
(i32.const 4)
)
)
)
@ -2430,11 +2426,9 @@
(local $3 i32)
(local $4 i32)
(local $5 i32)
(block
(set_local $2
(i32.load offset=4
(get_local $0)
)
(set_local $2
(i32.load offset=4
(get_local $0)
)
)
(if
@ -2445,16 +2439,14 @@
(get_local $2)
)
(block
(block
(set_local $3
(if (result i32)
(set_local $3
(if (result i32)
(get_local $2)
(i32.shl
(get_local $2)
(i32.shl
(get_local $2)
(i32.const 1)
)
(i32.const 1)
)
(i32.const 1)
)
)
(if
@ -2468,13 +2460,11 @@
)
(unreachable)
)
(block
(set_local $4
(call $std:heap/allocate_memory
(i32.mul
(get_local $3)
(i32.const 4)
)
(set_local $4
(call $std:heap/allocate_memory
(i32.mul
(get_local $3)
(i32.const 4)
)
)
)
@ -2648,15 +2638,13 @@
)
(return)
)
(block
(set_local $3
(i32.and
(i32.sub
(i32.const 0)
(get_local $0)
)
(i32.const 3)
(set_local $3
(i32.and
(i32.sub
(i32.const 0)
(get_local $0)
)
(i32.const 3)
)
)
(set_local $0
@ -2680,18 +2668,16 @@
)
)
)
(block
(set_local $4
(i32.mul
(i32.div_u
(i32.sub
(i32.const 0)
(i32.const 1)
)
(i32.const 255)
(set_local $4
(i32.mul
(i32.div_u
(i32.sub
(i32.const 0)
(i32.const 1)
)
(get_local $1)
(i32.const 255)
)
(get_local $1)
)
)
(i32.store
@ -2845,18 +2831,16 @@
(get_local $3)
)
)
(block
(set_local $5
(i64.or
(set_local $5
(i64.or
(i64.extend_u/i32
(get_local $4)
)
(i64.shl
(i64.extend_u/i32
(get_local $4)
)
(i64.shl
(i64.extend_u/i32
(get_local $4)
)
(i64.const 32)
)
(i64.const 32)
)
)
)
@ -2924,12 +2908,10 @@
)
(unreachable)
)
(block
(set_local $1
(set_local $1
(i32.load
(i32.load
(i32.load
(get_local $0)
)
(get_local $0)
)
)
)
@ -3010,17 +2992,15 @@
)
(block
(block
(block
(set_local $3
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(get_local $1)
(i32.const 4)
)
(set_local $3
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(get_local $1)
(i32.const 4)
)
)
)

View File

@ -30,10 +30,8 @@
(i32.const 0)
)
)
(block
(set_local $1
(current_memory)
)
(set_local $1
(current_memory)
)
(if
(i32.gt_u
@ -82,10 +80,8 @@
(unreachable)
)
)
(block
(set_local $4
(get_global $std:heap/HEAP_OFFSET)
)
(set_local $4
(get_global $std:heap/HEAP_OFFSET)
)
(if
(i32.and
@ -210,15 +206,13 @@
)
(return)
)
(block
(set_local $3
(i32.and
(i32.sub
(i32.const 0)
(get_local $0)
)
(i32.const 3)
(set_local $3
(i32.and
(i32.sub
(i32.const 0)
(get_local $0)
)
(i32.const 3)
)
)
(set_local $0
@ -242,18 +236,16 @@
)
)
)
(block
(set_local $4
(i32.mul
(i32.div_u
(i32.sub
(i32.const 0)
(i32.const 1)
)
(i32.const 255)
(set_local $4
(i32.mul
(i32.div_u
(i32.sub
(i32.const 0)
(i32.const 1)
)
(get_local $1)
(i32.const 255)
)
(get_local $1)
)
)
(i32.store
@ -407,18 +399,16 @@
(get_local $3)
)
)
(block
(set_local $5
(i64.or
(set_local $5
(i64.or
(i64.extend_u/i32
(get_local $4)
)
(i64.shl
(i64.extend_u/i32
(get_local $4)
)
(i64.shl
(i64.extend_u/i32
(get_local $4)
)
(i64.const 32)
)
(i64.const 32)
)
)
)
@ -2574,20 +2564,22 @@
(if
(get_local $2)
(block
(i32.store8
(i32.add
(get_local $0)
(tee_local $2
(i32.sub
(get_local $2)
(i32.const 1)
(block
(i32.store8
(i32.add
(get_local $0)
(tee_local $2
(i32.sub
(get_local $2)
(i32.const 1)
)
)
)
)
(i32.load8_u
(i32.add
(get_local $1)
(get_local $2)
(i32.load8_u
(i32.add
(get_local $1)
(get_local $2)
)
)
)
)

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,6 @@
(module
(type $ii (func (param i32) (result i32)))
(type $iiiv (func (param i32 i32 i32)))
(type $iv (func (param i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $v (func))
(global $std:heap/HEAP_OFFSET (mut i32) (i32.const 0))
@ -1970,10 +1969,7 @@
)
)
)
(func $std:heap/free_memory (; 4 ;) (type $iv) (param $0 i32)
(nop)
)
(func $std:set/Set#add (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $std:set/Set#add (; 4 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(if
@ -1999,12 +1995,10 @@
(i32.const 1)
)
)
(tee_local $3
(i32.const 8)
)
(i32.const 8)
(i32.gt_u
(get_local $2)
(get_local $3)
(i32.const 8)
)
)
)
@ -2029,7 +2023,7 @@
(i32.const 4)
)
)
(call $std:heap/free_memory
(drop
(i32.load
(get_local $0)
)
@ -2071,12 +2065,9 @@
)
(get_local $0)
)
(func $std:set/Set#has (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $std:set/Set#has (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(set_local $2
(i32.const 0)
)
(set_local $3
(i32.load offset=8
(get_local $0)
@ -2120,12 +2111,9 @@
)
(i32.const 0)
)
(func $std:set/Set#delete (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $std:set/Set#delete (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(set_local $2
(i32.const 0)
)
(set_local $3
(i32.load offset=8
(get_local $0)
@ -2223,13 +2211,7 @@
)
(i32.const 0)
)
(func $std:set/Set#clear (; 8 ;) (type $iv) (param $0 i32)
(i32.store offset=8
(get_local $0)
(i32.const 0)
)
)
(func $start (; 9 ;) (type $v)
(func $start (; 7 ;) (type $v)
(set_global $std:heap/HEAP_OFFSET
(get_global $HEAP_BASE)
)
@ -2345,8 +2327,9 @@
)
(unreachable)
)
(call $std:set/Set#clear
(i32.store offset=8
(get_global $std/set/set)
(i32.const 0)
)
(if
(call $std:set/Set#get:size

View File

@ -27,10 +27,8 @@
(i32.const 0)
)
)
(block
(set_local $1
(current_memory)
)
(set_local $1
(current_memory)
)
(if
(i32.gt_u
@ -79,10 +77,8 @@
(unreachable)
)
)
(block
(set_local $4
(get_global $std:heap/HEAP_OFFSET)
)
(set_local $4
(get_global $std:heap/HEAP_OFFSET)
)
(if
(i32.and
@ -2217,20 +2213,22 @@
(if
(get_local $2)
(block
(i32.store8
(i32.add
(get_local $0)
(tee_local $2
(i32.sub
(get_local $2)
(i32.const 1)
(block
(i32.store8
(i32.add
(get_local $0)
(tee_local $2
(i32.sub
(get_local $2)
(i32.const 1)
)
)
)
)
(i32.load8_u
(i32.add
(get_local $1)
(get_local $2)
(i32.load8_u
(i32.add
(get_local $1)
(get_local $2)
)
)
)
)
@ -2259,34 +2257,30 @@
)
)
(block
(block
(set_local $4
(select
(tee_local $2
(i32.shl
(i32.load offset=4
(get_local $0)
)
(i32.const 1)
(set_local $4
(select
(tee_local $2
(i32.shl
(i32.load offset=4
(get_local $0)
)
(i32.const 1)
)
(tee_local $3
(i32.const 8)
)
(i32.gt_u
(get_local $2)
(get_local $3)
)
)
(tee_local $3
(i32.const 8)
)
(i32.gt_u
(get_local $2)
(get_local $3)
)
)
)
(block
(set_local $5
(call $std:heap/allocate_memory
(i32.mul
(get_local $4)
(i32.const 4)
)
(set_local $5
(call $std:heap/allocate_memory
(i32.mul
(get_local $4)
(i32.const 4)
)
)
)