This commit is contained in:
dcode 2019-03-13 09:05:02 +01:00
parent e581f254d0
commit 6f70826e45
11 changed files with 251 additions and 227 deletions

View File

@ -4098,9 +4098,8 @@ export function compileIterateRoots(compiler: Compiler): void {
);
}
function typedArraySymbolToType(symbol: string): Type {
function typedArraySymbolToType(symbol: string): Type | null {
switch (symbol) {
default: assert(false);
case BuiltinSymbols.Int8Array: return Type.i8;
case BuiltinSymbols.Uint8ClampedArray:
case BuiltinSymbols.Uint8Array: return Type.u8;
@ -4113,9 +4112,10 @@ function typedArraySymbolToType(symbol: string): Type {
case BuiltinSymbols.Float32Array: return Type.f32;
case BuiltinSymbols.Float64Array: return Type.f64;
}
return null;
}
export function compileTypedArrayGet(
export function compileArrayGet(
compiler: Compiler,
target: Class,
thisExpression: Expression,
@ -4123,6 +4123,20 @@ export function compileTypedArrayGet(
contextualType: Type
): ExpressionRef {
var type = typedArraySymbolToType(target.internalName);
if (type) return compileTypedArrayGet(compiler, target, type, thisExpression, elementExpression, contextualType);
assert(target.prototype == compiler.program.arrayPrototype);
type = assert(target.typeArguments)[0];
throw new Error("not implemented");
}
function compileTypedArrayGet(
compiler: Compiler,
target: Class,
type: Type,
thisExpression: Expression,
elementExpression: Expression,
contextualType: Type
): ExpressionRef {
var module = compiler.module;
var outType = (
type.is(TypeFlags.INTEGER) &&
@ -4130,8 +4144,6 @@ export function compileTypedArrayGet(
contextualType.size > type.size
) ? contextualType : type;
var bufferField = assert(target.lookupInSelf("buffer"));
assert(bufferField.kind == ElementKind.FIELD);
var dataStart = assert(target.lookupInSelf("dataStart"));
assert(dataStart.kind == ElementKind.FIELD);
var dataEnd = assert(target.lookupInSelf("dataEnd"));
@ -4198,19 +4210,36 @@ export function compileTypedArrayGet(
);
}
export function compileTypedArraySet(
export function compileArraySet(
compiler: Compiler,
target: Class,
thisExpression: Expression,
elementExpression: Expression,
valueExpression: Expression,
contextualType: Type
): ExpressionRef {
var type = typedArraySymbolToType(target.internalName);
if (type) {
return compileTypedArraySet(compiler, target, type, thisExpression,
elementExpression, valueExpression, contextualType);
}
assert(target.prototype == compiler.program.arrayPrototype);
type = assert(target.typeArguments)[0];
throw new Error("not implemented");
}
function compileTypedArraySet(
compiler: Compiler,
target: Class,
type: Type,
thisExpression: Expression,
elementExpression: Expression,
valueExpression: Expression,
contextualType: Type
): ExpressionRef {
var type = typedArraySymbolToType(target.internalName);
var module = compiler.module;
var bufferField = assert(target.lookupInSelf("buffer"));
assert(bufferField.kind == ElementKind.FIELD);
var dataStart = assert(target.lookupInSelf("dataStart"));
assert(dataStart.kind == ElementKind.FIELD);
var dataEnd = assert(target.lookupInSelf("dataEnd"));

View File

@ -9,8 +9,8 @@ import {
compileIterateRoots,
ensureGCHook,
BuiltinSymbols,
compileTypedArrayGet,
compileTypedArraySet
compileArrayGet,
compileArraySet
} from "./builtins";
import {
@ -4687,22 +4687,22 @@ export class Compiler extends DiagnosticEmitter {
case ElementKind.CLASS: {
let elementExpression = resolver.currentElementExpression;
if (elementExpression) { // indexed access
let arrayBufferView = this.program.arrayBufferView;
if (arrayBufferView) {
if ((<Class>target).prototype.extends(arrayBufferView.prototype)) {
return compileTypedArraySet(
this,
<Class>target,
assert(this.resolver.currentThisExpression),
elementExpression,
valueExpression,
contextualType
);
}
}
let isUnchecked = flow.is(FlowFlags.UNCHECKED_CONTEXT);
let indexedSet = (<Class>target).lookupOverload(OperatorKind.INDEXED_SET, isUnchecked);
if (!indexedSet) {
let arrayBufferView = this.program.arrayBufferView;
if (arrayBufferView) {
if ((<Class>target).prototype.extends(arrayBufferView.prototype)) {
return compileArraySet(
this,
<Class>target,
assert(this.resolver.currentThisExpression),
elementExpression,
valueExpression,
contextualType
);
}
}
let indexedGet = (<Class>target).lookupOverload(OperatorKind.INDEXED_GET, isUnchecked);
if (!indexedGet) {
this.error(
@ -4718,7 +4718,7 @@ export class Compiler extends DiagnosticEmitter {
return this.module.createUnreachable();
}
assert(indexedSet.signature.parameterTypes.length == 2); // parser must guarantee this
targetType = indexedSet.signature.parameterTypes[1]; // 2nd parameter is the element
targetType = indexedSet.signature.parameterTypes[1]; // 2nd parameter is the element
break;
}
// fall-through
@ -5749,26 +5749,31 @@ export class Compiler extends DiagnosticEmitter {
let allOptionalsAreConstant = true;
for (let i = numArguments; i < maxArguments; ++i) {
let initializer = parameterNodes[i].initializer;
if (!(initializer && nodeIsConstantValue(initializer.kind))) {
allOptionalsAreConstant = false;
break;
}
}
if (allOptionalsAreConstant) { // inline into the call
for (let i = numArguments; i < maxArguments; ++i) {
operands.push(
this.compileExpression(
if (initializer) {
let resolved: Element | null;
if (
nodeIsConstantValue(initializer.kind) ||
(
(resolved = this.resolver.resolveExpression(initializer, instance.flow, parameterTypes[i])) &&
(
resolved.kind == ElementKind.GLOBAL
// resolved.kind == ElementKind.FUNCTION_TARGET
)
)
) { // inline into the call
operands.push(this.compileExpression(
<Expression>parameterNodes[i].initializer,
parameterTypes[i],
ConversionKind.IMPLICIT,
WrapMode.NONE
)
);
}
} else { // otherwise fill up with zeroes and call the trampoline
for (let i = numArguments; i < maxArguments; ++i) {
operands.push(parameterTypes[i].toNativeZero(module));
));
continue;
}
}
operands.push(parameterTypes[i].toNativeZero(module));
allOptionalsAreConstant = false;
}
if (!allOptionalsAreConstant) {
if (!isCallImport) {
let original = instance;
instance = this.ensureTrampoline(instance);
@ -5902,21 +5907,21 @@ export class Compiler extends DiagnosticEmitter {
if (!target) return this.module.createUnreachable();
switch (target.kind) {
case ElementKind.CLASS: {
let arrayBufferView = this.program.arrayBufferView;
if (arrayBufferView) {
if ((<Class>target).prototype.extends(arrayBufferView.prototype)) {
return compileTypedArrayGet(
this,
<Class>target,
expression.expression,
expression.elementExpression,
contextualType
);
}
}
let isUnchecked = this.currentFlow.is(FlowFlags.UNCHECKED_CONTEXT);
let indexedGet = (<Class>target).lookupOverload(OperatorKind.INDEXED_GET, isUnchecked);
if (!indexedGet) {
let arrayBufferView = this.program.arrayBufferView;
if (arrayBufferView) {
if ((<Class>target).prototype.extends(arrayBufferView.prototype)) {
return compileArrayGet(
this,
<Class>target,
expression.expression,
expression.elementExpression,
contextualType
);
}
}
this.error(
DiagnosticCode.Index_signature_is_missing_in_type_0,
expression.expression.range, (<Class>target).internalName

View File

@ -632,11 +632,10 @@ export class Program extends DiagnosticEmitter {
true // isImport
);
} else {
// FIXME: file not found is not reported if this happens?
this.error(
DiagnosticCode.Module_0_has_no_exported_member_1,
foreignIdentifier.range,
queuedImport.foreignPath,
foreignIdentifier.text
foreignIdentifier.range, queuedImport.foreignPath, foreignIdentifier.text
);
}
} else { // i.e. import * as bar from "./bar"

View File

@ -72,20 +72,13 @@ export class Array<T> extends ArrayBufferView {
// return LOAD<T>(this.buffer_, index);
// }
// @operator("[]=")
// private __set(index: i32, value: T): void {
// var buffer = this.buffer_;
// var capacity = buffer.byteLength >>> alignof<T>();
// if (<u32>index >= <u32>capacity) {
// const MAX_LENGTH = MAX_BLENGTH >>> alignof<T>();
// if (<u32>index >= <u32>MAX_LENGTH) throw new Error("Invalid array length");
// buffer = reallocateUnsafe(buffer, (index + 1) << alignof<T>());
// this.buffer_ = buffer;
// this.length_ = index + 1;
// }
// STORE<T>(buffer, index, value);
// if (isManaged<T>()) __gc_link(changetype<usize>(this), changetype<usize>(value)); // tslint:disable-line
// }
@operator("[]=")
private __set(index: i32, value: T): void {
this.resize(index + 1);
store<T>(this.dataStart + (<usize>index << alignof<T>()), value);
if (isManaged<T>()) LINK(changetype<usize>(value), changetype<usize>(this));
if (index >= this.length_) this.length_ = index + 1;
}
// @operator("{}=")
// private __unchecked_set(index: i32, value: T): void {

View File

@ -714,7 +714,7 @@ export class Float64Array extends ArrayBufferView {
begin: i32,
end: i32
): TArray {
var buffer = changetype<usize>(array.buffer);
var buffer = array.data;
var length = <i32>array.length;
if (begin < 0) begin = max(length + begin, 0);
else begin = min(begin, length);
@ -724,7 +724,7 @@ export class Float64Array extends ArrayBufferView {
store<usize>(out, buffer, offsetof<TArray>("buffer"));
store<usize>(out, array.dataStart + (<usize>begin << alignof<T>()) , offsetof<TArray>("dataStart"));
store<usize>(out, array.dataEnd + (<usize>(end - begin) << alignof<T>()), offsetof<TArray>("dataEnd"));
LINK(buffer, REGISTER<TArray,usize>(out)); // register first, then link
LINK(buffer, REGISTER<TArray>(out)); // register first, then link
return changetype<TArray>(out);
}

View File

@ -1,4 +1,3 @@
// this function will go away once `memory.copy` becomes an intrinsic
export function memcpy(dest: usize, src: usize, n: usize): void { // see: musl/src/string/memcpy.c
var w: u32, x: u32;
@ -142,7 +141,6 @@ export function memcpy(dest: usize, src: usize, n: usize): void { // see: musl/s
}
}
// this function will go away once `memory.copy` becomes an intrinsic
export function memmove(dest: usize, src: usize, n: usize): void { // see: musl/src/string/memmove.c
if (dest === src) return;
if (src + n <= dest || dest + n <= src) {
@ -184,7 +182,6 @@ export function memmove(dest: usize, src: usize, n: usize): void { // see: musl/
}
}
// this function will go away once `memory.fill` becomes an intrinsic
export function memset(dest: usize, c: u8, n: usize): void { // see: musl/src/string/memset
// fill head and tail with minimal branching

View File

@ -1,12 +1,5 @@
import {
CharCode
} from "./string";
import {
ALLOC,
REGISTER,
FREE
} from "../runtime";
import { ALLOC, REGISTER, FREE } from "../runtime";
import { CharCode } from "./string";
@inline export const MAX_DOUBLE_LENGTH = 28;

View File

@ -18,7 +18,7 @@
(data (i32.const 152) "\01\00\00\00\10\00\00\00b\00a\00r\00r\00i\00e\00r\003")
(data (i32.const 176) "\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s")
(table $0 1 funcref)
(elem (i32.const 0) $~lib/runtime/gc.collect)
(elem (i32.const 0) $std/runtime/gc.collect)
(global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0))
(global $std/runtime/register_ref (mut i32) (i32.const 0))
(global $std/runtime/barrier1 (mut i32) (i32.const 0))
@ -36,7 +36,7 @@
(export "table" (table $0))
(export "gc.register" (func $std/runtime/gc.register))
(export "gc.link" (func $std/runtime/gc.link))
(export "gc.collect" (func $~lib/runtime/gc.collect))
(export "gc.collect" (func $std/runtime/gc.collect))
(start $start)
(func $~lib/allocator/tlsf/Root#setSLMap (; 2 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
local.get $1
@ -45,7 +45,7 @@
if
i32.const 0
i32.const 16
i32.const 144
i32.const 140
i32.const 4
call $~lib/env/abort
unreachable
@ -65,7 +65,7 @@
if
i32.const 0
i32.const 16
i32.const 167
i32.const 163
i32.const 4
call $~lib/env/abort
unreachable
@ -76,7 +76,7 @@
if
i32.const 0
i32.const 16
i32.const 168
i32.const 164
i32.const 4
call $~lib/env/abort
unreachable
@ -102,7 +102,7 @@
if
i32.const 0
i32.const 16
i32.const 89
i32.const 85
i32.const 4
call $~lib/env/abort
unreachable
@ -120,7 +120,7 @@
if
i32.const 0
i32.const 16
i32.const 90
i32.const 86
i32.const 11
call $~lib/env/abort
unreachable
@ -133,7 +133,7 @@
if
i32.const 0
i32.const 16
i32.const 428
i32.const 424
i32.const 2
call $~lib/env/abort
unreachable
@ -150,7 +150,7 @@
if
i32.const 0
i32.const 16
i32.const 158
i32.const 154
i32.const 4
call $~lib/env/abort
unreachable
@ -161,7 +161,7 @@
if
i32.const 0
i32.const 16
i32.const 159
i32.const 155
i32.const 4
call $~lib/env/abort
unreachable
@ -184,7 +184,7 @@
if
i32.const 0
i32.const 16
i32.const 138
i32.const 134
i32.const 4
call $~lib/env/abort
unreachable
@ -210,7 +210,7 @@
if
i32.const 0
i32.const 16
i32.const 258
i32.const 254
i32.const 4
call $~lib/env/abort
unreachable
@ -233,7 +233,7 @@
if
i32.const 0
i32.const 16
i32.const 260
i32.const 256
i32.const 4
call $~lib/env/abort
unreachable
@ -334,7 +334,7 @@
if
i32.const 0
i32.const 16
i32.const 81
i32.const 77
i32.const 4
call $~lib/env/abort
unreachable
@ -348,7 +348,7 @@
if
i32.const 0
i32.const 16
i32.const 82
i32.const 78
i32.const 11
call $~lib/env/abort
unreachable
@ -364,7 +364,7 @@
if
i32.const 0
i32.const 16
i32.const 334
i32.const 330
i32.const 4
call $~lib/env/abort
unreachable
@ -376,7 +376,7 @@
if
i32.const 0
i32.const 16
i32.const 335
i32.const 331
i32.const 4
call $~lib/env/abort
unreachable
@ -389,7 +389,7 @@
if
i32.const 0
i32.const 16
i32.const 336
i32.const 332
i32.const 4
call $~lib/env/abort
unreachable
@ -411,7 +411,7 @@
if
i32.const 0
i32.const 16
i32.const 189
i32.const 185
i32.const 4
call $~lib/env/abort
unreachable
@ -425,7 +425,7 @@
if
i32.const 0
i32.const 16
i32.const 191
i32.const 187
i32.const 4
call $~lib/env/abort
unreachable
@ -449,7 +449,7 @@
if
i32.const 0
i32.const 16
i32.const 193
i32.const 189
i32.const 4
call $~lib/env/abort
unreachable
@ -461,7 +461,7 @@
if
i32.const 0
i32.const 16
i32.const 197
i32.const 193
i32.const 23
call $~lib/env/abort
unreachable
@ -503,7 +503,7 @@
if
i32.const 0
i32.const 16
i32.const 211
i32.const 207
i32.const 24
call $~lib/env/abort
unreachable
@ -517,7 +517,7 @@
if
i32.const 0
i32.const 16
i32.const 213
i32.const 209
i32.const 6
call $~lib/env/abort
unreachable
@ -566,7 +566,7 @@
if
i32.const 0
i32.const 16
i32.const 226
i32.const 222
i32.const 4
call $~lib/env/abort
unreachable
@ -645,7 +645,7 @@
if
i32.const 0
i32.const 16
i32.const 377
i32.const 373
i32.const 4
call $~lib/env/abort
unreachable
@ -656,7 +656,7 @@
if
i32.const 0
i32.const 16
i32.const 378
i32.const 374
i32.const 4
call $~lib/env/abort
unreachable
@ -667,7 +667,7 @@
if
i32.const 0
i32.const 16
i32.const 379
i32.const 375
i32.const 4
call $~lib/env/abort
unreachable
@ -684,7 +684,7 @@
if
i32.const 0
i32.const 16
i32.const 384
i32.const 380
i32.const 6
call $~lib/env/abort
unreachable
@ -712,7 +712,7 @@
if
i32.const 0
i32.const 16
i32.const 393
i32.const 389
i32.const 6
call $~lib/env/abort
unreachable
@ -765,7 +765,7 @@
if
i32.const 0
i32.const 16
i32.const 422
i32.const 418
i32.const 2
call $~lib/env/abort
unreachable
@ -790,7 +790,7 @@
if
i32.const 0
i32.const 16
i32.const 296
i32.const 292
i32.const 4
call $~lib/env/abort
unreachable
@ -870,7 +870,7 @@
if
i32.const 0
i32.const 16
i32.const 323
i32.const 319
i32.const 16
call $~lib/env/abort
unreachable
@ -898,7 +898,7 @@
if
i32.const 0
i32.const 16
i32.const 348
i32.const 344
i32.const 4
call $~lib/env/abort
unreachable
@ -918,7 +918,7 @@
if
i32.const 0
i32.const 16
i32.const 349
i32.const 345
i32.const 4
call $~lib/env/abort
unreachable
@ -929,7 +929,7 @@
if
i32.const 0
i32.const 16
i32.const 350
i32.const 346
i32.const 4
call $~lib/env/abort
unreachable
@ -981,7 +981,7 @@
if
i32.const 0
i32.const 16
i32.const 368
i32.const 364
i32.const 25
call $~lib/env/abort
unreachable
@ -1146,7 +1146,7 @@
else
i32.const 0
i32.const 16
i32.const 480
i32.const 476
i32.const 14
call $~lib/env/abort
unreachable
@ -1163,7 +1163,7 @@
if
i32.const 0
i32.const 16
i32.const 483
i32.const 479
i32.const 4
call $~lib/env/abort
unreachable
@ -1200,7 +1200,7 @@
i32.const 16
i32.add
)
(func $~lib/internal/memory/memset (; 18 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(func $~lib/util/memory/memset (; 18 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
local.get $1
i32.eqz
@ -1425,10 +1425,10 @@
call $~lib/runtime/ALLOC_RAW
local.tee $1
local.get $0
call $~lib/internal/memory/memset
call $~lib/util/memory/memset
local.get $1
)
(func $~lib/internal/memory/memcpy (; 20 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/util/memory/memcpy (; 20 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@ -2325,7 +2325,7 @@
i32.store8
end
)
(func $~lib/internal/memory/memmove (; 21 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/util/memory/memmove (; 21 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
local.get $0
@ -2354,7 +2354,7 @@
local.get $0
local.get $1
local.get $2
call $~lib/internal/memory/memcpy
call $~lib/util/memory/memcpy
return
end
local.get $0
@ -2543,7 +2543,7 @@
if
i32.const 0
i32.const 16
i32.const 494
i32.const 490
i32.const 8
call $~lib/env/abort
unreachable
@ -2561,7 +2561,11 @@
end
end
)
(func $~lib/runtime/REALLOC (; 23 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(func $std/runtime/gc.register (; 23 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
global.set $std/runtime/register_ref
)
(func $~lib/runtime/REALLOC (; 24 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -2616,14 +2620,14 @@
local.tee $4
local.get $0
local.get $2
call $~lib/internal/memory/memmove
call $~lib/util/memory/memmove
local.get $2
local.get $4
i32.add
local.get $1
local.get $2
i32.sub
call $~lib/internal/memory/memset
call $~lib/util/memory/memset
local.get $3
i32.load
i32.const -1520547049
@ -2635,13 +2639,16 @@
if
i32.const 0
i32.const 184
i32.const 88
i32.const 85
i32.const 8
call $~lib/env/abort
unreachable
end
local.get $3
call $~lib/allocator/tlsf/memory.free
else
local.get $0
global.set $std/runtime/register_ref
end
local.get $5
local.set $3
@ -2654,7 +2661,7 @@
local.get $1
local.get $2
i32.sub
call $~lib/internal/memory/memset
call $~lib/util/memory/memset
end
end
local.get $3
@ -2662,7 +2669,7 @@
i32.store offset=4
local.get $0
)
(func $~lib/runtime/unref (; 24 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $~lib/runtime/unref (; 25 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.const 232
i32.lt_u
@ -2691,10 +2698,6 @@
end
local.get $0
)
(func $std/runtime/gc.register (; 25 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
global.set $std/runtime/register_ref
)
(func $start:std/runtime (; 26 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
@ -2735,7 +2738,7 @@
else
i32.const 0
i32.const 72
i32.const 36
i32.const 38
i32.const 2
call $~lib/env/abort
unreachable
@ -2846,7 +2849,7 @@
if
i32.const 0
i32.const 72
i32.const 51
i32.const 53
i32.const 0
call $~lib/env/abort
unreachable
@ -2858,7 +2861,7 @@
if
i32.const 0
i32.const 72
i32.const 52
i32.const 54
i32.const 0
call $~lib/env/abort
unreachable
@ -2872,7 +2875,7 @@
if
i32.const 0
i32.const 72
i32.const 53
i32.const 55
i32.const 0
call $~lib/env/abort
unreachable
@ -2884,7 +2887,7 @@
if
i32.const 0
i32.const 72
i32.const 54
i32.const 56
i32.const 0
call $~lib/env/abort
unreachable
@ -2899,7 +2902,7 @@
if
i32.const 0
i32.const 72
i32.const 56
i32.const 58
i32.const 0
call $~lib/env/abort
unreachable
@ -2915,7 +2918,7 @@
if
i32.const 0
i32.const 72
i32.const 58
i32.const 60
i32.const 0
call $~lib/env/abort
unreachable
@ -2932,7 +2935,7 @@
if
i32.const 0
i32.const 72
i32.const 61
i32.const 63
i32.const 0
call $~lib/env/abort
unreachable
@ -2953,7 +2956,7 @@
if
i32.const 0
i32.const 72
i32.const 65
i32.const 67
i32.const 0
call $~lib/env/abort
unreachable
@ -2969,7 +2972,7 @@
if
i32.const 0
i32.const 72
i32.const 67
i32.const 69
i32.const 0
call $~lib/env/abort
unreachable
@ -2981,7 +2984,7 @@
if
i32.const 0
i32.const 72
i32.const 68
i32.const 70
i32.const 0
call $~lib/env/abort
unreachable
@ -2998,7 +3001,7 @@
if
i32.const 0
i32.const 72
i32.const 71
i32.const 73
i32.const 0
call $~lib/env/abort
unreachable
@ -3014,7 +3017,7 @@
if
i32.const 0
i32.const 72
i32.const 72
i32.const 74
i32.const 0
call $~lib/env/abort
unreachable
@ -3023,7 +3026,7 @@
(func $std/runtime/gc.link (; 27 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
nop
)
(func $~lib/runtime/gc.collect (; 28 ;) (type $FUNCSIG$v)
(func $std/runtime/gc.collect (; 28 ;) (type $FUNCSIG$v)
nop
)
(func $start (; 29 ;) (type $FUNCSIG$v)

View File

@ -8,6 +8,8 @@ var register_ref: usize = 0;
}
export function link(ref: usize, parentRef: usize): void {
}
export function collect(): void {
}
}
import {

View File

@ -53,7 +53,7 @@
(export "table" (table $0))
(export "gc.register" (func $std/runtime/gc.register))
(export "gc.link" (func $std/runtime/gc.link))
(export "gc.collect" (func $~lib/runtime/gc.collect))
(export "gc.collect" (func $std/runtime/gc.collect))
(start $start)
(func $start:~lib/allocator/tlsf (; 2 ;) (type $FUNCSIG$v)
i32.const 1
@ -65,7 +65,7 @@
if
i32.const 0
i32.const 16
i32.const 122
i32.const 118
i32.const 0
call $~lib/env/abort
unreachable
@ -114,7 +114,7 @@
if
i32.const 0
i32.const 16
i32.const 144
i32.const 140
i32.const 4
call $~lib/env/abort
unreachable
@ -135,7 +135,7 @@
if
i32.const 0
i32.const 16
i32.const 167
i32.const 163
i32.const 4
call $~lib/env/abort
unreachable
@ -147,7 +147,7 @@
if
i32.const 0
i32.const 16
i32.const 168
i32.const 164
i32.const 4
call $~lib/env/abort
unreachable
@ -180,7 +180,7 @@
if
i32.const 0
i32.const 16
i32.const 89
i32.const 85
i32.const 4
call $~lib/env/abort
unreachable
@ -200,7 +200,7 @@
if (result i32)
i32.const 0
i32.const 16
i32.const 90
i32.const 86
i32.const 11
call $~lib/env/abort
unreachable
@ -216,7 +216,7 @@
if
i32.const 0
i32.const 16
i32.const 428
i32.const 424
i32.const 2
call $~lib/env/abort
unreachable
@ -234,7 +234,7 @@
if
i32.const 0
i32.const 16
i32.const 158
i32.const 154
i32.const 4
call $~lib/env/abort
unreachable
@ -246,7 +246,7 @@
if
i32.const 0
i32.const 16
i32.const 159
i32.const 155
i32.const 4
call $~lib/env/abort
unreachable
@ -270,7 +270,7 @@
if
i32.const 0
i32.const 16
i32.const 138
i32.const 134
i32.const 4
call $~lib/env/abort
unreachable
@ -300,7 +300,7 @@
if
i32.const 0
i32.const 16
i32.const 258
i32.const 254
i32.const 4
call $~lib/env/abort
unreachable
@ -326,7 +326,7 @@
if
i32.const 0
i32.const 16
i32.const 260
i32.const 256
i32.const 4
call $~lib/env/abort
unreachable
@ -437,7 +437,7 @@
if
i32.const 0
i32.const 16
i32.const 81
i32.const 77
i32.const 4
call $~lib/env/abort
unreachable
@ -451,7 +451,7 @@
if (result i32)
i32.const 0
i32.const 16
i32.const 82
i32.const 78
i32.const 11
call $~lib/env/abort
unreachable
@ -468,7 +468,7 @@
if
i32.const 0
i32.const 16
i32.const 334
i32.const 330
i32.const 4
call $~lib/env/abort
unreachable
@ -481,7 +481,7 @@
if
i32.const 0
i32.const 16
i32.const 335
i32.const 331
i32.const 4
call $~lib/env/abort
unreachable
@ -494,7 +494,7 @@
if
i32.const 0
i32.const 16
i32.const 336
i32.const 332
i32.const 4
call $~lib/env/abort
unreachable
@ -520,7 +520,7 @@
if
i32.const 0
i32.const 16
i32.const 189
i32.const 185
i32.const 4
call $~lib/env/abort
unreachable
@ -535,7 +535,7 @@
if
i32.const 0
i32.const 16
i32.const 191
i32.const 187
i32.const 4
call $~lib/env/abort
unreachable
@ -561,7 +561,7 @@
if
i32.const 0
i32.const 16
i32.const 193
i32.const 189
i32.const 4
call $~lib/env/abort
unreachable
@ -573,7 +573,7 @@
if (result i32)
i32.const 0
i32.const 16
i32.const 197
i32.const 193
i32.const 23
call $~lib/env/abort
unreachable
@ -621,7 +621,7 @@
if (result i32)
i32.const 0
i32.const 16
i32.const 211
i32.const 207
i32.const 24
call $~lib/env/abort
unreachable
@ -639,7 +639,7 @@
if
i32.const 0
i32.const 16
i32.const 213
i32.const 209
i32.const 6
call $~lib/env/abort
unreachable
@ -694,7 +694,7 @@
if
i32.const 0
i32.const 16
i32.const 226
i32.const 222
i32.const 4
call $~lib/env/abort
unreachable
@ -785,7 +785,7 @@
if
i32.const 0
i32.const 16
i32.const 377
i32.const 373
i32.const 4
call $~lib/env/abort
unreachable
@ -798,7 +798,7 @@
if
i32.const 0
i32.const 16
i32.const 378
i32.const 374
i32.const 4
call $~lib/env/abort
unreachable
@ -811,7 +811,7 @@
if
i32.const 0
i32.const 16
i32.const 379
i32.const 375
i32.const 4
call $~lib/env/abort
unreachable
@ -832,7 +832,7 @@
if
i32.const 0
i32.const 16
i32.const 384
i32.const 380
i32.const 6
call $~lib/env/abort
unreachable
@ -861,7 +861,7 @@
if
i32.const 0
i32.const 16
i32.const 393
i32.const 389
i32.const 6
call $~lib/env/abort
unreachable
@ -932,7 +932,7 @@
if
i32.const 0
i32.const 16
i32.const 422
i32.const 418
i32.const 2
call $~lib/env/abort
unreachable
@ -948,7 +948,7 @@
if
i32.const 0
i32.const 16
i32.const 422
i32.const 418
i32.const 2
call $~lib/env/abort
unreachable
@ -978,7 +978,7 @@
if
i32.const 0
i32.const 16
i32.const 296
i32.const 292
i32.const 4
call $~lib/env/abort
unreachable
@ -1074,7 +1074,7 @@
else
i32.const 0
i32.const 16
i32.const 323
i32.const 319
i32.const 16
call $~lib/env/abort
unreachable
@ -1111,7 +1111,7 @@
if
i32.const 0
i32.const 16
i32.const 348
i32.const 344
i32.const 4
call $~lib/env/abort
unreachable
@ -1131,7 +1131,7 @@
if
i32.const 0
i32.const 16
i32.const 349
i32.const 345
i32.const 4
call $~lib/env/abort
unreachable
@ -1144,7 +1144,7 @@
if
i32.const 0
i32.const 16
i32.const 350
i32.const 346
i32.const 4
call $~lib/env/abort
unreachable
@ -1204,7 +1204,7 @@
if (result i32)
i32.const 0
i32.const 16
i32.const 368
i32.const 364
i32.const 25
call $~lib/env/abort
unreachable
@ -1430,7 +1430,7 @@
if (result i32)
i32.const 0
i32.const 16
i32.const 480
i32.const 476
i32.const 14
call $~lib/env/abort
unreachable
@ -1451,7 +1451,7 @@
if
i32.const 0
i32.const 16
i32.const 483
i32.const 479
i32.const 4
call $~lib/env/abort
unreachable
@ -1483,7 +1483,7 @@
i32.const 16
i32.add
)
(func $~lib/internal/memory/memset (; 24 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/util/memory/memset (; 24 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i64)
@ -1755,11 +1755,11 @@
local.get $2
local.get $3
local.get $4
call $~lib/internal/memory/memset
call $~lib/util/memory/memset
end
local.get $1
)
(func $~lib/internal/memory/memcpy (; 26 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/util/memory/memcpy (; 26 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@ -2960,7 +2960,7 @@
i32.store8
end
)
(func $~lib/internal/memory/memmove (; 27 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/util/memory/memmove (; 27 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
local.get $0
local.get $1
@ -2987,7 +2987,7 @@
local.get $0
local.get $1
local.get $2
call $~lib/internal/memory/memcpy
call $~lib/util/memory/memcpy
return
end
local.get $0
@ -3212,7 +3212,7 @@
if
i32.const 0
i32.const 16
i32.const 494
i32.const 490
i32.const 8
call $~lib/env/abort
unreachable
@ -3230,7 +3230,11 @@
end
end
)
(func $~lib/runtime/REALLOC (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(func $std/runtime/gc.register (; 29 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
global.set $std/runtime/register_ref
)
(func $~lib/runtime/REALLOC (; 30 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -3289,7 +3293,7 @@
local.get $7
local.get $8
local.get $9
call $~lib/internal/memory/memmove
call $~lib/util/memory/memmove
end
block $~lib/runtime/memory.fill|inlined.1
local.get $6
@ -3305,7 +3309,7 @@
local.get $9
local.get $8
local.get $7
call $~lib/internal/memory/memset
call $~lib/util/memory/memset
end
local.get $2
i32.load
@ -3319,13 +3323,16 @@
if
i32.const 0
i32.const 184
i32.const 88
i32.const 85
i32.const 8
call $~lib/env/abort
unreachable
end
local.get $2
call $~lib/allocator/tlsf/memory.free
else
local.get $0
call $std/runtime/gc.register
end
local.get $5
local.set $2
@ -3345,7 +3352,7 @@
local.get $6
local.get $5
local.get $7
call $~lib/internal/memory/memset
call $~lib/util/memory/memset
end
else
nop
@ -3355,7 +3362,7 @@
i32.store offset=4
local.get $0
)
(func $~lib/runtime/unref (; 30 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $~lib/runtime/unref (; 31 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
global.get $~lib/runtime/HEAP_BASE
@ -3390,15 +3397,11 @@
end
local.get $1
)
(func $~lib/runtime/FREE (; 31 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $~lib/runtime/FREE<usize> (; 32 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
call $~lib/runtime/unref
call $~lib/allocator/tlsf/memory.free
)
(func $std/runtime/gc.register (; 32 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
global.set $std/runtime/register_ref
)
(func $~lib/runtime/ArrayBufferBase#get:byteLength (; 33 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.const 16
@ -3423,7 +3426,7 @@
if
i32.const 0
i32.const 72
i32.const 28
i32.const 30
i32.const 0
call $~lib/env/abort
unreachable
@ -3436,7 +3439,7 @@
if
i32.const 0
i32.const 72
i32.const 34
i32.const 36
i32.const 0
call $~lib/env/abort
unreachable
@ -3457,7 +3460,7 @@
if
i32.const 0
i32.const 72
i32.const 36
i32.const 38
i32.const 2
call $~lib/env/abort
unreachable
@ -3560,7 +3563,7 @@
if
i32.const 0
i32.const 72
i32.const 51
i32.const 53
i32.const 0
call $~lib/env/abort
unreachable
@ -3573,7 +3576,7 @@
if
i32.const 0
i32.const 72
i32.const 52
i32.const 54
i32.const 0
call $~lib/env/abort
unreachable
@ -3587,7 +3590,7 @@
if
i32.const 0
i32.const 72
i32.const 53
i32.const 55
i32.const 0
call $~lib/env/abort
unreachable
@ -3600,7 +3603,7 @@
if
i32.const 0
i32.const 72
i32.const 54
i32.const 56
i32.const 0
call $~lib/env/abort
unreachable
@ -3616,7 +3619,7 @@
if
i32.const 0
i32.const 72
i32.const 56
i32.const 58
i32.const 0
call $~lib/env/abort
unreachable
@ -3633,13 +3636,13 @@
if
i32.const 0
i32.const 72
i32.const 58
i32.const 60
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $std/runtime/ref2
call $~lib/runtime/FREE
call $~lib/runtime/FREE<usize>
global.get $std/runtime/barrier2
call $~lib/runtime/ALLOC
global.set $std/runtime/ref3
@ -3650,7 +3653,7 @@
if
i32.const 0
i32.const 72
i32.const 61
i32.const 63
i32.const 0
call $~lib/env/abort
unreachable
@ -3658,7 +3661,7 @@
global.get $std/runtime/barrier1
call $~lib/runtime/ALLOC
global.set $std/runtime/ref4
block $~lib/runtime/REGISTER<A,A>|inlined.0 (result i32)
block $~lib/runtime/REGISTER<A>|inlined.0 (result i32)
global.get $std/runtime/ref4
local.set $0
local.get $0
@ -3677,7 +3680,7 @@
if
i32.const 0
i32.const 72
i32.const 65
i32.const 67
i32.const 0
call $~lib/env/abort
unreachable
@ -3694,7 +3697,7 @@
if
i32.const 0
i32.const 72
i32.const 67
i32.const 69
i32.const 0
call $~lib/env/abort
unreachable
@ -3707,7 +3710,7 @@
if
i32.const 0
i32.const 72
i32.const 68
i32.const 70
i32.const 0
call $~lib/env/abort
unreachable
@ -3723,7 +3726,7 @@
if
i32.const 0
i32.const 72
i32.const 71
i32.const 73
i32.const 0
call $~lib/env/abort
unreachable
@ -3736,7 +3739,7 @@
if
i32.const 0
i32.const 72
i32.const 72
i32.const 74
i32.const 0
call $~lib/env/abort
unreachable
@ -3745,7 +3748,7 @@
(func $std/runtime/gc.link (; 36 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
nop
)
(func $~lib/runtime/gc.collect (; 37 ;) (type $FUNCSIG$v)
(func $std/runtime/gc.collect (; 37 ;) (type $FUNCSIG$v)
nop
)
(func $start (; 38 ;) (type $FUNCSIG$v)

View File

@ -5,7 +5,7 @@ import {
utoa64,
itoa64,
dtoa
} from "internal/number";
} from "util/number";
// preliminary