Rename memory instructions; Rework constant handling

This commit is contained in:
dcodeIO
2018-07-18 23:49:32 +02:00
parent 34e8facfdc
commit a1b75b69b7
170 changed files with 26392 additions and 5185 deletions

View File

@ -1,6 +1,7 @@
(module
(type $ii (func (param i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $iv (func (param i32)))
(type $v (func))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
@ -9,7 +10,6 @@
(global $std/string-utf8/str (mut i32) (i32.const 8))
(global $std/string-utf8/len (mut i32) (i32.const 0))
(global $std/string-utf8/ptr (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 64))
(memory $0 1)
(data (i32.const 8) "\06\00\00\00\01\d87\dch\00i\00R\d8b\df")
(data (i32.const 24) "\12\00\00\00s\00t\00d\00/\00s\00t\00r\00i\00n\00g\00-\00u\00t\00f\008\00.\00t\00s")
@ -161,7 +161,15 @@
)
(get_local $1)
)
(func $~lib/allocator/arena/allocate_memory (; 2 ;) (type $ii) (param $0 i32) (result i32)
(func $~lib/memory/memory.size (; 2 ;) (type $i) (result i32)
(current_memory)
)
(func $~lib/memory/memory.grow (; 3 ;) (type $ii) (param $0 i32) (result i32)
(grow_memory
(get_local $0)
)
)
(func $~lib/allocator/arena/__memory_allocate (; 4 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
@ -193,14 +201,14 @@
)
(i32.shl
(tee_local $2
(current_memory)
(call $~lib/memory/memory.size)
)
(i32.const 16)
)
)
(if
(i32.lt_s
(grow_memory
(call $~lib/memory/memory.grow
(select
(get_local $2)
(tee_local $3
@ -228,7 +236,7 @@
)
(if
(i32.lt_s
(grow_memory
(call $~lib/memory/memory.grow
(get_local $3)
)
(i32.const 0)
@ -247,7 +255,12 @@
)
(i32.const 0)
)
(func $~lib/string/String#toUTF8 (; 3 ;) (type $ii) (param $0 i32) (result i32)
(func $~lib/memory/memory.allocate (; 5 ;) (type $ii) (param $0 i32) (result i32)
(call $~lib/allocator/arena/__memory_allocate
(get_local $0)
)
)
(func $~lib/string/String#toUTF8 (; 6 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
@ -256,7 +269,7 @@
(local $6 i32)
(local $7 i32)
(set_local $5
(call $~lib/allocator/arena/allocate_memory
(call $~lib/memory/memory.allocate
(call $~lib/string/String#get:lengthUTF8
(get_local $0)
)
@ -533,18 +546,17 @@
)
(get_local $5)
)
(func $~lib/allocator/arena/free_memory (; 4 ;) (type $iv) (param $0 i32)
(func $~lib/allocator/arena/__memory_free (; 7 ;) (type $iv) (param $0 i32)
(nop)
)
(func $start (; 5 ;) (type $v)
(func $~lib/memory/memory.free (; 8 ;) (type $iv) (param $0 i32)
(call $~lib/allocator/arena/__memory_free
(get_local $0)
)
)
(func $start (; 9 ;) (type $v)
(set_global $~lib/allocator/arena/startOffset
(i32.and
(i32.add
(get_global $HEAP_BASE)
(i32.const 7)
)
(i32.const -8)
)
(i32.const 64)
)
(set_global $~lib/allocator/arena/offset
(get_global $~lib/allocator/arena/startOffset)
@ -758,7 +770,7 @@
(unreachable)
)
)
(call $~lib/allocator/arena/free_memory
(call $~lib/memory/memory.free
(get_global $std/string-utf8/ptr)
)
)