mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-21 02:31:41 +00:00
Rename memory instructions; Rework constant handling
This commit is contained in:
@ -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 $iiiv (func (param i32 i32 i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
@ -11,12 +12,19 @@
|
||||
(global $std/allocator_arena/ptr1 (mut i32) (i32.const 0))
|
||||
(global $std/allocator_arena/ptr2 (mut i32) (i32.const 0))
|
||||
(global $std/allocator_arena/i (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 56))
|
||||
(memory $0 1)
|
||||
(data (i32.const 8) "\16\00\00\00s\00t\00d\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00_\00a\00r\00e\00n\00a\00.\00t\00s")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/allocator/arena/allocate_memory (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/memory/memory.size (; 1 ;) (type $i) (result i32)
|
||||
(current_memory)
|
||||
)
|
||||
(func $~lib/memory/memory.grow (; 2 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(grow_memory
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
@ -48,14 +56,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
|
||||
@ -83,7 +91,7 @@
|
||||
)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(grow_memory
|
||||
(call $~lib/memory/memory.grow
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 0)
|
||||
@ -102,7 +110,12 @@
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(func $~lib/memory/set_memory (; 2 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/memory/memory.allocate (; 4 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(call $~lib/allocator/arena/__memory_allocate
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/memory/memset (; 5 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i64)
|
||||
(if
|
||||
@ -432,7 +445,14 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/memory/copy_memory (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/memory/memory.fill (; 6 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(call $~lib/memory/memset
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $~lib/memory/memcpy (; 7 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
@ -1818,7 +1838,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/memory/move_memory (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/memory/memmove (; 8 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
@ -1853,7 +1873,7 @@
|
||||
(if
|
||||
(get_local $3)
|
||||
(block
|
||||
(call $~lib/memory/copy_memory
|
||||
(call $~lib/memory/memcpy
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
@ -2110,7 +2130,15 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/memory/compare_memory (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(func $~lib/memory/memory.copy (; 9 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(call $~lib/memory/memmove
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $~lib/memory/memcmp (; 10 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
@ -2122,8 +2150,13 @@
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(if (result i32)
|
||||
(get_local $2)
|
||||
(tee_local $3
|
||||
(i32.ne
|
||||
(get_local $2)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.eq
|
||||
(i32.load8_u
|
||||
(get_local $0)
|
||||
@ -2132,8 +2165,10 @@
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(get_local $3)
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
@ -2172,34 +2207,43 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/free_memory (; 6 ;) (type $iv) (param $0 i32)
|
||||
(func $~lib/memory/memory.compare (; 11 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(call $~lib/memory/memcmp
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/__memory_free (; 12 ;) (type $iv) (param $0 i32)
|
||||
(nop)
|
||||
)
|
||||
(func $~lib/allocator/arena/reset_memory (; 7 ;) (type $v)
|
||||
(func $~lib/memory/memory.free (; 13 ;) (type $iv) (param $0 i32)
|
||||
(call $~lib/allocator/arena/__memory_free
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/__memory_reset (; 14 ;) (type $v)
|
||||
(set_global $~lib/allocator/arena/offset
|
||||
(get_global $~lib/allocator/arena/startOffset)
|
||||
)
|
||||
)
|
||||
(func $start (; 8 ;) (type $v)
|
||||
(func $~lib/memory/memory.reset (; 15 ;) (type $v)
|
||||
(call $~lib/allocator/arena/__memory_reset)
|
||||
)
|
||||
(func $start (; 16 ;) (type $v)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
(i32.and
|
||||
(i32.add
|
||||
(get_global $HEAP_BASE)
|
||||
(i32.const 7)
|
||||
)
|
||||
(i32.const -8)
|
||||
)
|
||||
(i32.const 56)
|
||||
)
|
||||
(set_global $~lib/allocator/arena/offset
|
||||
(get_global $~lib/allocator/arena/startOffset)
|
||||
)
|
||||
(set_global $std/allocator_arena/ptr1
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(call $~lib/memory/memory.allocate
|
||||
(i32.const 42)
|
||||
)
|
||||
)
|
||||
(set_global $std/allocator_arena/ptr2
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(call $~lib/memory/memory.allocate
|
||||
(i32.const 42)
|
||||
)
|
||||
)
|
||||
@ -2218,7 +2262,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(call $~lib/memory/set_memory
|
||||
(call $~lib/memory/memory.fill
|
||||
(get_global $std/allocator_arena/ptr1)
|
||||
(i32.const 18)
|
||||
(i32.const 42)
|
||||
@ -2248,8 +2292,8 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 13)
|
||||
(i32.const 2)
|
||||
(i32.const 12)
|
||||
(i32.const 27)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@ -2265,7 +2309,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $~lib/memory/move_memory
|
||||
(call $~lib/memory/memory.copy
|
||||
(get_global $std/allocator_arena/ptr2)
|
||||
(get_global $std/allocator_arena/ptr1)
|
||||
(i32.const 42)
|
||||
@ -2295,8 +2339,8 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 18)
|
||||
(i32.const 2)
|
||||
(i32.const 16)
|
||||
(i32.const 27)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@ -2313,7 +2357,7 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(call $~lib/memory/compare_memory
|
||||
(call $~lib/memory/memory.compare
|
||||
(get_global $std/allocator_arena/ptr1)
|
||||
(get_global $std/allocator_arena/ptr2)
|
||||
(i32.const 42)
|
||||
@ -2322,40 +2366,34 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 20)
|
||||
(i32.const 18)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(call $~lib/allocator/arena/free_memory
|
||||
(call $~lib/memory/memory.free
|
||||
(get_global $std/allocator_arena/ptr1)
|
||||
)
|
||||
(call $~lib/allocator/arena/free_memory
|
||||
(call $~lib/memory/memory.free
|
||||
(get_global $std/allocator_arena/ptr2)
|
||||
)
|
||||
(call $~lib/allocator/arena/reset_memory)
|
||||
(call $~lib/memory/memory.reset)
|
||||
(set_global $std/allocator_arena/ptr1
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(call $~lib/memory/memory.allocate
|
||||
(i32.const 42)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $std/allocator_arena/ptr1)
|
||||
(i32.and
|
||||
(i32.add
|
||||
(get_global $HEAP_BASE)
|
||||
(i32.const 7)
|
||||
)
|
||||
(i32.const -8)
|
||||
)
|
||||
(i32.const 56)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 27)
|
||||
(i32.const 25)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
|
Reference in New Issue
Block a user