From 1928404f3bb4a92728bdfbbafd009200bb65330d Mon Sep 17 00:00:00 2001 From: Max Graey Date: Sun, 18 Nov 2018 12:43:44 +0200 Subject: [PATCH] Add ArrayBuffer/DataView/Symbol#toString and improve Errors (#332) --- std/assembly/arraybuffer.ts | 4 + std/assembly/dataview.ts | 4 + std/assembly/error.ts | 16 +- std/assembly/index.d.ts | 68 +- std/assembly/map.ts | 4 + std/assembly/set.ts | 4 + std/assembly/symbol.ts | 49 +- std/portable/index.d.ts | 77 +- tests/compiler/std/dataview.optimized.wat | 30 +- tests/compiler/std/dataview.untouched.wat | 40 +- tests/compiler/std/symbol.optimized.wat | 1447 +++++++++++++++- tests/compiler/std/symbol.ts | 10 +- tests/compiler/std/symbol.untouched.wat | 1844 ++++++++++++++++++++- 13 files changed, 3479 insertions(+), 118 deletions(-) diff --git a/std/assembly/arraybuffer.ts b/std/assembly/arraybuffer.ts index f8f2f4cd..9117c447 100644 --- a/std/assembly/arraybuffer.ts +++ b/std/assembly/arraybuffer.ts @@ -30,4 +30,8 @@ export class ArrayBuffer { memory.copy(changetype(buffer) + HEADER_SIZE, changetype(this) + HEADER_SIZE + begin, newLen); return buffer; } + + toString(): string { + return "[object ArrayBuffer]"; + } } diff --git a/std/assembly/dataview.ts b/std/assembly/dataview.ts index f3a4de3e..0e65466f 100644 --- a/std/assembly/dataview.ts +++ b/std/assembly/dataview.ts @@ -177,6 +177,10 @@ export class DataView { HEADER_SIZE ); } + + toString(): string { + return "[object DataView]"; + } } @inline function checkOffset(byteOffset: i32, n: i32, byteLength: i32): void { diff --git a/std/assembly/error.ts b/std/assembly/error.ts index 4e40a15f..9c694f57 100644 --- a/std/assembly/error.ts +++ b/std/assembly/error.ts @@ -1,12 +1,11 @@ export class Error { - name: string = "Error"; - message: string; + name: string = "Error"; stack: string = ""; // TODO - constructor(message: string = "") { - this.message = message; - } + constructor( + public message: string = "" + ) {} toString(): string { var message = this.message; @@ -29,3 +28,10 @@ export class TypeError extends Error { this.name = "TypeError"; } } + +export class SyntaxError extends Error { + constructor(message: string = "") { + super(message); + this.name = "SyntaxError"; + } +} diff --git a/std/assembly/index.d.ts b/std/assembly/index.d.ts index d48c8b5a..bf673a87 100644 --- a/std/assembly/index.d.ts +++ b/std/assembly/index.d.ts @@ -447,45 +447,47 @@ declare class DataView { /** Constructs a new `DataView` with the given properties */ constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32); /** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */ - getFloat32(byteOffset: i32, littleEndian?: boolean): f32 + getFloat32(byteOffset: i32, littleEndian?: boolean): f32; /** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */ - getFloat64(byteOffset: i32, littleEndian?: boolean): f64 + getFloat64(byteOffset: i32, littleEndian?: boolean): f64; /** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */ - getInt8(byteOffset: i32): i8 + getInt8(byteOffset: i32): i8; /** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */ - getInt16(byteOffset: i32, littleEndian?: boolean): i16 + getInt16(byteOffset: i32, littleEndian?: boolean): i16; /** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */ - getInt32(byteOffset: i32, littleEndian?: boolean): i32 + getInt32(byteOffset: i32, littleEndian?: boolean): i32; /** The `getInt64()` method gets a signed 64-bit integer (long long) at the specified byte offset from the start of the `DataView`. */ - getInt64(byteOffset: i32, littleEndian?: boolean): i64 + getInt64(byteOffset: i32, littleEndian?: boolean): i64; /** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */ - getUint8(byteOffset: i32): u8 + getUint8(byteOffset: i32): u8; /** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */ - getUint16(byteOffset: i32, littleEndian?: boolean): u16 + getUint16(byteOffset: i32, littleEndian?: boolean): u16; /** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */ - getUint32(byteOffset: i32, littleEndian?: boolean): u32 + getUint32(byteOffset: i32, littleEndian?: boolean): u32; /** The `getUint64()` method gets an unsigned 64-bit integer (unsigned long long) at the specified byte offset from the start of the `DataView`. */ - getUint64(byteOffset: i32, littleEndian?: boolean): u64 + getUint64(byteOffset: i32, littleEndian?: boolean): u64; /** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */ - setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void + setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void; /** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */ - setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void + setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void; /** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */ - setInt8(byteOffset: i32, value: i8): void + setInt8(byteOffset: i32, value: i8): void; /** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */ - setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void + setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void; /** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */ - setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void + setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void; /** The `setInt64()` method stores a signed 64-bit integer (long long) value at the specified byte offset from the start of the `DataView`. */ - setInt64(byteOffset: i32, value: i64, littleEndian?: boolean): void + setInt64(byteOffset: i32, value: i64, littleEndian?: boolean): void; /** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */ - setUint8(byteOffset: i32, value: u8): void + setUint8(byteOffset: i32, value: u8): void; /** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */ - setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void + setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void; /** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */ - setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void + setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void; /** The `setUint64()` method stores an unsigned 64-bit integer (unsigned long long) value at the specified byte offset from the start of the `DataView`. */ - setUint64(byteOffset: i32, value: u64, littleEndian?: boolean): void + setUint64(byteOffset: i32, value: u64, littleEndian?: boolean): void; + /** Returns a string representation of DataView. */ + toString(): string; } /** Interface for a typed view on an array buffer. */ @@ -621,15 +623,24 @@ declare class Error { message: string; /** Stack trace. */ - stack: string; + stack?: string; /** Constructs a new error, optionally with a message. */ constructor(message?: string); + + /** Method returns a string representing the specified Error class. */ + toString(): string; } /** Class for indicating an error when a value is not in the set or range of allowed values. */ declare class RangeError extends Error { } +/** Class for indicating an error when a value is not of the expected type. */ +declare class TypeError extends Error { } + +/** Class for indicating an error when trying to interpret syntactically invalid code. */ +declare class SyntaxError extends Error { } + interface Boolean {} interface Function {} interface IArguments {} @@ -644,6 +655,7 @@ declare class Map { get(key: K): V; delete(key: K): bool; clear(): void; + toString(): string; } declare class Set { @@ -652,13 +664,27 @@ declare class Set { add(value: T): void; delete(value: T): bool; clear(): void; + toString(): string; } interface SymbolConstructor { + readonly hasInstance: symbol; + readonly isConcatSpreadable: symbol; + readonly isRegExp: symbol; + readonly iterator: symbol; + readonly match: symbol; + readonly replace: symbol; + readonly search: symbol; + readonly species: symbol; + readonly split: symbol; + readonly toPrimitive: symbol; + readonly toStringTag: symbol; + readonly unscopables: symbol; (description?: string | null): symbol; for(key: string): symbol; keyFor(sym: symbol): string | null; } + declare const Symbol: SymbolConstructor; interface IMath { diff --git a/std/assembly/map.ts b/std/assembly/map.ts index 59c498de..6106fb72 100644 --- a/std/assembly/map.ts +++ b/std/assembly/map.ts @@ -165,6 +165,10 @@ export class Map { this.entriesOffset = this.entriesCount; } + toString(): string { + return "[object Map]"; + } + private __gc(): void { __gc_mark(changetype(this.buckets)); // tslint:disable-line var entries = this.entries; diff --git a/std/assembly/set.ts b/std/assembly/set.ts index 48a933e5..01b91f01 100644 --- a/std/assembly/set.ts +++ b/std/assembly/set.ts @@ -153,6 +153,10 @@ export class Set { this.entriesOffset = this.entriesCount; } + toString(): string { + return "[object Set]"; + } + private __gc(): void { __gc_mark(changetype(this.buckets)); // tslint:disable-line var entries = this.entries; diff --git a/std/assembly/symbol.ts b/std/assembly/symbol.ts index 2064cbc3..e0059a6a 100644 --- a/std/assembly/symbol.ts +++ b/std/assembly/symbol.ts @@ -4,7 +4,30 @@ var stringToId: Map; var idToString: Map; var nextId: usize = 12; // Symbol.unscopables + 1 -@unmanaged export class symbol {} +@unmanaged export class symbol { + toString(): string { + var id = changetype(this); + var str = ""; + switch (id) { + case 1: { str = "hasInstance"; break; } + case 2: { str = "isConcatSpreadable"; break; } + case 3: { str = "isRegExp"; break; } + case 4: { str = "match"; break; } + case 5: { str = "replace"; break; } + case 6: { str = "search"; break; } + case 7: { str = "species"; break; } + case 8: { str = "split"; break; } + case 9: { str = "toPrimitive"; break; } + case 10: { str = "toStringTag"; break; } + case 11: { str = "unscopables"; break; } + default: { + if (idToString !== null && idToString.has(id)) str = idToString.get(id); + break; + } + } + return "Symbol(" + str + ")"; + } +} type Symbol = symbol; @@ -17,18 +40,18 @@ export function Symbol(description: string | null = null): symbol { export namespace Symbol { // well-known symbols - export const hasInstance = changetype(1); - export const concatSpreadable = changetype(2); - export const isRegExp = changetype(3); - export const iterator = changetype(3); - export const match = changetype(4); - export const replace = changetype(5); - export const search = changetype(6); - export const species = changetype(7); - export const split = changetype(8); - export const toPrimitive = changetype(9); - export const toStringTag = changetype(10); - export const unscopables = changetype(11); + export const hasInstance = changetype(1); + export const isConcatSpreadable = changetype(2); + export const isRegExp = changetype(3); + export const iterator = changetype(3); + export const match = changetype(4); + export const replace = changetype(5); + export const search = changetype(6); + export const species = changetype(7); + export const split = changetype(8); + export const toPrimitive = changetype(9); + export const toStringTag = changetype(10); + export const unscopables = changetype(11); /* tslint:disable */// not valid TS export function for(key: string): symbol { diff --git a/std/portable/index.d.ts b/std/portable/index.d.ts index b0f3aec0..65128275 100644 --- a/std/portable/index.d.ts +++ b/std/portable/index.d.ts @@ -297,6 +297,8 @@ declare class ArrayBuffer { constructor(length: i32); /** Returns a copy of this array buffer's bytes from begin, inclusive, up to end, exclusive. */ slice(begin?: i32, end?: i32): ArrayBuffer; + /** Returns a string representation of ArrayBuffer. */ + toString(): string; } /** The `DataView` view provides a low-level interface for reading and writing multiple number types in a binary `ArrayBuffer`, without having to care about the platform's endianness. */ @@ -310,37 +312,39 @@ declare class DataView { /** Constructs a new `DataView` with the given properties */ constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32); /** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */ - getFloat32(byteOffset: i32, littleEndian?: boolean): f32 + getFloat32(byteOffset: i32, littleEndian?: boolean): f32; /** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */ - getFloat64(byteOffset: i32, littleEndian?: boolean): f64 + getFloat64(byteOffset: i32, littleEndian?: boolean): f64; /** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */ - getInt8(byteOffset: i32): i8 + getInt8(byteOffset: i32): i8; /** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */ - getInt16(byteOffset: i32, littleEndian?: boolean): i16 + getInt16(byteOffset: i32, littleEndian?: boolean): i16; /** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */ - getInt32(byteOffset: i32, littleEndian?: boolean): i32 + getInt32(byteOffset: i32, littleEndian?: boolean): i32; /** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */ - getUint8(byteOffset: i32): u8 + getUint8(byteOffset: i32): u8; /** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */ - getUint16(byteOffset: i32, littleEndian?: boolean): u16 + getUint16(byteOffset: i32, littleEndian?: boolean): u16; /** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */ - getUint32(byteOffset: i32, littleEndian?: boolean): u32 + getUint32(byteOffset: i32, littleEndian?: boolean): u32; /** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */ - setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void + setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void; /** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */ - setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void + setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void; /** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */ - setInt8(byteOffset: i32, value: i8): void + setInt8(byteOffset: i32, value: i8): void; /** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */ - setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void + setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void; /** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */ - setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void + setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void; /** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */ - setUint8(byteOffset: i32, value: u8): void + setUint8(byteOffset: i32, value: u8): void; /** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */ - setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void + setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void; /** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */ - setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void + setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void; + /** Returns a string representation of DataView. */ + toString(): string; } declare class Array { @@ -435,12 +439,34 @@ interface RegExp {} interface IArguments {} +/** Class for representing a runtime error. Base class of all errors. */ declare class Error { - constructor(message: string); + + /** Error name. */ + name: string; + + /** Message provided on construction. */ message: string; - stack: string | null; + + /** Stack trace. */ + stack?: string; + + /** Constructs a new error, optionally with a message. */ + constructor(message?: string); + + /** Method returns a string representing the specified Error class. */ + toString(): string; } +/** Class for indicating an error when a value is not in the set or range of allowed values. */ +declare class RangeError extends Error { } + +/** Class for indicating an error when a value is not of the expected type. */ +declare class TypeError extends Error { } + +/** Class for indicating an error when trying to interpret syntactically invalid code. */ +declare class SyntaxError extends Error { } + declare class Set { constructor(entries?: T[]); readonly size: i32; @@ -448,6 +474,7 @@ declare class Set { add(value: T): void; delete(value: T): bool; clear(): void; + toString(): string; [Symbol.iterator](): Iterator; } @@ -462,14 +489,26 @@ declare class Map { keys(): Iterable; values(): Iterable; delete(key: K): bool; + toString(): string; [Symbol.iterator](): Iterator<[K,V]>; } interface SymbolConstructor { + readonly hasInstance: symbol; + readonly isConcatSpreadable: symbol; + readonly isRegExp: symbol; + readonly iterator: symbol; + readonly match: symbol; + readonly replace: symbol; + readonly search: symbol; + readonly species: symbol; + readonly split: symbol; + readonly toPrimitive: symbol; + readonly toStringTag: symbol; + readonly unscopables: symbol; (description?: string | null): symbol; for(key: string): symbol; keyFor(sym: symbol): string | null; - readonly iterator: symbol; } declare const Symbol: SymbolConstructor; diff --git a/tests/compiler/std/dataview.optimized.wat b/tests/compiler/std/dataview.optimized.wat index ed1cc0b3..b986bd8e 100644 --- a/tests/compiler/std/dataview.optimized.wat +++ b/tests/compiler/std/dataview.optimized.wat @@ -478,7 +478,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -553,7 +553,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -602,7 +602,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -639,7 +639,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -696,7 +696,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -739,7 +739,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -785,7 +785,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -822,7 +822,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -863,7 +863,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -909,7 +909,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -945,7 +945,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -966,7 +966,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1007,7 +1007,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1048,7 +1048,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1080,7 +1080,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/dataview.untouched.wat b/tests/compiler/std/dataview.untouched.wat index 8c464c5a..5a0f8145 100644 --- a/tests/compiler/std/dataview.untouched.wat +++ b/tests/compiler/std/dataview.untouched.wat @@ -623,7 +623,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -717,7 +717,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -772,7 +772,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -828,7 +828,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -892,7 +892,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -981,7 +981,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1030,7 +1030,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1084,7 +1084,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1134,7 +1134,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1184,7 +1184,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1233,7 +1233,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1290,7 +1290,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1347,7 +1347,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1387,7 +1387,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1435,7 +1435,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1483,7 +1483,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1531,7 +1531,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1571,7 +1571,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1619,7 +1619,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable @@ -1667,7 +1667,7 @@ if i32.const 0 i32.const 136 - i32.const 184 + i32.const 188 i32.const 73 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index 866633bf..5217be33 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -11,12 +11,33 @@ (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (type $FUNCSIG$i (func (result i32))) (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\03\00\00\001\002\003") (data (i32.const 24) "\0d\00\00\00s\00t\00d\00/\00s\00y\00m\00b\00o\00l\00.\00t\00s") (data (i32.const 56) "\13\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") (data (i32.const 104) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") + (data (i32.const 176) "\0b\00\00\00h\00a\00s\00I\00n\00s\00t\00a\00n\00c\00e") + (data (i32.const 208) "\12\00\00\00i\00s\00C\00o\00n\00c\00a\00t\00S\00p\00r\00e\00a\00d\00a\00b\00l\00e") + (data (i32.const 248) "\08\00\00\00i\00s\00R\00e\00g\00E\00x\00p") + (data (i32.const 272) "\05\00\00\00m\00a\00t\00c\00h") + (data (i32.const 288) "\07\00\00\00r\00e\00p\00l\00a\00c\00e") + (data (i32.const 312) "\06\00\00\00s\00e\00a\00r\00c\00h") + (data (i32.const 328) "\07\00\00\00s\00p\00e\00c\00i\00e\00s") + (data (i32.const 352) "\05\00\00\00s\00p\00l\00i\00t") + (data (i32.const 368) "\0b\00\00\00t\00o\00P\00r\00i\00m\00i\00t\00i\00v\00e") + (data (i32.const 400) "\0b\00\00\00t\00o\00S\00t\00r\00i\00n\00g\00T\00a\00g") + (data (i32.const 432) "\0b\00\00\00u\00n\00s\00c\00o\00p\00a\00b\00l\00e\00s") + (data (i32.const 464) "\07\00\00\00S\00y\00m\00b\00o\00l\00(") + (data (i32.const 488) "\04\00\00\00n\00u\00l\00l") + (data (i32.const 504) "\0e\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s") + (data (i32.const 536) "\17\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s") + (data (i32.const 592) "\01\00\00\00)") + (data (i32.const 600) "\08\00\00\00S\00y\00m\00b\00o\00l\00(\00)") + (data (i32.const 624) "\0b\00\00\00S\00y\00m\00b\00o\00l\00(\001\002\003\00)") + (data (i32.const 656) "\13\00\00\00S\00y\00m\00b\00o\00l\00(\00h\00a\00s\00I\00n\00s\00t\00a\00n\00c\00e\00)") + (data (i32.const 704) "\1a\00\00\00S\00y\00m\00b\00o\00l\00(\00i\00s\00C\00o\00n\00c\00a\00t\00S\00p\00r\00e\00a\00d\00a\00b\00l\00e\00)") (table $0 1 anyfunc) (elem (i32.const 0) $null) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) @@ -32,6 +53,8 @@ (global $std/symbol/key2 (mut i32) (i32.const 0)) (global $std/symbol/key3 (mut i32) (i32.const 0)) (global $std/symbol/key4 (mut i32) (i32.const 0)) + (global $std/symbol/hasInstance (mut i32) (i32.const 0)) + (global $std/symbol/isConcatSpreadable (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -1103,7 +1126,31 @@ call $~lib/map/Map#set get_local $0 ) - (func $~lib/symbol/Symbol.keyFor (; 18 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#has (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + get_local $0 + get_local $1 + get_local $1 + call $~lib/internal/hash/hash32 + call $~lib/map/Map#find + i32.const 0 + i32.ne + ) + (func $~lib/map/Map#get (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + get_local $0 + get_local $1 + get_local $1 + call $~lib/internal/hash/hash32 + call $~lib/map/Map#find + tee_local $0 + if (result i32) + get_local $0 + i32.load offset=4 + else + unreachable + end + tee_local $0 + ) + (func $~lib/symbol/Symbol.keyFor (; 20 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) get_global $~lib/symbol/idToString i32.const 0 @@ -1112,35 +1159,1331 @@ if get_global $~lib/symbol/idToString get_local $0 - get_local $0 - call $~lib/internal/hash/hash32 - call $~lib/map/Map#find - i32.const 0 - i32.ne + call $~lib/map/Map#has set_local $1 end get_local $1 if (result i32) get_global $~lib/symbol/idToString get_local $0 - get_local $0 - call $~lib/internal/hash/hash32 - call $~lib/map/Map#find - tee_local $0 - if (result i32) - get_local $0 - i32.load offset=4 - else - unreachable - end + call $~lib/map/Map#get else i32.const 0 end tee_local $0 ) - (func $start (; 19 ;) (type $v) - (local $0 i32) + (func $~lib/internal/string/allocateUnsafe (; 21 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + get_local $0 + i32.const 0 + i32.gt_s + tee_local $1 + if + get_local $0 + i32.const 536870910 + i32.le_s + set_local $1 + end + get_local $1 + i32.eqz + if + i32.const 0 + i32.const 536 + i32.const 14 + i32.const 2 + call $~lib/env/abort + unreachable + end + get_local $0 + i32.const 1 + i32.shl + i32.const 4 + i32.add + call $~lib/allocator/arena/__memory_allocate + tee_local $1 + get_local $0 + i32.store + get_local $1 + ) + (func $~lib/internal/memory/memcpy (; 22 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + loop $continue|0 + get_local $2 + if (result i32) + get_local $1 + i32.const 3 + i32.and + else + get_local $2 + end + tee_local $3 + if + get_local $0 + tee_local $4 + i32.const 1 + i32.add + set_local $0 + get_local $1 + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $4 + get_local $3 + i32.load8_u + i32.store8 + get_local $2 + i32.const 1 + i32.sub + set_local $2 + br $continue|0 + end + end + get_local $0 + i32.const 3 + i32.and + i32.eqz + if + loop $continue|1 + get_local $2 + i32.const 16 + i32.ge_u + if + get_local $0 + get_local $1 + i32.load + i32.store + get_local $0 + i32.const 4 + i32.add + get_local $1 + i32.const 4 + i32.add + i32.load + i32.store + get_local $0 + i32.const 8 + i32.add + get_local $1 + i32.const 8 + i32.add + i32.load + i32.store + get_local $0 + i32.const 12 + i32.add + get_local $1 + i32.const 12 + i32.add + i32.load + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + br $continue|1 + end + end + get_local $2 + i32.const 8 + i32.and + if + get_local $0 + get_local $1 + i32.load + i32.store + get_local $0 + i32.const 4 + i32.add + get_local $1 + i32.const 4 + i32.add + i32.load + i32.store + get_local $0 + i32.const 8 + i32.add + set_local $0 + get_local $1 + i32.const 8 + i32.add + set_local $1 + end + get_local $2 + i32.const 4 + i32.and + if + get_local $0 + get_local $1 + i32.load + i32.store + get_local $0 + i32.const 4 + i32.add + set_local $0 + get_local $1 + i32.const 4 + i32.add + set_local $1 + end + get_local $2 + i32.const 2 + i32.and + if + get_local $0 + get_local $1 + i32.load16_u + i32.store16 + get_local $0 + i32.const 2 + i32.add + set_local $0 + get_local $1 + i32.const 2 + i32.add + set_local $1 + end + get_local $2 + i32.const 1 + i32.and + if + get_local $1 + set_local $3 + get_local $0 + get_local $1 + i32.load8_u + i32.store8 + end + return + end + get_local $2 + i32.const 32 + i32.ge_u + if + block $break|2 + block $case2|2 + block $case1|2 + get_local $0 + i32.const 3 + i32.and + tee_local $3 + i32.const 1 + i32.ne + if + get_local $3 + i32.const 2 + i32.eq + br_if $case1|2 + get_local $3 + i32.const 3 + i32.eq + br_if $case2|2 + br $break|2 + end + get_local $1 + i32.load + set_local $5 + get_local $0 + get_local $1 + tee_local $3 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $1 + set_local $0 + get_local $1 + get_local $3 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $4 + i32.const 1 + i32.add + set_local $0 + get_local $1 + i32.const 1 + i32.add + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $4 + get_local $3 + i32.load8_u + i32.store8 + get_local $2 + i32.const 3 + i32.sub + set_local $2 + loop $continue|3 + get_local $2 + i32.const 17 + i32.ge_u + if + get_local $0 + get_local $5 + i32.const 24 + i32.shr_u + get_local $1 + i32.const 1 + i32.add + i32.load + tee_local $3 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $0 + i32.const 4 + i32.add + get_local $3 + i32.const 24 + i32.shr_u + get_local $1 + i32.const 5 + i32.add + i32.load + tee_local $5 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $0 + i32.const 8 + i32.add + get_local $5 + i32.const 24 + i32.shr_u + get_local $1 + i32.const 9 + i32.add + i32.load + tee_local $3 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $0 + i32.const 12 + i32.add + get_local $3 + i32.const 24 + i32.shr_u + get_local $1 + i32.const 13 + i32.add + i32.load + tee_local $5 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + br $continue|3 + end + end + br $break|2 + end + get_local $1 + i32.load + set_local $5 + get_local $0 + get_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $4 + i32.const 1 + i32.add + set_local $0 + get_local $1 + i32.const 1 + i32.add + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $4 + get_local $3 + i32.load8_u + i32.store8 + get_local $2 + i32.const 2 + i32.sub + set_local $2 + loop $continue|4 + get_local $2 + i32.const 18 + i32.ge_u + if + get_local $0 + get_local $5 + i32.const 16 + i32.shr_u + get_local $1 + i32.const 2 + i32.add + i32.load + tee_local $3 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $0 + i32.const 4 + i32.add + get_local $3 + i32.const 16 + i32.shr_u + get_local $1 + i32.const 6 + i32.add + i32.load + tee_local $5 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $0 + i32.const 8 + i32.add + get_local $5 + i32.const 16 + i32.shr_u + get_local $1 + i32.const 10 + i32.add + i32.load + tee_local $3 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $0 + i32.const 12 + i32.add + get_local $3 + i32.const 16 + i32.shr_u + get_local $1 + i32.const 14 + i32.add + i32.load + tee_local $5 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + br $continue|4 + end + end + br $break|2 + end + get_local $1 + i32.load + set_local $5 + get_local $0 + tee_local $4 + i32.const 1 + i32.add + set_local $0 + get_local $1 + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $4 + get_local $3 + i32.load8_u + i32.store8 + get_local $2 + i32.const 1 + i32.sub + set_local $2 + loop $continue|5 + get_local $2 + i32.const 19 + i32.ge_u + if + get_local $0 + get_local $5 + i32.const 8 + i32.shr_u + get_local $1 + i32.const 3 + i32.add + i32.load + tee_local $3 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $0 + i32.const 4 + i32.add + get_local $3 + i32.const 8 + i32.shr_u + get_local $1 + i32.const 7 + i32.add + i32.load + tee_local $5 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $0 + i32.const 8 + i32.add + get_local $5 + i32.const 8 + i32.shr_u + get_local $1 + i32.const 11 + i32.add + i32.load + tee_local $3 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $0 + i32.const 12 + i32.add + get_local $3 + i32.const 8 + i32.shr_u + get_local $1 + i32.const 15 + i32.add + i32.load + tee_local $5 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + br $continue|5 + end + end + end + end + get_local $2 + i32.const 16 + i32.and + if + get_local $0 + get_local $1 + tee_local $3 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $1 + set_local $0 + get_local $1 + get_local $3 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $4 + i32.const 1 + i32.add + set_local $0 + get_local $1 + i32.const 1 + i32.add + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $4 + get_local $3 + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 8 + i32.and + if + get_local $0 + get_local $1 + tee_local $3 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $1 + set_local $0 + get_local $1 + get_local $3 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $4 + i32.const 1 + i32.add + set_local $0 + get_local $1 + i32.const 1 + i32.add + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $4 + get_local $3 + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 4 + i32.and + if + get_local $0 + get_local $1 + tee_local $3 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $1 + set_local $0 + get_local $1 + get_local $3 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $3 + set_local $0 + get_local $3 + get_local $1 + i32.const 1 + i32.add + tee_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $4 + i32.const 1 + i32.add + set_local $0 + get_local $1 + i32.const 1 + i32.add + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $4 + get_local $3 + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 2 + i32.and + if + get_local $0 + get_local $1 + i32.load8_u + i32.store8 + get_local $0 + i32.const 1 + i32.add + tee_local $4 + i32.const 1 + i32.add + set_local $0 + get_local $1 + i32.const 1 + i32.add + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $4 + get_local $3 + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 1 + i32.and + if + get_local $1 + set_local $3 + get_local $0 + get_local $1 + i32.load8_u + i32.store8 + end + ) + (func $~lib/internal/memory/memmove (; 23 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + get_local $0 + get_local $1 + i32.eq + if + return + end + get_local $1 + get_local $2 + i32.add + get_local $0 + i32.le_u + tee_local $3 + i32.eqz + if + get_local $0 + get_local $2 + i32.add + get_local $1 + i32.le_u + set_local $3 + end + get_local $3 + if + get_local $0 + get_local $1 + get_local $2 + call $~lib/internal/memory/memcpy + return + end + get_local $0 + get_local $1 + i32.lt_u + if + get_local $1 + i32.const 7 + i32.and + get_local $0 + i32.const 7 + i32.and + i32.eq + if + loop $continue|0 + get_local $0 + i32.const 7 + i32.and + if + get_local $2 + i32.eqz + if + return + end + get_local $2 + i32.const 1 + i32.sub + set_local $2 + get_local $0 + tee_local $4 + tee_local $3 + i32.const 1 + i32.add + set_local $0 + get_local $1 + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $4 + get_local $3 + i32.load8_u + i32.store8 + br $continue|0 + end + end + loop $continue|1 + get_local $2 + i32.const 8 + i32.ge_u + if + get_local $0 + get_local $1 + i64.load + i64.store + get_local $2 + i32.const 8 + i32.sub + set_local $2 + get_local $0 + i32.const 8 + i32.add + set_local $0 + get_local $1 + i32.const 8 + i32.add + set_local $1 + br $continue|1 + end + end + end + loop $continue|2 + get_local $2 + if + get_local $0 + tee_local $4 + tee_local $3 + i32.const 1 + i32.add + set_local $0 + get_local $1 + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $4 + get_local $3 + i32.load8_u + i32.store8 + get_local $2 + i32.const 1 + i32.sub + set_local $2 + br $continue|2 + end + end + else + get_local $1 + i32.const 7 + i32.and + get_local $0 + i32.const 7 + i32.and + i32.eq + if + loop $continue|3 + get_local $0 + get_local $2 + i32.add + i32.const 7 + i32.and + if + get_local $2 + i32.eqz + if + return + end + get_local $0 + get_local $2 + i32.const 1 + i32.sub + tee_local $2 + i32.add + get_local $1 + get_local $2 + i32.add + i32.load8_u + i32.store8 + br $continue|3 + end + end + loop $continue|4 + get_local $2 + i32.const 8 + i32.ge_u + if + get_local $0 + get_local $2 + i32.const 8 + i32.sub + tee_local $2 + i32.add + get_local $1 + get_local $2 + i32.add + i64.load + i64.store + br $continue|4 + end + end + end + loop $continue|5 + get_local $2 + if + get_local $0 + get_local $2 + i32.const 1 + i32.sub + tee_local $2 + i32.add + get_local $1 + get_local $2 + i32.add + i32.load8_u + i32.store8 + br $continue|5 + end + end + end + ) + (func $~lib/internal/string/copyUnsafe (; 24 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + get_local $0 + get_local $1 + i32.const 1 + i32.shl + i32.add + i32.const 4 + i32.add + get_local $2 + i32.const 4 + i32.add + get_local $3 + i32.const 1 + i32.shl + call $~lib/internal/memory/memmove + ) + (func $~lib/string/String#concat (; 25 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + get_local $0 + i32.eqz + if + i32.const 0 + i32.const 504 + i32.const 110 + i32.const 4 + call $~lib/env/abort + unreachable + end + get_local $1 + i32.eqz + if + i32.const 488 + set_local $1 + end + get_local $0 + i32.load + tee_local $3 + get_local $1 + i32.load + tee_local $4 + i32.add + tee_local $2 + i32.eqz + if + i32.const 168 + return + end + get_local $2 + call $~lib/internal/string/allocateUnsafe + tee_local $2 + i32.const 0 + get_local $0 + get_local $3 + call $~lib/internal/string/copyUnsafe + get_local $2 + get_local $3 + get_local $1 + get_local $4 + call $~lib/internal/string/copyUnsafe + get_local $2 + ) + (func $~lib/string/String.__concat (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + get_local $0 + i32.eqz + if + i32.const 488 + set_local $0 + end + get_local $0 + get_local $1 + call $~lib/string/String#concat + ) + (func $~lib/symbol/symbol#toString (; 27 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) i32.const 168 + set_local $1 + block $break|0 + block $case11|0 + block $case10|0 + block $case9|0 + block $case8|0 + block $case7|0 + block $case6|0 + block $case5|0 + block $case4|0 + block $case3|0 + block $case2|0 + block $case1|0 + get_local $0 + tee_local $2 + i32.const 1 + i32.ne + if + block $tablify|0 + get_local $2 + i32.const 2 + i32.sub + br_table $case1|0 $case2|0 $case3|0 $case4|0 $case5|0 $case6|0 $case7|0 $case8|0 $case9|0 $case10|0 $tablify|0 + end + br $case11|0 + end + i32.const 176 + set_local $1 + br $break|0 + end + i32.const 208 + set_local $1 + br $break|0 + end + i32.const 248 + set_local $1 + br $break|0 + end + i32.const 272 + set_local $1 + br $break|0 + end + i32.const 288 + set_local $1 + br $break|0 + end + i32.const 312 + set_local $1 + br $break|0 + end + i32.const 328 + set_local $1 + br $break|0 + end + i32.const 352 + set_local $1 + br $break|0 + end + i32.const 368 + set_local $1 + br $break|0 + end + i32.const 400 + set_local $1 + br $break|0 + end + i32.const 432 + set_local $1 + br $break|0 + end + get_global $~lib/symbol/idToString + i32.const 0 + i32.ne + tee_local $2 + if + get_global $~lib/symbol/idToString + get_local $0 + call $~lib/map/Map#has + set_local $2 + end + get_local $2 + if + get_global $~lib/symbol/idToString + get_local $0 + call $~lib/map/Map#get + set_local $1 + end + end + i32.const 464 + get_local $1 + call $~lib/string/String.__concat + i32.const 592 + call $~lib/string/String.__concat + ) + (func $start (; 28 ;) (type $v) + (local $0 i32) + i32.const 760 set_global $~lib/allocator/arena/startOffset get_global $~lib/allocator/arena/startOffset set_global $~lib/allocator/arena/offset @@ -1248,8 +2591,74 @@ call $~lib/env/abort unreachable end + get_global $~lib/symbol/nextId + tee_local $0 + i32.const 1 + i32.add + set_global $~lib/symbol/nextId + get_local $0 + i32.eqz + if + unreachable + end + get_local $0 + call $~lib/symbol/symbol#toString + i32.const 600 + call $~lib/string/String.__eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 25 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/symbol/sym3 + call $~lib/symbol/symbol#toString + i32.const 624 + call $~lib/string/String.__eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 26 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 1 + set_global $std/symbol/hasInstance + i32.const 2 + set_global $std/symbol/isConcatSpreadable + get_global $std/symbol/hasInstance + call $~lib/symbol/symbol#toString + i32.const 656 + call $~lib/string/String.__eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 30 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/symbol/isConcatSpreadable + call $~lib/symbol/symbol#toString + i32.const 704 + call $~lib/string/String.__eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 31 + i32.const 0 + call $~lib/env/abort + unreachable + end ) - (func $null (; 20 ;) (type $v) + (func $null (; 29 ;) (type $v) nop ) ) diff --git a/tests/compiler/std/symbol.ts b/tests/compiler/std/symbol.ts index ace259df..e5168b36 100644 --- a/tests/compiler/std/symbol.ts +++ b/tests/compiler/std/symbol.ts @@ -22,6 +22,14 @@ var key4 = Symbol.keyFor(sym4); assert(key3 == "123"); assert(key3 == key4); +assert(Symbol().toString() == "Symbol()"); +assert(sym3.toString() == "Symbol(123)"); + +var hasInstance = Symbol.hasInstance; +var isConcatSpreadable = Symbol.isConcatSpreadable; +assert(hasInstance.toString() == "Symbol(hasInstance)"); +assert(isConcatSpreadable.toString() == "Symbol(isConcatSpreadable)"); + Symbol.hasInstance; -Symbol.concatSpreadable; +Symbol.isConcatSpreadable; // ... diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index 65b4aa93..4a9142d4 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -7,6 +7,7 @@ (type $iii (func (param i32 i32) (result i32))) (type $iiiiii (func (param i32 i32 i32 i32 i32) (result i32))) (type $iiv (func (param i32 i32))) + (type $iiiiiv (func (param i32 i32 i32 i32 i32))) (type $v (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) @@ -14,6 +15,27 @@ (data (i32.const 24) "\0d\00\00\00s\00t\00d\00/\00s\00y\00m\00b\00o\00l\00.\00t\00s\00") (data (i32.const 56) "\13\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") (data (i32.const 104) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") + (data (i32.const 168) "\00\00\00\00") + (data (i32.const 176) "\0b\00\00\00h\00a\00s\00I\00n\00s\00t\00a\00n\00c\00e\00") + (data (i32.const 208) "\12\00\00\00i\00s\00C\00o\00n\00c\00a\00t\00S\00p\00r\00e\00a\00d\00a\00b\00l\00e\00") + (data (i32.const 248) "\08\00\00\00i\00s\00R\00e\00g\00E\00x\00p\00") + (data (i32.const 272) "\05\00\00\00m\00a\00t\00c\00h\00") + (data (i32.const 288) "\07\00\00\00r\00e\00p\00l\00a\00c\00e\00") + (data (i32.const 312) "\06\00\00\00s\00e\00a\00r\00c\00h\00") + (data (i32.const 328) "\07\00\00\00s\00p\00e\00c\00i\00e\00s\00") + (data (i32.const 352) "\05\00\00\00s\00p\00l\00i\00t\00") + (data (i32.const 368) "\0b\00\00\00t\00o\00P\00r\00i\00m\00i\00t\00i\00v\00e\00") + (data (i32.const 400) "\0b\00\00\00t\00o\00S\00t\00r\00i\00n\00g\00T\00a\00g\00") + (data (i32.const 432) "\0b\00\00\00u\00n\00s\00c\00o\00p\00a\00b\00l\00e\00s\00") + (data (i32.const 464) "\07\00\00\00S\00y\00m\00b\00o\00l\00(\00") + (data (i32.const 488) "\04\00\00\00n\00u\00l\00l\00") + (data (i32.const 504) "\0e\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00") + (data (i32.const 536) "\17\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00") + (data (i32.const 592) "\01\00\00\00)\00") + (data (i32.const 600) "\08\00\00\00S\00y\00m\00b\00o\00l\00(\00)\00") + (data (i32.const 624) "\0b\00\00\00S\00y\00m\00b\00o\00l\00(\001\002\003\00)\00") + (data (i32.const 656) "\13\00\00\00S\00y\00m\00b\00o\00l\00(\00h\00a\00s\00I\00n\00s\00t\00a\00n\00c\00e\00)\00") + (data (i32.const 704) "\1a\00\00\00S\00y\00m\00b\00o\00l\00(\00i\00s\00C\00o\00n\00c\00a\00t\00S\00p\00r\00e\00a\00d\00a\00b\00l\00e\00)\00") (table $0 1 anyfunc) (elem (i32.const 0) $null) (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) @@ -43,9 +65,12 @@ (global $std/symbol/key2 (mut i32) (i32.const 0)) (global $std/symbol/key3 (mut i32) (i32.const 0)) (global $std/symbol/key4 (mut i32) (i32.const 0)) + (global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910)) (global $~lib/symbol/Symbol.hasInstance i32 (i32.const 1)) - (global $~lib/symbol/Symbol.concatSpreadable i32 (i32.const 2)) - (global $HEAP_BASE i32 (i32.const 164)) + (global $std/symbol/hasInstance (mut i32) (i32.const 0)) + (global $~lib/symbol/Symbol.isConcatSpreadable i32 (i32.const 2)) + (global $std/symbol/isConcatSpreadable (mut i32) (i32.const 0)) + (global $HEAP_BASE i32 (i32.const 760)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -1512,7 +1537,1759 @@ i32.const 0 end ) - (func $start (; 28 ;) (type $v) + (func $~lib/internal/string/allocateUnsafe (; 28 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + get_local $0 + i32.const 0 + i32.gt_s + tee_local $1 + if (result i32) + get_local $0 + get_global $~lib/internal/string/MAX_LENGTH + i32.le_s + else + get_local $1 + end + i32.eqz + if + i32.const 0 + i32.const 536 + i32.const 14 + i32.const 2 + call $~lib/env/abort + unreachable + end + block $~lib/memory/memory.allocate|inlined.1 (result i32) + get_global $~lib/internal/string/HEADER_SIZE + get_local $0 + i32.const 1 + i32.shl + i32.add + set_local $1 + get_local $1 + call $~lib/allocator/arena/__memory_allocate + br $~lib/memory/memory.allocate|inlined.1 + end + set_local $2 + get_local $2 + get_local $0 + i32.store + get_local $2 + ) + (func $~lib/internal/memory/memcpy (; 29 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + block $break|0 + loop $continue|0 + get_local $2 + if (result i32) + get_local $1 + i32.const 3 + i32.and + else + get_local $2 + end + if + block + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + get_local $2 + i32.const 1 + i32.sub + set_local $2 + end + br $continue|0 + end + end + end + get_local $0 + i32.const 3 + i32.and + i32.const 0 + i32.eq + if + block $break|1 + loop $continue|1 + get_local $2 + i32.const 16 + i32.ge_u + if + block + get_local $0 + get_local $1 + i32.load + i32.store + get_local $0 + i32.const 4 + i32.add + get_local $1 + i32.const 4 + i32.add + i32.load + i32.store + get_local $0 + i32.const 8 + i32.add + get_local $1 + i32.const 8 + i32.add + i32.load + i32.store + get_local $0 + i32.const 12 + i32.add + get_local $1 + i32.const 12 + i32.add + i32.load + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + end + br $continue|1 + end + end + end + get_local $2 + i32.const 8 + i32.and + if + get_local $0 + get_local $1 + i32.load + i32.store + get_local $0 + i32.const 4 + i32.add + get_local $1 + i32.const 4 + i32.add + i32.load + i32.store + get_local $0 + i32.const 8 + i32.add + set_local $0 + get_local $1 + i32.const 8 + i32.add + set_local $1 + end + get_local $2 + i32.const 4 + i32.and + if + get_local $0 + get_local $1 + i32.load + i32.store + get_local $0 + i32.const 4 + i32.add + set_local $0 + get_local $1 + i32.const 4 + i32.add + set_local $1 + end + get_local $2 + i32.const 2 + i32.and + if + get_local $0 + get_local $1 + i32.load16_u + i32.store16 + get_local $0 + i32.const 2 + i32.add + set_local $0 + get_local $1 + i32.const 2 + i32.add + set_local $1 + end + get_local $2 + i32.const 1 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + return + end + get_local $2 + i32.const 32 + i32.ge_u + if + block $break|2 + block $case2|2 + block $case1|2 + block $case0|2 + get_local $0 + i32.const 3 + i32.and + set_local $5 + get_local $5 + i32.const 1 + i32.eq + br_if $case0|2 + get_local $5 + i32.const 2 + i32.eq + br_if $case1|2 + get_local $5 + i32.const 3 + i32.eq + br_if $case2|2 + br $break|2 + end + block + get_local $1 + i32.load + set_local $3 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + get_local $2 + i32.const 3 + i32.sub + set_local $2 + block $break|3 + loop $continue|3 + get_local $2 + i32.const 17 + i32.ge_u + if + block + get_local $1 + i32.const 1 + i32.add + i32.load + set_local $4 + get_local $0 + get_local $3 + i32.const 24 + i32.shr_u + get_local $4 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 5 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 4 + i32.add + get_local $4 + i32.const 24 + i32.shr_u + get_local $3 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 9 + i32.add + i32.load + set_local $4 + get_local $0 + i32.const 8 + i32.add + get_local $3 + i32.const 24 + i32.shr_u + get_local $4 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 13 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 12 + i32.add + get_local $4 + i32.const 24 + i32.shr_u + get_local $3 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + end + br $continue|3 + end + end + end + br $break|2 + unreachable + end + unreachable + end + block + get_local $1 + i32.load + set_local $3 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + get_local $2 + i32.const 2 + i32.sub + set_local $2 + block $break|4 + loop $continue|4 + get_local $2 + i32.const 18 + i32.ge_u + if + block + get_local $1 + i32.const 2 + i32.add + i32.load + set_local $4 + get_local $0 + get_local $3 + i32.const 16 + i32.shr_u + get_local $4 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 6 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 4 + i32.add + get_local $4 + i32.const 16 + i32.shr_u + get_local $3 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 10 + i32.add + i32.load + set_local $4 + get_local $0 + i32.const 8 + i32.add + get_local $3 + i32.const 16 + i32.shr_u + get_local $4 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 14 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 12 + i32.add + get_local $4 + i32.const 16 + i32.shr_u + get_local $3 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + end + br $continue|4 + end + end + end + br $break|2 + unreachable + end + unreachable + end + block + get_local $1 + i32.load + set_local $3 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + get_local $2 + i32.const 1 + i32.sub + set_local $2 + block $break|5 + loop $continue|5 + get_local $2 + i32.const 19 + i32.ge_u + if + block + get_local $1 + i32.const 3 + i32.add + i32.load + set_local $4 + get_local $0 + get_local $3 + i32.const 8 + i32.shr_u + get_local $4 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 7 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 4 + i32.add + get_local $4 + i32.const 8 + i32.shr_u + get_local $3 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 11 + i32.add + i32.load + set_local $4 + get_local $0 + i32.const 8 + i32.add + get_local $3 + i32.const 8 + i32.shr_u + get_local $4 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 15 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 12 + i32.add + get_local $4 + i32.const 8 + i32.shr_u + get_local $3 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + end + br $continue|5 + end + end + end + br $break|2 + unreachable + end + unreachable + end + end + get_local $2 + i32.const 16 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 8 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 4 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 2 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 1 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + ) + (func $~lib/internal/memory/memmove (; 30 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + get_local $0 + get_local $1 + i32.eq + if + return + end + get_local $1 + get_local $2 + i32.add + get_local $0 + i32.le_u + tee_local $3 + if (result i32) + get_local $3 + else + get_local $0 + get_local $2 + i32.add + get_local $1 + i32.le_u + end + if + get_local $0 + get_local $1 + get_local $2 + call $~lib/internal/memory/memcpy + return + end + get_local $0 + get_local $1 + i32.lt_u + if + get_local $1 + i32.const 7 + i32.and + get_local $0 + i32.const 7 + i32.and + i32.eq + if + block $break|0 + loop $continue|0 + get_local $0 + i32.const 7 + i32.and + if + block + get_local $2 + i32.eqz + if + return + end + get_local $2 + i32.const 1 + i32.sub + set_local $2 + block (result i32) + get_local $0 + tee_local $3 + i32.const 1 + i32.add + set_local $0 + get_local $3 + end + block (result i32) + get_local $1 + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $3 + end + i32.load8_u + i32.store8 + end + br $continue|0 + end + end + end + block $break|1 + loop $continue|1 + get_local $2 + i32.const 8 + i32.ge_u + if + block + get_local $0 + get_local $1 + i64.load + i64.store + get_local $2 + i32.const 8 + i32.sub + set_local $2 + get_local $0 + i32.const 8 + i32.add + set_local $0 + get_local $1 + i32.const 8 + i32.add + set_local $1 + end + br $continue|1 + end + end + end + end + block $break|2 + loop $continue|2 + get_local $2 + if + block + block (result i32) + get_local $0 + tee_local $3 + i32.const 1 + i32.add + set_local $0 + get_local $3 + end + block (result i32) + get_local $1 + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $3 + end + i32.load8_u + i32.store8 + get_local $2 + i32.const 1 + i32.sub + set_local $2 + end + br $continue|2 + end + end + end + else + get_local $1 + i32.const 7 + i32.and + get_local $0 + i32.const 7 + i32.and + i32.eq + if + block $break|3 + loop $continue|3 + get_local $0 + get_local $2 + i32.add + i32.const 7 + i32.and + if + block + get_local $2 + i32.eqz + if + return + end + get_local $0 + get_local $2 + i32.const 1 + i32.sub + tee_local $2 + i32.add + get_local $1 + get_local $2 + i32.add + i32.load8_u + i32.store8 + end + br $continue|3 + end + end + end + block $break|4 + loop $continue|4 + get_local $2 + i32.const 8 + i32.ge_u + if + block + get_local $2 + i32.const 8 + i32.sub + set_local $2 + get_local $0 + get_local $2 + i32.add + get_local $1 + get_local $2 + i32.add + i64.load + i64.store + end + br $continue|4 + end + end + end + end + block $break|5 + loop $continue|5 + get_local $2 + if + get_local $0 + get_local $2 + i32.const 1 + i32.sub + tee_local $2 + i32.add + get_local $1 + get_local $2 + i32.add + i32.load8_u + i32.store8 + br $continue|5 + end + end + end + end + ) + (func $~lib/internal/string/copyUnsafe (; 31 ;) (type $iiiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + get_local $0 + get_local $1 + i32.const 1 + i32.shl + i32.add + get_global $~lib/internal/string/HEADER_SIZE + i32.add + set_local $5 + get_local $2 + get_local $3 + i32.const 1 + i32.shl + i32.add + get_global $~lib/internal/string/HEADER_SIZE + i32.add + set_local $6 + get_local $4 + i32.const 1 + i32.shl + set_local $7 + get_local $5 + get_local $6 + get_local $7 + call $~lib/internal/memory/memmove + ) + (func $~lib/string/String#concat (; 32 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + get_local $0 + i32.const 0 + i32.ne + i32.eqz + if + i32.const 0 + i32.const 504 + i32.const 110 + i32.const 4 + call $~lib/env/abort + unreachable + end + get_local $1 + i32.const 0 + i32.eq + if + i32.const 488 + set_local $1 + end + get_local $0 + i32.load + set_local $2 + get_local $1 + i32.load + set_local $3 + get_local $2 + get_local $3 + i32.add + set_local $4 + get_local $4 + i32.const 0 + i32.eq + if + i32.const 168 + return + end + get_local $4 + call $~lib/internal/string/allocateUnsafe + set_local $5 + get_local $5 + i32.const 0 + get_local $0 + i32.const 0 + get_local $2 + call $~lib/internal/string/copyUnsafe + get_local $5 + get_local $2 + get_local $1 + i32.const 0 + get_local $3 + call $~lib/internal/string/copyUnsafe + get_local $5 + ) + (func $~lib/string/String.__concat (; 33 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + get_local $0 + i32.eqz + if + i32.const 488 + set_local $0 + end + get_local $0 + get_local $1 + call $~lib/string/String#concat + ) + (func $~lib/symbol/symbol#toString (; 34 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + get_local $0 + set_local $1 + i32.const 168 + set_local $2 + block $break|0 + block $case11|0 + block $case10|0 + block $case9|0 + block $case8|0 + block $case7|0 + block $case6|0 + block $case5|0 + block $case4|0 + block $case3|0 + block $case2|0 + block $case1|0 + block $case0|0 + get_local $1 + set_local $3 + get_local $3 + i32.const 1 + i32.eq + br_if $case0|0 + get_local $3 + i32.const 2 + i32.eq + br_if $case1|0 + get_local $3 + i32.const 3 + i32.eq + br_if $case2|0 + get_local $3 + i32.const 4 + i32.eq + br_if $case3|0 + get_local $3 + i32.const 5 + i32.eq + br_if $case4|0 + get_local $3 + i32.const 6 + i32.eq + br_if $case5|0 + get_local $3 + i32.const 7 + i32.eq + br_if $case6|0 + get_local $3 + i32.const 8 + i32.eq + br_if $case7|0 + get_local $3 + i32.const 9 + i32.eq + br_if $case8|0 + get_local $3 + i32.const 10 + i32.eq + br_if $case9|0 + get_local $3 + i32.const 11 + i32.eq + br_if $case10|0 + br $case11|0 + end + block + i32.const 176 + set_local $2 + br $break|0 + unreachable + end + unreachable + end + block + i32.const 208 + set_local $2 + br $break|0 + unreachable + end + unreachable + end + block + i32.const 248 + set_local $2 + br $break|0 + unreachable + end + unreachable + end + block + i32.const 272 + set_local $2 + br $break|0 + unreachable + end + unreachable + end + block + i32.const 288 + set_local $2 + br $break|0 + unreachable + end + unreachable + end + block + i32.const 312 + set_local $2 + br $break|0 + unreachable + end + unreachable + end + block + i32.const 328 + set_local $2 + br $break|0 + unreachable + end + unreachable + end + block + i32.const 352 + set_local $2 + br $break|0 + unreachable + end + unreachable + end + block + i32.const 368 + set_local $2 + br $break|0 + unreachable + end + unreachable + end + block + i32.const 400 + set_local $2 + br $break|0 + unreachable + end + unreachable + end + block + i32.const 432 + set_local $2 + br $break|0 + unreachable + end + unreachable + end + block + get_global $~lib/symbol/idToString + i32.const 0 + i32.ne + tee_local $3 + if (result i32) + get_global $~lib/symbol/idToString + get_local $1 + call $~lib/map/Map#has + else + get_local $3 + end + if + get_global $~lib/symbol/idToString + get_local $1 + call $~lib/map/Map#get + set_local $2 + end + br $break|0 + unreachable + end + unreachable + end + i32.const 464 + get_local $2 + call $~lib/string/String.__concat + i32.const 592 + call $~lib/string/String.__concat + ) + (func $start (; 35 ;) (type $v) get_global $HEAP_BASE get_global $~lib/internal/allocator/AL_MASK i32.add @@ -1619,11 +3396,68 @@ call $~lib/env/abort unreachable end + i32.const 0 + call $~lib/symbol/Symbol + call $~lib/symbol/symbol#toString + i32.const 600 + call $~lib/string/String.__eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 25 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/symbol/sym3 + call $~lib/symbol/symbol#toString + i32.const 624 + call $~lib/string/String.__eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 26 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $~lib/symbol/Symbol.hasInstance + set_global $std/symbol/hasInstance + get_global $~lib/symbol/Symbol.isConcatSpreadable + set_global $std/symbol/isConcatSpreadable + get_global $std/symbol/hasInstance + call $~lib/symbol/symbol#toString + i32.const 656 + call $~lib/string/String.__eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 30 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/symbol/isConcatSpreadable + call $~lib/symbol/symbol#toString + i32.const 704 + call $~lib/string/String.__eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 31 + i32.const 0 + call $~lib/env/abort + unreachable + end get_global $~lib/symbol/Symbol.hasInstance drop - get_global $~lib/symbol/Symbol.concatSpreadable + get_global $~lib/symbol/Symbol.isConcatSpreadable drop ) - (func $null (; 29 ;) (type $v) + (func $null (; 36 ;) (type $v) ) )