Make sure temp locals don't collide when allocating literal arrays, fixes #281

Originally part of #288
This commit is contained in:
dcodeIO
2018-10-03 01:32:28 +02:00
parent db0e82fbc3
commit eeb8a8fd6c
10 changed files with 513 additions and 60 deletions

View File

@ -4,8 +4,8 @@
(type $ii (func (param i32) (result i32)))
(type $iiiv (func (param i32 i32 i32)))
(type $v (func))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$i (func (result i32)))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
@ -13,6 +13,8 @@
(global $std/array-literal/i (mut i32) (i32.const 0))
(global $std/array-literal/dynamicArrayI8 (mut i32) (i32.const 0))
(global $std/array-literal/dynamicArrayI32 (mut i32) (i32.const 0))
(global $std/array-literal/dynamicArrayRef (mut i32) (i32.const 0))
(global $std/array-literal/dynamicArrayRefWithCtor (mut i32) (i32.const 0))
(memory $0 1)
(data (i32.const 8) "\03")
(data (i32.const 17) "\01\02")
@ -206,9 +208,9 @@
)
(get_local $1)
)
(func $~lib/memory/memory.allocate (; 6 ;) (; has Stack IR ;) (type $FUNCSIG$i) (result i32)
(func $~lib/memory/memory.allocate (; 6 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
(call $~lib/allocator/arena/__memory_allocate
(i32.const 8)
(get_local $0)
)
)
(func $~lib/internal/memory/memset (; 7 ;) (; has Stack IR ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
@ -526,7 +528,9 @@
)
(i32.store
(tee_local $0
(call $~lib/memory/memory.allocate)
(call $~lib/memory/memory.allocate
(i32.const 8)
)
)
(i32.const 0)
)
@ -572,7 +576,9 @@
)
(i32.store
(tee_local $0
(call $~lib/memory/memory.allocate)
(call $~lib/memory/memory.allocate
(i32.const 8)
)
)
(i32.const 0)
)
@ -611,7 +617,12 @@
(get_local $2)
)
)
(func $start (; 12 ;) (; has Stack IR ;) (type $v)
(func $std/array-literal/RefWithCtor#constructor (; 12 ;) (; has Stack IR ;) (type $FUNCSIG$i) (result i32)
(call $~lib/memory/memory.allocate
(i32.const 0)
)
)
(func $start (; 13 ;) (; has Stack IR ;) (type $v)
(local $0 i32)
(set_global $~lib/allocator/arena/startOffset
(i32.const 232)
@ -990,8 +1001,88 @@
(unreachable)
)
)
(call $~lib/array/Array<i32>#__unchecked_set
(tee_local $0
(call $~lib/array/Array<i32>#constructor)
)
(i32.const 0)
(call $~lib/memory/memory.allocate
(i32.const 0)
)
)
(call $~lib/array/Array<i32>#__unchecked_set
(get_local $0)
(i32.const 1)
(call $~lib/memory/memory.allocate
(i32.const 0)
)
)
(call $~lib/array/Array<i32>#__unchecked_set
(get_local $0)
(i32.const 2)
(call $~lib/memory/memory.allocate
(i32.const 0)
)
)
(set_global $std/array-literal/dynamicArrayRef
(get_local $0)
)
(if
(i32.ne
(i32.load offset=4
(get_global $std/array-literal/dynamicArrayRef)
)
(i32.const 3)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 32)
(i32.const 36)
(i32.const 0)
)
(unreachable)
)
)
(call $~lib/array/Array<i32>#__unchecked_set
(tee_local $0
(call $~lib/array/Array<i32>#constructor)
)
(i32.const 0)
(call $std/array-literal/RefWithCtor#constructor)
)
(call $~lib/array/Array<i32>#__unchecked_set
(get_local $0)
(i32.const 1)
(call $std/array-literal/RefWithCtor#constructor)
)
(call $~lib/array/Array<i32>#__unchecked_set
(get_local $0)
(i32.const 2)
(call $std/array-literal/RefWithCtor#constructor)
)
(set_global $std/array-literal/dynamicArrayRefWithCtor
(get_local $0)
)
(if
(i32.ne
(i32.load offset=4
(get_global $std/array-literal/dynamicArrayRefWithCtor)
)
(i32.const 3)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 32)
(i32.const 40)
(i32.const 0)
)
(unreachable)
)
)
)
(func $null (; 13 ;) (; has Stack IR ;) (type $v)
(func $null (; 14 ;) (; has Stack IR ;) (type $v)
(nop)
)
)