2018-03-04 17:25:32 +01:00
|
|
|
(module
|
|
|
|
(type $ii (func (param i32) (result i32)))
|
|
|
|
(type $iv (func (param i32)))
|
|
|
|
(type $v (func))
|
2018-03-19 19:36:39 +01:00
|
|
|
(global "$(lib)/allocator/arena/startOffset" (mut i32) (i32.const 0))
|
2018-03-12 14:06:39 +01:00
|
|
|
(global "$(lib)/allocator/arena/offset" (mut i32) (i32.const 0))
|
2018-03-04 17:25:32 +01:00
|
|
|
(global $HEAP_BASE i32 (i32.const 4))
|
|
|
|
(memory $0 1)
|
|
|
|
(export "allocate_memory" (func "$(lib)/allocator/arena/allocate_memory"))
|
|
|
|
(export "free_memory" (func "$(lib)/allocator/arena/free_memory"))
|
|
|
|
(export "reset_memory" (func "$(lib)/allocator/arena/reset_memory"))
|
|
|
|
(export "memory" (memory $0))
|
2018-03-19 19:36:39 +01:00
|
|
|
(start $start)
|
2018-03-04 17:25:32 +01:00
|
|
|
(func "$(lib)/allocator/arena/allocate_memory" (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
|
|
|
(local $1 i32)
|
|
|
|
(local $2 i32)
|
|
|
|
(local $3 i32)
|
|
|
|
(local $4 i32)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:17:2
|
2018-03-04 17:25:32 +01:00
|
|
|
(if
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:17:6
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.eqz
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:17:7
|
2018-03-04 17:25:32 +01:00
|
|
|
(get_local $0)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:17:20
|
2018-03-04 17:25:32 +01:00
|
|
|
(return
|
|
|
|
(i32.const 0)
|
|
|
|
)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:21:2
|
2018-03-04 17:25:32 +01:00
|
|
|
(if
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:21:6
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.gt_u
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:19:2
|
2018-03-04 17:25:32 +01:00
|
|
|
(tee_local $2
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:19:15
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.and
|
|
|
|
(i32.add
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:19:16
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.add
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:18:2
|
2018-03-04 17:25:32 +01:00
|
|
|
(tee_local $1
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:18:12
|
2018-03-12 14:06:39 +01:00
|
|
|
(get_global "$(lib)/allocator/arena/offset")
|
2018-03-04 17:25:32 +01:00
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:19:22
|
2018-03-04 17:25:32 +01:00
|
|
|
(get_local $0)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:19:29
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.const 7)
|
|
|
|
)
|
|
|
|
(i32.const -8)
|
|
|
|
)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:21:15
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.shl
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:20:2
|
2018-03-04 17:25:32 +01:00
|
|
|
(tee_local $0
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:20:20
|
2018-03-04 17:25:32 +01:00
|
|
|
(current_memory)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:21:37
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.const 16)
|
|
|
|
)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:24:4
|
2018-03-04 17:25:32 +01:00
|
|
|
(if
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:24:8
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.lt_s
|
|
|
|
(grow_memory
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:23:22
|
2018-03-04 17:25:32 +01:00
|
|
|
(select
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:23:26
|
2018-03-04 17:25:32 +01:00
|
|
|
(get_local $0)
|
|
|
|
(tee_local $4
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:22:4
|
2018-03-04 17:25:32 +01:00
|
|
|
(tee_local $3
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:22:22
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.shr_u
|
|
|
|
(i32.and
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:22:23
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.add
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:22:24
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.sub
|
|
|
|
(get_local $2)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:22:33
|
2018-03-04 17:25:32 +01:00
|
|
|
(get_local $1)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:22:39
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.const 65535)
|
|
|
|
)
|
|
|
|
(i32.const -65536)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:22:62
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.const 16)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(i32.gt_s
|
|
|
|
(get_local $0)
|
|
|
|
(get_local $4)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:24:35
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.const 0)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:25:6
|
2018-03-04 17:25:32 +01:00
|
|
|
(if
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:25:10
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.lt_s
|
|
|
|
(grow_memory
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:25:22
|
2018-03-04 17:25:32 +01:00
|
|
|
(get_local $3)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:25:37
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.const 0)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:26:8
|
2018-03-04 17:25:32 +01:00
|
|
|
(unreachable)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:30:2
|
2018-03-12 14:06:39 +01:00
|
|
|
(set_global "$(lib)/allocator/arena/offset"
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:30:11
|
2018-03-04 17:25:32 +01:00
|
|
|
(get_local $2)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:31:9
|
2018-03-04 17:25:32 +01:00
|
|
|
(get_local $1)
|
|
|
|
)
|
|
|
|
(func "$(lib)/allocator/arena/free_memory" (; 1 ;) (type $iv) (param $0 i32)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:35:46
|
2018-03-04 17:25:32 +01:00
|
|
|
(nop)
|
|
|
|
)
|
|
|
|
(func "$(lib)/allocator/arena/reset_memory" (; 2 ;) (type $v)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:41:2
|
2018-03-12 14:06:39 +01:00
|
|
|
(set_global "$(lib)/allocator/arena/offset"
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:41:11
|
|
|
|
(get_global "$(lib)/allocator/arena/startOffset")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(func $start (; 3 ;) (type $v)
|
|
|
|
(set_global "$(lib)/allocator/arena/startOffset"
|
|
|
|
;;@ (lib)/allocator/arena.ts:12:25
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.and
|
|
|
|
(i32.add
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:12:26
|
2018-03-04 17:25:32 +01:00
|
|
|
(get_global $HEAP_BASE)
|
2018-03-19 19:36:39 +01:00
|
|
|
;;@ (lib)/allocator/arena.ts:12:38
|
2018-03-04 17:25:32 +01:00
|
|
|
(i32.const 7)
|
|
|
|
)
|
|
|
|
(i32.const -8)
|
|
|
|
)
|
|
|
|
)
|
2018-03-19 19:36:39 +01:00
|
|
|
(set_global "$(lib)/allocator/arena/offset"
|
|
|
|
;;@ (lib)/allocator/arena.ts:13:20
|
|
|
|
(get_global "$(lib)/allocator/arena/startOffset")
|
|
|
|
)
|
2018-03-04 17:25:32 +01:00
|
|
|
)
|
|
|
|
)
|