Improve reallocateUnsafe and properly free unmanaged objects (#368)

This commit is contained in:
Max Graey
2018-12-09 00:54:45 +02:00
committed by Daniel Wirtz
parent 3ed83ef3ae
commit 8e61e0ead8
9 changed files with 1278 additions and 1354 deletions

View File

@ -5,12 +5,12 @@
(type $iiiv (func (param i32 i32 i32)))
(type $iiiii (func (param i32 i32 i32 i32) (result i32)))
(type $iiii (func (param i32 i32 i32) (result i32)))
(type $iv (func (param i32)))
(type $iiv (func (param i32 i32)))
(type $iiif (func (param i32 i32 i32) (result f32)))
(type $F (func (result f64)))
(type $Iv (func (param i64)))
(type $ffi (func (param f32 f32) (result i32)))
(type $iv (func (param i32)))
(type $FFi (func (param f64 f64) (result i32)))
(type $Fi (func (param f64) (result i32)))
(type $iiiiiv (func (param i32 i32 i32 i32 i32)))
@ -2229,7 +2229,6 @@
(func $~lib/internal/arraybuffer/reallocateUnsafe (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
get_local $1
get_local $0
i32.load
@ -2263,39 +2262,30 @@
get_local $0
get_local $1
i32.store
get_local $0
i32.const 8
i32.add
get_local $2
i32.add
i32.const 0
get_local $1
get_local $2
i32.sub
call $~lib/internal/memory/memset
else
get_local $1
call $~lib/internal/arraybuffer/allocateUnsafe
tee_local $3
i32.const 8
i32.add
tee_local $4
get_local $0
i32.const 8
i32.add
get_local $2
call $~lib/internal/memory/memmove
get_local $2
get_local $4
i32.add
i32.const 0
get_local $1
get_local $2
i32.sub
call $~lib/internal/memory/memset
get_local $3
return
set_local $0
end
get_local $0
i32.const 8
i32.add
get_local $2
i32.add
i32.const 0
get_local $1
get_local $2
i32.sub
call $~lib/internal/memory/memset
else
get_local $1
get_local $2
@ -2307,7 +2297,7 @@
if
i32.const 0
i32.const 40
i32.const 64
i32.const 62
i32.const 4
call $~lib/env/abort
unreachable