Implement a mechanism to realloc array buffers; Trap when trying to allocate more than max size; Test allocators in CI

This commit is contained in:
dcodeIO 2018-04-08 00:43:38 +02:00
parent dcc0e284fb
commit 9731958738
41 changed files with 2911 additions and 2024 deletions

View File

@ -2,8 +2,8 @@ language: node_js
notifications:
email: false
stages:
- name: check-pr
if: type = pull_request
- name: check-pr
if: type = pull_request
jobs:
include:
@ -24,6 +24,13 @@ jobs:
- node_js: node
script: npm run clean && node bin/asc -v && npm test
env: Tests the sources on latest stable node.js
- node_js: lts/*
script:
- npm run clean
- cd $TRAVIS_BUILD_DIR/tests/allocators/arena && npm run build && cd .. && npm test arena
- cd $TRAVIS_BUILD_DIR/tests/allocators/buddy && npm run build && cd .. && npm test buddy
- cd $TRAVIS_BUILD_DIR/tests/allocators/tlsf && npm run build && cd .. && npm test tlsf
env: Tests the allocators on latest node.js LTS
- stage: build
node_js: lts/*

View File

@ -279,10 +279,12 @@ exports.main = function main(argv, options, callback) {
sourceText = readFile(path.join(dir, plainName + ".ts"));
if (sourceText !== null) {
sourcePath = exports.libraryPrefix + plainName + ".ts";
break;
} else {
sourceText = readFile(path.join(dir, indexName + ".ts"));
if (sourceText !== null) {
sourcePath = exports.libraryPrefix + indexName + ".ts";
break;
}
}
}
@ -312,10 +314,12 @@ exports.main = function main(argv, options, callback) {
sourceText = readFile(path.join(dir, plainName + ".ts"));
if (sourceText !== null) {
sourcePath = exports.libraryPrefix + plainName + ".ts";
break;
} else {
sourceText = readFile(path.join(dir, indexName + ".ts"));
if (sourceText !== null) {
sourcePath = exports.libraryPrefix + indexName + ".ts";
break;
}
}
}
@ -530,12 +534,17 @@ exports.main = function main(argv, options, callback) {
sourceMap.sources.forEach((name, index) => {
let text = null;
if (name.startsWith(exports.libraryPrefix)) {
for (let i = 0, k = customLibDirs.length; i < k; ++i) {
text = readFile(path.join(
customLibDirs[i],
name.substring(exports.libraryPrefix.length))
);
if (text !== null) break;
let stdName = name.substring(exports.libraryPrefix.length).replace(/\.ts$/, "");
if (exports.libraryFiles.hasOwnProperty(stdName)) {
text = exports.libraryFiles[stdName];
} else {
for (let i = 0, k = customLibDirs.length; i < k; ++i) {
text = readFile(path.join(
customLibDirs[i],
name.substring(exports.libraryPrefix.length))
);
if (text !== null) break;
}
}
} else {
text = readFile(path.join(baseDir, name));

2
dist/asc.js vendored

File diff suppressed because one or more lines are too long

2
dist/asc.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -7,15 +7,15 @@
* @module std/assembly/allocator/arena
*//***/
import { AL_MASK } from "../internal/allocator";
import { AL_MASK, MAX_SIZE_32 } from "../internal/allocator";
var startOffset: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK;
var offset: usize = startOffset;
@global
export function allocate_memory(size: usize): usize {
const MAX_SIZE: usize = 1 << 30;
if (size && size < MAX_SIZE) {
if (size) {
if (size > MAX_SIZE_32) unreachable();
let ptr = offset;
let newPtr = (ptr + size + AL_MASK) & ~AL_MASK;
let pagesBefore = current_memory();

View File

@ -347,9 +347,7 @@ export function allocate_memory(request: usize): usize {
* a hard-coded limit on the maximum allocation size because of the way this
* allocator works.
*/
if (request > MAX_ALLOC - HEADER_SIZE) {
return 0;
}
if (request > MAX_ALLOC - HEADER_SIZE) unreachable();
/*
* Initialize our global state if this is the first call to "malloc". At the

View File

@ -457,7 +457,8 @@ export function allocate_memory(size: usize): usize {
// search for a suitable block
var data: usize = 0;
if (size && size <= Block.MAX_SIZE) {
if (size) {
if (size > Block.MAX_SIZE) unreachable();
// 32-bit MAX_SIZE is 1 << 30 and itself aligned, hence the following can't overflow MAX_SIZE
size = max<usize>((size + AL_MASK) & ~AL_MASK, Block.MIN_SIZE);

View File

@ -1,7 +1,7 @@
import {
HEADER_SIZE,
MAX_BLENGTH,
allocate
allocUnsafe
} from "./internal/arraybuffer";
@sealed
@ -11,7 +11,7 @@ export class ArrayBuffer {
constructor(length: i32) {
if (<u32>length > <u32>MAX_BLENGTH) throw new RangeError("Invalid array buffer length");
var buffer = allocate(length);
var buffer = allocUnsafe(length);
set_memory(changetype<usize>(buffer) + HEADER_SIZE, 0, <usize>length);
return buffer;
}
@ -23,7 +23,7 @@ export class ArrayBuffer {
if (end < 0) end = max(len + end, 0);
else end = min(end, len);
var newLen = max(end - begin, 0);
var buffer = allocate(newLen);
var buffer = allocUnsafe(newLen);
move_memory(changetype<usize>(buffer) + HEADER_SIZE, changetype<usize>(this) + HEADER_SIZE + begin, newLen);
return buffer;
}

View File

@ -17,14 +17,44 @@ export function computeSize(byteLength: i32): usize {
return <usize>1 << <usize>(<u32>32 - clz<u32>(byteLength + HEADER_SIZE - 1));
}
/** Allocates a raw ArrayBuffer with uninitialized contents. */
export function allocate(byteLength: i32): ArrayBuffer {
/** Allocates a raw ArrayBuffer. Contents remain uninitialized. */
export function allocUnsafe(byteLength: i32): ArrayBuffer {
assert(<u32>byteLength <= <u32>MAX_BLENGTH);
var buffer = allocate_memory(computeSize(byteLength));
store<i32>(buffer, byteLength, offsetof<ArrayBuffer>("byteLength"));
return changetype<ArrayBuffer>(buffer);
}
/** Reallocates an ArrayBuffer, resizing it as requested. Tries to modify the buffer in place. */
export function reallocUnsafe(buffer: ArrayBuffer, newByteLength: i32): ArrayBuffer {
var oldByteLength = buffer.byteLength;
if (newByteLength > oldByteLength) {
assert(newByteLength <= MAX_BLENGTH);
let oldSize = computeSize(oldByteLength);
if (<i32>(oldSize - HEADER_SIZE) <= newByteLength) { // fast path: zero out additional space
store<i32>(changetype<usize>(buffer), newByteLength, offsetof<ArrayBuffer>("byteLength"));
set_memory(
changetype<usize>(buffer) + HEADER_SIZE + oldByteLength,
0,
<usize>(newByteLength - oldByteLength)
);
} else { // slow path: copy to new buffer
let newBuffer = allocUnsafe(newByteLength);
move_memory(
changetype<usize>(newBuffer) + HEADER_SIZE,
changetype<usize>(buffer) + HEADER_SIZE,
<usize>newByteLength
);
return newBuffer;
}
} else if (newByteLength < oldByteLength) { // fast path: override size
// TBD: worth to copy and release if size is significantly less than before?
assert(newByteLength >= 0);
store<i32>(changetype<usize>(buffer), newByteLength, offsetof<ArrayBuffer>("byteLength"));
}
return buffer;
}
/** Common typed array interface. Not a global object. */
// export declare interface ArrayBufferView<T> {
// readonly buffer: ArrayBuffer;

View File

@ -1,6 +1,7 @@
import {
HEADER_SIZE,
MAX_BLENGTH,
allocate
allocUnsafe
// ArrayBufferView
} from "./arraybuffer";
@ -15,7 +16,9 @@ export abstract class TypedArray<T> /* implements ArrayBufferView<T> */ {
const MAX_LENGTH = <u32>MAX_BLENGTH / sizeof<T>();
if (<u32>length > MAX_LENGTH) throw new RangeError("Invalid typed array length");
var byteLength = length << alignof<T>();
this.buffer = allocate(byteLength);
var buffer = allocUnsafe(byteLength);
set_memory(changetype<usize>(buffer) + HEADER_SIZE, 0, <usize>byteLength);
this.buffer = buffer;
this.byteOffset = 0;
this.byteLength = byteLength;
}

View File

@ -16,21 +16,23 @@
(local $2 i32)
(local $3 i32)
(local $4 i32)
;;@ ~lib/allocator/arena.ts:18:2
;;@ ~lib/allocator/arena.ts:17:2
(if
(select
;;@ ~lib/allocator/arena.ts:18:14
(i32.lt_u
(get_local $0)
;;@ ~lib/allocator/arena.ts:18:21
(i32.const 1073741824)
)
(get_local $0)
;;@ ~lib/allocator/arena.ts:18:6
(get_local $0)
)
;;@ ~lib/allocator/arena.ts:18:31
;;@ ~lib/allocator/arena.ts:17:6
(get_local $0)
;;@ ~lib/allocator/arena.ts:17:12
(block
;;@ ~lib/allocator/arena.ts:18:4
(if
;;@ ~lib/allocator/arena.ts:18:8
(i32.gt_u
(get_local $0)
;;@ ~lib/allocator/arena.ts:18:15
(i32.const 1073741824)
)
;;@ ~lib/allocator/arena.ts:18:28
(unreachable)
)
;;@ ~lib/allocator/arena.ts:22:4
(if
;;@ ~lib/allocator/arena.ts:22:8

View File

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

View File

@ -3,10 +3,10 @@
(type $ii (func (param i32) (result i32)))
(type $iv (func (param i32)))
(type $v (func))
(global $~lib/allocator/common/index/AL_BITS i32 (i32.const 3))
(global $~lib/allocator/common/index/AL_SIZE i32 (i32.const 8))
(global $~lib/allocator/common/index/AL_MASK i32 (i32.const 7))
(global $~lib/allocator/common/index/MAX_SIZE_32 i32 (i32.const 1073741824))
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
(global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8))
(global $~lib/internal/allocator/AL_MASK i32 (i32.const 7))
(global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 4))
@ -24,22 +24,22 @@
(local $5 i32)
(local $6 i32)
;;@ ~lib/allocator/arena.ts:17:2
(nop)
;;@ ~lib/allocator/arena.ts:18:2
(if
;;@ ~lib/allocator/arena.ts:18:6
(if (result i32)
(get_local $0)
;;@ ~lib/allocator/arena.ts:18:14
(i32.lt_u
(get_local $0)
;;@ ~lib/allocator/arena.ts:18:21
(i32.const 1073741824)
)
(get_local $0)
)
;;@ ~lib/allocator/arena.ts:18:31
;;@ ~lib/allocator/arena.ts:17:6
(get_local $0)
;;@ ~lib/allocator/arena.ts:17:12
(block
;;@ ~lib/allocator/arena.ts:18:4
(if
;;@ ~lib/allocator/arena.ts:18:8
(i32.gt_u
(get_local $0)
;;@ ~lib/allocator/arena.ts:18:15
(i32.const 1073741824)
)
;;@ ~lib/allocator/arena.ts:18:28
(unreachable)
)
;;@ ~lib/allocator/arena.ts:19:4
(set_local $1
;;@ ~lib/allocator/arena.ts:19:14

View File

@ -577,95 +577,93 @@
;;@ ~lib/allocator/buddy.ts:350:16
(i32.const 1073741816)
)
;;@ ~lib/allocator/buddy.ts:351:11
(return
(i32.const 0)
)
;;@ ~lib/allocator/buddy.ts:350:41
(unreachable)
)
;;@ ~lib/allocator/buddy.ts:359:2
;;@ ~lib/allocator/buddy.ts:357:2
(if
(i32.eqz
;;@ ~lib/allocator/buddy.ts:359:6
;;@ ~lib/allocator/buddy.ts:357:6
(get_global $~lib/allocator/buddy/base_ptr)
)
;;@ ~lib/allocator/buddy.ts:359:21
;;@ ~lib/allocator/buddy.ts:357:21
(block
;;@ ~lib/allocator/buddy.ts:361:4
;;@ ~lib/allocator/buddy.ts:359:4
(set_global $~lib/allocator/buddy/base_ptr
;;@ ~lib/allocator/buddy.ts:361:15
;;@ ~lib/allocator/buddy.ts:359:15
(i32.and
(i32.add
;;@ ~lib/allocator/buddy.ts:361:16
;;@ ~lib/allocator/buddy.ts:359:16
(get_global $~lib/allocator/buddy/NODE_IS_SPLIT_END)
;;@ ~lib/allocator/buddy.ts:361:36
;;@ ~lib/allocator/buddy.ts:359:36
(i32.const 7)
)
(i32.const -8)
)
)
;;@ ~lib/allocator/buddy.ts:362:4
;;@ ~lib/allocator/buddy.ts:360:4
(set_global $~lib/allocator/buddy/max_ptr
;;@ ~lib/allocator/buddy.ts:362:14
;;@ ~lib/allocator/buddy.ts:360:14
(i32.shl
(current_memory)
;;@ ~lib/allocator/buddy.ts:362:41
;;@ ~lib/allocator/buddy.ts:360:41
(i32.const 16)
)
)
;;@ ~lib/allocator/buddy.ts:363:4
;;@ ~lib/allocator/buddy.ts:361:4
(set_global $~lib/allocator/buddy/bucket_limit
;;@ ~lib/allocator/buddy.ts:363:19
;;@ ~lib/allocator/buddy.ts:361:19
(i32.const 26)
)
;;@ ~lib/allocator/buddy.ts:364:4
;;@ ~lib/allocator/buddy.ts:362:4
(if
;;@ ~lib/allocator/buddy.ts:364:8
;;@ ~lib/allocator/buddy.ts:362:8
(i32.eqz
;;@ ~lib/allocator/buddy.ts:364:9
;;@ ~lib/allocator/buddy.ts:362:9
(call $~lib/allocator/buddy/update_max_ptr
;;@ ~lib/allocator/buddy.ts:364:24
;;@ ~lib/allocator/buddy.ts:362:24
(i32.add
(get_global $~lib/allocator/buddy/base_ptr)
;;@ ~lib/allocator/buddy.ts:364:35
;;@ ~lib/allocator/buddy.ts:362:35
(i32.const 8)
)
)
)
;;@ ~lib/allocator/buddy.ts:365:13
;;@ ~lib/allocator/buddy.ts:363:13
(return
(i32.const 0)
)
)
;;@ ~lib/allocator/buddy.ts:367:4
;;@ ~lib/allocator/buddy.ts:365:4
(call $~lib/allocator/buddy/list_init
;;@ ~lib/allocator/buddy.ts:367:14
;;@ ~lib/allocator/buddy.ts:365:14
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:367:26
;;@ ~lib/allocator/buddy.ts:365:26
(i32.const 26)
)
)
;;@ ~lib/allocator/buddy.ts:368:4
;;@ ~lib/allocator/buddy.ts:366:4
(call $~lib/allocator/buddy/list_push
;;@ ~lib/allocator/buddy.ts:368:14
;;@ ~lib/allocator/buddy.ts:366:14
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:368:26
;;@ ~lib/allocator/buddy.ts:366:26
(i32.const 26)
)
;;@ ~lib/allocator/buddy.ts:368:45
;;@ ~lib/allocator/buddy.ts:366:45
(get_global $~lib/allocator/buddy/base_ptr)
)
)
)
;;@ ~lib/allocator/buddy.ts:376:2
;;@ ~lib/allocator/buddy.ts:374:2
(set_local $4
;;@ ~lib/allocator/buddy.ts:375:2
;;@ ~lib/allocator/buddy.ts:373:2
(tee_local $1
;;@ ~lib/allocator/buddy.ts:375:11
;;@ ~lib/allocator/buddy.ts:373:11
(call $~lib/allocator/buddy/bucket_for_request
;;@ ~lib/allocator/buddy.ts:375:30
;;@ ~lib/allocator/buddy.ts:373:30
(i32.add
(get_local $0)
;;@ ~lib/allocator/buddy.ts:375:40
;;@ ~lib/allocator/buddy.ts:373:40
(i32.const 8)
)
)
@ -673,224 +671,224 @@
)
(loop $continue|0
(if
;;@ ~lib/allocator/buddy.ts:383:9
;;@ ~lib/allocator/buddy.ts:381:9
(i32.add
(get_local $1)
;;@ ~lib/allocator/buddy.ts:383:18
;;@ ~lib/allocator/buddy.ts:381:18
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:383:26
;;@ ~lib/allocator/buddy.ts:381:26
(block
;;@ ~lib/allocator/buddy.ts:391:4
;;@ ~lib/allocator/buddy.ts:389:4
(if
;;@ ~lib/allocator/buddy.ts:391:8
;;@ ~lib/allocator/buddy.ts:389:8
(i32.eqz
;;@ ~lib/allocator/buddy.ts:391:9
;;@ ~lib/allocator/buddy.ts:389:9
(call $~lib/allocator/buddy/lower_bucket_limit
;;@ ~lib/allocator/buddy.ts:391:28
;;@ ~lib/allocator/buddy.ts:389:28
(get_local $1)
)
)
;;@ ~lib/allocator/buddy.ts:392:13
;;@ ~lib/allocator/buddy.ts:390:13
(return
(i32.const 0)
)
)
;;@ ~lib/allocator/buddy.ts:400:4
;;@ ~lib/allocator/buddy.ts:398:4
(if
;;@ ~lib/allocator/buddy.ts:400:8
;;@ ~lib/allocator/buddy.ts:398:8
(i32.eqz
;;@ ~lib/allocator/buddy.ts:399:4
;;@ ~lib/allocator/buddy.ts:397:4
(tee_local $2
;;@ ~lib/allocator/buddy.ts:399:10
;;@ ~lib/allocator/buddy.ts:397:10
(call $~lib/allocator/buddy/list_pop
;;@ ~lib/allocator/buddy.ts:399:37
;;@ ~lib/allocator/buddy.ts:397:37
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:399:49
;;@ ~lib/allocator/buddy.ts:397:49
(get_local $1)
)
)
)
)
;;@ ~lib/allocator/buddy.ts:400:14
;;@ ~lib/allocator/buddy.ts:398:14
(block
;;@ ~lib/allocator/buddy.ts:405:6
;;@ ~lib/allocator/buddy.ts:403:6
(if
;;@ ~lib/allocator/buddy.ts:405:10
;;@ ~lib/allocator/buddy.ts:403:10
(i32.and
(if (result i32)
(tee_local $2
(i32.ne
(get_local $1)
;;@ ~lib/allocator/buddy.ts:405:20
;;@ ~lib/allocator/buddy.ts:403:20
(get_global $~lib/allocator/buddy/bucket_limit)
)
)
(get_local $2)
(i32.eqz
;;@ ~lib/allocator/buddy.ts:405:36
;;@ ~lib/allocator/buddy.ts:403:36
(get_local $1)
)
)
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:405:49
;;@ ~lib/allocator/buddy.ts:403:49
(block
;;@ ~lib/allocator/buddy.ts:406:8
;;@ ~lib/allocator/buddy.ts:404:8
(set_local $1
(i32.sub
(get_local $1)
(i32.const 1)
)
)
;;@ ~lib/allocator/buddy.ts:407:8
;;@ ~lib/allocator/buddy.ts:405:8
(br $continue|0)
)
)
;;@ ~lib/allocator/buddy.ts:417:6
;;@ ~lib/allocator/buddy.ts:415:6
(if
;;@ ~lib/allocator/buddy.ts:417:10
;;@ ~lib/allocator/buddy.ts:415:10
(i32.eqz
;;@ ~lib/allocator/buddy.ts:417:11
;;@ ~lib/allocator/buddy.ts:415:11
(call $~lib/allocator/buddy/lower_bucket_limit
;;@ ~lib/allocator/buddy.ts:417:30
;;@ ~lib/allocator/buddy.ts:415:30
(i32.sub
(get_local $1)
;;@ ~lib/allocator/buddy.ts:417:39
;;@ ~lib/allocator/buddy.ts:415:39
(i32.const 1)
)
)
)
;;@ ~lib/allocator/buddy.ts:418:15
;;@ ~lib/allocator/buddy.ts:416:15
(return
(i32.const 0)
)
)
;;@ ~lib/allocator/buddy.ts:420:6
;;@ ~lib/allocator/buddy.ts:418:6
(set_local $2
;;@ ~lib/allocator/buddy.ts:420:12
;;@ ~lib/allocator/buddy.ts:418:12
(call $~lib/allocator/buddy/list_pop
;;@ ~lib/allocator/buddy.ts:420:39
;;@ ~lib/allocator/buddy.ts:418:39
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:420:51
;;@ ~lib/allocator/buddy.ts:418:51
(get_local $1)
)
)
)
)
)
;;@ ~lib/allocator/buddy.ts:427:4
;;@ ~lib/allocator/buddy.ts:425:4
(set_local $3
;;@ ~lib/allocator/buddy.ts:427:11
;;@ ~lib/allocator/buddy.ts:425:11
(i32.shl
(i32.const 1)
;;@ ~lib/allocator/buddy.ts:427:16
;;@ ~lib/allocator/buddy.ts:425:16
(i32.sub
;;@ ~lib/allocator/buddy.ts:427:17
;;@ ~lib/allocator/buddy.ts:425:17
(i32.const 30)
;;@ ~lib/allocator/buddy.ts:427:34
;;@ ~lib/allocator/buddy.ts:425:34
(get_local $1)
)
)
)
;;@ ~lib/allocator/buddy.ts:429:4
;;@ ~lib/allocator/buddy.ts:427:4
(if
;;@ ~lib/allocator/buddy.ts:429:8
;;@ ~lib/allocator/buddy.ts:427:8
(i32.eqz
;;@ ~lib/allocator/buddy.ts:429:9
;;@ ~lib/allocator/buddy.ts:427:9
(call $~lib/allocator/buddy/update_max_ptr
;;@ ~lib/allocator/buddy.ts:429:24
;;@ ~lib/allocator/buddy.ts:427:24
(i32.add
(get_local $2)
;;@ ~lib/allocator/buddy.ts:428:19
;;@ ~lib/allocator/buddy.ts:426:19
(if (result i32)
(i32.lt_u
(get_local $1)
;;@ ~lib/allocator/buddy.ts:428:28
;;@ ~lib/allocator/buddy.ts:426:28
(get_local $4)
)
;;@ ~lib/allocator/buddy.ts:428:46
;;@ ~lib/allocator/buddy.ts:426:46
(i32.add
(i32.div_u
(get_local $3)
;;@ ~lib/allocator/buddy.ts:428:53
;;@ ~lib/allocator/buddy.ts:426:53
(i32.const 2)
)
;;@ ~lib/allocator/buddy.ts:428:57
;;@ ~lib/allocator/buddy.ts:426:57
(i32.const 8)
)
;;@ ~lib/allocator/buddy.ts:428:69
;;@ ~lib/allocator/buddy.ts:426:69
(get_local $3)
)
)
)
)
;;@ ~lib/allocator/buddy.ts:429:45
;;@ ~lib/allocator/buddy.ts:427:45
(block
;;@ ~lib/allocator/buddy.ts:430:6
;;@ ~lib/allocator/buddy.ts:428:6
(call $~lib/allocator/buddy/list_push
;;@ ~lib/allocator/buddy.ts:430:16
;;@ ~lib/allocator/buddy.ts:428:16
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:430:28
;;@ ~lib/allocator/buddy.ts:428:28
(get_local $1)
)
;;@ ~lib/allocator/buddy.ts:430:37
;;@ ~lib/allocator/buddy.ts:428:37
(get_local $2)
)
;;@ ~lib/allocator/buddy.ts:431:13
;;@ ~lib/allocator/buddy.ts:429:13
(return
(i32.const 0)
)
)
)
;;@ ~lib/allocator/buddy.ts:446:4
;;@ ~lib/allocator/buddy.ts:444:4
(if
;;@ ~lib/allocator/buddy.ts:445:4
;;@ ~lib/allocator/buddy.ts:443:4
(tee_local $3
;;@ ~lib/allocator/buddy.ts:445:8
;;@ ~lib/allocator/buddy.ts:443:8
(call $~lib/allocator/buddy/node_for_ptr
;;@ ~lib/allocator/buddy.ts:445:21
;;@ ~lib/allocator/buddy.ts:443:21
(get_local $2)
;;@ ~lib/allocator/buddy.ts:445:26
;;@ ~lib/allocator/buddy.ts:443:26
(get_local $1)
)
)
;;@ ~lib/allocator/buddy.ts:447:6
;;@ ~lib/allocator/buddy.ts:445:6
(call $~lib/allocator/buddy/flip_parent_is_split
;;@ ~lib/allocator/buddy.ts:447:27
;;@ ~lib/allocator/buddy.ts:445:27
(get_local $3)
)
)
(loop $continue|1
(if
;;@ ~lib/allocator/buddy.ts:457:11
;;@ ~lib/allocator/buddy.ts:455:11
(i32.lt_u
(get_local $1)
;;@ ~lib/allocator/buddy.ts:457:20
;;@ ~lib/allocator/buddy.ts:455:20
(get_local $4)
)
(block
;;@ ~lib/allocator/buddy.ts:460:6
;;@ ~lib/allocator/buddy.ts:458:6
(call $~lib/allocator/buddy/flip_parent_is_split
;;@ ~lib/allocator/buddy.ts:458:6
;;@ ~lib/allocator/buddy.ts:456:6
(tee_local $3
;;@ ~lib/allocator/buddy.ts:458:10
;;@ ~lib/allocator/buddy.ts:456:10
(i32.add
(i32.shl
(get_local $3)
;;@ ~lib/allocator/buddy.ts:458:14
;;@ ~lib/allocator/buddy.ts:456:14
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:458:18
;;@ ~lib/allocator/buddy.ts:456:18
(i32.const 1)
)
)
)
;;@ ~lib/allocator/buddy.ts:461:6
;;@ ~lib/allocator/buddy.ts:459:6
(call $~lib/allocator/buddy/list_push
;;@ ~lib/allocator/buddy.ts:462:8
;;@ ~lib/allocator/buddy.ts:460:8
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:459:6
;;@ ~lib/allocator/buddy.ts:457:6
(tee_local $1
(i32.add
(get_local $1)
@ -898,15 +896,15 @@
)
)
)
;;@ ~lib/allocator/buddy.ts:463:8
;;@ ~lib/allocator/buddy.ts:461:8
(call $~lib/allocator/buddy/ptr_for_node
;;@ ~lib/allocator/buddy.ts:463:38
;;@ ~lib/allocator/buddy.ts:461:38
(i32.add
(get_local $3)
;;@ ~lib/allocator/buddy.ts:463:42
;;@ ~lib/allocator/buddy.ts:461:42
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:463:45
;;@ ~lib/allocator/buddy.ts:461:45
(get_local $1)
)
)
@ -914,143 +912,143 @@
)
)
)
;;@ ~lib/allocator/buddy.ts:471:4
;;@ ~lib/allocator/buddy.ts:469:4
(i32.store
;;@ ~lib/allocator/buddy.ts:471:17
;;@ ~lib/allocator/buddy.ts:469:17
(get_local $2)
;;@ ~lib/allocator/buddy.ts:471:22
;;@ ~lib/allocator/buddy.ts:469:22
(get_local $0)
)
;;@ ~lib/allocator/buddy.ts:472:17
;;@ ~lib/allocator/buddy.ts:470:17
(return
;;@ ~lib/allocator/buddy.ts:472:11
;;@ ~lib/allocator/buddy.ts:470:11
(i32.add
(get_local $2)
;;@ ~lib/allocator/buddy.ts:472:17
;;@ ~lib/allocator/buddy.ts:470:17
(i32.const 8)
)
)
)
)
)
;;@ ~lib/allocator/buddy.ts:475:9
;;@ ~lib/allocator/buddy.ts:473:9
(i32.const 0)
)
(func $~lib/allocator/buddy/free_memory (; 14 ;) (type $iv) (param $0 i32)
(local $1 i32)
(local $2 i32)
;;@ ~lib/allocator/buddy.ts:485:2
;;@ ~lib/allocator/buddy.ts:483:2
(if
;;@ ~lib/allocator/buddy.ts:485:6
;;@ ~lib/allocator/buddy.ts:483:6
(i32.eqz
;;@ ~lib/allocator/buddy.ts:485:7
;;@ ~lib/allocator/buddy.ts:483:7
(get_local $0)
)
;;@ ~lib/allocator/buddy.ts:486:4
;;@ ~lib/allocator/buddy.ts:484:4
(return)
)
;;@ ~lib/allocator/buddy.ts:495:2
;;@ ~lib/allocator/buddy.ts:493:2
(set_local $1
;;@ ~lib/allocator/buddy.ts:495:11
;;@ ~lib/allocator/buddy.ts:493:11
(call $~lib/allocator/buddy/bucket_for_request
;;@ ~lib/allocator/buddy.ts:495:30
;;@ ~lib/allocator/buddy.ts:493:30
(i32.add
(i32.load
;;@ ~lib/allocator/buddy.ts:494:2
;;@ ~lib/allocator/buddy.ts:492:2
(tee_local $0
;;@ ~lib/allocator/buddy.ts:494:8
;;@ ~lib/allocator/buddy.ts:492:8
(i32.sub
(get_local $0)
;;@ ~lib/allocator/buddy.ts:494:14
;;@ ~lib/allocator/buddy.ts:492:14
(i32.const 8)
)
)
)
;;@ ~lib/allocator/buddy.ts:495:49
;;@ ~lib/allocator/buddy.ts:493:49
(i32.const 8)
)
)
)
;;@ ~lib/allocator/buddy.ts:496:2
;;@ ~lib/allocator/buddy.ts:494:2
(set_local $0
;;@ ~lib/allocator/buddy.ts:496:6
;;@ ~lib/allocator/buddy.ts:494:6
(call $~lib/allocator/buddy/node_for_ptr
;;@ ~lib/allocator/buddy.ts:496:19
;;@ ~lib/allocator/buddy.ts:494:19
(get_local $0)
;;@ ~lib/allocator/buddy.ts:496:24
;;@ ~lib/allocator/buddy.ts:494:24
(get_local $1)
)
)
;;@ ~lib/allocator/buddy.ts:502:2
;;@ ~lib/allocator/buddy.ts:500:2
(block $break|0
(loop $continue|0
(if
;;@ ~lib/allocator/buddy.ts:502:9
;;@ ~lib/allocator/buddy.ts:500:9
(get_local $0)
(block
;;@ ~lib/allocator/buddy.ts:509:4
;;@ ~lib/allocator/buddy.ts:507:4
(call $~lib/allocator/buddy/flip_parent_is_split
;;@ ~lib/allocator/buddy.ts:509:25
;;@ ~lib/allocator/buddy.ts:507:25
(get_local $0)
)
;;@ ~lib/allocator/buddy.ts:520:6
;;@ ~lib/allocator/buddy.ts:518:6
(br_if $break|0
;;@ ~lib/allocator/buddy.ts:519:8
;;@ ~lib/allocator/buddy.ts:517:8
(if (result i32)
(tee_local $2
(call $~lib/allocator/buddy/parent_is_split
;;@ ~lib/allocator/buddy.ts:519:24
;;@ ~lib/allocator/buddy.ts:517:24
(get_local $0)
)
)
(get_local $2)
;;@ ~lib/allocator/buddy.ts:519:30
;;@ ~lib/allocator/buddy.ts:517:30
(i32.eq
(get_local $1)
;;@ ~lib/allocator/buddy.ts:519:40
;;@ ~lib/allocator/buddy.ts:517:40
(get_global $~lib/allocator/buddy/bucket_limit)
)
)
)
;;@ ~lib/allocator/buddy.ts:530:4
;;@ ~lib/allocator/buddy.ts:528:4
(call $~lib/allocator/buddy/list_remove
;;@ ~lib/allocator/buddy.ts:530:16
;;@ ~lib/allocator/buddy.ts:528:16
(call $~lib/allocator/buddy/ptr_for_node
;;@ ~lib/allocator/buddy.ts:530:46
;;@ ~lib/allocator/buddy.ts:528:46
(i32.add
(i32.xor
;;@ ~lib/allocator/buddy.ts:530:47
;;@ ~lib/allocator/buddy.ts:528:47
(i32.sub
;;@ ~lib/allocator/buddy.ts:530:48
;;@ ~lib/allocator/buddy.ts:528:48
(get_local $0)
;;@ ~lib/allocator/buddy.ts:530:52
;;@ ~lib/allocator/buddy.ts:528:52
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:530:57
;;@ ~lib/allocator/buddy.ts:528:57
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:530:62
;;@ ~lib/allocator/buddy.ts:528:62
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:530:65
;;@ ~lib/allocator/buddy.ts:528:65
(get_local $1)
)
)
;;@ ~lib/allocator/buddy.ts:531:4
;;@ ~lib/allocator/buddy.ts:529:4
(set_local $0
;;@ ~lib/allocator/buddy.ts:531:8
;;@ ~lib/allocator/buddy.ts:529:8
(i32.div_u
(i32.sub
;;@ ~lib/allocator/buddy.ts:531:9
;;@ ~lib/allocator/buddy.ts:529:9
(get_local $0)
;;@ ~lib/allocator/buddy.ts:531:13
;;@ ~lib/allocator/buddy.ts:529:13
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:531:18
;;@ ~lib/allocator/buddy.ts:529:18
(i32.const 2)
)
)
;;@ ~lib/allocator/buddy.ts:532:4
;;@ ~lib/allocator/buddy.ts:530:4
(set_local $1
(i32.sub
(get_local $1)
@ -1062,18 +1060,18 @@
)
)
)
;;@ ~lib/allocator/buddy.ts:541:2
;;@ ~lib/allocator/buddy.ts:539:2
(call $~lib/allocator/buddy/list_push
;;@ ~lib/allocator/buddy.ts:541:12
;;@ ~lib/allocator/buddy.ts:539:12
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:541:24
;;@ ~lib/allocator/buddy.ts:539:24
(get_local $1)
)
;;@ ~lib/allocator/buddy.ts:541:33
;;@ ~lib/allocator/buddy.ts:539:33
(call $~lib/allocator/buddy/ptr_for_node
;;@ ~lib/allocator/buddy.ts:541:63
;;@ ~lib/allocator/buddy.ts:539:63
(get_local $0)
;;@ ~lib/allocator/buddy.ts:541:66
;;@ ~lib/allocator/buddy.ts:539:66
(get_local $1)
)
)

View File

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

View File

@ -752,389 +752,387 @@
(i32.const 8)
)
)
;;@ ~lib/allocator/buddy.ts:351:11
(return
(i32.const 0)
)
;;@ ~lib/allocator/buddy.ts:350:41
(unreachable)
)
;;@ ~lib/allocator/buddy.ts:359:2
;;@ ~lib/allocator/buddy.ts:357:2
(if
;;@ ~lib/allocator/buddy.ts:359:6
;;@ ~lib/allocator/buddy.ts:357:6
(i32.eq
(get_global $~lib/allocator/buddy/base_ptr)
;;@ ~lib/allocator/buddy.ts:359:18
;;@ ~lib/allocator/buddy.ts:357:18
(i32.const 0)
)
;;@ ~lib/allocator/buddy.ts:359:21
;;@ ~lib/allocator/buddy.ts:357:21
(block
;;@ ~lib/allocator/buddy.ts:361:4
;;@ ~lib/allocator/buddy.ts:359:4
(set_global $~lib/allocator/buddy/base_ptr
;;@ ~lib/allocator/buddy.ts:361:15
;;@ ~lib/allocator/buddy.ts:359:15
(i32.and
(i32.add
;;@ ~lib/allocator/buddy.ts:361:16
;;@ ~lib/allocator/buddy.ts:359:16
(get_global $~lib/allocator/buddy/NODE_IS_SPLIT_END)
;;@ ~lib/allocator/buddy.ts:361:36
;;@ ~lib/allocator/buddy.ts:359:36
(i32.const 7)
)
;;@ ~lib/allocator/buddy.ts:361:41
;;@ ~lib/allocator/buddy.ts:359:41
(i32.xor
;;@ ~lib/allocator/buddy.ts:361:42
;;@ ~lib/allocator/buddy.ts:359:42
(i32.const 7)
(i32.const -1)
)
)
)
;;@ ~lib/allocator/buddy.ts:362:4
;;@ ~lib/allocator/buddy.ts:360:4
(set_global $~lib/allocator/buddy/max_ptr
;;@ ~lib/allocator/buddy.ts:362:14
;;@ ~lib/allocator/buddy.ts:360:14
(i32.shl
(current_memory)
;;@ ~lib/allocator/buddy.ts:362:41
;;@ ~lib/allocator/buddy.ts:360:41
(i32.const 16)
)
)
;;@ ~lib/allocator/buddy.ts:363:4
;;@ ~lib/allocator/buddy.ts:361:4
(set_global $~lib/allocator/buddy/bucket_limit
;;@ ~lib/allocator/buddy.ts:363:19
;;@ ~lib/allocator/buddy.ts:361:19
(i32.sub
(i32.const 27)
;;@ ~lib/allocator/buddy.ts:363:34
;;@ ~lib/allocator/buddy.ts:361:34
(i32.const 1)
)
)
;;@ ~lib/allocator/buddy.ts:364:4
;;@ ~lib/allocator/buddy.ts:362:4
(if
;;@ ~lib/allocator/buddy.ts:364:8
;;@ ~lib/allocator/buddy.ts:362:8
(i32.eqz
;;@ ~lib/allocator/buddy.ts:364:9
;;@ ~lib/allocator/buddy.ts:362:9
(call $~lib/allocator/buddy/update_max_ptr
;;@ ~lib/allocator/buddy.ts:364:24
;;@ ~lib/allocator/buddy.ts:362:24
(i32.add
(get_global $~lib/allocator/buddy/base_ptr)
;;@ ~lib/allocator/buddy.ts:364:35
;;@ ~lib/allocator/buddy.ts:362:35
(i32.const 8)
)
)
)
;;@ ~lib/allocator/buddy.ts:365:13
;;@ ~lib/allocator/buddy.ts:363:13
(return
(i32.const 0)
)
)
;;@ ~lib/allocator/buddy.ts:367:4
;;@ ~lib/allocator/buddy.ts:365:4
(call $~lib/allocator/buddy/list_init
;;@ ~lib/allocator/buddy.ts:367:14
;;@ ~lib/allocator/buddy.ts:365:14
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:367:26
;;@ ~lib/allocator/buddy.ts:365:26
(i32.sub
(i32.const 27)
;;@ ~lib/allocator/buddy.ts:367:41
;;@ ~lib/allocator/buddy.ts:365:41
(i32.const 1)
)
)
)
;;@ ~lib/allocator/buddy.ts:368:4
;;@ ~lib/allocator/buddy.ts:366:4
(call $~lib/allocator/buddy/list_push
;;@ ~lib/allocator/buddy.ts:368:14
;;@ ~lib/allocator/buddy.ts:366:14
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:368:26
;;@ ~lib/allocator/buddy.ts:366:26
(i32.sub
(i32.const 27)
;;@ ~lib/allocator/buddy.ts:368:41
;;@ ~lib/allocator/buddy.ts:366:41
(i32.const 1)
)
)
;;@ ~lib/allocator/buddy.ts:368:45
;;@ ~lib/allocator/buddy.ts:366:45
(get_global $~lib/allocator/buddy/base_ptr)
)
)
)
;;@ ~lib/allocator/buddy.ts:375:2
;;@ ~lib/allocator/buddy.ts:373:2
(set_local $2
;;@ ~lib/allocator/buddy.ts:375:11
;;@ ~lib/allocator/buddy.ts:373:11
(call $~lib/allocator/buddy/bucket_for_request
;;@ ~lib/allocator/buddy.ts:375:30
;;@ ~lib/allocator/buddy.ts:373:30
(i32.add
(get_local $0)
;;@ ~lib/allocator/buddy.ts:375:40
;;@ ~lib/allocator/buddy.ts:373:40
(i32.const 8)
)
)
)
;;@ ~lib/allocator/buddy.ts:376:2
;;@ ~lib/allocator/buddy.ts:374:2
(set_local $1
;;@ ~lib/allocator/buddy.ts:376:20
;;@ ~lib/allocator/buddy.ts:374:20
(get_local $2)
)
;;@ ~lib/allocator/buddy.ts:383:2
;;@ ~lib/allocator/buddy.ts:381:2
(block $break|0
(loop $continue|0
(if
;;@ ~lib/allocator/buddy.ts:383:9
;;@ ~lib/allocator/buddy.ts:381:9
(i32.ne
(i32.add
(get_local $2)
;;@ ~lib/allocator/buddy.ts:383:18
;;@ ~lib/allocator/buddy.ts:381:18
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:383:23
;;@ ~lib/allocator/buddy.ts:381:23
(i32.const 0)
)
(block
(block
;;@ ~lib/allocator/buddy.ts:384:4
;;@ ~lib/allocator/buddy.ts:382:4
(nop)
;;@ ~lib/allocator/buddy.ts:385:4
;;@ ~lib/allocator/buddy.ts:383:4
(nop)
;;@ ~lib/allocator/buddy.ts:391:4
;;@ ~lib/allocator/buddy.ts:389:4
(if
;;@ ~lib/allocator/buddy.ts:391:8
;;@ ~lib/allocator/buddy.ts:389:8
(i32.eqz
;;@ ~lib/allocator/buddy.ts:391:9
;;@ ~lib/allocator/buddy.ts:389:9
(call $~lib/allocator/buddy/lower_bucket_limit
;;@ ~lib/allocator/buddy.ts:391:28
;;@ ~lib/allocator/buddy.ts:389:28
(get_local $2)
)
)
;;@ ~lib/allocator/buddy.ts:392:13
;;@ ~lib/allocator/buddy.ts:390:13
(return
(i32.const 0)
)
)
;;@ ~lib/allocator/buddy.ts:399:4
;;@ ~lib/allocator/buddy.ts:397:4
(set_local $6
;;@ ~lib/allocator/buddy.ts:399:10
;;@ ~lib/allocator/buddy.ts:397:10
(call $~lib/allocator/buddy/list_pop
;;@ ~lib/allocator/buddy.ts:399:37
;;@ ~lib/allocator/buddy.ts:397:37
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:399:49
;;@ ~lib/allocator/buddy.ts:397:49
(get_local $2)
)
)
)
;;@ ~lib/allocator/buddy.ts:400:4
;;@ ~lib/allocator/buddy.ts:398:4
(if
;;@ ~lib/allocator/buddy.ts:400:8
;;@ ~lib/allocator/buddy.ts:398:8
(i32.eqz
;;@ ~lib/allocator/buddy.ts:400:9
;;@ ~lib/allocator/buddy.ts:398:9
(get_local $6)
)
;;@ ~lib/allocator/buddy.ts:400:14
;;@ ~lib/allocator/buddy.ts:398:14
(block
;;@ ~lib/allocator/buddy.ts:405:6
;;@ ~lib/allocator/buddy.ts:403:6
(if
;;@ ~lib/allocator/buddy.ts:405:10
;;@ ~lib/allocator/buddy.ts:403:10
(i32.and
(if (result i32)
(tee_local $7
(i32.ne
(get_local $2)
;;@ ~lib/allocator/buddy.ts:405:20
;;@ ~lib/allocator/buddy.ts:403:20
(get_global $~lib/allocator/buddy/bucket_limit)
)
)
(get_local $7)
;;@ ~lib/allocator/buddy.ts:405:36
;;@ ~lib/allocator/buddy.ts:403:36
(i32.eq
(get_local $2)
;;@ ~lib/allocator/buddy.ts:405:46
;;@ ~lib/allocator/buddy.ts:403:46
(i32.const 0)
)
)
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:405:49
;;@ ~lib/allocator/buddy.ts:403:49
(block
;;@ ~lib/allocator/buddy.ts:406:8
;;@ ~lib/allocator/buddy.ts:404:8
(set_local $2
(i32.sub
(get_local $2)
(i32.const 1)
)
)
;;@ ~lib/allocator/buddy.ts:407:8
;;@ ~lib/allocator/buddy.ts:405:8
(br $continue|0)
)
)
;;@ ~lib/allocator/buddy.ts:417:6
;;@ ~lib/allocator/buddy.ts:415:6
(if
;;@ ~lib/allocator/buddy.ts:417:10
;;@ ~lib/allocator/buddy.ts:415:10
(i32.eqz
;;@ ~lib/allocator/buddy.ts:417:11
;;@ ~lib/allocator/buddy.ts:415:11
(call $~lib/allocator/buddy/lower_bucket_limit
;;@ ~lib/allocator/buddy.ts:417:30
;;@ ~lib/allocator/buddy.ts:415:30
(i32.sub
(get_local $2)
;;@ ~lib/allocator/buddy.ts:417:39
;;@ ~lib/allocator/buddy.ts:415:39
(i32.const 1)
)
)
)
;;@ ~lib/allocator/buddy.ts:418:15
;;@ ~lib/allocator/buddy.ts:416:15
(return
(i32.const 0)
)
)
;;@ ~lib/allocator/buddy.ts:420:6
;;@ ~lib/allocator/buddy.ts:418:6
(set_local $6
;;@ ~lib/allocator/buddy.ts:420:12
;;@ ~lib/allocator/buddy.ts:418:12
(call $~lib/allocator/buddy/list_pop
;;@ ~lib/allocator/buddy.ts:420:39
;;@ ~lib/allocator/buddy.ts:418:39
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:420:51
;;@ ~lib/allocator/buddy.ts:418:51
(get_local $2)
)
)
)
)
)
;;@ ~lib/allocator/buddy.ts:427:4
;;@ ~lib/allocator/buddy.ts:425:4
(set_local $3
;;@ ~lib/allocator/buddy.ts:427:11
;;@ ~lib/allocator/buddy.ts:425:11
(i32.shl
(i32.const 1)
;;@ ~lib/allocator/buddy.ts:427:16
;;@ ~lib/allocator/buddy.ts:425:16
(i32.sub
;;@ ~lib/allocator/buddy.ts:427:17
;;@ ~lib/allocator/buddy.ts:425:17
(i32.const 30)
;;@ ~lib/allocator/buddy.ts:427:34
;;@ ~lib/allocator/buddy.ts:425:34
(get_local $2)
)
)
)
;;@ ~lib/allocator/buddy.ts:428:4
;;@ ~lib/allocator/buddy.ts:426:4
(set_local $4
;;@ ~lib/allocator/buddy.ts:428:19
;;@ ~lib/allocator/buddy.ts:426:19
(if (result i32)
(i32.lt_u
(get_local $2)
;;@ ~lib/allocator/buddy.ts:428:28
;;@ ~lib/allocator/buddy.ts:426:28
(get_local $1)
)
;;@ ~lib/allocator/buddy.ts:428:46
;;@ ~lib/allocator/buddy.ts:426:46
(i32.add
(i32.div_u
(get_local $3)
;;@ ~lib/allocator/buddy.ts:428:53
;;@ ~lib/allocator/buddy.ts:426:53
(i32.const 2)
)
;;@ ~lib/allocator/buddy.ts:428:57
;;@ ~lib/allocator/buddy.ts:426:57
(i32.const 8)
)
;;@ ~lib/allocator/buddy.ts:428:69
;;@ ~lib/allocator/buddy.ts:426:69
(get_local $3)
)
)
;;@ ~lib/allocator/buddy.ts:429:4
;;@ ~lib/allocator/buddy.ts:427:4
(if
;;@ ~lib/allocator/buddy.ts:429:8
;;@ ~lib/allocator/buddy.ts:427:8
(i32.eqz
;;@ ~lib/allocator/buddy.ts:429:9
;;@ ~lib/allocator/buddy.ts:427:9
(call $~lib/allocator/buddy/update_max_ptr
;;@ ~lib/allocator/buddy.ts:429:24
;;@ ~lib/allocator/buddy.ts:427:24
(i32.add
(get_local $6)
;;@ ~lib/allocator/buddy.ts:429:30
;;@ ~lib/allocator/buddy.ts:427:30
(get_local $4)
)
)
)
;;@ ~lib/allocator/buddy.ts:429:45
;;@ ~lib/allocator/buddy.ts:427:45
(block
;;@ ~lib/allocator/buddy.ts:430:6
;;@ ~lib/allocator/buddy.ts:428:6
(call $~lib/allocator/buddy/list_push
;;@ ~lib/allocator/buddy.ts:430:16
;;@ ~lib/allocator/buddy.ts:428:16
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:430:28
;;@ ~lib/allocator/buddy.ts:428:28
(get_local $2)
)
;;@ ~lib/allocator/buddy.ts:430:37
;;@ ~lib/allocator/buddy.ts:428:37
(get_local $6)
)
;;@ ~lib/allocator/buddy.ts:431:13
;;@ ~lib/allocator/buddy.ts:429:13
(return
(i32.const 0)
)
)
)
;;@ ~lib/allocator/buddy.ts:445:4
;;@ ~lib/allocator/buddy.ts:443:4
(set_local $5
;;@ ~lib/allocator/buddy.ts:445:8
;;@ ~lib/allocator/buddy.ts:443:8
(call $~lib/allocator/buddy/node_for_ptr
;;@ ~lib/allocator/buddy.ts:445:21
;;@ ~lib/allocator/buddy.ts:443:21
(get_local $6)
;;@ ~lib/allocator/buddy.ts:445:26
;;@ ~lib/allocator/buddy.ts:443:26
(get_local $2)
)
)
;;@ ~lib/allocator/buddy.ts:446:4
;;@ ~lib/allocator/buddy.ts:444:4
(if
;;@ ~lib/allocator/buddy.ts:446:8
;;@ ~lib/allocator/buddy.ts:444:8
(i32.ne
(get_local $5)
;;@ ~lib/allocator/buddy.ts:446:13
;;@ ~lib/allocator/buddy.ts:444:13
(i32.const 0)
)
;;@ ~lib/allocator/buddy.ts:447:6
;;@ ~lib/allocator/buddy.ts:445:6
(call $~lib/allocator/buddy/flip_parent_is_split
;;@ ~lib/allocator/buddy.ts:447:27
;;@ ~lib/allocator/buddy.ts:445:27
(get_local $5)
)
)
;;@ ~lib/allocator/buddy.ts:457:4
;;@ ~lib/allocator/buddy.ts:455:4
(block $break|1
(loop $continue|1
(if
;;@ ~lib/allocator/buddy.ts:457:11
;;@ ~lib/allocator/buddy.ts:455:11
(i32.lt_u
(get_local $2)
;;@ ~lib/allocator/buddy.ts:457:20
;;@ ~lib/allocator/buddy.ts:455:20
(get_local $1)
)
(block
(block
;;@ ~lib/allocator/buddy.ts:458:6
;;@ ~lib/allocator/buddy.ts:456:6
(set_local $5
;;@ ~lib/allocator/buddy.ts:458:10
;;@ ~lib/allocator/buddy.ts:456:10
(i32.add
(i32.mul
(get_local $5)
;;@ ~lib/allocator/buddy.ts:458:14
;;@ ~lib/allocator/buddy.ts:456:14
(i32.const 2)
)
;;@ ~lib/allocator/buddy.ts:458:18
;;@ ~lib/allocator/buddy.ts:456:18
(i32.const 1)
)
)
;;@ ~lib/allocator/buddy.ts:459:6
;;@ ~lib/allocator/buddy.ts:457:6
(set_local $2
(i32.add
(get_local $2)
(i32.const 1)
)
)
;;@ ~lib/allocator/buddy.ts:460:6
;;@ ~lib/allocator/buddy.ts:458:6
(call $~lib/allocator/buddy/flip_parent_is_split
;;@ ~lib/allocator/buddy.ts:460:27
;;@ ~lib/allocator/buddy.ts:458:27
(get_local $5)
)
;;@ ~lib/allocator/buddy.ts:461:6
;;@ ~lib/allocator/buddy.ts:459:6
(call $~lib/allocator/buddy/list_push
;;@ ~lib/allocator/buddy.ts:462:8
;;@ ~lib/allocator/buddy.ts:460:8
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:462:20
;;@ ~lib/allocator/buddy.ts:460:20
(get_local $2)
)
;;@ ~lib/allocator/buddy.ts:463:8
;;@ ~lib/allocator/buddy.ts:461:8
(call $~lib/allocator/buddy/ptr_for_node
;;@ ~lib/allocator/buddy.ts:463:38
;;@ ~lib/allocator/buddy.ts:461:38
(i32.add
(get_local $5)
;;@ ~lib/allocator/buddy.ts:463:42
;;@ ~lib/allocator/buddy.ts:461:42
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:463:45
;;@ ~lib/allocator/buddy.ts:461:45
(get_local $2)
)
)
@ -1144,19 +1142,19 @@
)
)
)
;;@ ~lib/allocator/buddy.ts:471:4
;;@ ~lib/allocator/buddy.ts:469:4
(i32.store
;;@ ~lib/allocator/buddy.ts:471:17
;;@ ~lib/allocator/buddy.ts:469:17
(get_local $6)
;;@ ~lib/allocator/buddy.ts:471:22
;;@ ~lib/allocator/buddy.ts:469:22
(get_local $0)
)
;;@ ~lib/allocator/buddy.ts:472:17
;;@ ~lib/allocator/buddy.ts:470:17
(return
;;@ ~lib/allocator/buddy.ts:472:11
;;@ ~lib/allocator/buddy.ts:470:11
(i32.add
(get_local $6)
;;@ ~lib/allocator/buddy.ts:472:17
;;@ ~lib/allocator/buddy.ts:470:17
(i32.const 8)
)
)
@ -1166,7 +1164,7 @@
)
)
)
;;@ ~lib/allocator/buddy.ts:475:9
;;@ ~lib/allocator/buddy.ts:473:9
(return
(i32.const 0)
)
@ -1175,129 +1173,129 @@
(local $1 i32)
(local $2 i32)
(local $3 i32)
;;@ ~lib/allocator/buddy.ts:480:2
;;@ ~lib/allocator/buddy.ts:478:2
(nop)
;;@ ~lib/allocator/buddy.ts:485:2
;;@ ~lib/allocator/buddy.ts:483:2
(if
;;@ ~lib/allocator/buddy.ts:485:6
;;@ ~lib/allocator/buddy.ts:483:6
(i32.eqz
;;@ ~lib/allocator/buddy.ts:485:7
;;@ ~lib/allocator/buddy.ts:483:7
(get_local $0)
)
;;@ ~lib/allocator/buddy.ts:486:4
;;@ ~lib/allocator/buddy.ts:484:4
(return)
)
;;@ ~lib/allocator/buddy.ts:494:2
;;@ ~lib/allocator/buddy.ts:492:2
(set_local $0
;;@ ~lib/allocator/buddy.ts:494:8
;;@ ~lib/allocator/buddy.ts:492:8
(i32.sub
(get_local $0)
;;@ ~lib/allocator/buddy.ts:494:14
;;@ ~lib/allocator/buddy.ts:492:14
(i32.const 8)
)
)
;;@ ~lib/allocator/buddy.ts:495:2
;;@ ~lib/allocator/buddy.ts:493:2
(set_local $1
;;@ ~lib/allocator/buddy.ts:495:11
;;@ ~lib/allocator/buddy.ts:493:11
(call $~lib/allocator/buddy/bucket_for_request
;;@ ~lib/allocator/buddy.ts:495:30
;;@ ~lib/allocator/buddy.ts:493:30
(i32.add
(i32.load
;;@ ~lib/allocator/buddy.ts:495:42
;;@ ~lib/allocator/buddy.ts:493:42
(get_local $0)
)
;;@ ~lib/allocator/buddy.ts:495:49
;;@ ~lib/allocator/buddy.ts:493:49
(i32.const 8)
)
)
)
;;@ ~lib/allocator/buddy.ts:496:2
;;@ ~lib/allocator/buddy.ts:494:2
(set_local $2
;;@ ~lib/allocator/buddy.ts:496:6
;;@ ~lib/allocator/buddy.ts:494:6
(call $~lib/allocator/buddy/node_for_ptr
;;@ ~lib/allocator/buddy.ts:496:19
;;@ ~lib/allocator/buddy.ts:494:19
(get_local $0)
;;@ ~lib/allocator/buddy.ts:496:24
;;@ ~lib/allocator/buddy.ts:494:24
(get_local $1)
)
)
;;@ ~lib/allocator/buddy.ts:502:2
;;@ ~lib/allocator/buddy.ts:500:2
(block $break|0
(loop $continue|0
(if
;;@ ~lib/allocator/buddy.ts:502:9
;;@ ~lib/allocator/buddy.ts:500:9
(i32.ne
(get_local $2)
;;@ ~lib/allocator/buddy.ts:502:14
;;@ ~lib/allocator/buddy.ts:500:14
(i32.const 0)
)
(block
(block
;;@ ~lib/allocator/buddy.ts:509:4
;;@ ~lib/allocator/buddy.ts:507:4
(call $~lib/allocator/buddy/flip_parent_is_split
;;@ ~lib/allocator/buddy.ts:509:25
;;@ ~lib/allocator/buddy.ts:507:25
(get_local $2)
)
;;@ ~lib/allocator/buddy.ts:519:4
;;@ ~lib/allocator/buddy.ts:517:4
(if
;;@ ~lib/allocator/buddy.ts:519:8
;;@ ~lib/allocator/buddy.ts:517:8
(if (result i32)
(tee_local $3
(call $~lib/allocator/buddy/parent_is_split
;;@ ~lib/allocator/buddy.ts:519:24
;;@ ~lib/allocator/buddy.ts:517:24
(get_local $2)
)
)
(get_local $3)
;;@ ~lib/allocator/buddy.ts:519:30
;;@ ~lib/allocator/buddy.ts:517:30
(i32.eq
(get_local $1)
;;@ ~lib/allocator/buddy.ts:519:40
;;@ ~lib/allocator/buddy.ts:517:40
(get_global $~lib/allocator/buddy/bucket_limit)
)
)
;;@ ~lib/allocator/buddy.ts:520:6
;;@ ~lib/allocator/buddy.ts:518:6
(br $break|0)
)
;;@ ~lib/allocator/buddy.ts:530:4
;;@ ~lib/allocator/buddy.ts:528:4
(call $~lib/allocator/buddy/list_remove
;;@ ~lib/allocator/buddy.ts:530:16
;;@ ~lib/allocator/buddy.ts:528:16
(call $~lib/allocator/buddy/ptr_for_node
;;@ ~lib/allocator/buddy.ts:530:46
;;@ ~lib/allocator/buddy.ts:528:46
(i32.add
(i32.xor
;;@ ~lib/allocator/buddy.ts:530:47
;;@ ~lib/allocator/buddy.ts:528:47
(i32.sub
;;@ ~lib/allocator/buddy.ts:530:48
;;@ ~lib/allocator/buddy.ts:528:48
(get_local $2)
;;@ ~lib/allocator/buddy.ts:530:52
;;@ ~lib/allocator/buddy.ts:528:52
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:530:57
;;@ ~lib/allocator/buddy.ts:528:57
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:530:62
;;@ ~lib/allocator/buddy.ts:528:62
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:530:65
;;@ ~lib/allocator/buddy.ts:528:65
(get_local $1)
)
)
;;@ ~lib/allocator/buddy.ts:531:4
;;@ ~lib/allocator/buddy.ts:529:4
(set_local $2
;;@ ~lib/allocator/buddy.ts:531:8
;;@ ~lib/allocator/buddy.ts:529:8
(i32.div_u
(i32.sub
;;@ ~lib/allocator/buddy.ts:531:9
;;@ ~lib/allocator/buddy.ts:529:9
(get_local $2)
;;@ ~lib/allocator/buddy.ts:531:13
;;@ ~lib/allocator/buddy.ts:529:13
(i32.const 1)
)
;;@ ~lib/allocator/buddy.ts:531:18
;;@ ~lib/allocator/buddy.ts:529:18
(i32.const 2)
)
)
;;@ ~lib/allocator/buddy.ts:532:4
;;@ ~lib/allocator/buddy.ts:530:4
(set_local $1
(i32.sub
(get_local $1)
@ -1310,18 +1308,18 @@
)
)
)
;;@ ~lib/allocator/buddy.ts:541:2
;;@ ~lib/allocator/buddy.ts:539:2
(call $~lib/allocator/buddy/list_push
;;@ ~lib/allocator/buddy.ts:541:12
;;@ ~lib/allocator/buddy.ts:539:12
(call $~lib/allocator/buddy/buckets$get
;;@ ~lib/allocator/buddy.ts:541:24
;;@ ~lib/allocator/buddy.ts:539:24
(get_local $1)
)
;;@ ~lib/allocator/buddy.ts:541:33
;;@ ~lib/allocator/buddy.ts:539:33
(call $~lib/allocator/buddy/ptr_for_node
;;@ ~lib/allocator/buddy.ts:541:63
;;@ ~lib/allocator/buddy.ts:539:63
(get_local $2)
;;@ ~lib/allocator/buddy.ts:541:66
;;@ ~lib/allocator/buddy.ts:539:66
(get_local $1)
)
)

View File

@ -25,12 +25,14 @@ function test(file) {
console.log("mem final: " + exports.memory.buffer.byteLength);
console.log();
if (exports.allocate_memory(COMMON_MAX + 1) != 0) {
try {
exports.allocate_memory(COMMON_MAX + 1); // unreachable
throw Error("allocation is allowed to overflow MAX_SIZE");
}
if (exports.allocate_memory(0xffffffff) != 0) {
} catch (e) {}
try {
exports.allocate_memory(0xffffffff); // unreachable
throw Error("allocation is allowed to overflow INT_MAX");
}
} catch (e) {}
}
if (process.argv.length > 2) {

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@ if (args.help) {
}
var successes = 0;
var failures = 0;
var failedTests = [];
const basedir = path.join(__dirname, "compiler");
@ -136,15 +136,15 @@ tests.forEach(filename => {
failed = true;
}
if (failed) ++failures;
if (failed) failedTests.push(basename);
else ++successes;
console.log();
});
});
});
if (failures) {
if (failedTests.length) {
process.exitCode = 1;
console.log(chalk.red("ERROR: ") + failures + " compiler tests failed");
console.log(chalk.red("ERROR: ") + failedTests.length + " compiler tests failed: " + failedTests.join(", "));
} else
console.log("[ " + chalk.whiteBright("SUCCESS") + " ]");

View File

@ -22,15 +22,15 @@
(local $3 i32)
(local $4 i32)
(if
(select
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(if
(i32.gt_u
(tee_local $2

View File

@ -29,17 +29,16 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(nop)
(if
(if (result i32)
(get_local $0)
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(set_local $1
(get_global $~lib/allocator/arena/offset)
)

View File

@ -121,15 +121,15 @@
(local $3 i32)
(local $4 i32)
(if
(select
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(if
(i32.gt_u
(tee_local $2

View File

@ -139,17 +139,16 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(nop)
(if
(if (result i32)
(get_local $0)
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(set_local $1
(get_global $~lib/allocator/arena/offset)
)

View File

@ -37,15 +37,15 @@
(local $3 i32)
(local $4 i32)
(if
(select
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(if
(i32.gt_u
(tee_local $2
@ -120,7 +120,7 @@
)
(i32.const 0)
)
(func $~lib/internal/arraybuffer/allocate (; 3 ;) (type $ii) (param $0 i32) (result i32)
(func $~lib/internal/arraybuffer/allocUnsafe (; 3 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(if
(i32.gt_u
@ -494,7 +494,7 @@
(call $~lib/memory/set_memory
(i32.add
(tee_local $2
(call $~lib/internal/arraybuffer/allocate
(call $~lib/internal/arraybuffer/allocUnsafe
(get_local $1)
)
)
@ -2416,7 +2416,7 @@
(call $~lib/memory/move_memory
(i32.add
(tee_local $3
(call $~lib/internal/arraybuffer/allocate
(call $~lib/internal/arraybuffer/allocUnsafe
(tee_local $2
(select
(tee_local $3

View File

@ -50,17 +50,16 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(nop)
(if
(if (result i32)
(get_local $0)
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(set_local $1
(get_global $~lib/allocator/arena/offset)
)
@ -154,7 +153,7 @@
(i32.const 0)
)
)
(func $~lib/internal/arraybuffer/allocate (; 3 ;) (type $ii) (param $0 i32) (result i32)
(func $~lib/internal/arraybuffer/allocUnsafe (; 3 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(if
(i32.eqz
@ -547,7 +546,7 @@
(unreachable)
)
(set_local $2
(call $~lib/internal/arraybuffer/allocate
(call $~lib/internal/arraybuffer/allocUnsafe
(get_local $1)
)
)
@ -2792,7 +2791,7 @@
)
)
(set_local $7
(call $~lib/internal/arraybuffer/allocate
(call $~lib/internal/arraybuffer/allocUnsafe
(get_local $6)
)
)

View File

@ -24,15 +24,15 @@
(local $3 i32)
(local $4 i32)
(if
(select
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(if
(i32.gt_u
(tee_local $2

View File

@ -30,17 +30,16 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(nop)
(if
(if (result i32)
(get_local $0)
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(set_local $1
(get_global $~lib/allocator/arena/offset)
)

View File

@ -15,15 +15,15 @@
(local $3 i32)
(local $4 i32)
(if
(select
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(if
(i32.gt_u
(tee_local $2

View File

@ -21,17 +21,16 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(nop)
(if
(if (result i32)
(get_local $0)
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(set_local $1
(get_global $~lib/allocator/arena/offset)
)

View File

@ -60,15 +60,15 @@
(local $3 i32)
(local $4 i32)
(if
(select
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(if
(i32.gt_u
(tee_local $2

View File

@ -66,17 +66,16 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(nop)
(if
(if (result i32)
(get_local $0)
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(set_local $1
(get_global $~lib/allocator/arena/offset)
)

View File

@ -21,15 +21,15 @@
(local $3 i32)
(local $4 i32)
(if
(select
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(if
(i32.gt_u
(tee_local $2

View File

@ -27,17 +27,16 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(nop)
(if
(if (result i32)
(get_local $0)
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(set_local $1
(get_global $~lib/allocator/arena/offset)
)

View File

@ -59,15 +59,15 @@
(local $3 i32)
(local $4 i32)
(if
(select
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(if
(i32.gt_u
(tee_local $2

View File

@ -75,17 +75,16 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(nop)
(if
(if (result i32)
(get_local $0)
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(set_local $1
(get_global $~lib/allocator/arena/offset)
)

View File

@ -1184,15 +1184,15 @@
(local $3 i32)
(local $4 i32)
(if
(select
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(if
(i32.gt_u
(tee_local $2

View File

@ -1373,17 +1373,16 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(nop)
(if
(if (result i32)
(get_local $0)
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(set_local $1
(get_global $~lib/allocator/arena/offset)
)

View File

@ -3,6 +3,7 @@
(type $iv (func (param i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $ii (func (param i32) (result i32)))
(type $iiiv (func (param i32 i32 i32)))
(type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
@ -33,15 +34,15 @@
(local $3 i32)
(local $4 i32)
(if
(select
(i32.lt_u
(get_local $0)
(i32.const 1073741824)
)
(get_local $0)
(get_local $0)
)
(get_local $0)
(block
(if
(i32.gt_u
(get_local $0)
(i32.const 1073741824)
)
(unreachable)
)
(if
(i32.gt_u
(tee_local $2
@ -116,7 +117,7 @@
)
(i32.const 0)
)
(func $~lib/internal/arraybuffer/allocate (; 3 ;) (type $ii) (param $0 i32) (result i32)
(func $~lib/internal/arraybuffer/allocUnsafe (; 3 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(if
(i32.gt_u
@ -145,7 +146,341 @@
)
(get_local $1)
)
(func $~lib/internal/typedarray/TypedArray<i8>#constructor (; 4 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/memory/set_memory (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i64)
(local $4 i32)
(if
(i32.eqz
(get_local $2)
)
(return)
)
(i32.store8
(get_local $0)
(get_local $1)
)
(i32.store8
(i32.sub
(i32.add
(get_local $0)
(get_local $2)
)
(i32.const 1)
)
(get_local $1)
)
(if
(i32.le_u
(get_local $2)
(i32.const 2)
)
(return)
)
(i32.store8
(i32.add
(get_local $0)
(i32.const 1)
)
(get_local $1)
)
(i32.store8
(i32.add
(get_local $0)
(i32.const 2)
)
(get_local $1)
)
(i32.store8
(i32.sub
(i32.add
(get_local $0)
(get_local $2)
)
(i32.const 2)
)
(get_local $1)
)
(i32.store8
(i32.sub
(i32.add
(get_local $0)
(get_local $2)
)
(i32.const 3)
)
(get_local $1)
)
(if
(i32.le_u
(get_local $2)
(i32.const 6)
)
(return)
)
(i32.store8
(i32.add
(get_local $0)
(i32.const 3)
)
(get_local $1)
)
(i32.store8
(i32.sub
(i32.add
(get_local $0)
(get_local $2)
)
(i32.const 4)
)
(get_local $1)
)
(if
(i32.le_u
(get_local $2)
(i32.const 8)
)
(return)
)
(i32.store
(tee_local $0
(i32.add
(get_local $0)
(tee_local $4
(i32.and
(i32.sub
(i32.const 0)
(get_local $0)
)
(i32.const 3)
)
)
)
)
(tee_local $1
(i32.mul
(get_local $1)
(i32.const 16843009)
)
)
)
(i32.store
(i32.sub
(i32.add
(get_local $0)
(tee_local $2
(i32.and
(i32.sub
(get_local $2)
(get_local $4)
)
(i32.const -4)
)
)
)
(i32.const 4)
)
(get_local $1)
)
(if
(i32.le_u
(get_local $2)
(i32.const 8)
)
(return)
)
(i32.store
(i32.add
(get_local $0)
(i32.const 4)
)
(get_local $1)
)
(i32.store
(i32.add
(get_local $0)
(i32.const 8)
)
(get_local $1)
)
(i32.store
(i32.sub
(i32.add
(get_local $0)
(get_local $2)
)
(i32.const 12)
)
(get_local $1)
)
(i32.store
(i32.sub
(i32.add
(get_local $0)
(get_local $2)
)
(i32.const 8)
)
(get_local $1)
)
(if
(i32.le_u
(get_local $2)
(i32.const 24)
)
(return)
)
(i32.store
(i32.add
(get_local $0)
(i32.const 12)
)
(get_local $1)
)
(i32.store
(i32.add
(get_local $0)
(i32.const 16)
)
(get_local $1)
)
(i32.store
(i32.add
(get_local $0)
(i32.const 20)
)
(get_local $1)
)
(i32.store
(i32.add
(get_local $0)
(i32.const 24)
)
(get_local $1)
)
(i32.store
(i32.sub
(i32.add
(get_local $0)
(get_local $2)
)
(i32.const 28)
)
(get_local $1)
)
(i32.store
(i32.sub
(i32.add
(get_local $0)
(get_local $2)
)
(i32.const 24)
)
(get_local $1)
)
(i32.store
(i32.sub
(i32.add
(get_local $0)
(get_local $2)
)
(i32.const 20)
)
(get_local $1)
)
(i32.store
(i32.sub
(i32.add
(get_local $0)
(get_local $2)
)
(i32.const 16)
)
(get_local $1)
)
(set_local $0
(i32.add
(get_local $0)
(tee_local $4
(i32.add
(i32.and
(get_local $0)
(i32.const 4)
)
(i32.const 24)
)
)
)
)
(set_local $2
(i32.sub
(get_local $2)
(get_local $4)
)
)
(set_local $3
(i64.or
(i64.extend_u/i32
(get_local $1)
)
(i64.shl
(i64.extend_u/i32
(get_local $1)
)
(i64.const 32)
)
)
)
(loop $continue|0
(if
(i32.ge_u
(get_local $2)
(i32.const 32)
)
(block
(i64.store
(get_local $0)
(get_local $3)
)
(i64.store
(i32.add
(get_local $0)
(i32.const 8)
)
(get_local $3)
)
(i64.store
(i32.add
(get_local $0)
(i32.const 16)
)
(get_local $3)
)
(i64.store
(i32.add
(get_local $0)
(i32.const 24)
)
(get_local $3)
)
(set_local $2
(i32.sub
(get_local $2)
(i32.const 32)
)
)
(set_local $0
(i32.add
(get_local $0)
(i32.const 32)
)
)
(br $continue|0)
)
)
)
)
(func $~lib/internal/typedarray/TypedArray<i8>#constructor (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(if
(i32.gt_u
(get_local $1)
@ -153,6 +488,18 @@
)
(unreachable)
)
(call $~lib/memory/set_memory
(i32.add
(tee_local $2
(call $~lib/internal/arraybuffer/allocUnsafe
(get_local $1)
)
)
(i32.const 8)
)
(i32.const 0)
(get_local $1)
)
(i32.store
(if (result i32)
(get_local $0)
@ -177,9 +524,7 @@
(get_local $0)
)
)
(call $~lib/internal/arraybuffer/allocate
(get_local $1)
)
(get_local $2)
)
(i32.store offset=4
(get_local $0)
@ -191,12 +536,13 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i8>#get:length (; 5 ;) (type $ii) (param $0 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i8>#get:length (; 6 ;) (type $ii) (param $0 i32) (result i32)
(i32.load offset=8
(get_local $0)
)
)
(func $~lib/internal/typedarray/TypedArray<i16>#constructor (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i16>#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(if
(i32.gt_u
(get_local $1)
@ -204,11 +550,22 @@
)
(unreachable)
)
(set_local $1
(i32.shl
(get_local $1)
(i32.const 1)
(call $~lib/memory/set_memory
(i32.add
(tee_local $2
(call $~lib/internal/arraybuffer/allocUnsafe
(tee_local $1
(i32.shl
(get_local $1)
(i32.const 1)
)
)
)
)
(i32.const 8)
)
(i32.const 0)
(get_local $1)
)
(i32.store
(if (result i32)
@ -234,9 +591,7 @@
(get_local $0)
)
)
(call $~lib/internal/arraybuffer/allocate
(get_local $1)
)
(get_local $2)
)
(i32.store offset=4
(get_local $0)
@ -248,7 +603,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i16>#get:length (; 7 ;) (type $ii) (param $0 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i16>#get:length (; 8 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.load offset=8
(get_local $0)
@ -256,7 +611,8 @@
(i32.const 1)
)
)
(func $~lib/internal/typedarray/TypedArray<i32>#constructor (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i32>#constructor (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(if
(i32.gt_u
(get_local $1)
@ -264,11 +620,22 @@
)
(unreachable)
)
(set_local $1
(i32.shl
(get_local $1)
(i32.const 2)
(call $~lib/memory/set_memory
(i32.add
(tee_local $2
(call $~lib/internal/arraybuffer/allocUnsafe
(tee_local $1
(i32.shl
(get_local $1)
(i32.const 2)
)
)
)
)
(i32.const 8)
)
(i32.const 0)
(get_local $1)
)
(i32.store
(if (result i32)
@ -294,9 +661,7 @@
(get_local $0)
)
)
(call $~lib/internal/arraybuffer/allocate
(get_local $1)
)
(get_local $2)
)
(i32.store offset=4
(get_local $0)
@ -308,7 +673,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i32>#get:length (; 9 ;) (type $ii) (param $0 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i32>#get:length (; 10 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.load offset=8
(get_local $0)
@ -316,7 +681,8 @@
(i32.const 2)
)
)
(func $~lib/internal/typedarray/TypedArray<i64>#constructor (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i64>#constructor (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(if
(i32.gt_u
(get_local $1)
@ -324,11 +690,22 @@
)
(unreachable)
)
(set_local $1
(i32.shl
(get_local $1)
(i32.const 3)
(call $~lib/memory/set_memory
(i32.add
(tee_local $2
(call $~lib/internal/arraybuffer/allocUnsafe
(tee_local $1
(i32.shl
(get_local $1)
(i32.const 3)
)
)
)
)
(i32.const 8)
)
(i32.const 0)
(get_local $1)
)
(i32.store
(if (result i32)
@ -354,9 +731,7 @@
(get_local $0)
)
)
(call $~lib/internal/arraybuffer/allocate
(get_local $1)
)
(get_local $2)
)
(i32.store offset=4
(get_local $0)
@ -368,7 +743,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i64>#get:length (; 11 ;) (type $ii) (param $0 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i64>#get:length (; 12 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.load offset=8
(get_local $0)
@ -376,7 +751,7 @@
(i32.const 3)
)
)
(func $std/typedarray/testInstantiate (; 12 ;) (type $iv) (param $0 i32)
(func $std/typedarray/testInstantiate (; 13 ;) (type $iv) (param $0 i32)
(local $1 i32)
(if
(i32.load offset=4
@ -933,7 +1308,7 @@
)
)
)
(func $start (; 13 ;) (type $v)
(func $start (; 14 ;) (type $v)
(set_global $~lib/allocator/arena/startOffset
(i32.and
(i32.add

File diff suppressed because it is too large Load Diff