mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-26 05:01:52 +00:00
rt hooks all over the place
still some work to do on optimizing away retain/release calls, but this looks promising
This commit is contained in:
@ -1,5 +0,0 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,602 +0,0 @@
|
||||
(module
|
||||
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
|
||||
(type $FUNCSIG$v (func))
|
||||
(type $FUNCSIG$i (func (result i32)))
|
||||
(type $FUNCSIG$vi (func (param i32)))
|
||||
(type $FUNCSIG$vii (func (param i32 i32)))
|
||||
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
|
||||
(memory $0 1)
|
||||
(data (i32.const 8) "\10\00\00\00,")
|
||||
(data (i32.const 24) "s\00t\00d\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00_\00a\00r\00e\00n\00a\00.\00t\00s")
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(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))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/allocator/arena/__mem_allocate (; 1 ;) (type $FUNCSIG$i) (result i32)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
global.get $~lib/allocator/arena/offset
|
||||
local.tee $0
|
||||
i32.const 49
|
||||
i32.add
|
||||
i32.const -8
|
||||
i32.and
|
||||
local.tee $1
|
||||
current_memory
|
||||
local.tee $2
|
||||
i32.const 16
|
||||
i32.shl
|
||||
i32.gt_u
|
||||
if
|
||||
local.get $2
|
||||
local.get $1
|
||||
local.get $0
|
||||
i32.sub
|
||||
i32.const 65535
|
||||
i32.add
|
||||
i32.const -65536
|
||||
i32.and
|
||||
i32.const 16
|
||||
i32.shr_u
|
||||
local.tee $3
|
||||
local.get $2
|
||||
local.get $3
|
||||
i32.gt_s
|
||||
select
|
||||
grow_memory
|
||||
i32.const 0
|
||||
i32.lt_s
|
||||
if
|
||||
local.get $3
|
||||
grow_memory
|
||||
i32.const 0
|
||||
i32.lt_s
|
||||
if
|
||||
unreachable
|
||||
end
|
||||
end
|
||||
end
|
||||
local.get $1
|
||||
global.set $~lib/allocator/arena/offset
|
||||
local.get $0
|
||||
)
|
||||
(func $~lib/memory/memory.fill (; 2 ;) (type $FUNCSIG$vi) (param $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
block $~lib/util/memory/memset|inlined.0
|
||||
local.get $0
|
||||
i32.const 18
|
||||
i32.store8
|
||||
local.get $0
|
||||
i32.const 42
|
||||
i32.add
|
||||
local.tee $1
|
||||
i32.const 1
|
||||
i32.sub
|
||||
i32.const 18
|
||||
i32.store8
|
||||
local.get $0
|
||||
i32.const 1
|
||||
i32.add
|
||||
i32.const 18
|
||||
i32.store8
|
||||
local.get $0
|
||||
i32.const 2
|
||||
i32.add
|
||||
i32.const 18
|
||||
i32.store8
|
||||
local.get $1
|
||||
i32.const 2
|
||||
i32.sub
|
||||
i32.const 18
|
||||
i32.store8
|
||||
local.get $1
|
||||
i32.const 3
|
||||
i32.sub
|
||||
i32.const 18
|
||||
i32.store8
|
||||
local.get $0
|
||||
i32.const 3
|
||||
i32.add
|
||||
i32.const 18
|
||||
i32.store8
|
||||
local.get $1
|
||||
i32.const 4
|
||||
i32.sub
|
||||
i32.const 18
|
||||
i32.store8
|
||||
i32.const 42
|
||||
i32.const 0
|
||||
local.get $0
|
||||
i32.sub
|
||||
i32.const 3
|
||||
i32.and
|
||||
local.tee $1
|
||||
i32.sub
|
||||
local.set $2
|
||||
local.get $0
|
||||
local.get $1
|
||||
i32.add
|
||||
local.tee $0
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $2
|
||||
i32.const -4
|
||||
i32.and
|
||||
local.tee $1
|
||||
local.get $0
|
||||
i32.add
|
||||
i32.const 4
|
||||
i32.sub
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $1
|
||||
i32.const 8
|
||||
i32.le_u
|
||||
br_if $~lib/util/memory/memset|inlined.0
|
||||
local.get $0
|
||||
i32.const 4
|
||||
i32.add
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $0
|
||||
i32.const 8
|
||||
i32.add
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $1
|
||||
i32.add
|
||||
local.tee $2
|
||||
i32.const 12
|
||||
i32.sub
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $2
|
||||
i32.const 8
|
||||
i32.sub
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $1
|
||||
i32.const 24
|
||||
i32.le_u
|
||||
br_if $~lib/util/memory/memset|inlined.0
|
||||
local.get $0
|
||||
i32.const 12
|
||||
i32.add
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $0
|
||||
i32.const 16
|
||||
i32.add
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $0
|
||||
i32.const 20
|
||||
i32.add
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $0
|
||||
i32.const 24
|
||||
i32.add
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $1
|
||||
i32.add
|
||||
local.tee $2
|
||||
i32.const 28
|
||||
i32.sub
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $2
|
||||
i32.const 24
|
||||
i32.sub
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $2
|
||||
i32.const 20
|
||||
i32.sub
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $2
|
||||
i32.const 16
|
||||
i32.sub
|
||||
i32.const 303174162
|
||||
i32.store
|
||||
local.get $0
|
||||
i32.const 4
|
||||
i32.and
|
||||
i32.const 24
|
||||
i32.add
|
||||
local.tee $2
|
||||
local.get $0
|
||||
i32.add
|
||||
local.set $0
|
||||
local.get $1
|
||||
local.get $2
|
||||
i32.sub
|
||||
local.set $1
|
||||
loop $continue|0
|
||||
local.get $1
|
||||
i32.const 32
|
||||
i32.ge_u
|
||||
if
|
||||
local.get $0
|
||||
i64.const 1302123111085380114
|
||||
i64.store
|
||||
local.get $0
|
||||
i32.const 8
|
||||
i32.add
|
||||
i64.const 1302123111085380114
|
||||
i64.store
|
||||
local.get $0
|
||||
i32.const 16
|
||||
i32.add
|
||||
i64.const 1302123111085380114
|
||||
i64.store
|
||||
local.get $0
|
||||
i32.const 24
|
||||
i32.add
|
||||
i64.const 1302123111085380114
|
||||
i64.store
|
||||
local.get $1
|
||||
i32.const 32
|
||||
i32.sub
|
||||
local.set $1
|
||||
local.get $0
|
||||
i32.const 32
|
||||
i32.add
|
||||
local.set $0
|
||||
br $continue|0
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
(func $~lib/memory/memory.copy (; 3 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
i32.const 42
|
||||
local.set $2
|
||||
block $~lib/util/memory/memmove|inlined.0
|
||||
local.get $0
|
||||
local.get $1
|
||||
i32.eq
|
||||
br_if $~lib/util/memory/memmove|inlined.0
|
||||
local.get $0
|
||||
local.get $1
|
||||
i32.lt_u
|
||||
if
|
||||
local.get $1
|
||||
i32.const 7
|
||||
i32.and
|
||||
local.get $0
|
||||
i32.const 7
|
||||
i32.and
|
||||
i32.eq
|
||||
if
|
||||
loop $continue|0
|
||||
local.get $0
|
||||
i32.const 7
|
||||
i32.and
|
||||
if
|
||||
local.get $2
|
||||
i32.eqz
|
||||
br_if $~lib/util/memory/memmove|inlined.0
|
||||
local.get $2
|
||||
i32.const 1
|
||||
i32.sub
|
||||
local.set $2
|
||||
local.get $0
|
||||
local.tee $3
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $0
|
||||
local.get $1
|
||||
local.tee $4
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $1
|
||||
local.get $3
|
||||
local.get $4
|
||||
i32.load8_u
|
||||
i32.store8
|
||||
br $continue|0
|
||||
end
|
||||
end
|
||||
loop $continue|1
|
||||
local.get $2
|
||||
i32.const 8
|
||||
i32.ge_u
|
||||
if
|
||||
local.get $0
|
||||
local.get $1
|
||||
i64.load
|
||||
i64.store
|
||||
local.get $2
|
||||
i32.const 8
|
||||
i32.sub
|
||||
local.set $2
|
||||
local.get $0
|
||||
i32.const 8
|
||||
i32.add
|
||||
local.set $0
|
||||
local.get $1
|
||||
i32.const 8
|
||||
i32.add
|
||||
local.set $1
|
||||
br $continue|1
|
||||
end
|
||||
end
|
||||
end
|
||||
loop $continue|2
|
||||
local.get $2
|
||||
if
|
||||
local.get $0
|
||||
local.tee $3
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $0
|
||||
local.get $1
|
||||
local.tee $4
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $1
|
||||
local.get $3
|
||||
local.get $4
|
||||
i32.load8_u
|
||||
i32.store8
|
||||
local.get $2
|
||||
i32.const 1
|
||||
i32.sub
|
||||
local.set $2
|
||||
br $continue|2
|
||||
end
|
||||
end
|
||||
else
|
||||
local.get $1
|
||||
i32.const 7
|
||||
i32.and
|
||||
local.get $0
|
||||
i32.const 7
|
||||
i32.and
|
||||
i32.eq
|
||||
if
|
||||
loop $continue|3
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 7
|
||||
i32.and
|
||||
if
|
||||
local.get $2
|
||||
i32.eqz
|
||||
br_if $~lib/util/memory/memmove|inlined.0
|
||||
local.get $2
|
||||
i32.const 1
|
||||
i32.sub
|
||||
local.tee $2
|
||||
local.get $0
|
||||
i32.add
|
||||
local.get $1
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.load8_u
|
||||
i32.store8
|
||||
br $continue|3
|
||||
end
|
||||
end
|
||||
loop $continue|4
|
||||
local.get $2
|
||||
i32.const 8
|
||||
i32.ge_u
|
||||
if
|
||||
local.get $2
|
||||
i32.const 8
|
||||
i32.sub
|
||||
local.tee $2
|
||||
local.get $0
|
||||
i32.add
|
||||
local.get $1
|
||||
local.get $2
|
||||
i32.add
|
||||
i64.load
|
||||
i64.store
|
||||
br $continue|4
|
||||
end
|
||||
end
|
||||
end
|
||||
loop $continue|5
|
||||
local.get $2
|
||||
if
|
||||
local.get $2
|
||||
i32.const 1
|
||||
i32.sub
|
||||
local.tee $2
|
||||
local.get $0
|
||||
i32.add
|
||||
local.get $1
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.load8_u
|
||||
i32.store8
|
||||
br $continue|5
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
(func $start:std/allocator_arena (; 4 ;) (type $FUNCSIG$v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
i32.const 72
|
||||
global.set $~lib/allocator/arena/startOffset
|
||||
global.get $~lib/allocator/arena/startOffset
|
||||
global.set $~lib/allocator/arena/offset
|
||||
call $~lib/allocator/arena/__mem_allocate
|
||||
global.set $std/allocator_arena/ptr1
|
||||
call $~lib/allocator/arena/__mem_allocate
|
||||
global.set $std/allocator_arena/ptr2
|
||||
global.get $std/allocator_arena/ptr1
|
||||
global.get $std/allocator_arena/ptr2
|
||||
i32.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 24
|
||||
i32.const 7
|
||||
i32.const 0
|
||||
call $~lib/builtins/abort
|
||||
unreachable
|
||||
end
|
||||
global.get $std/allocator_arena/ptr1
|
||||
call $~lib/memory/memory.fill
|
||||
i32.const 0
|
||||
global.set $std/allocator_arena/i
|
||||
loop $repeat|0
|
||||
global.get $std/allocator_arena/i
|
||||
i32.const 42
|
||||
i32.lt_u
|
||||
if
|
||||
global.get $std/allocator_arena/ptr1
|
||||
global.get $std/allocator_arena/i
|
||||
i32.add
|
||||
i32.load8_u
|
||||
i32.const 18
|
||||
i32.ne
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 24
|
||||
i32.const 12
|
||||
i32.const 27
|
||||
call $~lib/builtins/abort
|
||||
unreachable
|
||||
else
|
||||
global.get $std/allocator_arena/i
|
||||
i32.const 1
|
||||
i32.add
|
||||
global.set $std/allocator_arena/i
|
||||
br $repeat|0
|
||||
end
|
||||
unreachable
|
||||
end
|
||||
end
|
||||
global.get $std/allocator_arena/ptr2
|
||||
global.get $std/allocator_arena/ptr1
|
||||
call $~lib/memory/memory.copy
|
||||
i32.const 0
|
||||
global.set $std/allocator_arena/i
|
||||
loop $repeat|1
|
||||
global.get $std/allocator_arena/i
|
||||
i32.const 42
|
||||
i32.lt_u
|
||||
if
|
||||
global.get $std/allocator_arena/ptr2
|
||||
global.get $std/allocator_arena/i
|
||||
i32.add
|
||||
i32.load8_u
|
||||
i32.const 18
|
||||
i32.ne
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 24
|
||||
i32.const 16
|
||||
i32.const 27
|
||||
call $~lib/builtins/abort
|
||||
unreachable
|
||||
else
|
||||
global.get $std/allocator_arena/i
|
||||
i32.const 1
|
||||
i32.add
|
||||
global.set $std/allocator_arena/i
|
||||
br $repeat|1
|
||||
end
|
||||
unreachable
|
||||
end
|
||||
end
|
||||
block $~lib/util/memory/memcmp|inlined.0 (result i32)
|
||||
i32.const 42
|
||||
local.set $0
|
||||
i32.const 0
|
||||
global.get $std/allocator_arena/ptr2
|
||||
local.tee $1
|
||||
global.get $std/allocator_arena/ptr1
|
||||
local.tee $2
|
||||
i32.eq
|
||||
br_if $~lib/util/memory/memcmp|inlined.0
|
||||
drop
|
||||
loop $continue|2
|
||||
local.get $0
|
||||
if (result i32)
|
||||
local.get $2
|
||||
i32.load8_u
|
||||
local.get $1
|
||||
i32.load8_u
|
||||
i32.eq
|
||||
else
|
||||
i32.const 0
|
||||
end
|
||||
if
|
||||
local.get $0
|
||||
i32.const 1
|
||||
i32.sub
|
||||
local.set $0
|
||||
local.get $2
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $2
|
||||
local.get $1
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $1
|
||||
br $continue|2
|
||||
end
|
||||
end
|
||||
local.get $0
|
||||
if (result i32)
|
||||
local.get $2
|
||||
i32.load8_u
|
||||
local.get $1
|
||||
i32.load8_u
|
||||
i32.sub
|
||||
else
|
||||
i32.const 0
|
||||
end
|
||||
end
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 24
|
||||
i32.const 18
|
||||
i32.const 0
|
||||
call $~lib/builtins/abort
|
||||
unreachable
|
||||
end
|
||||
global.get $~lib/allocator/arena/startOffset
|
||||
global.set $~lib/allocator/arena/offset
|
||||
call $~lib/allocator/arena/__mem_allocate
|
||||
global.set $std/allocator_arena/ptr1
|
||||
global.get $std/allocator_arena/ptr1
|
||||
i32.const 72
|
||||
i32.ne
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 24
|
||||
i32.const 25
|
||||
i32.const 0
|
||||
call $~lib/builtins/abort
|
||||
unreachable
|
||||
end
|
||||
)
|
||||
(func $start (; 5 ;) (type $FUNCSIG$v)
|
||||
call $start:std/allocator_arena
|
||||
)
|
||||
(func $null (; 6 ;) (type $FUNCSIG$v)
|
||||
nop
|
||||
)
|
||||
)
|
@ -1,25 +0,0 @@
|
||||
import "allocator/arena";
|
||||
|
||||
const size: usize = 42;
|
||||
var ptr1: usize = memory.allocate(size);
|
||||
var ptr2: usize = memory.allocate(size);
|
||||
|
||||
assert(ptr1 != ptr2);
|
||||
|
||||
memory.fill(ptr1, 0x12, size);
|
||||
|
||||
var i: usize;
|
||||
for (i = 0; i < size; ++i) assert(load<u8>(ptr1 + i) == 0x12);
|
||||
|
||||
memory.copy(ptr2, ptr1, size);
|
||||
|
||||
for (i = 0; i < size; ++i) assert(load<u8>(ptr2 + i) == 0x12);
|
||||
|
||||
assert(memory.compare(ptr1, ptr2, size) == 0);
|
||||
|
||||
memory.free(ptr1);
|
||||
memory.free(ptr2);
|
||||
|
||||
memory.reset();
|
||||
ptr1 = memory.allocate(size);
|
||||
assert(ptr1 == ((HEAP_BASE + 7) & ~7));
|
@ -1,803 +0,0 @@
|
||||
(module
|
||||
(type $FUNCSIG$ii (func (param i32) (result i32)))
|
||||
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
|
||||
(type $FUNCSIG$viii (func (param i32 i32 i32)))
|
||||
(type $FUNCSIG$vi (func (param i32)))
|
||||
(type $FUNCSIG$v (func))
|
||||
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
|
||||
(memory $0 1)
|
||||
(data (i32.const 8) "\10\00\00\00,\00\00\00\00\00\00\00\00\00\00\00s\00t\00d\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00_\00a\00r\00e\00n\00a\00.\00t\00s\00")
|
||||
(table $0 1 funcref)
|
||||
(elem (i32.const 0) $null)
|
||||
(global $std/allocator_arena/size i32 (i32.const 42))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(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 $~lib/memory/HEAP_BASE i32 (i32.const 68))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/allocator/arena/__mem_allocate (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
local.get $0
|
||||
i32.const 1073741824
|
||||
i32.gt_u
|
||||
if
|
||||
unreachable
|
||||
end
|
||||
global.get $~lib/allocator/arena/offset
|
||||
local.set $1
|
||||
local.get $1
|
||||
local.get $0
|
||||
local.tee $2
|
||||
i32.const 1
|
||||
local.tee $3
|
||||
local.get $2
|
||||
local.get $3
|
||||
i32.gt_u
|
||||
select
|
||||
i32.add
|
||||
i32.const 7
|
||||
i32.add
|
||||
i32.const 7
|
||||
i32.const -1
|
||||
i32.xor
|
||||
i32.and
|
||||
local.set $4
|
||||
current_memory
|
||||
local.set $5
|
||||
local.get $4
|
||||
local.get $5
|
||||
i32.const 16
|
||||
i32.shl
|
||||
i32.gt_u
|
||||
if
|
||||
local.get $4
|
||||
local.get $1
|
||||
i32.sub
|
||||
i32.const 65535
|
||||
i32.add
|
||||
i32.const 65535
|
||||
i32.const -1
|
||||
i32.xor
|
||||
i32.and
|
||||
i32.const 16
|
||||
i32.shr_u
|
||||
local.set $2
|
||||
local.get $5
|
||||
local.tee $3
|
||||
local.get $2
|
||||
local.tee $6
|
||||
local.get $3
|
||||
local.get $6
|
||||
i32.gt_s
|
||||
select
|
||||
local.set $3
|
||||
local.get $3
|
||||
grow_memory
|
||||
i32.const 0
|
||||
i32.lt_s
|
||||
if
|
||||
local.get $2
|
||||
grow_memory
|
||||
i32.const 0
|
||||
i32.lt_s
|
||||
if
|
||||
unreachable
|
||||
end
|
||||
end
|
||||
end
|
||||
local.get $4
|
||||
global.set $~lib/allocator/arena/offset
|
||||
local.get $1
|
||||
)
|
||||
(func $~lib/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
|
||||
local.get $0
|
||||
call $~lib/allocator/arena/__mem_allocate
|
||||
return
|
||||
)
|
||||
(func $~lib/memory/memory.fill (; 3 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i64)
|
||||
block $~lib/util/memory/memset|inlined.0
|
||||
local.get $2
|
||||
i32.eqz
|
||||
if
|
||||
br $~lib/util/memory/memset|inlined.0
|
||||
end
|
||||
local.get $0
|
||||
local.get $1
|
||||
i32.store8
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 1
|
||||
i32.sub
|
||||
local.get $1
|
||||
i32.store8
|
||||
local.get $2
|
||||
i32.const 2
|
||||
i32.le_u
|
||||
if
|
||||
br $~lib/util/memory/memset|inlined.0
|
||||
end
|
||||
local.get $0
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.get $1
|
||||
i32.store8
|
||||
local.get $0
|
||||
i32.const 2
|
||||
i32.add
|
||||
local.get $1
|
||||
i32.store8
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 2
|
||||
i32.sub
|
||||
local.get $1
|
||||
i32.store8
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 3
|
||||
i32.sub
|
||||
local.get $1
|
||||
i32.store8
|
||||
local.get $2
|
||||
i32.const 6
|
||||
i32.le_u
|
||||
if
|
||||
br $~lib/util/memory/memset|inlined.0
|
||||
end
|
||||
local.get $0
|
||||
i32.const 3
|
||||
i32.add
|
||||
local.get $1
|
||||
i32.store8
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 4
|
||||
i32.sub
|
||||
local.get $1
|
||||
i32.store8
|
||||
local.get $2
|
||||
i32.const 8
|
||||
i32.le_u
|
||||
if
|
||||
br $~lib/util/memory/memset|inlined.0
|
||||
end
|
||||
i32.const 0
|
||||
local.get $0
|
||||
i32.sub
|
||||
i32.const 3
|
||||
i32.and
|
||||
local.set $5
|
||||
local.get $0
|
||||
local.get $5
|
||||
i32.add
|
||||
local.set $0
|
||||
local.get $2
|
||||
local.get $5
|
||||
i32.sub
|
||||
local.set $2
|
||||
local.get $2
|
||||
i32.const -4
|
||||
i32.and
|
||||
local.set $2
|
||||
i32.const -1
|
||||
i32.const 255
|
||||
i32.div_u
|
||||
local.get $1
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.mul
|
||||
local.set $4
|
||||
local.get $0
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 4
|
||||
i32.sub
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $2
|
||||
i32.const 8
|
||||
i32.le_u
|
||||
if
|
||||
br $~lib/util/memory/memset|inlined.0
|
||||
end
|
||||
local.get $0
|
||||
i32.const 4
|
||||
i32.add
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $0
|
||||
i32.const 8
|
||||
i32.add
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 12
|
||||
i32.sub
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 8
|
||||
i32.sub
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $2
|
||||
i32.const 24
|
||||
i32.le_u
|
||||
if
|
||||
br $~lib/util/memory/memset|inlined.0
|
||||
end
|
||||
local.get $0
|
||||
i32.const 12
|
||||
i32.add
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $0
|
||||
i32.const 16
|
||||
i32.add
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $0
|
||||
i32.const 20
|
||||
i32.add
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $0
|
||||
i32.const 24
|
||||
i32.add
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 28
|
||||
i32.sub
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 24
|
||||
i32.sub
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 20
|
||||
i32.sub
|
||||
local.get $4
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 16
|
||||
i32.sub
|
||||
local.get $4
|
||||
i32.store
|
||||
i32.const 24
|
||||
local.get $0
|
||||
i32.const 4
|
||||
i32.and
|
||||
i32.add
|
||||
local.set $5
|
||||
local.get $0
|
||||
local.get $5
|
||||
i32.add
|
||||
local.set $0
|
||||
local.get $2
|
||||
local.get $5
|
||||
i32.sub
|
||||
local.set $2
|
||||
local.get $4
|
||||
i64.extend_i32_u
|
||||
local.get $4
|
||||
i64.extend_i32_u
|
||||
i64.const 32
|
||||
i64.shl
|
||||
i64.or
|
||||
local.set $6
|
||||
block $break|0
|
||||
loop $continue|0
|
||||
local.get $2
|
||||
i32.const 32
|
||||
i32.ge_u
|
||||
if
|
||||
block
|
||||
local.get $0
|
||||
local.get $6
|
||||
i64.store
|
||||
local.get $0
|
||||
i32.const 8
|
||||
i32.add
|
||||
local.get $6
|
||||
i64.store
|
||||
local.get $0
|
||||
i32.const 16
|
||||
i32.add
|
||||
local.get $6
|
||||
i64.store
|
||||
local.get $0
|
||||
i32.const 24
|
||||
i32.add
|
||||
local.get $6
|
||||
i64.store
|
||||
local.get $2
|
||||
i32.const 32
|
||||
i32.sub
|
||||
local.set $2
|
||||
local.get $0
|
||||
i32.const 32
|
||||
i32.add
|
||||
local.set $0
|
||||
end
|
||||
br $continue|0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
(func $~lib/memory/memory.copy (; 4 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
block $~lib/util/memory/memmove|inlined.0
|
||||
local.get $0
|
||||
local.get $1
|
||||
i32.eq
|
||||
if
|
||||
br $~lib/util/memory/memmove|inlined.0
|
||||
end
|
||||
local.get $0
|
||||
local.get $1
|
||||
i32.lt_u
|
||||
if
|
||||
local.get $1
|
||||
i32.const 7
|
||||
i32.and
|
||||
local.get $0
|
||||
i32.const 7
|
||||
i32.and
|
||||
i32.eq
|
||||
if
|
||||
block $break|0
|
||||
loop $continue|0
|
||||
local.get $0
|
||||
i32.const 7
|
||||
i32.and
|
||||
if
|
||||
block
|
||||
local.get $2
|
||||
i32.eqz
|
||||
if
|
||||
br $~lib/util/memory/memmove|inlined.0
|
||||
end
|
||||
local.get $2
|
||||
i32.const 1
|
||||
i32.sub
|
||||
local.set $2
|
||||
block (result i32)
|
||||
local.get $0
|
||||
local.tee $5
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $0
|
||||
local.get $5
|
||||
end
|
||||
block (result i32)
|
||||
local.get $1
|
||||
local.tee $5
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $1
|
||||
local.get $5
|
||||
end
|
||||
i32.load8_u
|
||||
i32.store8
|
||||
end
|
||||
br $continue|0
|
||||
end
|
||||
end
|
||||
end
|
||||
block $break|1
|
||||
loop $continue|1
|
||||
local.get $2
|
||||
i32.const 8
|
||||
i32.ge_u
|
||||
if
|
||||
block
|
||||
local.get $0
|
||||
local.get $1
|
||||
i64.load
|
||||
i64.store
|
||||
local.get $2
|
||||
i32.const 8
|
||||
i32.sub
|
||||
local.set $2
|
||||
local.get $0
|
||||
i32.const 8
|
||||
i32.add
|
||||
local.set $0
|
||||
local.get $1
|
||||
i32.const 8
|
||||
i32.add
|
||||
local.set $1
|
||||
end
|
||||
br $continue|1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
block $break|2
|
||||
loop $continue|2
|
||||
local.get $2
|
||||
if
|
||||
block
|
||||
block (result i32)
|
||||
local.get $0
|
||||
local.tee $5
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $0
|
||||
local.get $5
|
||||
end
|
||||
block (result i32)
|
||||
local.get $1
|
||||
local.tee $5
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $1
|
||||
local.get $5
|
||||
end
|
||||
i32.load8_u
|
||||
i32.store8
|
||||
local.get $2
|
||||
i32.const 1
|
||||
i32.sub
|
||||
local.set $2
|
||||
end
|
||||
br $continue|2
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
local.get $1
|
||||
i32.const 7
|
||||
i32.and
|
||||
local.get $0
|
||||
i32.const 7
|
||||
i32.and
|
||||
i32.eq
|
||||
if
|
||||
block $break|3
|
||||
loop $continue|3
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.const 7
|
||||
i32.and
|
||||
if
|
||||
block
|
||||
local.get $2
|
||||
i32.eqz
|
||||
if
|
||||
br $~lib/util/memory/memmove|inlined.0
|
||||
end
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.const 1
|
||||
i32.sub
|
||||
local.tee $2
|
||||
i32.add
|
||||
local.get $1
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.load8_u
|
||||
i32.store8
|
||||
end
|
||||
br $continue|3
|
||||
end
|
||||
end
|
||||
end
|
||||
block $break|4
|
||||
loop $continue|4
|
||||
local.get $2
|
||||
i32.const 8
|
||||
i32.ge_u
|
||||
if
|
||||
block
|
||||
local.get $2
|
||||
i32.const 8
|
||||
i32.sub
|
||||
local.set $2
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.add
|
||||
local.get $1
|
||||
local.get $2
|
||||
i32.add
|
||||
i64.load
|
||||
i64.store
|
||||
end
|
||||
br $continue|4
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
block $break|5
|
||||
loop $continue|5
|
||||
local.get $2
|
||||
if
|
||||
local.get $0
|
||||
local.get $2
|
||||
i32.const 1
|
||||
i32.sub
|
||||
local.tee $2
|
||||
i32.add
|
||||
local.get $1
|
||||
local.get $2
|
||||
i32.add
|
||||
i32.load8_u
|
||||
i32.store8
|
||||
br $continue|5
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
(func $~lib/allocator/arena/__mem_free (; 5 ;) (type $FUNCSIG$vi) (param $0 i32)
|
||||
nop
|
||||
)
|
||||
(func $~lib/memory/memory.free (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
|
||||
local.get $0
|
||||
call $~lib/allocator/arena/__mem_free
|
||||
)
|
||||
(func $~lib/allocator/arena/__mem_reset (; 7 ;) (type $FUNCSIG$v)
|
||||
global.get $~lib/allocator/arena/startOffset
|
||||
global.set $~lib/allocator/arena/offset
|
||||
)
|
||||
(func $~lib/memory/memory.reset (; 8 ;) (type $FUNCSIG$v)
|
||||
call $~lib/allocator/arena/__mem_reset
|
||||
)
|
||||
(func $start:std/allocator_arena (; 9 ;) (type $FUNCSIG$v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
global.get $~lib/memory/HEAP_BASE
|
||||
i32.const 7
|
||||
i32.add
|
||||
i32.const 7
|
||||
i32.const -1
|
||||
i32.xor
|
||||
i32.and
|
||||
global.set $~lib/allocator/arena/startOffset
|
||||
global.get $~lib/allocator/arena/startOffset
|
||||
global.set $~lib/allocator/arena/offset
|
||||
global.get $std/allocator_arena/size
|
||||
call $~lib/memory/memory.allocate
|
||||
global.set $std/allocator_arena/ptr1
|
||||
global.get $std/allocator_arena/size
|
||||
call $~lib/memory/memory.allocate
|
||||
global.set $std/allocator_arena/ptr2
|
||||
global.get $std/allocator_arena/ptr1
|
||||
global.get $std/allocator_arena/ptr2
|
||||
i32.ne
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 24
|
||||
i32.const 7
|
||||
i32.const 0
|
||||
call $~lib/builtins/abort
|
||||
unreachable
|
||||
end
|
||||
global.get $std/allocator_arena/ptr1
|
||||
i32.const 18
|
||||
global.get $std/allocator_arena/size
|
||||
call $~lib/memory/memory.fill
|
||||
block $break|0
|
||||
i32.const 0
|
||||
global.set $std/allocator_arena/i
|
||||
loop $repeat|0
|
||||
global.get $std/allocator_arena/i
|
||||
global.get $std/allocator_arena/size
|
||||
i32.lt_u
|
||||
i32.eqz
|
||||
br_if $break|0
|
||||
global.get $std/allocator_arena/ptr1
|
||||
global.get $std/allocator_arena/i
|
||||
i32.add
|
||||
i32.load8_u
|
||||
i32.const 18
|
||||
i32.eq
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 24
|
||||
i32.const 12
|
||||
i32.const 27
|
||||
call $~lib/builtins/abort
|
||||
unreachable
|
||||
end
|
||||
global.get $std/allocator_arena/i
|
||||
i32.const 1
|
||||
i32.add
|
||||
global.set $std/allocator_arena/i
|
||||
br $repeat|0
|
||||
unreachable
|
||||
end
|
||||
unreachable
|
||||
end
|
||||
global.get $std/allocator_arena/ptr2
|
||||
global.get $std/allocator_arena/ptr1
|
||||
global.get $std/allocator_arena/size
|
||||
call $~lib/memory/memory.copy
|
||||
block $break|1
|
||||
i32.const 0
|
||||
global.set $std/allocator_arena/i
|
||||
loop $repeat|1
|
||||
global.get $std/allocator_arena/i
|
||||
global.get $std/allocator_arena/size
|
||||
i32.lt_u
|
||||
i32.eqz
|
||||
br_if $break|1
|
||||
global.get $std/allocator_arena/ptr2
|
||||
global.get $std/allocator_arena/i
|
||||
i32.add
|
||||
i32.load8_u
|
||||
i32.const 18
|
||||
i32.eq
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 24
|
||||
i32.const 16
|
||||
i32.const 27
|
||||
call $~lib/builtins/abort
|
||||
unreachable
|
||||
end
|
||||
global.get $std/allocator_arena/i
|
||||
i32.const 1
|
||||
i32.add
|
||||
global.set $std/allocator_arena/i
|
||||
br $repeat|1
|
||||
unreachable
|
||||
end
|
||||
unreachable
|
||||
end
|
||||
block $~lib/memory/memory.compare|inlined.0 (result i32)
|
||||
global.get $std/allocator_arena/ptr1
|
||||
local.set $2
|
||||
global.get $std/allocator_arena/ptr2
|
||||
local.set $1
|
||||
global.get $std/allocator_arena/size
|
||||
local.set $0
|
||||
block $~lib/util/memory/memcmp|inlined.0 (result i32)
|
||||
local.get $2
|
||||
local.set $5
|
||||
local.get $1
|
||||
local.set $4
|
||||
local.get $0
|
||||
local.set $3
|
||||
local.get $5
|
||||
local.get $4
|
||||
i32.eq
|
||||
if
|
||||
i32.const 0
|
||||
br $~lib/util/memory/memcmp|inlined.0
|
||||
end
|
||||
block $break|2
|
||||
loop $continue|2
|
||||
local.get $3
|
||||
i32.const 0
|
||||
i32.ne
|
||||
if (result i32)
|
||||
local.get $5
|
||||
i32.load8_u
|
||||
local.get $4
|
||||
i32.load8_u
|
||||
i32.eq
|
||||
else
|
||||
i32.const 0
|
||||
end
|
||||
if
|
||||
block
|
||||
local.get $3
|
||||
i32.const 1
|
||||
i32.sub
|
||||
local.set $3
|
||||
local.get $5
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $5
|
||||
local.get $4
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set $4
|
||||
end
|
||||
br $continue|2
|
||||
end
|
||||
end
|
||||
end
|
||||
local.get $3
|
||||
if (result i32)
|
||||
local.get $5
|
||||
i32.load8_u
|
||||
local.get $4
|
||||
i32.load8_u
|
||||
i32.sub
|
||||
else
|
||||
i32.const 0
|
||||
end
|
||||
end
|
||||
end
|
||||
i32.const 0
|
||||
i32.eq
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 24
|
||||
i32.const 18
|
||||
i32.const 0
|
||||
call $~lib/builtins/abort
|
||||
unreachable
|
||||
end
|
||||
global.get $std/allocator_arena/ptr1
|
||||
call $~lib/memory/memory.free
|
||||
global.get $std/allocator_arena/ptr2
|
||||
call $~lib/memory/memory.free
|
||||
call $~lib/memory/memory.reset
|
||||
global.get $std/allocator_arena/size
|
||||
call $~lib/memory/memory.allocate
|
||||
global.set $std/allocator_arena/ptr1
|
||||
global.get $std/allocator_arena/ptr1
|
||||
global.get $~lib/memory/HEAP_BASE
|
||||
i32.const 7
|
||||
i32.add
|
||||
i32.const 7
|
||||
i32.const -1
|
||||
i32.xor
|
||||
i32.and
|
||||
i32.eq
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 24
|
||||
i32.const 25
|
||||
i32.const 0
|
||||
call $~lib/builtins/abort
|
||||
unreachable
|
||||
end
|
||||
)
|
||||
(func $start (; 10 ;) (type $FUNCSIG$v)
|
||||
call $start:std/allocator_arena
|
||||
)
|
||||
(func $null (; 11 ;) (type $FUNCSIG$v)
|
||||
)
|
||||
)
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,88 +0,0 @@
|
||||
import "allocator/tlsf";
|
||||
import { HEADER, HEADER_SIZE, HEADER_MAGIC, adjust, allocate, reallocate, discard, register } from "util/runtime";
|
||||
import { runtime, __runtime_id } from "runtime";
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@start
|
||||
export function main(): void {}
|
||||
|
||||
var register_ref: usize = 0;
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global
|
||||
function __ref_register(ref: usize): void {
|
||||
register_ref = ref;
|
||||
}
|
||||
|
||||
var link_ref: usize = 0;
|
||||
var link_parentRef: usize = 0;
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global
|
||||
function __ref_link(ref: usize, parentRef: usize): void {
|
||||
link_ref = ref;
|
||||
link_parentRef = parentRef;
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global
|
||||
function __ref_unlink(ref: usize, parentRef: usize): void {
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global
|
||||
function __ref_collect(): void {
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global
|
||||
function __ref_mark(ref: usize): void {
|
||||
}
|
||||
|
||||
class A {}
|
||||
class B {}
|
||||
assert(__runtime_id<A>() != __runtime_id<B>());
|
||||
|
||||
function isPowerOf2(x: i32): bool {
|
||||
return x != 0 && (x & (x - 1)) == 0;
|
||||
}
|
||||
|
||||
assert(adjust(0) > 0);
|
||||
for (let i = 0; i < 9000; ++i) {
|
||||
assert(isPowerOf2(adjust(i)));
|
||||
}
|
||||
|
||||
var barrier1 = adjust(0);
|
||||
var barrier2 = barrier1 + 1;
|
||||
while (adjust(barrier2 + 1) == adjust(barrier2)) ++barrier2;
|
||||
var barrier3 = barrier2 + 1;
|
||||
while (adjust(barrier3 + 1) == adjust(barrier3)) ++barrier3;
|
||||
|
||||
trace("barrier1", 1, barrier1);
|
||||
trace("barrier2", 1, barrier2);
|
||||
trace("barrier3", 1, barrier3);
|
||||
|
||||
var ref1 = allocate(1);
|
||||
var header1 = changetype<HEADER>(ref1 - HEADER_SIZE);
|
||||
assert(header1.classId == HEADER_MAGIC);
|
||||
assert(header1.payloadSize == 1);
|
||||
assert(ref1 == reallocate(ref1, barrier1)); // same segment
|
||||
assert(header1.payloadSize == barrier1);
|
||||
var ref2 = reallocate(ref1, barrier2);
|
||||
assert(ref1 != ref2); // moves
|
||||
var header2 = changetype<HEADER>(ref2 - HEADER_SIZE);
|
||||
assert(header2.payloadSize == barrier2);
|
||||
discard(ref2);
|
||||
var ref3 = allocate(barrier2);
|
||||
assert(ref1 == ref3); // reuses space of ref1 (free'd in realloc), ref2 (explicitly free'd)
|
||||
|
||||
var ref4 = allocate(barrier1);
|
||||
register(ref4, __runtime_id<A>()); // should call __gc_register
|
||||
assert(register_ref == ref4);
|
||||
var header4 = changetype<HEADER>(register_ref - HEADER_SIZE);
|
||||
assert(header4.classId == __runtime_id<A>());
|
||||
assert(header4.payloadSize == barrier1);
|
||||
|
||||
var ref5 = allocate(10);
|
||||
assert(changetype<ArrayBuffer>(ref5).byteLength == 10);
|
||||
assert(changetype<String>(ref5).length == 5);
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
/// <reference path="../../../std/assembly/rt/index.d.ts" />
|
||||
|
||||
var str = "𐐷hi𤭢"; // -> f0 90 90 b7 68 69 f0 a4 ad a2 00
|
||||
|
||||
var len = str.lengthUTF8;
|
||||
@ -25,4 +27,4 @@ assert(String.fromUTF8(ptr + 4, 2) == "hi");
|
||||
assert(String.fromUTF8(ptr + 6, 4) == "𤭢");
|
||||
assert(String.fromUTF8(ptr + 10, 1) == "\0");
|
||||
|
||||
memory.free(ptr);
|
||||
__free(ptr);
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime arena"
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
@ -193,9 +193,9 @@ assert(sub32.byteLength == 3 * sizeof<i32>());
|
||||
assert(isInt32ArrayEqual(sub32, <i32[]>[0, 0, 0]));
|
||||
assert(isInt32ArrayEqual(arr32, <i32[]>[1, 0, 0, 0, 2]));
|
||||
|
||||
import { MAX_BYTELENGTH } from "util/runtime";
|
||||
import { BLOCK_OVERHEAD } from "rt/common";
|
||||
|
||||
const MAX_F64LENGTH = <u32>MAX_BYTELENGTH >> alignof<f64>();
|
||||
const MAX_F64LENGTH = <u32>BLOCK_OVERHEAD >> alignof<f64>();
|
||||
new Float64Array(MAX_F64LENGTH); // 1GB
|
||||
// new Float64Array(MAX_F64 + 1); // throws
|
||||
|
||||
|
Reference in New Issue
Block a user