update allocator tests

This commit is contained in:
dcode 2019-05-23 03:33:32 +02:00
parent 51fdf9db4f
commit 2263dfc87a
28 changed files with 5946 additions and 8960 deletions

View File

@ -10,9 +10,8 @@ jobs:
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then ./scripts/check-pr.sh; fi - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then ./scripts/check-pr.sh; fi
- npm run all - npm run all
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
cd $TRAVIS_BUILD_DIR/tests/allocators/arena && npm run build && cd .. && npm test arena && cd $TRAVIS_BUILD_DIR/tests/allocators/arena && npm run build && cd .. && npm test rt-full &&
cd $TRAVIS_BUILD_DIR/tests/allocators/buddy && npm run build && cd .. && npm test buddy && cd $TRAVIS_BUILD_DIR/tests/allocators/arena && npm run build && cd .. && npm test rt-stub;
cd $TRAVIS_BUILD_DIR/tests/allocators/tlsf && npm run build && cd .. && npm test tlsf;
fi fi
env: Runs the tests on node.js LTS, also tests allocators env: Runs the tests on node.js LTS, also tests allocators
- node_js: node - node_js: node

View File

@ -50,10 +50,10 @@ export function __free(ref: usize): void {
} }
// @ts-ignore: decorator // @ts-ignore: decorator
// @unsafe @global @unsafe @global
// export function __reset(): void { // special function __reset(): void { // special
// offset = startOffset; offset = startOffset;
// } }
// @ts-ignore: decorator // @ts-ignore: decorator
@global @unsafe @global @unsafe

View File

@ -1,2 +0,0 @@
import "allocator/arena";
export { memory };

View File

@ -1,6 +0,0 @@
{
"extends": "../../../../std/assembly.json",
"include": [
"./**/*.ts"
]
}

View File

@ -1,8 +0,0 @@
{
"private": true,
"scripts": {
"build": "npm run build:untouched && npm run build:optimized",
"build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime none --validate --sourceMap --measure",
"build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime none --validate --sourceMap --measure --noAssert --optimize"
}
}

View File

@ -1,460 +0,0 @@
(module
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$v (func))
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00\1c\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s\00")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $~lib/memory/memory.implemented i32 (i32.const 1))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $~lib/memory/HEAP_BASE i32 (i32.const 52))
(export "memory" (memory $0))
(export "memory.implemented" (global $~lib/memory/memory.implemented))
(export "memory.copy" (func $~lib/memory/memory.copy))
(export "memory.init" (func $~lib/memory/memory.init))
(export "memory.drop" (func $~lib/memory/memory.drop))
(export "memory.allocate" (func $~lib/memory/memory.allocate))
(export "memory.free" (func $~lib/memory/memory.free))
(export "memory.reset" (func $~lib/memory/memory.reset))
(export "memory.repeat" (func $~lib/memory/memory.repeat))
(export "memory.compare" (func $~lib/memory/memory.compare))
(start $start)
(func $~lib/memory/memory.init (; 1 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
i32.const 0
i32.const 24
i32.const 46
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.drop (; 2 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 0
i32.const 24
i32.const 53
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/allocator/arena/__mem_allocate (; 3 ;) (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 (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
call $~lib/allocator/arena/__mem_allocate
return
)
(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 $~lib/memory/memory.copy (; 9 ;) (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/memory/memory.repeat (; 10 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(local $4 i32)
(local $5 i32)
i32.const 0
local.set $4
local.get $2
local.get $3
i32.mul
local.set $5
block $break|0
loop $continue|0
local.get $4
local.get $5
i32.lt_u
if
block
local.get $0
local.get $4
i32.add
local.get $1
local.get $2
call $~lib/memory/memory.copy
local.get $4
local.get $2
i32.add
local.set $4
end
br $continue|0
end
end
end
)
(func $~lib/memory/memory.compare (; 11 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
block $~lib/util/memory/memcmp|inlined.0 (result i32)
local.get $0
local.set $5
local.get $1
local.set $4
local.get $2
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|0
loop $continue|0
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|0
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
)
(func $start (; 12 ;) (type $FUNCSIG$v)
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
)
(func $null (; 13 ;) (type $FUNCSIG$v)
)
)

View File

@ -1,2 +1,3 @@
import "./buddy"; import "./buddy";
export { memory }; export { memory };
export { __mem_allocate as __alloc, __mem_free as __free };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ function test(file) {
console.log("mem final: " + exports.memory.buffer.byteLength); console.log("mem final: " + exports.memory.buffer.byteLength);
console.log(); console.log();
const alloc = exports["memory.allocate"]; const alloc = exports["__alloc"];
var overflow = false; var overflow = false;
try { try {
alloc(COMMON_MAX + 1); // unreachable alloc(COMMON_MAX + 1); // unreachable

View File

@ -3,6 +3,6 @@
"scripts": { "scripts": {
"test": "node ./index", "test": "node ./index",
"test:forever": "node ./forever", "test:forever": "node ./forever",
"test:all": "npm run test tlsf && npm run test buddy && npm run test arena" "test:all": "npm run test rt-full && npm run test rt-stub && npm run test buddy"
} }
} }

View File

@ -0,0 +1 @@
export { memory } from "memory";

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"private": true, "private": true,
"scripts": { "scripts": {
"build": "npm run build:untouched && npm run build:optimized", "build": "npm run build:untouched && npm run build:optimized",
"build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime none --validate --sourceMap --measure", "build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime full --validate --sourceMap --measure",
"build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime none --validate --sourceMap --measure --noAssert --optimize" "build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime full --validate --sourceMap --measure --noAssert --optimize"
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
export { memory } from "memory";
export { __reset };

View File

@ -1,79 +1,74 @@
(module (module
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(type $FUNCSIG$viii (func (param i32 i32 i32))) (type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\1c") (data (i32.const 8) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e")
(data (i32.const 24) "~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s") (data (i32.const 64) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00~\00l\00i\00b\00/\00r\00t\00.\00t\00s")
(global $~lib/memory/memory.implemented i32 (i32.const 1)) (data (i32.const 104) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00N\00o\00t\00 \00i\00m\00p\00l\00e\00m\00e\00n\00t\00e\00d")
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (data (i32.const 152) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s")
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (data (i32.const 200) "\03\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08")
(global $~lib/rt/stub/startOffset (mut i32) (i32.const 0))
(global $~lib/rt/stub/offset (mut i32) (i32.const 0))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "memory.implemented" (global $~lib/memory/memory.implemented)) (export "__alloc" (func $~lib/rt/stub/__alloc))
(export "__realloc" (func $~lib/rt/stub/__realloc))
(export "__free" (func $~lib/rt/stub/__free))
(export "__retain" (func $~lib/rt/stub/__retain))
(export "__release" (func $~lib/rt/stub/__free))
(export "__collect" (func $~lib/rt/stub/__collect))
(export "__instanceof" (func $~lib/rt/__instanceof))
(export "__typeinfo" (func $~lib/rt/__typeinfo))
(export "memory.copy" (func $~lib/memory/memory.copy)) (export "memory.copy" (func $~lib/memory/memory.copy))
(export "memory.init" (func $~lib/memory/memory.init)) (export "memory.init" (func $~lib/memory/memory.init))
(export "memory.drop" (func $~lib/memory/memory.drop)) (export "memory.drop" (func $~lib/memory/memory.drop))
(export "memory.allocate" (func $~lib/memory/memory.allocate))
(export "memory.free" (func $~lib/memory/memory.free))
(export "memory.reset" (func $~lib/memory/memory.reset))
(export "memory.repeat" (func $~lib/memory/memory.repeat)) (export "memory.repeat" (func $~lib/memory/memory.repeat))
(export "memory.compare" (func $~lib/memory/memory.compare)) (export "memory.compare" (func $~lib/memory/memory.compare))
(export "__reset" (func $~lib/rt/stub/__reset))
(start $start) (start $start)
(func $~lib/memory/memory.init (; 1 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
i32.const 0
i32.const 24
i32.const 46
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.drop (; 2 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 0
i32.const 24
i32.const 53
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/allocator/arena/__mem_allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32)
(local $6 i32)
local.get $0 local.get $0
i32.const 1073741824 i32.const 1073741808
i32.gt_u i32.gt_u
if if
unreachable unreachable
end end
local.get $0 local.get $0
i32.const 1 i32.const 1
local.tee $1 local.tee $2
local.get $0 local.get $0
local.get $1 local.get $2
i32.gt_u i32.gt_u
select select
global.get $~lib/allocator/arena/offset global.get $~lib/rt/stub/offset
local.tee $0 i32.const 16
i32.add i32.add
i32.const 7
i32.add
i32.const -8
i32.and
local.tee $1
current_memory
local.tee $2 local.tee $2
i32.add
i32.const 15
i32.add
i32.const -16
i32.and
local.tee $3
current_memory
local.tee $4
i32.const 16 i32.const 16
i32.shl i32.shl
i32.gt_u i32.gt_u
if if
local.get $4
local.get $3
local.get $2 local.get $2
local.get $1
local.get $0
i32.sub i32.sub
i32.const 65535 i32.const 65535
i32.add i32.add
@ -81,17 +76,17 @@
i32.and i32.and
i32.const 16 i32.const 16
i32.shr_u i32.shr_u
local.tee $3 local.tee $5
local.tee $4 local.tee $6
local.get $2
local.get $4 local.get $4
local.get $6
i32.gt_s i32.gt_s
select select
grow_memory grow_memory
i32.const 0 i32.const 0
i32.lt_s i32.lt_s
if if
local.get $3 local.get $5
grow_memory grow_memory
i32.const 0 i32.const 0
i32.lt_s i32.lt_s
@ -100,24 +95,24 @@
end end
end end
end end
local.get $3
global.set $~lib/rt/stub/offset
local.get $2
i32.const 16
i32.sub
local.tee $3
local.get $1 local.get $1
global.set $~lib/allocator/arena/offset i32.store offset=8
local.get $3
local.get $0 local.get $0
i32.store offset=12
local.get $2
) )
(func $~lib/memory/memory.allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $~lib/memory/memory.copy (; 2 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
local.get $0
call $~lib/allocator/arena/__mem_allocate
)
(func $~lib/memory/memory.free (; 5 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $~lib/memory/memory.reset (; 6 ;) (type $FUNCSIG$v)
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
)
(func $~lib/memory/memory.copy (; 7 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32) (local $3 i32)
block $~lib/util/memory/memmove|inlined.0 block $~lib/util/memory/memmove|inlined.0
local.get $2
local.set $3
local.get $0 local.get $0
local.get $1 local.get $1
i32.eq i32.eq
@ -139,26 +134,26 @@
i32.const 7 i32.const 7
i32.and i32.and
if if
local.get $2 local.get $3
i32.eqz i32.eqz
br_if $~lib/util/memory/memmove|inlined.0 br_if $~lib/util/memory/memmove|inlined.0
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.set $2 local.set $3
local.get $0 local.get $0
local.tee $3 local.tee $2
i32.const 1 i32.const 1
i32.add i32.add
local.set $0 local.set $0
local.get $3 local.get $2
block (result i32) block (result i32)
local.get $1 local.get $1
local.tee $3 local.tee $2
i32.const 1 i32.const 1
i32.add i32.add
local.set $1 local.set $1
local.get $3 local.get $2
i32.load8_u i32.load8_u
end end
i32.store8 i32.store8
@ -166,7 +161,7 @@
end end
end end
loop $continue|1 loop $continue|1
local.get $2 local.get $3
i32.const 8 i32.const 8
i32.ge_u i32.ge_u
if if
@ -174,10 +169,10 @@
local.get $1 local.get $1
i64.load i64.load
i64.store i64.store
local.get $2 local.get $3
i32.const 8 i32.const 8
i32.sub i32.sub
local.set $2 local.set $3
local.get $0 local.get $0
i32.const 8 i32.const 8
i32.add i32.add
@ -191,28 +186,28 @@
end end
end end
loop $continue|2 loop $continue|2
local.get $2 local.get $3
if if
local.get $0 local.get $0
local.tee $3 local.tee $2
i32.const 1 i32.const 1
i32.add i32.add
local.set $0 local.set $0
local.get $3 local.get $2
block (result i32) block (result i32)
local.get $1 local.get $1
local.tee $3 local.tee $2
i32.const 1 i32.const 1
i32.add i32.add
local.set $1 local.set $1
local.get $3 local.get $2
i32.load8_u i32.load8_u
end end
i32.store8 i32.store8
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.set $2 local.set $3
br $continue|2 br $continue|2
end end
end end
@ -227,22 +222,22 @@
if if
loop $continue|3 loop $continue|3
local.get $0 local.get $0
local.get $2 local.get $3
i32.add i32.add
i32.const 7 i32.const 7
i32.and i32.and
if if
local.get $2 local.get $3
i32.eqz i32.eqz
br_if $~lib/util/memory/memmove|inlined.0 br_if $~lib/util/memory/memmove|inlined.0
local.get $0 local.get $0
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.tee $2 local.tee $3
i32.add i32.add
local.get $1 local.get $1
local.get $2 local.get $3
i32.add i32.add
i32.load8_u i32.load8_u
i32.store8 i32.store8
@ -250,18 +245,18 @@
end end
end end
loop $continue|4 loop $continue|4
local.get $2 local.get $3
i32.const 8 i32.const 8
i32.ge_u i32.ge_u
if if
local.get $2 local.get $0
local.get $3
i32.const 8 i32.const 8
i32.sub i32.sub
local.tee $2 local.tee $3
local.get $0
i32.add i32.add
local.get $1 local.get $1
local.get $2 local.get $3
i32.add i32.add
i64.load i64.load
i64.store i64.store
@ -270,16 +265,16 @@
end end
end end
loop $continue|5 loop $continue|5
local.get $2 local.get $3
if if
local.get $0 local.get $0
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.tee $2 local.tee $3
i32.add i32.add
local.get $1 local.get $1
local.get $2 local.get $3
i32.add i32.add
i32.load8_u i32.load8_u
i32.store8 i32.store8
@ -289,7 +284,119 @@
end end
end end
) )
(func $~lib/memory/memory.repeat (; 8 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (func $~lib/rt/stub/__realloc (; 3 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
local.get $1
local.get $0
i32.const 16
i32.sub
local.tee $2
i32.load offset=12
local.tee $3
i32.gt_u
if
local.get $1
local.get $2
i32.load offset=8
call $~lib/rt/stub/__alloc
local.tee $1
local.get $0
local.get $3
call $~lib/memory/memory.copy
local.get $1
local.set $0
else
local.get $2
local.get $1
i32.store offset=12
end
local.get $0
)
(func $~lib/rt/stub/__free (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $~lib/rt/stub/__retain (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
)
(func $~lib/rt/stub/__collect (; 6 ;) (type $FUNCSIG$v)
nop
)
(func $~lib/rt/__instanceof (; 7 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
i32.const 16
i32.sub
i32.load offset=8
local.tee $0
i32.const 200
local.tee $2
i32.load
i32.le_u
if
loop $continue|0
local.get $0
local.get $1
i32.eq
if
i32.const 1
return
end
local.get $2
i32.const 4
i32.add
local.get $0
i32.const 3
i32.shl
i32.add
i32.load offset=4
local.tee $0
br_if $continue|0
end
end
i32.const 0
)
(func $~lib/rt/__typeinfo (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.const 200
local.tee $1
i32.load
i32.gt_u
if
i32.const 24
i32.const 80
i32.const 22
i32.const 27
call $~lib/builtins/abort
unreachable
end
local.get $1
i32.const 4
i32.add
local.get $0
i32.const 3
i32.shl
i32.add
i32.load
)
(func $~lib/memory/memory.init (; 9 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
i32.const 120
i32.const 168
i32.const 35
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.drop (; 10 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 120
i32.const 168
i32.const 42
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.repeat (; 11 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(local $4 i32) (local $4 i32)
local.get $2 local.get $2
local.get $3 local.get $3
@ -314,7 +421,7 @@
end end
end end
) )
(func $~lib/memory/memory.compare (; 9 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (func $~lib/memory/memory.compare (; 12 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
local.get $0 local.get $0
local.get $1 local.get $1
i32.eq i32.eq
@ -360,13 +467,14 @@
end end
end end
) )
(func $start (; 10 ;) (type $FUNCSIG$v) (func $~lib/rt/stub/__reset (; 13 ;) (type $FUNCSIG$v)
i32.const 56 global.get $~lib/rt/stub/startOffset
global.set $~lib/allocator/arena/startOffset global.set $~lib/rt/stub/offset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
) )
(func $null (; 11 ;) (type $FUNCSIG$v) (func $start (; 14 ;) (type $FUNCSIG$v)
nop i32.const 240
global.set $~lib/rt/stub/startOffset
global.get $~lib/rt/stub/startOffset
global.set $~lib/rt/stub/offset
) )
) )

View File

@ -2,7 +2,7 @@
"private": true, "private": true,
"scripts": { "scripts": {
"build": "npm run build:untouched && npm run build:optimized", "build": "npm run build:untouched && npm run build:optimized",
"build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime none --validate --sourceMap --measure", "build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime stub --validate --sourceMap --measure",
"build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime none --validate --sourceMap --measure --noAssert --optimize" "build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime stub --validate --sourceMap --measure --noAssert --optimize"
} }
} }

View File

@ -0,0 +1,568 @@
(module
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$v (func))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e\00")
(data (i32.const 64) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00~\00l\00i\00b\00/\00r\00t\00.\00t\00s\00")
(data (i32.const 104) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00N\00o\00t\00 \00i\00m\00p\00l\00e\00m\00e\00n\00t\00e\00d\00")
(data (i32.const 152) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s\00")
(data (i32.const 200) "\03\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $~lib/rt/stub/startOffset (mut i32) (i32.const 0))
(global $~lib/rt/stub/offset (mut i32) (i32.const 0))
(global $~lib/rt/RTTI_BASE i32 (i32.const 200))
(global $~lib/heap/HEAP_BASE i32 (i32.const 228))
(export "memory" (memory $0))
(export "__alloc" (func $~lib/rt/stub/__alloc))
(export "__realloc" (func $~lib/rt/stub/__realloc))
(export "__free" (func $~lib/rt/stub/__free))
(export "__retain" (func $~lib/rt/stub/__retain))
(export "__release" (func $~lib/rt/stub/__release))
(export "__collect" (func $~lib/rt/stub/__collect))
(export "__instanceof" (func $~lib/rt/__instanceof))
(export "__typeinfo" (func $~lib/rt/__typeinfo))
(export "memory.copy" (func $~lib/memory/memory.copy))
(export "memory.init" (func $~lib/memory/memory.init))
(export "memory.drop" (func $~lib/memory/memory.drop))
(export "memory.repeat" (func $~lib/memory/memory.repeat))
(export "memory.compare" (func $~lib/memory/memory.compare))
(export "__reset" (func $~lib/rt/stub/__reset))
(start $start)
(func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
local.get $0
i32.const 1073741808
i32.gt_u
if
unreachable
end
global.get $~lib/rt/stub/offset
i32.const 16
i32.add
local.set $2
local.get $2
local.get $0
local.tee $3
i32.const 1
local.tee $4
local.get $3
local.get $4
i32.gt_u
select
i32.add
i32.const 15
i32.add
i32.const 15
i32.const -1
i32.xor
i32.and
local.set $5
current_memory
local.set $6
local.get $5
local.get $6
i32.const 16
i32.shl
i32.gt_u
if
local.get $5
local.get $2
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 $3
local.get $6
local.tee $4
local.get $3
local.tee $7
local.get $4
local.get $7
i32.gt_s
select
local.set $4
local.get $4
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 $5
global.set $~lib/rt/stub/offset
local.get $2
i32.const 16
i32.sub
local.set $8
local.get $8
local.get $1
i32.store offset=8
local.get $8
local.get $0
i32.store offset=12
local.get $2
)
(func $~lib/memory/memory.copy (; 2 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
block $~lib/util/memory/memmove|inlined.0
local.get $0
local.set $5
local.get $1
local.set $4
local.get $2
local.set $3
local.get $5
local.get $4
i32.eq
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $5
local.get $4
i32.lt_u
if
local.get $4
i32.const 7
i32.and
local.get $5
i32.const 7
i32.and
i32.eq
if
block $break|0
loop $continue|0
local.get $5
i32.const 7
i32.and
if
local.get $3
i32.eqz
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $3
i32.const 1
i32.sub
local.set $3
block (result i32)
local.get $5
local.tee $6
i32.const 1
i32.add
local.set $5
local.get $6
end
block (result i32)
local.get $4
local.tee $6
i32.const 1
i32.add
local.set $4
local.get $6
end
i32.load8_u
i32.store8
br $continue|0
end
end
end
block $break|1
loop $continue|1
local.get $3
i32.const 8
i32.ge_u
if
local.get $5
local.get $4
i64.load
i64.store
local.get $3
i32.const 8
i32.sub
local.set $3
local.get $5
i32.const 8
i32.add
local.set $5
local.get $4
i32.const 8
i32.add
local.set $4
br $continue|1
end
end
end
end
block $break|2
loop $continue|2
local.get $3
if
block (result i32)
local.get $5
local.tee $6
i32.const 1
i32.add
local.set $5
local.get $6
end
block (result i32)
local.get $4
local.tee $6
i32.const 1
i32.add
local.set $4
local.get $6
end
i32.load8_u
i32.store8
local.get $3
i32.const 1
i32.sub
local.set $3
br $continue|2
end
end
end
else
local.get $4
i32.const 7
i32.and
local.get $5
i32.const 7
i32.and
i32.eq
if
block $break|3
loop $continue|3
local.get $5
local.get $3
i32.add
i32.const 7
i32.and
if
local.get $3
i32.eqz
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $5
local.get $3
i32.const 1
i32.sub
local.tee $3
i32.add
local.get $4
local.get $3
i32.add
i32.load8_u
i32.store8
br $continue|3
end
end
end
block $break|4
loop $continue|4
local.get $3
i32.const 8
i32.ge_u
if
local.get $3
i32.const 8
i32.sub
local.set $3
local.get $5
local.get $3
i32.add
local.get $4
local.get $3
i32.add
i64.load
i64.store
br $continue|4
end
end
end
end
block $break|5
loop $continue|5
local.get $3
if
local.get $5
local.get $3
i32.const 1
i32.sub
local.tee $3
i32.add
local.get $4
local.get $3
i32.add
i32.load8_u
i32.store8
br $continue|5
end
end
end
end
end
)
(func $~lib/rt/stub/__realloc (; 3 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
local.get $0
i32.const 16
i32.sub
local.set $2
local.get $2
i32.load offset=12
local.set $3
local.get $1
local.get $3
i32.gt_u
if
local.get $1
local.get $2
i32.load offset=8
call $~lib/rt/stub/__alloc
local.set $4
local.get $4
local.get $0
local.get $3
call $~lib/memory/memory.copy
local.get $4
local.set $0
else
local.get $2
local.get $1
i32.store offset=12
end
local.get $0
)
(func $~lib/rt/stub/__free (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $~lib/rt/stub/__retain (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
)
(func $~lib/rt/stub/__release (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $~lib/rt/stub/__collect (; 7 ;) (type $FUNCSIG$v)
nop
)
(func $~lib/rt/__instanceof (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
local.get $0
i32.const 16
i32.sub
i32.load offset=8
local.set $2
global.get $~lib/rt/RTTI_BASE
local.set $3
local.get $2
local.get $3
i32.load
i32.le_u
if
loop $continue|0
local.get $2
local.get $1
i32.eq
if
i32.const 1
return
end
local.get $3
i32.const 4
i32.add
local.get $2
i32.const 8
i32.mul
i32.add
i32.load offset=4
local.tee $2
br_if $continue|0
end
end
i32.const 0
)
(func $~lib/rt/__typeinfo (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
global.get $~lib/rt/RTTI_BASE
local.set $1
local.get $0
local.get $1
i32.load
i32.gt_u
if
i32.const 24
i32.const 80
i32.const 22
i32.const 27
call $~lib/builtins/abort
unreachable
end
local.get $1
i32.const 4
i32.add
local.get $0
i32.const 8
i32.mul
i32.add
i32.load
)
(func $~lib/memory/memory.init (; 10 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
i32.const 120
i32.const 168
i32.const 35
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.drop (; 11 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 120
i32.const 168
i32.const 42
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.repeat (; 12 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(local $4 i32)
(local $5 i32)
i32.const 0
local.set $4
local.get $2
local.get $3
i32.mul
local.set $5
block $break|0
loop $continue|0
local.get $4
local.get $5
i32.lt_u
if
local.get $0
local.get $4
i32.add
local.get $1
local.get $2
call $~lib/memory/memory.copy
local.get $4
local.get $2
i32.add
local.set $4
br $continue|0
end
end
end
)
(func $~lib/memory/memory.compare (; 13 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
block $~lib/util/memory/memcmp|inlined.0 (result i32)
local.get $0
local.set $5
local.get $1
local.set $4
local.get $2
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|0
loop $continue|0
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
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
br $continue|0
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
)
(func $~lib/rt/stub/__reset (; 14 ;) (type $FUNCSIG$v)
global.get $~lib/rt/stub/startOffset
global.set $~lib/rt/stub/offset
)
(func $start (; 15 ;) (type $FUNCSIG$v)
global.get $~lib/heap/HEAP_BASE
i32.const 15
i32.add
i32.const 15
i32.const -1
i32.xor
i32.and
global.set $~lib/rt/stub/startOffset
global.get $~lib/rt/stub/startOffset
global.set $~lib/rt/stub/offset
)
(func $null (; 16 ;) (type $FUNCSIG$v)
)
)

View File

@ -1,14 +0,0 @@
import "rt";
import { memory as builtin_memory } from "memory";
export namespace memory {
export function allocate(size: usize): usize {
return __rt_allocate(size, 0);
}
export function free(ptr: usize): void {
__rt_free(ptr);
}
export function fill(dst: usize, c: u8, n: usize): void {
builtin_memory.fill(dst, c, n);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
function runner(exports, runs, allocs) { function runner(exports, runs, allocs) {
const alloc = exports["memory.allocate"]; const alloc = exports["__alloc"];
const free = exports["memory.free"]; const free = exports["__free"];
const reset = exports["__reset"];
const fill = exports["memory.fill"]; const fill = exports["memory.fill"];
const reset = exports["memory.reset"];
const ptrs = []; const ptrs = [];

View File

@ -1,2 +0,0 @@
import "allocator/tlsf";
export { memory };

View File

@ -1,991 +0,0 @@
(module
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result 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\1c")
(data (i32.const 24) "~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s")
(global $~lib/memory/memory.implemented i32 (i32.const 1))
(global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0))
(export "memory" (memory $0))
(export "memory.implemented" (global $~lib/memory/memory.implemented))
(export "memory.copy" (func $~lib/memory/memory.copy))
(export "memory.init" (func $~lib/memory/memory.init))
(export "memory.drop" (func $~lib/memory/memory.drop))
(export "memory.allocate" (func $~lib/memory/memory.allocate))
(export "memory.free" (func $~lib/memory/memory.free))
(export "memory.reset" (func $~lib/memory/memory.reset))
(export "memory.repeat" (func $~lib/memory/memory.repeat))
(export "memory.compare" (func $~lib/memory/memory.compare))
(func $~lib/memory/memory.init (; 1 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
i32.const 0
i32.const 24
i32.const 46
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.drop (; 2 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 0
i32.const 24
i32.const 53
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/allocator/tlsf/Root#set:tailRef (; 3 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0
local.get $1
i32.store offset=2912
)
(func $~lib/allocator/tlsf/Root#setSLMap (; 4 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
local.get $0
local.get $1
i32.const 2
i32.shl
i32.add
local.get $2
i32.store offset=4
)
(func $~lib/allocator/tlsf/Root#setHead (; 5 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
local.get $0
local.get $1
i32.const 5
i32.shl
local.get $2
i32.add
i32.const 2
i32.shl
i32.add
local.get $3
i32.store offset=96
)
(func $~lib/allocator/tlsf/Block#get:right (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.const 8
i32.add
local.get $0
i32.load
i32.const -4
i32.and
i32.add
)
(func $~lib/allocator/tlsf/fls<usize> (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
i32.const 31
local.get $0
i32.clz
i32.sub
)
(func $~lib/allocator/tlsf/Root#getHead (; 8 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
local.get $0
local.get $1
i32.const 5
i32.shl
local.get $2
i32.add
i32.const 2
i32.shl
i32.add
i32.load offset=96
)
(func $~lib/allocator/tlsf/Root#getSLMap (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
local.get $0
local.get $1
i32.const 2
i32.shl
i32.add
i32.load offset=4
)
(func $~lib/allocator/tlsf/Root#remove (; 10 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
local.get $1
i32.load
i32.const -4
i32.and
local.tee $2
i32.const 256
i32.lt_u
if (result i32)
local.get $2
i32.const 8
i32.div_u
local.set $4
i32.const 0
else
local.get $2
local.get $2
call $~lib/allocator/tlsf/fls<usize>
local.tee $3
i32.const 5
i32.sub
i32.shr_u
i32.const 32
i32.xor
local.set $4
local.get $3
i32.const 7
i32.sub
end
local.set $3
local.get $1
i32.load offset=8
local.set $2
local.get $1
i32.load offset=4
local.tee $5
if
local.get $5
local.get $2
i32.store offset=8
end
local.get $2
if
local.get $2
local.get $5
i32.store offset=4
end
local.get $0
local.get $3
local.get $4
call $~lib/allocator/tlsf/Root#getHead
local.get $1
i32.eq
if
local.get $0
local.get $3
local.get $4
local.get $2
call $~lib/allocator/tlsf/Root#setHead
local.get $2
i32.eqz
if
local.get $0
local.get $3
local.get $0
local.get $3
call $~lib/allocator/tlsf/Root#getSLMap
i32.const 1
local.get $4
i32.shl
i32.const -1
i32.xor
i32.and
local.tee $1
call $~lib/allocator/tlsf/Root#setSLMap
local.get $1
i32.eqz
if
local.get $0
local.get $0
i32.load
i32.const 1
local.get $3
i32.shl
i32.const -1
i32.xor
i32.and
i32.store
end
end
end
)
(func $~lib/allocator/tlsf/Root#insert (; 11 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
local.get $1
i32.load
local.set $2
local.get $1
call $~lib/allocator/tlsf/Block#get:right
local.tee $3
i32.load
local.tee $4
i32.const 1
i32.and
if
local.get $0
local.get $3
call $~lib/allocator/tlsf/Root#remove
local.get $1
local.get $2
local.get $4
i32.const -4
i32.and
i32.const 8
i32.add
i32.add
local.tee $2
i32.store
local.get $1
call $~lib/allocator/tlsf/Block#get:right
local.tee $3
i32.load
local.set $4
end
local.get $2
i32.const 2
i32.and
if
local.get $1
i32.const 4
i32.sub
i32.load
local.tee $1
i32.load
local.set $5
local.get $0
local.get $1
call $~lib/allocator/tlsf/Root#remove
local.get $1
local.get $5
local.get $2
i32.const -4
i32.and
i32.const 8
i32.add
i32.add
local.tee $2
i32.store
end
local.get $3
local.get $4
i32.const 2
i32.or
i32.store
local.get $3
i32.const 4
i32.sub
local.get $1
i32.store
local.get $0
local.get $2
i32.const -4
i32.and
local.tee $2
i32.const 256
i32.lt_u
if (result i32)
local.get $2
i32.const 8
i32.div_u
local.set $2
i32.const 0
else
local.get $2
local.get $2
call $~lib/allocator/tlsf/fls<usize>
local.tee $3
i32.const 5
i32.sub
i32.shr_u
i32.const 32
i32.xor
local.set $2
local.get $3
i32.const 7
i32.sub
end
local.tee $3
local.get $2
call $~lib/allocator/tlsf/Root#getHead
local.set $4
local.get $1
i32.const 0
i32.store offset=4
local.get $1
local.get $4
i32.store offset=8
local.get $4
if
local.get $4
local.get $1
i32.store offset=4
end
local.get $0
local.get $3
local.get $2
local.get $1
call $~lib/allocator/tlsf/Root#setHead
local.get $0
local.get $0
i32.load
i32.const 1
local.get $3
i32.shl
i32.or
i32.store
local.get $0
local.get $3
local.get $0
local.get $3
call $~lib/allocator/tlsf/Root#getSLMap
i32.const 1
local.get $2
i32.shl
i32.or
call $~lib/allocator/tlsf/Root#setSLMap
)
(func $~lib/allocator/tlsf/Root#addMemory (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
local.get $2
block (result i32)
local.get $0
i32.load offset=2912
local.tee $2
if
local.get $1
i32.const 8
i32.sub
local.get $2
i32.eq
if
local.get $2
i32.load
local.set $3
local.get $1
i32.const 8
i32.sub
local.set $1
end
end
local.get $1
end
i32.sub
local.tee $2
i32.const 32
i32.lt_u
if
return
end
local.get $1
local.get $3
i32.const 2
i32.and
local.get $2
i32.const 16
i32.sub
i32.const 1
i32.or
i32.or
i32.store
local.get $1
i32.const 0
i32.store offset=4
local.get $1
i32.const 0
i32.store offset=8
local.get $1
local.get $2
i32.add
i32.const 8
i32.sub
local.tee $2
i32.const 2
i32.store
local.get $0
local.get $2
call $~lib/allocator/tlsf/Root#set:tailRef
local.get $0
local.get $1
call $~lib/allocator/tlsf/Root#insert
)
(func $~lib/allocator/tlsf/Root#search (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $1
i32.const 256
i32.lt_u
if (result i32)
local.get $1
i32.const 8
i32.div_u
else
local.get $1
local.get $1
call $~lib/allocator/tlsf/fls<usize>
local.tee $2
i32.const 5
i32.sub
i32.shr_u
i32.const 32
i32.xor
local.set $1
local.get $2
i32.const 7
i32.sub
local.set $2
local.get $1
i32.const 31
i32.lt_u
if (result i32)
local.get $1
i32.const 1
i32.add
else
local.get $2
i32.const 1
i32.add
local.set $2
i32.const 0
end
end
local.set $1
local.get $0
local.get $2
call $~lib/allocator/tlsf/Root#getSLMap
i32.const -1
local.get $1
i32.shl
i32.and
local.tee $1
if (result i32)
local.get $0
local.get $2
local.get $1
i32.ctz
call $~lib/allocator/tlsf/Root#getHead
else
local.get $0
i32.load
i32.const -1
local.get $2
i32.const 1
i32.add
i32.shl
i32.and
local.tee $1
if (result i32)
local.get $0
local.get $1
i32.ctz
local.tee $1
local.get $0
local.get $1
call $~lib/allocator/tlsf/Root#getSLMap
i32.ctz
call $~lib/allocator/tlsf/Root#getHead
else
i32.const 0
end
end
)
(func $~lib/allocator/tlsf/Root#use (; 14 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
local.get $1
i32.load
local.set $3
local.get $0
local.get $1
call $~lib/allocator/tlsf/Root#remove
local.get $3
i32.const -4
i32.and
local.get $2
i32.sub
local.tee $4
i32.const 24
i32.ge_u
if
local.get $1
local.get $2
local.get $3
i32.const 2
i32.and
i32.or
i32.store
local.get $1
i32.const 8
i32.add
local.get $2
i32.add
local.tee $2
local.get $4
i32.const 8
i32.sub
i32.const 1
i32.or
i32.store
local.get $0
local.get $2
call $~lib/allocator/tlsf/Root#insert
else
local.get $1
local.get $3
i32.const -2
i32.and
i32.store
local.get $1
call $~lib/allocator/tlsf/Block#get:right
local.tee $0
local.get $0
i32.load
i32.const -3
i32.and
i32.store
end
local.get $1
i32.const 8
i32.add
)
(func $~lib/allocator/tlsf/__mem_allocate (; 15 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
global.get $~lib/allocator/tlsf/ROOT
local.tee $1
i32.eqz
if
i32.const 56
local.tee $4
i32.const 68451
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $2
current_memory
local.tee $1
i32.gt_s
if (result i32)
local.get $2
local.get $1
i32.sub
grow_memory
i32.const 0
i32.lt_s
else
i32.const 0
end
if
unreachable
end
local.get $4
local.tee $1
global.set $~lib/allocator/tlsf/ROOT
local.get $1
i32.const 0
call $~lib/allocator/tlsf/Root#set:tailRef
local.get $1
i32.const 0
i32.store
loop $repeat|0
block $break|0
local.get $3
i32.const 22
i32.ge_u
br_if $break|0
local.get $1
local.get $3
i32.const 0
call $~lib/allocator/tlsf/Root#setSLMap
i32.const 0
local.set $2
loop $repeat|1
block $break|1
local.get $2
i32.const 32
i32.ge_u
br_if $break|1
local.get $1
local.get $3
local.get $2
i32.const 0
call $~lib/allocator/tlsf/Root#setHead
local.get $2
i32.const 1
i32.add
local.set $2
br $repeat|1
end
end
local.get $3
i32.const 1
i32.add
local.set $3
br $repeat|0
end
end
local.get $1
local.get $4
i32.const 2923
i32.add
i32.const -8
i32.and
current_memory
i32.const 16
i32.shl
call $~lib/allocator/tlsf/Root#addMemory
end
local.get $0
i32.const 1073741824
i32.gt_u
if
unreachable
end
local.get $1
local.get $1
local.get $0
i32.const 7
i32.add
i32.const -8
i32.and
local.tee $4
i32.const 16
local.tee $0
local.get $4
local.get $0
i32.gt_u
select
local.tee $5
call $~lib/allocator/tlsf/Root#search
local.tee $0
if (result i32)
local.get $0
else
current_memory
local.tee $3
local.tee $2
local.get $5
i32.const 65535
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $4
local.tee $0
local.get $2
local.get $0
i32.gt_s
select
grow_memory
i32.const 0
i32.lt_s
if
local.get $4
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
local.get $1
local.get $3
i32.const 16
i32.shl
current_memory
i32.const 16
i32.shl
call $~lib/allocator/tlsf/Root#addMemory
local.get $1
local.get $5
call $~lib/allocator/tlsf/Root#search
end
local.get $5
call $~lib/allocator/tlsf/Root#use
)
(func $~lib/memory/memory.allocate (; 16 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
call $~lib/allocator/tlsf/__mem_allocate
)
(func $~lib/allocator/tlsf/__mem_free (; 17 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
local.get $0
if
global.get $~lib/allocator/tlsf/ROOT
local.tee $1
if
local.get $0
i32.const 8
i32.sub
local.tee $2
local.get $2
i32.load
i32.const 1
i32.or
i32.store
local.get $1
local.get $0
i32.const 8
i32.sub
call $~lib/allocator/tlsf/Root#insert
end
end
)
(func $~lib/memory/memory.free (; 18 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
call $~lib/allocator/tlsf/__mem_free
)
(func $~lib/memory/memory.reset (; 19 ;) (type $FUNCSIG$v)
i32.const 0
i32.const 24
i32.const 77
i32.const 9
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.copy (; 20 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
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 $3
block (result i32)
local.get $1
local.tee $3
i32.const 1
i32.add
local.set $1
local.get $3
i32.load8_u
end
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 $3
block (result i32)
local.get $1
local.tee $3
i32.const 1
i32.add
local.set $1
local.get $3
i32.load8_u
end
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 $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|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 $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
)
(func $~lib/memory/memory.repeat (; 21 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(local $4 i32)
local.get $2
local.get $3
i32.mul
local.set $3
loop $continue|0
local.get $4
local.get $3
i32.lt_u
if
local.get $0
local.get $4
i32.add
local.get $1
local.get $2
call $~lib/memory/memory.copy
local.get $2
local.get $4
i32.add
local.set $4
br $continue|0
end
end
)
(func $~lib/memory/memory.compare (; 22 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
local.get $0
local.get $1
i32.eq
if (result i32)
i32.const 0
else
loop $continue|0
local.get $2
if (result i32)
local.get $0
i32.load8_u
local.get $1
i32.load8_u
i32.eq
else
i32.const 0
end
if
local.get $2
i32.const 1
i32.sub
local.set $2
local.get $0
i32.const 1
i32.add
local.set $0
local.get $1
i32.const 1
i32.add
local.set $1
br $continue|0
end
end
local.get $2
if (result i32)
local.get $0
i32.load8_u
local.get $1
i32.load8_u
i32.sub
else
i32.const 0
end
end
)
(func $null (; 23 ;) (type $FUNCSIG$v)
nop
)
)

File diff suppressed because it is too large Load Diff