From 8acc6aba500951b049309f7c87f57d560eb24c11 Mon Sep 17 00:00:00 2001 From: Joshua Tenner Date: Fri, 5 Jul 2019 16:22:26 -0400 Subject: [PATCH 1/3] [Feature] Add Buffer Class, implement naive Buffer.from() --- std/assembly/arraybuffer.ts | 1 + std/assembly/buffer.ts | 62 + std/assembly/index.d.ts | 5 +- tests/compiler/std/arraybuffer.optimized.wat | 24 +- tests/compiler/std/arraybuffer.untouched.wat | 8 +- tests/compiler/std/buffer.json | 6 + tests/compiler/std/buffer.optimized.wat | 2509 +++++++++++ tests/compiler/std/buffer.ts | 28 + tests/compiler/std/buffer.untouched.wat | 4161 ++++++++++++++++++ tests/compiler/std/map.optimized.wat | 2 +- tests/compiler/std/map.untouched.wat | 2 +- tests/compiler/std/set.optimized.wat | 2 +- tests/compiler/std/set.untouched.wat | 2 +- tests/compiler/std/symbol.optimized.wat | 2 +- tests/compiler/std/symbol.untouched.wat | 2 +- 15 files changed, 6793 insertions(+), 23 deletions(-) create mode 100644 std/assembly/buffer.ts create mode 100644 tests/compiler/std/buffer.json create mode 100644 tests/compiler/std/buffer.optimized.wat create mode 100644 tests/compiler/std/buffer.ts create mode 100644 tests/compiler/std/buffer.untouched.wat diff --git a/std/assembly/arraybuffer.ts b/std/assembly/arraybuffer.ts index ea44f6c6b9..2b40d36390 100644 --- a/std/assembly/arraybuffer.ts +++ b/std/assembly/arraybuffer.ts @@ -49,6 +49,7 @@ export abstract class ArrayBufferView { if (value instanceof Float32Array) return true; if (value instanceof Float64Array) return true; if (value instanceof DataView) return true; + if (value instanceof Buffer) return true; } return false; } diff --git a/std/assembly/buffer.ts b/std/assembly/buffer.ts new file mode 100644 index 0000000000..0a1073856e --- /dev/null +++ b/std/assembly/buffer.ts @@ -0,0 +1,62 @@ +import { Uint8Array } from "typedarray"; +import { ArrayBufferView } from "arraybuffer"; +import { TypeinfoFlags } from "shared/typeinfo"; + +export class Buffer extends Uint8Array { + + // TODO: Add more + private static NO_ENCODING: i32 = 0; + private static UTF8_ENCODING: i32 = 1; + private static UTF16_ENCODING: i32 = 2; + private encoding: i32 = 0; + + constructor(size: i32) { + super(size); + } + + public static isBuffer(obj: T): bool { + return obj instanceof Buffer && obj != null; + } + + public static from(source: T, encoding: string = "utf8"): Buffer { + if (source instanceof ArrayBuffer) { + let length = source.byteLength; + let buffer = new Buffer(length); + memory.copy(changetype(buffer.buffer), changetype(source), length); + return buffer; + } else if (source instanceof string) { + if (encoding == null) encoding = "utf8"; + + if (encoding == "utf8") { + let encoded = String.UTF8.encode(source); + let buffer = changetype(__alloc(offsetof(), idof())); + buffer.buffer = encoded; + buffer.dataStart = 0; + buffer.dataLength = encoded.byteLength; + return buffer; + } else if (encoding == "utf16") { + let encoded = String.UTF16.encode(source); + let buffer = changetype(__alloc(offsetof(), idof())); + buffer.buffer = encoded; + buffer.dataStart = 0; + buffer.dataLength = encoded.byteLength; + return buffer; + } + assert(false); + return null; + } else if (source instanceof ArrayBufferView) { + var sourceInfo = __typeinfo(idof()); + var sourceIsManaged = (sourceInfo & TypeinfoFlags.VALUE_MANAGED) != 0; // disallow this + assert(!sourceIsManaged); + let length = source.length; + let buffer = new Buffer(length); + for (let i = 0; i < length; i++) { + buffer[i] = source[i]; + } + return buffer; + } else { + assert(false, "hit"); + return null; + } + } +} diff --git a/std/assembly/index.d.ts b/std/assembly/index.d.ts index cd4beeb5e1..ce2858ba1e 100644 --- a/std/assembly/index.d.ts +++ b/std/assembly/index.d.ts @@ -1,3 +1,5 @@ +import { Uint8Array } from "typedarray"; + /** * Environment definitions for compiling AssemblyScript to WebAssembly using asc. * @module std/assembly @@ -1150,7 +1152,8 @@ declare abstract class TypedArray implements ArrayBufferView { /** The reverse() method reverses a typed array in place. The first typed array element becomes the last and the last becomes the first. This method has the same algorithm as Array.prototype.reverse(). */ reverse(): this; } - +/** A node buffer. */ +declare class Buffer extends Uint8Array {} /** An array of twos-complement 8-bit signed integers. */ declare class Int8Array extends TypedArray {} /** An array of 8-bit unsigned integers. */ diff --git a/tests/compiler/std/arraybuffer.optimized.wat b/tests/compiler/std/arraybuffer.optimized.wat index 8520ac3206..302615e695 100644 --- a/tests/compiler/std/arraybuffer.optimized.wat +++ b/tests/compiler/std/arraybuffer.optimized.wat @@ -24,7 +24,7 @@ (data (i32.const 376) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00~\00l\00i\00b\00/\00r\00t\00.\00t\00s") (data (i32.const 416) "\08\00\00\00\01\00\00\00\00\00\00\00\08\00\00\00\01\00\00\00\02") (data (i32.const 440) " \00\00\00\01\00\00\00\01\00\00\00 \00\00\00~\00l\00i\00b\00/\00d\00a\00t\00a\00v\00i\00e\00w\00.\00t\00s") - (data (i32.const 488) "\10\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\93\04\00\00\02\00\00\001\04\00\00\02\00\00\001\00\00\00\02\00\00\001\00\00\00\02\00\00\00Q\04\00\00\02\00\00\00Q\00\00\00\02\00\00\00\91\04\00\00\02\00\00\00\91\00\00\00\02\00\00\00\11\05\00\00\02\00\00\00\11\01\00\00\02\00\00\00\91\0c\00\00\02\00\00\00\11\0d\00\00\02\00\00\00\10") + (data (i32.const 488) "\11\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\93\04\00\00\02\00\00\001\04\00\00\02\00\00\001\00\00\00\02\00\00\001\00\00\00\02\00\00\00Q\04\00\00\02\00\00\00Q\00\00\00\02\00\00\00\91\04\00\00\02\00\00\00\91\00\00\00\02\00\00\00\11\05\00\00\02\00\00\00\11\01\00\00\02\00\00\00\91\0c\00\00\02\00\00\00\11\0d\00\00\02\00\00\00\10\00\00\00\00\00\00\001\00\00\00\05") (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) (global $~lib/rt/pure/CUR (mut i32) (i32.const 0)) (global $~lib/rt/pure/END (mut i32) (i32.const 0)) @@ -617,10 +617,10 @@ if unreachable end - i32.const 624 + i32.const 640 i32.const 0 i32.store - i32.const 2192 + i32.const 2208 i32.const 0 i32.store i32.const 0 @@ -634,7 +634,7 @@ local.get $0 i32.const 2 i32.shl - i32.const 624 + i32.const 640 i32.add i32.const 0 i32.store offset=4 @@ -653,7 +653,7 @@ i32.add i32.const 2 i32.shl - i32.const 624 + i32.const 640 i32.add i32.const 0 i32.store offset=96 @@ -671,13 +671,13 @@ br $loop|0 end end - i32.const 624 - i32.const 2208 + i32.const 640 + i32.const 2224 memory.size i32.const 16 i32.shl call $~lib/rt/tlsf/addMemory - i32.const 624 + i32.const 640 global.set $~lib/rt/tlsf/ROOT ) (func $~lib/rt/tlsf/prepareSize (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) @@ -1278,7 +1278,7 @@ ) (func $~lib/rt/pure/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 - i32.const 620 + i32.const 628 i32.gt_u if local.get $0 @@ -1776,7 +1776,7 @@ ) (func $~lib/rt/pure/__release (; 27 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 - i32.const 620 + i32.const 628 i32.gt_u if local.get $0 @@ -2406,7 +2406,7 @@ ) (func $~lib/rt/pure/__visit (; 39 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) local.get $0 - i32.const 620 + i32.const 628 i32.lt_u if return @@ -2522,7 +2522,7 @@ i32.const 8 i32.sub i32.load - br_table $switch$1$case$2 $switch$1$case$2 $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $switch$1$default + br_table $switch$1$case$2 $switch$1$case$2 $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $switch$1$default end return end diff --git a/tests/compiler/std/arraybuffer.untouched.wat b/tests/compiler/std/arraybuffer.untouched.wat index 703d2aa797..25dd0be0d9 100644 --- a/tests/compiler/std/arraybuffer.untouched.wat +++ b/tests/compiler/std/arraybuffer.untouched.wat @@ -24,7 +24,7 @@ (data (i32.const 376) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00~\00l\00i\00b\00/\00r\00t\00.\00t\00s\00") (data (i32.const 416) "\08\00\00\00\01\00\00\00\00\00\00\00\08\00\00\00\01\00\00\00\02\00\00\00") (data (i32.const 440) " \00\00\00\01\00\00\00\01\00\00\00 \00\00\00~\00l\00i\00b\00/\00d\00a\00t\00a\00v\00i\00e\00w\00.\00t\00s\00") - (data (i32.const 488) "\10\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\93\04\00\00\02\00\00\001\04\00\00\02\00\00\001\00\00\00\02\00\00\001\00\00\00\02\00\00\00Q\04\00\00\02\00\00\00Q\00\00\00\02\00\00\00\91\04\00\00\02\00\00\00\91\00\00\00\02\00\00\00\11\05\00\00\02\00\00\00\11\01\00\00\02\00\00\00\91\0c\00\00\02\00\00\00\11\0d\00\00\02\00\00\00\10\00\00\00\00\00\00\00") + (data (i32.const 488) "\11\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\93\04\00\00\02\00\00\001\04\00\00\02\00\00\001\00\00\00\02\00\00\001\00\00\00\02\00\00\00Q\04\00\00\02\00\00\00Q\00\00\00\02\00\00\00\91\04\00\00\02\00\00\00\91\00\00\00\02\00\00\00\11\05\00\00\02\00\00\00\11\01\00\00\02\00\00\00\91\0c\00\00\02\00\00\00\11\0d\00\00\02\00\00\00\10\00\00\00\00\00\00\001\00\00\00\05\00\00\00") (table $0 1 funcref) (elem (i32.const 0) $null) (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) @@ -34,7 +34,7 @@ (global $~lib/rt/pure/ROOTS (mut i32) (i32.const 0)) (global $~lib/argc (mut i32) (i32.const 0)) (global $~lib/rt/__rtti_base i32 (i32.const 488)) - (global $~lib/heap/__heap_base i32 (i32.const 620)) + (global $~lib/heap/__heap_base i32 (i32.const 628)) (export "memory" (memory $0)) (start $start) (func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) @@ -1665,7 +1665,7 @@ if i32.const 24 i32.const 72 - i32.const 57 + i32.const 58 i32.const 42 call $~lib/builtins/abort unreachable @@ -4265,7 +4265,7 @@ i32.const 8 i32.sub i32.load - br_table $switch$1$case$2 $switch$1$case$2 $switch$1$case$4 $switch$1$case$5 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$default + br_table $switch$1$case$2 $switch$1$case$2 $switch$1$case$4 $switch$1$case$5 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$default end return end diff --git a/tests/compiler/std/buffer.json b/tests/compiler/std/buffer.json new file mode 100644 index 0000000000..9f7878d475 --- /dev/null +++ b/tests/compiler/std/buffer.json @@ -0,0 +1,6 @@ +{ + "asc_flags": [ + "--runtime half", + "--use ASC_RTRACE=1" + ] +} \ No newline at end of file diff --git a/tests/compiler/std/buffer.optimized.wat b/tests/compiler/std/buffer.optimized.wat new file mode 100644 index 0000000000..6de6b15ad2 --- /dev/null +++ b/tests/compiler/std/buffer.optimized.wat @@ -0,0 +1,2509 @@ +(module + (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$v (func)) + (type $FUNCSIG$vii (func (param i32 i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$viii (func (param i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32))) + (type $FUNCSIG$dii (func (param i32 i32) (result f64))) + (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) + (import "rtrace" "onalloc" (func $~lib/rt/rtrace/onalloc (param i32))) + (import "rtrace" "onincrement" (func $~lib/rt/rtrace/onincrement (param i32))) + (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) + (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) + (memory $0 1) + (data (i32.const 8) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") + (data (i32.const 56) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") + (data (i32.const 112) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") + (data (i32.const 160) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e") + (data (i32.const 216) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s") + (data (i32.const 264) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e") + (data (i32.const 320) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00~\00l\00i\00b\00/\00r\00t\00.\00t\00s") + (data (i32.const 360) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00~\00l\00i\00b\00/\00t\00y\00p\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s") + (data (i32.const 416) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00s\00t\00d\00/\00b\00u\00f\00f\00e\00r\00.\00t\00s") + (data (i32.const 464) "\1c\00\00\00\01\00\00\00\00\00\00\00\1c\00\00\00\01\00\00\00\02\00\00\00\03\00\00\00\04\00\00\00\05\00\00\00\06\00\00\00\01\01") + (data (i32.const 512) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00b\00u\00f\00f\00e\00r\00.\00t\00s") + (data (i32.const 560) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s") + (data (i32.const 608) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00u\00t\00f\008") + (data (i32.const 632) " \00\00\00\01\00\00\00\00\00\00\00 \00\00\00\9a\99\99\99\99\99\f1?\9a\99\99\99\99\99\01@ffffff\n@\9a\99\99\99\99\99\11@") + (data (i32.const 680) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\001\00\00\00\02\00\00\001\00\00\00\03\00\00\00\93\04\00\00\02\00\00\00\13\0d\00\00\02") + (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) + (global $~lib/rt/pure/CUR (mut i32) (i32.const 0)) + (global $~lib/rt/pure/END (mut i32) (i32.const 0)) + (global $~lib/rt/pure/ROOTS (mut i32) (i32.const 0)) + (export "memory" (memory $0)) + (start $start) + (func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + local.get $1 + i32.load + local.tee $3 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 277 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const -4 + i32.and + local.tee $2 + i32.const 16 + i32.ge_u + if (result i32) + local.get $2 + i32.const 1073741808 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 279 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.const 256 + i32.lt_u + if (result i32) + local.get $2 + i32.const 4 + i32.shr_u + local.set $2 + i32.const 0 + else + local.get $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + local.tee $3 + i32.const 4 + i32.sub + i32.shr_u + i32.const 16 + i32.xor + local.set $2 + local.get $3 + i32.const 7 + i32.sub + end + local.tee $3 + i32.const 23 + i32.lt_u + if (result i32) + local.get $2 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 292 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.load offset=20 + local.set $4 + local.get $1 + i32.load offset=16 + local.tee $5 + if + local.get $5 + local.get $4 + i32.store offset=20 + end + local.get $4 + if + local.get $4 + local.get $5 + i32.store offset=16 + end + local.get $3 + i32.const 4 + i32.shl + local.get $2 + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=96 + local.get $1 + i32.eq + if + local.get $3 + i32.const 4 + i32.shl + local.get $2 + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add + local.get $4 + i32.store offset=96 + local.get $4 + i32.eqz + if + local.get $3 + i32.const 2 + i32.shl + local.get $0 + i32.add + local.get $3 + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=4 + i32.const 1 + local.get $2 + i32.shl + i32.const -1 + i32.xor + i32.and + local.tee $1 + i32.store offset=4 + local.get $1 + i32.eqz + if + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $3 + i32.shl + i32.const -1 + i32.xor + i32.and + i32.store + end + end + end + ) + (func $~lib/rt/tlsf/insertBlock (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + local.get $1 + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 205 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.load + local.tee $3 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 207 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 16 + i32.add + local.get $1 + i32.load + i32.const -4 + i32.and + i32.add + local.tee $4 + i32.load + local.tee $5 + i32.const 1 + i32.and + if + local.get $3 + i32.const -4 + i32.and + i32.const 16 + i32.add + local.get $5 + i32.const -4 + i32.and + i32.add + local.tee $2 + i32.const 1073741808 + i32.lt_u + if + local.get $0 + local.get $4 + call $~lib/rt/tlsf/removeBlock + local.get $1 + local.get $3 + i32.const 3 + i32.and + local.get $2 + i32.or + local.tee $3 + i32.store + local.get $1 + i32.const 16 + i32.add + local.get $1 + i32.load + i32.const -4 + i32.and + i32.add + local.tee $4 + i32.load + local.set $5 + end + end + local.get $3 + i32.const 2 + i32.and + if + local.get $1 + i32.const 4 + i32.sub + i32.load + local.tee $2 + i32.load + local.tee $6 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 228 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + local.get $6 + i32.const -4 + i32.and + i32.const 16 + i32.add + local.get $3 + i32.const -4 + i32.and + i32.add + local.tee $7 + i32.const 1073741808 + i32.lt_u + if (result i32) + local.get $0 + local.get $2 + call $~lib/rt/tlsf/removeBlock + local.get $2 + local.get $6 + i32.const 3 + i32.and + local.get $7 + i32.or + local.tee $3 + i32.store + local.get $2 + else + local.get $1 + end + local.set $1 + end + local.get $4 + local.get $5 + i32.const 2 + i32.or + i32.store + local.get $3 + i32.const -4 + i32.and + local.tee $2 + i32.const 16 + i32.ge_u + if (result i32) + local.get $2 + i32.const 1073741808 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 243 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $4 + local.get $1 + i32.const 16 + i32.add + local.get $2 + i32.add + i32.ne + if + i32.const 0 + i32.const 128 + i32.const 244 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $4 + i32.const 4 + i32.sub + local.get $1 + i32.store + local.get $2 + i32.const 256 + i32.lt_u + if (result i32) + local.get $2 + i32.const 4 + i32.shr_u + local.set $4 + i32.const 0 + else + local.get $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + local.tee $2 + i32.const 4 + i32.sub + i32.shr_u + i32.const 16 + i32.xor + local.set $4 + local.get $2 + i32.const 7 + i32.sub + end + local.tee $3 + i32.const 23 + i32.lt_u + if (result i32) + local.get $4 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 260 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 4 + i32.shl + local.get $4 + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=96 + local.set $2 + local.get $1 + i32.const 0 + i32.store offset=16 + local.get $1 + local.get $2 + i32.store offset=20 + local.get $2 + if + local.get $2 + local.get $1 + i32.store offset=16 + end + local.get $3 + i32.const 4 + i32.shl + local.get $4 + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add + local.get $1 + i32.store offset=96 + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $3 + i32.shl + i32.or + i32.store + local.get $3 + i32.const 2 + i32.shl + local.get $0 + i32.add + local.get $3 + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=4 + i32.const 1 + local.get $4 + i32.shl + i32.or + i32.store offset=4 + ) + (func $~lib/rt/tlsf/addMemory (; 7 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + local.get $2 + i32.const 15 + i32.and + i32.eqz + i32.const 0 + local.get $1 + i32.const 15 + i32.and + i32.eqz + i32.const 0 + local.get $1 + local.get $2 + i32.le_u + select + select + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 386 + i32.const 4 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=1568 + local.tee $3 + if + local.get $1 + local.get $3 + i32.const 16 + i32.add + i32.lt_u + if + i32.const 0 + i32.const 128 + i32.const 396 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 16 + i32.sub + local.get $3 + i32.eq + if + local.get $3 + i32.load + local.set $4 + local.get $1 + i32.const 16 + i32.sub + local.set $1 + end + else + local.get $1 + local.get $0 + i32.const 1572 + i32.add + i32.lt_u + if + i32.const 0 + i32.const 128 + i32.const 408 + i32.const 4 + call $~lib/builtins/abort + unreachable + end + end + local.get $2 + local.get $1 + i32.sub + local.tee $2 + i32.const 48 + i32.lt_u + if + return + end + local.get $1 + local.get $4 + i32.const 2 + i32.and + local.get $2 + i32.const 32 + i32.sub + i32.const 1 + i32.or + i32.or + i32.store + local.get $1 + i32.const 0 + i32.store offset=16 + local.get $1 + i32.const 0 + i32.store offset=20 + local.get $1 + local.get $2 + i32.add + i32.const 16 + i32.sub + local.tee $2 + i32.const 2 + i32.store + local.get $0 + local.get $2 + i32.store offset=1568 + local.get $0 + local.get $1 + call $~lib/rt/tlsf/insertBlock + ) + (func $~lib/rt/tlsf/initializeRoot (; 8 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + i32.const 1 + memory.size + local.tee $0 + i32.gt_s + if (result i32) + i32.const 1 + local.get $0 + i32.sub + memory.grow + i32.const 0 + i32.lt_s + else + i32.const 0 + end + if + unreachable + end + i32.const 752 + i32.const 0 + i32.store + i32.const 2320 + i32.const 0 + i32.store + i32.const 0 + local.set $0 + loop $loop|0 + block $break|0 + local.get $0 + i32.const 23 + i32.ge_u + br_if $break|0 + local.get $0 + i32.const 2 + i32.shl + i32.const 752 + i32.add + i32.const 0 + i32.store offset=4 + i32.const 0 + local.set $1 + loop $loop|1 + block $break|1 + local.get $1 + i32.const 16 + i32.ge_u + br_if $break|1 + local.get $0 + i32.const 4 + i32.shl + local.get $1 + i32.add + i32.const 2 + i32.shl + i32.const 752 + i32.add + i32.const 0 + i32.store offset=96 + local.get $1 + i32.const 1 + i32.add + local.set $1 + br $loop|1 + end + end + local.get $0 + i32.const 1 + i32.add + local.set $0 + br $loop|0 + end + end + i32.const 752 + i32.const 2336 + memory.size + i32.const 16 + i32.shl + call $~lib/rt/tlsf/addMemory + i32.const 752 + global.set $~lib/rt/tlsf/ROOT + ) + (func $~lib/rt/tlsf/prepareSize (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 1073741808 + i32.ge_u + if + i32.const 176 + i32.const 128 + i32.const 448 + i32.const 29 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $0 + i32.const 16 + local.get $0 + i32.const 16 + i32.gt_u + select + ) + (func $~lib/rt/tlsf/searchBlock (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + local.get $1 + i32.const 256 + i32.lt_u + if (result i32) + local.get $1 + i32.const 4 + i32.shr_u + local.set $1 + i32.const 0 + else + local.get $1 + i32.const 536870904 + i32.lt_u + if + i32.const 1 + i32.const 27 + local.get $1 + i32.clz + i32.sub + i32.shl + local.get $1 + i32.add + i32.const 1 + i32.sub + local.set $1 + end + local.get $1 + i32.const 31 + local.get $1 + i32.clz + i32.sub + local.tee $2 + i32.const 4 + i32.sub + i32.shr_u + i32.const 16 + i32.xor + local.set $1 + local.get $2 + i32.const 7 + i32.sub + end + local.tee $2 + i32.const 23 + i32.lt_u + if (result i32) + local.get $1 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 338 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=4 + i32.const -1 + local.get $1 + i32.shl + i32.and + local.tee $1 + if (result i32) + local.get $1 + i32.ctz + local.get $2 + i32.const 4 + i32.shl + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=96 + else + local.get $0 + i32.load + i32.const -1 + local.get $2 + i32.const 1 + i32.add + i32.shl + i32.and + local.tee $1 + if (result i32) + local.get $1 + i32.ctz + local.tee $1 + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=4 + local.tee $2 + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 351 + i32.const 17 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.ctz + local.get $1 + i32.const 4 + i32.shl + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=96 + else + i32.const 0 + end + end + ) + (func $~lib/rt/tlsf/growMemory (; 11 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + memory.size + local.tee $2 + local.get $1 + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $1 + local.get $2 + local.get $1 + i32.gt_s + select + memory.grow + i32.const 0 + i32.lt_s + if + local.get $1 + memory.grow + i32.const 0 + i32.lt_s + if + unreachable + end + end + local.get $0 + local.get $2 + i32.const 16 + i32.shl + memory.size + i32.const 16 + i32.shl + call $~lib/rt/tlsf/addMemory + ) + (func $~lib/rt/tlsf/prepareBlock (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + local.get $1 + i32.load + local.set $3 + local.get $2 + i32.const 15 + i32.and + if + i32.const 0 + i32.const 128 + i32.const 365 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const -4 + i32.and + local.get $2 + i32.sub + local.tee $4 + i32.const 32 + i32.ge_u + if + local.get $1 + local.get $3 + i32.const 2 + i32.and + local.get $2 + i32.or + i32.store + local.get $1 + i32.const 16 + i32.add + local.get $2 + i32.add + local.tee $1 + local.get $4 + i32.const 16 + i32.sub + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $1 + call $~lib/rt/tlsf/insertBlock + else + local.get $1 + local.get $3 + i32.const -2 + i32.and + i32.store + local.get $1 + i32.const 16 + i32.add + local.get $1 + i32.load + i32.const -4 + i32.and + i32.add + local.get $1 + i32.const 16 + i32.add + local.get $1 + i32.load + i32.const -4 + i32.and + i32.add + i32.load + i32.const -3 + i32.and + i32.store + end + ) + (func $~lib/rt/tlsf/allocateBlock (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + local.get $0 + local.get $1 + call $~lib/rt/tlsf/prepareSize + local.tee $3 + call $~lib/rt/tlsf/searchBlock + local.tee $2 + i32.eqz + if + local.get $0 + local.get $3 + call $~lib/rt/tlsf/growMemory + local.get $0 + local.get $3 + call $~lib/rt/tlsf/searchBlock + local.tee $2 + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 478 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + end + local.get $2 + i32.load + i32.const -4 + i32.and + local.get $3 + i32.lt_u + if + i32.const 0 + i32.const 128 + i32.const 480 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.const 0 + i32.store offset=4 + local.get $2 + local.get $1 + i32.store offset=12 + local.get $0 + local.get $2 + call $~lib/rt/tlsf/removeBlock + local.get $0 + local.get $2 + local.get $3 + call $~lib/rt/tlsf/prepareBlock + local.get $2 + call $~lib/rt/rtrace/onalloc + local.get $2 + ) + (func $~lib/rt/tlsf/__alloc (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + global.get $~lib/rt/tlsf/ROOT + local.tee $2 + if (result i32) + local.get $2 + else + call $~lib/rt/tlsf/initializeRoot + global.get $~lib/rt/tlsf/ROOT + end + local.get $0 + call $~lib/rt/tlsf/allocateBlock + local.tee $0 + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 16 + i32.add + ) + (func $~lib/memory/memory.fill (; 15 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + block $~lib/util/memory/memset|inlined.0 + local.get $1 + i32.eqz + br_if $~lib/util/memory/memset|inlined.0 + local.get $0 + i32.const 0 + i32.store8 + local.get $0 + local.get $1 + i32.add + i32.const 1 + i32.sub + i32.const 0 + i32.store8 + local.get $1 + i32.const 2 + i32.le_u + br_if $~lib/util/memory/memset|inlined.0 + local.get $0 + i32.const 1 + i32.add + i32.const 0 + i32.store8 + local.get $0 + i32.const 2 + i32.add + i32.const 0 + i32.store8 + local.get $0 + local.get $1 + i32.add + local.tee $2 + i32.const 2 + i32.sub + i32.const 0 + i32.store8 + local.get $2 + i32.const 3 + i32.sub + i32.const 0 + i32.store8 + local.get $1 + i32.const 6 + i32.le_u + br_if $~lib/util/memory/memset|inlined.0 + local.get $0 + i32.const 3 + i32.add + i32.const 0 + i32.store8 + local.get $0 + local.get $1 + i32.add + i32.const 4 + i32.sub + i32.const 0 + i32.store8 + local.get $1 + i32.const 8 + i32.le_u + br_if $~lib/util/memory/memset|inlined.0 + local.get $1 + i32.const 0 + local.get $0 + i32.sub + i32.const 3 + i32.and + local.tee $1 + i32.sub + local.get $0 + local.get $1 + i32.add + local.tee $0 + i32.const 0 + i32.store + i32.const -4 + i32.and + local.tee $1 + local.get $0 + i32.add + i32.const 4 + i32.sub + i32.const 0 + i32.store + local.get $1 + i32.const 8 + i32.le_u + br_if $~lib/util/memory/memset|inlined.0 + local.get $0 + i32.const 4 + i32.add + i32.const 0 + i32.store + local.get $0 + i32.const 8 + i32.add + i32.const 0 + i32.store + local.get $0 + local.get $1 + i32.add + local.tee $2 + i32.const 12 + i32.sub + i32.const 0 + i32.store + local.get $2 + i32.const 8 + i32.sub + i32.const 0 + i32.store + local.get $1 + i32.const 24 + i32.le_u + br_if $~lib/util/memory/memset|inlined.0 + local.get $0 + i32.const 12 + i32.add + i32.const 0 + i32.store + local.get $0 + i32.const 16 + i32.add + i32.const 0 + i32.store + local.get $0 + i32.const 20 + i32.add + i32.const 0 + i32.store + local.get $0 + i32.const 24 + i32.add + i32.const 0 + i32.store + local.get $0 + local.get $1 + i32.add + local.tee $2 + i32.const 28 + i32.sub + i32.const 0 + i32.store + local.get $2 + i32.const 24 + i32.sub + i32.const 0 + i32.store + local.get $2 + i32.const 20 + i32.sub + i32.const 0 + i32.store + local.get $2 + i32.const 16 + i32.sub + i32.const 0 + i32.store + local.get $0 + i32.const 4 + i32.and + i32.const 24 + i32.add + local.tee $2 + local.get $0 + i32.add + local.set $0 + local.get $1 + local.get $2 + i32.sub + local.set $1 + loop $continue|0 + local.get $1 + i32.const 32 + i32.ge_u + if + local.get $0 + i64.const 0 + i64.store + local.get $0 + i32.const 8 + i32.add + i64.const 0 + i64.store + local.get $0 + i32.const 16 + i32.add + i64.const 0 + i64.store + local.get $0 + i32.const 24 + i32.add + i64.const 0 + i64.store + local.get $1 + i32.const 32 + i32.sub + local.set $1 + local.get $0 + i32.const 32 + i32.add + local.set $0 + br $continue|0 + end + end + end + ) + (func $~lib/rt/pure/increment (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.tee $1 + i32.const -268435456 + i32.and + local.get $1 + i32.const 1 + i32.add + i32.const -268435456 + i32.and + i32.ne + if + i32.const 0 + i32.const 232 + i32.const 104 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 1 + i32.add + i32.store offset=4 + local.get $0 + call $~lib/rt/rtrace/onincrement + local.get $0 + i32.load + i32.const 1 + i32.and + if + i32.const 0 + i32.const 232 + i32.const 107 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + ) + (func $~lib/rt/pure/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 740 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/increment + end + local.get $0 + ) + (func $~lib/rt/tlsf/freeBlock (; 18 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + local.get $1 + i32.load + local.tee $2 + i32.const 1 + i32.and + if + i32.const 0 + i32.const 128 + i32.const 537 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.get $2 + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $1 + call $~lib/rt/tlsf/insertBlock + local.get $1 + call $~lib/rt/rtrace/onfree + ) + (func $~lib/rt/__typeinfo (; 19 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 680 + i32.load + i32.gt_u + if + i32.const 280 + i32.const 336 + i32.const 22 + i32.const 27 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 3 + i32.shl + i32.const 684 + i32.add + i32.load + ) + (func $~lib/memory/memory.copy (; 20 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + block $~lib/util/memory/memmove|inlined.0 + local.get $2 + local.set $3 + local.get $0 + local.get $1 + i32.eq + br_if $~lib/util/memory/memmove|inlined.0 + local.get $0 + local.get $1 + i32.lt_u + if + local.get $1 + i32.const 7 + i32.and + local.get $0 + i32.const 7 + i32.and + i32.eq + if + loop $continue|0 + local.get $0 + i32.const 7 + i32.and + if + local.get $3 + i32.eqz + br_if $~lib/util/memory/memmove|inlined.0 + local.get $3 + i32.const 1 + i32.sub + local.set $3 + local.get $0 + local.tee $2 + i32.const 1 + i32.add + local.set $0 + local.get $1 + local.tee $4 + i32.const 1 + i32.add + local.set $1 + local.get $2 + local.get $4 + i32.load8_u + i32.store8 + br $continue|0 + end + end + loop $continue|1 + local.get $3 + i32.const 8 + i32.lt_u + i32.eqz + if + local.get $0 + local.get $1 + i64.load + i64.store + local.get $3 + i32.const 8 + i32.sub + local.set $3 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + br $continue|1 + end + end + end + loop $continue|2 + local.get $3 + if + local.get $0 + local.tee $2 + i32.const 1 + i32.add + local.set $0 + local.get $1 + local.tee $4 + i32.const 1 + i32.add + local.set $1 + local.get $2 + local.get $4 + i32.load8_u + i32.store8 + local.get $3 + i32.const 1 + i32.sub + local.set $3 + br $continue|2 + end + end + else + local.get $1 + i32.const 7 + i32.and + local.get $0 + i32.const 7 + i32.and + i32.eq + if + loop $continue|3 + local.get $0 + local.get $3 + i32.add + i32.const 7 + i32.and + if + local.get $3 + i32.eqz + br_if $~lib/util/memory/memmove|inlined.0 + local.get $0 + local.get $3 + i32.const 1 + i32.sub + local.tee $3 + i32.add + local.get $1 + local.get $3 + i32.add + i32.load8_u + i32.store8 + br $continue|3 + end + end + loop $continue|4 + local.get $3 + i32.const 8 + i32.lt_u + i32.eqz + if + local.get $0 + local.get $3 + i32.const 8 + i32.sub + local.tee $3 + i32.add + local.get $1 + local.get $3 + i32.add + i64.load + i64.store + br $continue|4 + end + end + end + loop $continue|5 + local.get $3 + if + local.get $0 + local.get $3 + i32.const 1 + i32.sub + local.tee $3 + i32.add + local.get $1 + local.get $3 + i32.add + i32.load8_u + i32.store8 + br $continue|5 + end + end + end + end + ) + (func $~lib/rt/tlsf/__free (; 21 ;) (type $FUNCSIG$vi) (param $0 i32) + global.get $~lib/rt/tlsf/ROOT + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 567 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 15 + i32.and + i32.eqz + i32.const 0 + local.get $0 + select + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 568 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/rt/tlsf/ROOT + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/tlsf/freeBlock + ) + (func $~lib/rt/pure/growRoots (; 22 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + global.get $~lib/rt/pure/CUR + global.get $~lib/rt/pure/ROOTS + local.tee $1 + i32.sub + local.tee $2 + i32.const 1 + i32.shl + local.tee $0 + i32.const 256 + local.get $0 + i32.const 256 + i32.gt_u + select + local.tee $3 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $0 + i32.const 16 + i32.sub + call $~lib/rt/rtrace/onfree + local.get $0 + local.get $1 + local.get $2 + call $~lib/memory/memory.copy + local.get $1 + if + local.get $1 + i32.const 16 + i32.sub + call $~lib/rt/rtrace/onalloc + local.get $1 + call $~lib/rt/tlsf/__free + end + local.get $0 + global.set $~lib/rt/pure/ROOTS + local.get $0 + local.get $2 + i32.add + global.set $~lib/rt/pure/CUR + local.get $0 + local.get $3 + i32.add + global.set $~lib/rt/pure/END + ) + (func $~lib/rt/pure/appendRoot (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + global.get $~lib/rt/pure/CUR + local.tee $1 + global.get $~lib/rt/pure/END + i32.ge_u + if + call $~lib/rt/pure/growRoots + global.get $~lib/rt/pure/CUR + local.set $1 + end + local.get $1 + local.get $0 + i32.store + local.get $1 + i32.const 4 + i32.add + global.set $~lib/rt/pure/CUR + ) + (func $~lib/rt/pure/decrement (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.load offset=4 + local.tee $2 + i32.const 268435455 + i32.and + local.set $1 + local.get $0 + call $~lib/rt/rtrace/ondecrement + local.get $0 + i32.load + i32.const 1 + i32.and + if + i32.const 0 + i32.const 232 + i32.const 115 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 1 + i32.eq + if + local.get $0 + i32.const 16 + i32.add + i32.const 1 + call $~lib/rt/__visit_members + local.get $2 + i32.const -2147483648 + i32.and + if + local.get $0 + i32.const -2147483648 + i32.store offset=4 + else + global.get $~lib/rt/tlsf/ROOT + local.get $0 + call $~lib/rt/tlsf/freeBlock + end + else + local.get $1 + i32.const 0 + i32.le_u + if + i32.const 0 + i32.const 232 + i32.const 124 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=8 + call $~lib/rt/__typeinfo + i32.const 16 + i32.and + if + local.get $0 + local.get $1 + i32.const 1 + i32.sub + local.get $2 + i32.const -268435456 + i32.and + i32.or + i32.store offset=4 + else + local.get $0 + local.get $1 + i32.const 1 + i32.sub + i32.const -1342177280 + i32.or + i32.store offset=4 + local.get $2 + i32.const -2147483648 + i32.and + i32.eqz + if + local.get $0 + call $~lib/rt/pure/appendRoot + end + end + end + ) + (func $~lib/rt/pure/__release (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + i32.const 740 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) + (func $~lib/arraybuffer/ArrayBufferView#constructor (; 26 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + local.get $1 + i32.const 1073741808 + i32.gt_u + if + i32.const 24 + i32.const 72 + i32.const 14 + i32.const 56 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $2 + local.get $1 + call $~lib/memory/memory.fill + local.get $0 + i32.eqz + if + i32.const 12 + i32.const 2 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.set $0 + end + local.get $0 + i32.const 0 + i32.store + local.get $0 + i32.const 0 + i32.store offset=4 + local.get $0 + i32.const 0 + i32.store offset=8 + local.get $2 + local.get $0 + i32.load + local.tee $3 + i32.ne + if + local.get $2 + call $~lib/rt/pure/__retain + drop + local.get $3 + call $~lib/rt/pure/__release + end + local.get $0 + local.get $2 + i32.store + local.get $0 + local.get $2 + i32.store offset=4 + local.get $0 + local.get $1 + i32.store offset=8 + local.get $0 + ) + (func $~lib/buffer/Buffer#constructor (; 27 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + i32.const 16 + i32.const 4 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $1 + if (result i32) + local.get $1 + else + i32.const 12 + i32.const 3 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + end + local.get $0 + call $~lib/arraybuffer/ArrayBufferView#constructor + local.tee $0 + i32.const 0 + i32.store offset=12 + local.get $0 + ) + (func $~lib/typedarray/Uint8Array#__set (; 28 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + local.get $1 + local.get $0 + i32.load offset=8 + i32.ge_u + if + i32.const 280 + i32.const 376 + i32.const 131 + i32.const 44 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=4 + local.get $1 + i32.add + local.get $2 + i32.store8 + ) + (func $~lib/typedarray/Uint8Array#__get (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + local.get $1 + local.get $0 + i32.load offset=8 + i32.ge_u + if + i32.const 280 + i32.const 376 + i32.const 125 + i32.const 44 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=4 + local.get $1 + i32.add + i32.load8_u + ) + (func $~lib/rt/__allocArray (; 30 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (local $4 i32) + i32.const 16 + local.get $2 + call $~lib/rt/tlsf/__alloc + local.tee $2 + local.get $0 + local.get $1 + i32.shl + local.tee $1 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $4 + call $~lib/rt/pure/__retain + i32.store + local.get $2 + local.get $4 + i32.store offset=4 + local.get $2 + local.get $1 + i32.store offset=8 + local.get $2 + local.get $0 + i32.store offset=12 + local.get $3 + if + local.get $4 + local.get $3 + local.get $1 + call $~lib/memory/memory.copy + end + local.get $2 + ) + (func $~lib/array/Array#__get (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + local.get $1 + local.get $0 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.ge_u + if + i32.const 280 + i32.const 576 + i32.const 109 + i32.const 61 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 2 + i32.shl + i32.add + i32.load + ) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + call $~lib/rt/pure/__retain + drop + i32.const 624 + call $~lib/rt/pure/__retain + drop + i32.const 5 + call $~lib/rt/__typeinfo + i32.const 8192 + i32.and + if + i32.const 0 + i32.const 528 + i32.const 50 + i32.const 6 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=12 + local.tee $1 + local.set $3 + local.get $1 + call $~lib/buffer/Buffer#constructor + local.set $1 + loop $loop|0 + local.get $2 + local.get $3 + i32.lt_s + if + local.get $1 + local.get $2 + local.get $0 + local.get $2 + call $~lib/array/Array#__get + i32.const 255 + i32.and + call $~lib/typedarray/Uint8Array#__set + local.get $2 + i32.const 1 + i32.add + local.set $2 + br $loop|0 + end + end + local.get $0 + call $~lib/rt/pure/__release + i32.const 624 + call $~lib/rt/pure/__release + local.get $1 + ) + (func $~lib/array/Array#__get (; 33 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) + local.get $1 + local.get $0 + i32.load offset=8 + i32.const 3 + i32.shr_u + i32.ge_u + if + i32.const 280 + i32.const 576 + i32.const 109 + i32.const 61 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 3 + i32.shl + i32.add + f64.load + ) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 34 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + call $~lib/rt/pure/__retain + drop + i32.const 624 + call $~lib/rt/pure/__retain + drop + i32.const 6 + call $~lib/rt/__typeinfo + i32.const 8192 + i32.and + if + i32.const 0 + i32.const 528 + i32.const 50 + i32.const 6 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=12 + local.tee $1 + local.set $3 + local.get $1 + call $~lib/buffer/Buffer#constructor + local.set $1 + loop $loop|0 + local.get $2 + local.get $3 + i32.lt_s + if + local.get $1 + local.get $2 + local.get $0 + local.get $2 + call $~lib/array/Array#__get + i32.trunc_f64_u + i32.const 255 + i32.and + call $~lib/typedarray/Uint8Array#__set + local.get $2 + i32.const 1 + i32.add + local.set $2 + br $loop|0 + end + end + local.get $0 + call $~lib/rt/pure/__release + i32.const 624 + call $~lib/rt/pure/__release + local.get $1 + ) + (func $start:std/buffer (; 35 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + i32.const 3 + call $~lib/buffer/Buffer#constructor + local.tee $1 + i32.const 0 + i32.const 0 + call $~lib/typedarray/Uint8Array#__set + local.get $1 + i32.const 1 + i32.const 1 + call $~lib/typedarray/Uint8Array#__set + local.get $1 + i32.const 2 + i32.const 2 + call $~lib/typedarray/Uint8Array#__set + local.get $1 + i32.const 0 + call $~lib/typedarray/Uint8Array#__get + if + i32.const 0 + i32.const 432 + i32.const 8 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 1 + call $~lib/typedarray/Uint8Array#__get + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 9 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 2 + call $~lib/typedarray/Uint8Array#__get + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 10 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + i32.const 7 + i32.const 2 + i32.const 5 + i32.const 480 + call $~lib/rt/__allocArray + call $~lib/rt/pure/__retain + local.tee $2 + call $~lib/rt/pure/__retain + local.tee $3 + call $~lib/buffer/Buffer.from<~lib/array/Array> + local.set $0 + local.get $1 + call $~lib/rt/pure/__release + local.get $0 + i32.const 0 + call $~lib/typedarray/Uint8Array#__get + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 14 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 1 + call $~lib/typedarray/Uint8Array#__get + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 15 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 2 + call $~lib/typedarray/Uint8Array#__get + i32.const 3 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 16 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 3 + call $~lib/typedarray/Uint8Array#__get + i32.const 4 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 17 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 4 + call $~lib/typedarray/Uint8Array#__get + i32.const 5 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 18 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 5 + call $~lib/typedarray/Uint8Array#__get + i32.const 6 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 19 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 6 + call $~lib/typedarray/Uint8Array#__get + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 20 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + i32.const 4 + i32.const 3 + i32.const 6 + i32.const 648 + call $~lib/rt/__allocArray + call $~lib/rt/pure/__retain + local.tee $4 + call $~lib/rt/pure/__retain + local.tee $5 + call $~lib/buffer/Buffer.from<~lib/array/Array> + local.get $0 + call $~lib/rt/pure/__release + local.tee $0 + i32.const 0 + call $~lib/typedarray/Uint8Array#__get + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 24 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 1 + call $~lib/typedarray/Uint8Array#__get + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 25 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 2 + call $~lib/typedarray/Uint8Array#__get + i32.const 3 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 26 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 3 + call $~lib/typedarray/Uint8Array#__get + i32.const 4 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 27 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $3 + call $~lib/rt/pure/__release + local.get $4 + call $~lib/rt/pure/__release + local.get $5 + call $~lib/rt/pure/__release + ) + (func $start (; 36 ;) (type $FUNCSIG$v) + call $start:std/buffer + ) + (func $~lib/rt/pure/markGray (; 37 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.tee $1 + i32.const 1879048192 + i32.and + i32.const 268435456 + i32.ne + if + local.get $0 + local.get $1 + i32.const -1879048193 + i32.and + i32.const 268435456 + i32.or + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 2 + call $~lib/rt/__visit_members + end + ) + (func $~lib/rt/pure/scanBlack (; 38 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + local.get $0 + i32.load offset=4 + i32.const -1879048193 + i32.and + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 4 + call $~lib/rt/__visit_members + ) + (func $~lib/rt/pure/scan (; 39 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.tee $1 + i32.const 1879048192 + i32.and + i32.const 268435456 + i32.eq + if + local.get $1 + i32.const 268435455 + i32.and + i32.const 0 + i32.gt_u + if + local.get $0 + call $~lib/rt/pure/scanBlack + else + local.get $0 + local.get $1 + i32.const -1879048193 + i32.and + i32.const 536870912 + i32.or + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 3 + call $~lib/rt/__visit_members + end + end + ) + (func $~lib/rt/pure/collectWhite (; 40 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.tee $1 + i32.const 1879048192 + i32.and + i32.const 536870912 + i32.eq + if (result i32) + local.get $1 + i32.const -2147483648 + i32.and + i32.eqz + else + i32.const 0 + end + if + local.get $0 + local.get $1 + i32.const -1879048193 + i32.and + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 5 + call $~lib/rt/__visit_members + global.get $~lib/rt/tlsf/ROOT + local.get $0 + call $~lib/rt/tlsf/freeBlock + end + ) + (func $~lib/rt/pure/__visit (; 41 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + local.get $0 + i32.const 740 + i32.lt_u + if + return + end + local.get $0 + i32.const 16 + i32.sub + local.set $0 + block $break|0 + block $case5|0 + block $case4|0 + block $case3|0 + block $case2|0 + block $case1|0 + local.get $1 + i32.const 1 + i32.ne + if + local.get $1 + i32.const 2 + i32.eq + br_if $case1|0 + block $tablify|0 + local.get $1 + i32.const 3 + i32.sub + br_table $case2|0 $case3|0 $case4|0 $tablify|0 + end + br $case5|0 + end + local.get $0 + call $~lib/rt/pure/decrement + br $break|0 + end + local.get $0 + i32.load offset=4 + i32.const 268435455 + i32.and + i32.const 0 + i32.le_u + if + i32.const 0 + i32.const 232 + i32.const 75 + i32.const 17 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + call $~lib/rt/pure/markGray + br $break|0 + end + local.get $0 + call $~lib/rt/pure/scan + br $break|0 + end + local.get $0 + i32.load offset=4 + local.tee $1 + i32.const -268435456 + i32.and + local.get $1 + i32.const 1 + i32.add + i32.const -268435456 + i32.and + i32.ne + if + i32.const 0 + i32.const 232 + i32.const 86 + i32.const 6 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 1 + i32.add + i32.store offset=4 + local.get $1 + i32.const 1879048192 + i32.and + if + local.get $0 + call $~lib/rt/pure/scanBlack + end + br $break|0 + end + local.get $0 + call $~lib/rt/pure/collectWhite + br $break|0 + end + i32.const 0 + i32.const 232 + i32.const 97 + i32.const 24 + call $~lib/builtins/abort + unreachable + end + ) + (func $~lib/rt/__visit_members (; 42 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + block $block$4$break + block $switch$1$default + block $switch$1$case$2 + local.get $0 + i32.const 8 + i32.sub + i32.load + br_table $switch$1$case$2 $switch$1$case$2 $block$4$break $block$4$break $block$4$break $block$4$break $block$4$break $switch$1$default + end + return + end + unreachable + end + local.get $0 + i32.load + local.tee $0 + if + local.get $0 + local.get $1 + call $~lib/rt/pure/__visit + end + ) + (func $null (; 43 ;) (type $FUNCSIG$v) + nop + ) +) diff --git a/tests/compiler/std/buffer.ts b/tests/compiler/std/buffer.ts new file mode 100644 index 0000000000..caf3c07a73 --- /dev/null +++ b/tests/compiler/std/buffer.ts @@ -0,0 +1,28 @@ +// Buffer.from ///////////////////////////////////////////////////////////////////////////////////// +{ + let buffer = new Buffer(3); + buffer[0] = 0; + buffer[1] = 1; + buffer[2] = 2; + + assert(buffer[0] == 0); + assert(buffer[1] == 1); + assert(buffer[2] == 2); + + let i32array: i32[] = [1, 2, 3, 4, 5, 6, 257]; + buffer = Buffer.from(i32array); + assert(buffer[0] == 1); + assert(buffer[1] == 2); + assert(buffer[2] == 3); + assert(buffer[3] == 4); + assert(buffer[4] == 5); + assert(buffer[5] == 6); + assert(buffer[6] == 1); + + let f64array: f64[] = [1.1, 2.2, 3.3, 4.4]; + buffer = Buffer.from(f64array); + assert(buffer[0] == 1.1); + assert(buffer[1] == 2.2); + assert(buffer[2] == 3.3); + assert(buffer[3] == 4.4); +} diff --git a/tests/compiler/std/buffer.untouched.wat b/tests/compiler/std/buffer.untouched.wat new file mode 100644 index 0000000000..71d050843a --- /dev/null +++ b/tests/compiler/std/buffer.untouched.wat @@ -0,0 +1,4161 @@ +(module + (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$v (func)) + (type $FUNCSIG$vii (func (param i32 i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$viii (func (param i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32))) + (type $FUNCSIG$dii (func (param i32 i32) (result f64))) + (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) + (import "rtrace" "onalloc" (func $~lib/rt/rtrace/onalloc (param i32))) + (import "rtrace" "onincrement" (func $~lib/rt/rtrace/onincrement (param i32))) + (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) + (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) + (memory $0 1) + (data (i32.const 8) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") + (data (i32.const 56) "&\00\00\00\01\00\00\00\01\00\00\00&\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 112) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00") + (data (i32.const 160) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00") + (data (i32.const 216) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") + (data (i32.const 264) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e\00") + (data (i32.const 320) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00~\00l\00i\00b\00/\00r\00t\00.\00t\00s\00") + (data (i32.const 360) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00~\00l\00i\00b\00/\00t\00y\00p\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s\00") + (data (i32.const 416) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00s\00t\00d\00/\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") + (data (i32.const 464) "\1c\00\00\00\01\00\00\00\00\00\00\00\1c\00\00\00\01\00\00\00\02\00\00\00\03\00\00\00\04\00\00\00\05\00\00\00\06\00\00\00\01\01\00\00") + (data (i32.const 512) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") + (data (i32.const 560) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s\00") + (data (i32.const 608) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00u\00t\00f\008\00") + (data (i32.const 632) " \00\00\00\01\00\00\00\00\00\00\00 \00\00\00\9a\99\99\99\99\99\f1?\9a\99\99\99\99\99\01@ffffff\n@\9a\99\99\99\99\99\11@") + (data (i32.const 680) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\001\00\00\00\02\00\00\001\00\00\00\03\00\00\00\93\04\00\00\02\00\00\00\13\0d\00\00\02\00\00\00") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) + (global $~lib/rt/pure/CUR (mut i32) (i32.const 0)) + (global $~lib/rt/pure/END (mut i32) (i32.const 0)) + (global $~lib/rt/pure/ROOTS (mut i32) (i32.const 0)) + (global $~lib/buffer/Buffer.NO_ENCODING (mut i32) (i32.const 0)) + (global $~lib/buffer/Buffer.UTF8_ENCODING (mut i32) (i32.const 1)) + (global $~lib/buffer/Buffer.UTF16_ENCODING (mut i32) (i32.const 2)) + (global $~lib/rt/__rtti_base i32 (i32.const 680)) + (global $~lib/heap/__heap_base i32 (i32.const 740)) + (export "memory" (memory $0)) + (start $start) + (func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (local $11 i32) + local.get $1 + i32.load + local.set $2 + local.get $2 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 277 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.const 3 + i32.const -1 + i32.xor + i32.and + local.set $3 + local.get $3 + i32.const 16 + i32.ge_u + if (result i32) + local.get $3 + i32.const 1073741808 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 279 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 256 + i32.lt_u + if + i32.const 0 + local.set $4 + local.get $3 + i32.const 4 + i32.shr_u + local.set $5 + else + i32.const 31 + local.get $3 + i32.clz + i32.sub + local.set $4 + local.get $3 + local.get $4 + i32.const 4 + i32.sub + i32.shr_u + i32.const 1 + i32.const 4 + i32.shl + i32.xor + local.set $5 + local.get $4 + i32.const 8 + i32.const 1 + i32.sub + i32.sub + local.set $4 + end + local.get $4 + i32.const 23 + i32.lt_u + if (result i32) + local.get $5 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 292 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.load offset=16 + local.set $6 + local.get $1 + i32.load offset=20 + local.set $7 + local.get $6 + if + local.get $6 + local.get $7 + i32.store offset=20 + end + local.get $7 + if + local.get $7 + local.get $6 + i32.store offset=16 + end + local.get $1 + local.get $0 + local.set $10 + local.get $4 + local.set $9 + local.get $5 + local.set $8 + local.get $10 + local.get $9 + i32.const 4 + i32.shl + local.get $8 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + i32.eq + if + local.get $0 + local.set $11 + local.get $4 + local.set $10 + local.get $5 + local.set $9 + local.get $7 + local.set $8 + local.get $11 + local.get $10 + i32.const 4 + i32.shl + local.get $9 + i32.add + i32.const 2 + i32.shl + i32.add + local.get $8 + i32.store offset=96 + local.get $7 + i32.eqz + if + local.get $0 + local.set $9 + local.get $4 + local.set $8 + local.get $9 + local.get $8 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 + local.set $9 + local.get $0 + local.set $8 + local.get $4 + local.set $11 + local.get $9 + i32.const 1 + local.get $5 + i32.shl + i32.const -1 + i32.xor + i32.and + local.tee $9 + local.set $10 + local.get $8 + local.get $11 + i32.const 2 + i32.shl + i32.add + local.get $10 + i32.store offset=4 + local.get $9 + i32.eqz + if + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $4 + i32.shl + i32.const -1 + i32.xor + i32.and + i32.store + end + end + end + ) + (func $~lib/rt/tlsf/insertBlock (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (local $11 i32) + (local $12 i32) + (local $13 i32) + local.get $1 + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 205 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.load + local.set $2 + local.get $2 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 207 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.set $3 + local.get $3 + i32.const 16 + i32.add + local.get $3 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + local.set $4 + local.get $4 + i32.load + local.set $5 + local.get $5 + i32.const 1 + i32.and + if + local.get $2 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.add + local.get $5 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + local.set $3 + local.get $3 + i32.const 1073741808 + i32.lt_u + if + local.get $0 + local.get $4 + call $~lib/rt/tlsf/removeBlock + local.get $1 + local.get $2 + i32.const 3 + i32.and + local.get $3 + i32.or + local.tee $2 + i32.store + local.get $1 + local.set $6 + local.get $6 + i32.const 16 + i32.add + local.get $6 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + local.set $4 + local.get $4 + i32.load + local.set $5 + end + end + local.get $2 + i32.const 2 + i32.and + if + local.get $1 + local.set $6 + local.get $6 + i32.const 4 + i32.sub + i32.load + local.set $6 + local.get $6 + i32.load + local.set $3 + local.get $3 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 228 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.add + local.get $2 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + local.set $7 + local.get $7 + i32.const 1073741808 + i32.lt_u + if + local.get $0 + local.get $6 + call $~lib/rt/tlsf/removeBlock + local.get $6 + local.get $3 + i32.const 3 + i32.and + local.get $7 + i32.or + local.tee $2 + i32.store + local.get $6 + local.set $1 + end + end + local.get $4 + local.get $5 + i32.const 2 + i32.or + i32.store + local.get $2 + i32.const 3 + i32.const -1 + i32.xor + i32.and + local.set $8 + local.get $8 + i32.const 16 + i32.ge_u + if (result i32) + local.get $8 + i32.const 1073741808 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 243 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 16 + i32.add + local.get $8 + i32.add + local.get $4 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 244 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $4 + i32.const 4 + i32.sub + local.get $1 + i32.store + local.get $8 + i32.const 256 + i32.lt_u + if + i32.const 0 + local.set $9 + local.get $8 + i32.const 4 + i32.shr_u + local.set $10 + else + i32.const 31 + local.get $8 + i32.clz + i32.sub + local.set $9 + local.get $8 + local.get $9 + i32.const 4 + i32.sub + i32.shr_u + i32.const 1 + i32.const 4 + i32.shl + i32.xor + local.set $10 + local.get $9 + i32.const 8 + i32.const 1 + i32.sub + i32.sub + local.set $9 + end + local.get $9 + i32.const 23 + i32.lt_u + if (result i32) + local.get $10 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 260 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.set $7 + local.get $9 + local.set $3 + local.get $10 + local.set $6 + local.get $7 + local.get $3 + i32.const 4 + i32.shl + local.get $6 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + local.set $11 + local.get $1 + i32.const 0 + i32.store offset=16 + local.get $1 + local.get $11 + i32.store offset=20 + local.get $11 + if + local.get $11 + local.get $1 + i32.store offset=16 + end + local.get $0 + local.set $12 + local.get $9 + local.set $7 + local.get $10 + local.set $3 + local.get $1 + local.set $6 + local.get $12 + local.get $7 + i32.const 4 + i32.shl + local.get $3 + i32.add + i32.const 2 + i32.shl + i32.add + local.get $6 + i32.store offset=96 + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $9 + i32.shl + i32.or + i32.store + local.get $0 + local.set $13 + local.get $9 + local.set $12 + local.get $0 + local.set $3 + local.get $9 + local.set $6 + local.get $3 + local.get $6 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 + i32.const 1 + local.get $10 + i32.shl + i32.or + local.set $7 + local.get $13 + local.get $12 + i32.const 2 + i32.shl + i32.add + local.get $7 + i32.store offset=4 + ) + (func $~lib/rt/tlsf/addMemory (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + local.get $1 + local.get $2 + i32.le_u + if (result i32) + local.get $1 + i32.const 15 + i32.and + i32.eqz + else + i32.const 0 + end + if (result i32) + local.get $2 + i32.const 15 + i32.and + i32.eqz + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 386 + i32.const 4 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.set $3 + local.get $3 + i32.load offset=1568 + local.set $4 + i32.const 0 + local.set $5 + local.get $4 + if + local.get $1 + local.get $4 + i32.const 16 + i32.add + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 396 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 16 + i32.sub + local.get $4 + i32.eq + if + local.get $1 + i32.const 16 + i32.sub + local.set $1 + local.get $4 + i32.load + local.set $5 + else + nop + end + else + local.get $1 + local.get $0 + i32.const 1572 + i32.add + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 408 + i32.const 4 + call $~lib/builtins/abort + unreachable + end + end + local.get $2 + local.get $1 + i32.sub + local.set $6 + local.get $6 + i32.const 48 + i32.lt_u + if + i32.const 0 + return + end + local.get $6 + i32.const 2 + i32.const 16 + i32.mul + i32.sub + local.set $7 + local.get $1 + local.set $8 + local.get $8 + local.get $7 + i32.const 1 + i32.or + local.get $5 + i32.const 2 + i32.and + i32.or + i32.store + local.get $8 + i32.const 0 + i32.store offset=16 + local.get $8 + i32.const 0 + i32.store offset=20 + local.get $1 + local.get $6 + i32.add + i32.const 16 + i32.sub + local.set $4 + local.get $4 + i32.const 0 + i32.const 2 + i32.or + i32.store + local.get $0 + local.set $9 + local.get $4 + local.set $3 + local.get $9 + local.get $3 + i32.store offset=1568 + local.get $0 + local.get $8 + call $~lib/rt/tlsf/insertBlock + i32.const 1 + ) + (func $~lib/rt/tlsf/initializeRoot (; 8 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + global.get $~lib/heap/__heap_base + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.set $0 + memory.size + local.set $1 + local.get $0 + i32.const 1572 + i32.add + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $2 + local.get $2 + local.get $1 + i32.gt_s + if (result i32) + local.get $2 + local.get $1 + i32.sub + memory.grow + i32.const 0 + i32.lt_s + else + i32.const 0 + end + if + unreachable + end + local.get $0 + local.set $3 + local.get $3 + i32.const 0 + i32.store + local.get $3 + local.set $5 + i32.const 0 + local.set $4 + local.get $5 + local.get $4 + i32.store offset=1568 + block $break|0 + i32.const 0 + local.set $5 + loop $loop|0 + local.get $5 + i32.const 23 + i32.lt_u + i32.eqz + br_if $break|0 + local.get $3 + local.set $7 + local.get $5 + local.set $6 + i32.const 0 + local.set $4 + local.get $7 + local.get $6 + i32.const 2 + i32.shl + i32.add + local.get $4 + i32.store offset=4 + block $break|1 + i32.const 0 + local.set $7 + loop $loop|1 + local.get $7 + i32.const 16 + i32.lt_u + i32.eqz + br_if $break|1 + local.get $3 + local.set $9 + local.get $5 + local.set $8 + local.get $7 + local.set $6 + i32.const 0 + local.set $4 + local.get $9 + local.get $8 + i32.const 4 + i32.shl + local.get $6 + i32.add + i32.const 2 + i32.shl + i32.add + local.get $4 + i32.store offset=96 + local.get $7 + i32.const 1 + i32.add + local.set $7 + br $loop|1 + end + unreachable + end + local.get $5 + i32.const 1 + i32.add + local.set $5 + br $loop|0 + end + unreachable + end + local.get $3 + local.get $0 + i32.const 1572 + i32.add + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + memory.size + i32.const 16 + i32.shl + call $~lib/rt/tlsf/addMemory + drop + local.get $3 + global.set $~lib/rt/tlsf/ROOT + ) + (func $~lib/rt/tlsf/prepareSize (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.const 1073741808 + i32.ge_u + if + i32.const 176 + i32.const 128 + i32.const 448 + i32.const 29 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.tee $1 + i32.const 16 + local.tee $2 + local.get $1 + local.get $2 + i32.gt_u + select + ) + (func $~lib/rt/tlsf/searchBlock (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + local.get $1 + i32.const 256 + i32.lt_u + if + i32.const 0 + local.set $2 + local.get $1 + i32.const 4 + i32.shr_u + local.set $3 + else + local.get $1 + i32.const 536870904 + i32.lt_u + if (result i32) + local.get $1 + i32.const 1 + i32.const 27 + local.get $1 + i32.clz + i32.sub + i32.shl + i32.add + i32.const 1 + i32.sub + else + local.get $1 + end + local.set $4 + i32.const 31 + local.get $4 + i32.clz + i32.sub + local.set $2 + local.get $4 + local.get $2 + i32.const 4 + i32.sub + i32.shr_u + i32.const 1 + i32.const 4 + i32.shl + i32.xor + local.set $3 + local.get $2 + i32.const 8 + i32.const 1 + i32.sub + i32.sub + local.set $2 + end + local.get $2 + i32.const 23 + i32.lt_u + if (result i32) + local.get $3 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 338 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.set $5 + local.get $2 + local.set $4 + local.get $5 + local.get $4 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 + i32.const 0 + i32.const -1 + i32.xor + local.get $3 + i32.shl + i32.and + local.set $6 + i32.const 0 + local.set $7 + local.get $6 + i32.eqz + if + local.get $0 + i32.load + i32.const 0 + i32.const -1 + i32.xor + local.get $2 + i32.const 1 + i32.add + i32.shl + i32.and + local.set $5 + local.get $5 + i32.eqz + if + i32.const 0 + local.set $7 + else + local.get $5 + i32.ctz + local.set $2 + local.get $0 + local.set $8 + local.get $2 + local.set $4 + local.get $8 + local.get $4 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 + local.set $6 + local.get $6 + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 351 + i32.const 17 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.set $9 + local.get $2 + local.set $8 + local.get $6 + i32.ctz + local.set $4 + local.get $9 + local.get $8 + i32.const 4 + i32.shl + local.get $4 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + local.set $7 + end + else + local.get $0 + local.set $9 + local.get $2 + local.set $8 + local.get $6 + i32.ctz + local.set $4 + local.get $9 + local.get $8 + i32.const 4 + i32.shl + local.get $4 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + local.set $7 + end + local.get $7 + ) + (func $~lib/rt/tlsf/growMemory (; 11 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + memory.size + local.set $2 + local.get $1 + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $3 + local.get $2 + local.tee $4 + local.get $3 + local.tee $5 + local.get $4 + local.get $5 + i32.gt_s + select + local.set $6 + local.get $6 + memory.grow + i32.const 0 + i32.lt_s + if + local.get $3 + memory.grow + i32.const 0 + i32.lt_s + if + unreachable + end + end + memory.size + local.set $7 + local.get $0 + local.get $2 + i32.const 16 + i32.shl + local.get $7 + i32.const 16 + i32.shl + call $~lib/rt/tlsf/addMemory + drop + ) + (func $~lib/rt/tlsf/prepareBlock (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + local.get $1 + i32.load + local.set $3 + local.get $2 + i32.const 15 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 365 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 3 + i32.const -1 + i32.xor + i32.and + local.get $2 + i32.sub + local.set $4 + local.get $4 + i32.const 32 + i32.ge_u + if + local.get $1 + local.get $2 + local.get $3 + i32.const 2 + i32.and + i32.or + i32.store + local.get $1 + i32.const 16 + i32.add + local.get $2 + i32.add + local.set $5 + local.get $5 + local.get $4 + i32.const 16 + i32.sub + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $5 + call $~lib/rt/tlsf/insertBlock + else + local.get $1 + local.get $3 + i32.const 1 + i32.const -1 + i32.xor + i32.and + i32.store + local.get $1 + local.set $5 + local.get $5 + i32.const 16 + i32.add + local.get $5 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + local.get $1 + local.set $5 + local.get $5 + i32.const 16 + i32.add + local.get $5 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + i32.load + i32.const 2 + i32.const -1 + i32.xor + i32.and + i32.store + end + ) + (func $~lib/rt/tlsf/allocateBlock (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + local.get $1 + call $~lib/rt/tlsf/prepareSize + local.set $2 + local.get $0 + local.get $2 + call $~lib/rt/tlsf/searchBlock + local.set $3 + local.get $3 + i32.eqz + if + local.get $0 + local.get $2 + call $~lib/rt/tlsf/growMemory + local.get $0 + local.get $2 + call $~lib/rt/tlsf/searchBlock + local.set $3 + local.get $3 + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 478 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + end + local.get $3 + i32.load + i32.const -4 + i32.and + local.get $2 + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 480 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + local.get $1 + i32.store offset=12 + local.get $0 + local.get $3 + call $~lib/rt/tlsf/removeBlock + local.get $0 + local.get $3 + local.get $2 + call $~lib/rt/tlsf/prepareBlock + local.get $3 + call $~lib/rt/rtrace/onalloc + local.get $3 + ) + (func $~lib/rt/tlsf/__alloc (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + global.get $~lib/rt/tlsf/ROOT + local.set $2 + local.get $2 + i32.eqz + if + call $~lib/rt/tlsf/initializeRoot + global.get $~lib/rt/tlsf/ROOT + local.set $2 + end + local.get $2 + local.get $0 + call $~lib/rt/tlsf/allocateBlock + local.set $3 + local.get $3 + local.get $1 + i32.store offset=8 + local.get $3 + i32.const 16 + i32.add + ) + (func $~lib/memory/memory.fill (; 15 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i64) + block $~lib/util/memory/memset|inlined.0 + local.get $0 + local.set $5 + local.get $1 + local.set $4 + local.get $2 + local.set $3 + local.get $3 + i32.eqz + if + br $~lib/util/memory/memset|inlined.0 + end + local.get $5 + local.get $4 + i32.store8 + local.get $5 + local.get $3 + i32.add + i32.const 1 + i32.sub + local.get $4 + i32.store8 + local.get $3 + i32.const 2 + i32.le_u + if + br $~lib/util/memory/memset|inlined.0 + end + local.get $5 + i32.const 1 + i32.add + local.get $4 + i32.store8 + local.get $5 + i32.const 2 + i32.add + local.get $4 + i32.store8 + local.get $5 + local.get $3 + i32.add + i32.const 2 + i32.sub + local.get $4 + i32.store8 + local.get $5 + local.get $3 + i32.add + i32.const 3 + i32.sub + local.get $4 + i32.store8 + local.get $3 + i32.const 6 + i32.le_u + if + br $~lib/util/memory/memset|inlined.0 + end + local.get $5 + i32.const 3 + i32.add + local.get $4 + i32.store8 + local.get $5 + local.get $3 + i32.add + i32.const 4 + i32.sub + local.get $4 + i32.store8 + local.get $3 + i32.const 8 + i32.le_u + if + br $~lib/util/memory/memset|inlined.0 + end + i32.const 0 + local.get $5 + i32.sub + i32.const 3 + i32.and + local.set $6 + local.get $5 + local.get $6 + i32.add + local.set $5 + local.get $3 + local.get $6 + i32.sub + local.set $3 + local.get $3 + i32.const -4 + i32.and + local.set $3 + i32.const -1 + i32.const 255 + i32.div_u + local.get $4 + i32.const 255 + i32.and + i32.mul + local.set $7 + local.get $5 + local.get $7 + i32.store + local.get $5 + local.get $3 + i32.add + i32.const 4 + i32.sub + local.get $7 + i32.store + local.get $3 + i32.const 8 + i32.le_u + if + br $~lib/util/memory/memset|inlined.0 + end + local.get $5 + i32.const 4 + i32.add + local.get $7 + i32.store + local.get $5 + i32.const 8 + i32.add + local.get $7 + i32.store + local.get $5 + local.get $3 + i32.add + i32.const 12 + i32.sub + local.get $7 + i32.store + local.get $5 + local.get $3 + i32.add + i32.const 8 + i32.sub + local.get $7 + i32.store + local.get $3 + i32.const 24 + i32.le_u + if + br $~lib/util/memory/memset|inlined.0 + end + local.get $5 + i32.const 12 + i32.add + local.get $7 + i32.store + local.get $5 + i32.const 16 + i32.add + local.get $7 + i32.store + local.get $5 + i32.const 20 + i32.add + local.get $7 + i32.store + local.get $5 + i32.const 24 + i32.add + local.get $7 + i32.store + local.get $5 + local.get $3 + i32.add + i32.const 28 + i32.sub + local.get $7 + i32.store + local.get $5 + local.get $3 + i32.add + i32.const 24 + i32.sub + local.get $7 + i32.store + local.get $5 + local.get $3 + i32.add + i32.const 20 + i32.sub + local.get $7 + i32.store + local.get $5 + local.get $3 + i32.add + i32.const 16 + i32.sub + local.get $7 + i32.store + i32.const 24 + local.get $5 + i32.const 4 + i32.and + i32.add + local.set $6 + local.get $5 + local.get $6 + i32.add + local.set $5 + local.get $3 + local.get $6 + i32.sub + local.set $3 + local.get $7 + i64.extend_i32_u + local.get $7 + i64.extend_i32_u + i64.const 32 + i64.shl + i64.or + local.set $8 + block $break|0 + loop $continue|0 + local.get $3 + i32.const 32 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $5 + local.get $8 + i64.store + local.get $5 + i32.const 8 + i32.add + local.get $8 + i64.store + local.get $5 + i32.const 16 + i32.add + local.get $8 + i64.store + local.get $5 + i32.const 24 + i32.add + local.get $8 + i64.store + local.get $3 + i32.const 32 + i32.sub + local.set $3 + local.get $5 + i32.const 32 + i32.add + local.set $5 + br $continue|0 + end + unreachable + end + end + ) + (func $~lib/rt/pure/increment (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const -268435456 + i32.and + local.get $1 + i32.const 1 + i32.add + i32.const -268435456 + i32.and + i32.eq + i32.eqz + if + i32.const 0 + i32.const 232 + i32.const 104 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 1 + i32.add + i32.store offset=4 + local.get $0 + call $~lib/rt/rtrace/onincrement + local.get $0 + i32.load + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 232 + i32.const 107 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + ) + (func $~lib/rt/pure/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/increment + end + local.get $0 + ) + (func $~lib/rt/tlsf/freeBlock (; 18 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + local.get $1 + i32.load + local.set $2 + local.get $2 + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 537 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.get $2 + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $1 + call $~lib/rt/tlsf/insertBlock + local.get $1 + call $~lib/rt/rtrace/onfree + ) + (func $~lib/rt/__typeinfo (; 19 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + global.get $~lib/rt/__rtti_base + local.set $1 + local.get $0 + local.get $1 + i32.load + i32.gt_u + if + i32.const 280 + i32.const 336 + i32.const 22 + i32.const 27 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 4 + i32.add + local.get $0 + i32.const 8 + i32.mul + i32.add + i32.load + ) + (func $~lib/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) + block $break|0 + loop $continue|0 + local.get $2 + if (result i32) + local.get $1 + i32.const 3 + i32.and + else + i32.const 0 + end + i32.eqz + br_if $break|0 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $2 + i32.const 1 + i32.sub + local.set $2 + br $continue|0 + end + unreachable + end + local.get $0 + i32.const 3 + i32.and + i32.const 0 + i32.eq + if + block $break|1 + loop $continue|1 + local.get $2 + i32.const 16 + i32.ge_u + i32.eqz + br_if $break|1 + local.get $0 + local.get $1 + i32.load + i32.store + local.get $0 + i32.const 4 + i32.add + local.get $1 + i32.const 4 + i32.add + i32.load + i32.store + local.get $0 + i32.const 8 + i32.add + local.get $1 + i32.const 8 + i32.add + i32.load + i32.store + local.get $0 + i32.const 12 + i32.add + local.get $1 + i32.const 12 + i32.add + i32.load + i32.store + local.get $1 + i32.const 16 + i32.add + local.set $1 + local.get $0 + i32.const 16 + i32.add + local.set $0 + local.get $2 + i32.const 16 + i32.sub + local.set $2 + br $continue|1 + end + unreachable + end + local.get $2 + i32.const 8 + i32.and + if + local.get $0 + local.get $1 + i32.load + i32.store + local.get $0 + i32.const 4 + i32.add + local.get $1 + i32.const 4 + i32.add + i32.load + i32.store + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + end + local.get $2 + i32.const 4 + i32.and + if + local.get $0 + local.get $1 + i32.load + i32.store + local.get $0 + i32.const 4 + i32.add + local.set $0 + local.get $1 + i32.const 4 + i32.add + local.set $1 + end + local.get $2 + i32.const 2 + i32.and + if + local.get $0 + local.get $1 + i32.load16_u + i32.store16 + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $1 + i32.const 2 + i32.add + local.set $1 + end + local.get $2 + i32.const 1 + i32.and + if + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + end + return + end + local.get $2 + i32.const 32 + i32.ge_u + if + block $break|2 + block $case2|2 + block $case1|2 + block $case0|2 + local.get $0 + i32.const 3 + i32.and + local.set $5 + local.get $5 + i32.const 1 + i32.eq + br_if $case0|2 + local.get $5 + i32.const 2 + i32.eq + br_if $case1|2 + local.get $5 + i32.const 3 + i32.eq + br_if $case2|2 + br $break|2 + end + local.get $1 + i32.load + local.set $3 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $2 + i32.const 3 + i32.sub + local.set $2 + block $break|3 + loop $continue|3 + local.get $2 + i32.const 17 + i32.ge_u + i32.eqz + br_if $break|3 + local.get $1 + i32.const 1 + i32.add + i32.load + local.set $4 + local.get $0 + local.get $3 + i32.const 24 + i32.shr_u + local.get $4 + i32.const 8 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 5 + i32.add + i32.load + local.set $3 + local.get $0 + i32.const 4 + i32.add + local.get $4 + i32.const 24 + i32.shr_u + local.get $3 + i32.const 8 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 9 + i32.add + i32.load + local.set $4 + local.get $0 + i32.const 8 + i32.add + local.get $3 + i32.const 24 + i32.shr_u + local.get $4 + i32.const 8 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 13 + i32.add + i32.load + local.set $3 + local.get $0 + i32.const 12 + i32.add + local.get $4 + i32.const 24 + i32.shr_u + local.get $3 + i32.const 8 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 16 + i32.add + local.set $1 + local.get $0 + i32.const 16 + i32.add + local.set $0 + local.get $2 + i32.const 16 + i32.sub + local.set $2 + br $continue|3 + end + unreachable + end + br $break|2 + end + local.get $1 + i32.load + local.set $3 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $2 + i32.const 2 + i32.sub + local.set $2 + block $break|4 + loop $continue|4 + local.get $2 + i32.const 18 + i32.ge_u + i32.eqz + br_if $break|4 + local.get $1 + i32.const 2 + i32.add + i32.load + local.set $4 + local.get $0 + local.get $3 + i32.const 16 + i32.shr_u + local.get $4 + i32.const 16 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 6 + i32.add + i32.load + local.set $3 + local.get $0 + i32.const 4 + i32.add + local.get $4 + i32.const 16 + i32.shr_u + local.get $3 + i32.const 16 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 10 + i32.add + i32.load + local.set $4 + local.get $0 + i32.const 8 + i32.add + local.get $3 + i32.const 16 + i32.shr_u + local.get $4 + i32.const 16 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 14 + i32.add + i32.load + local.set $3 + local.get $0 + i32.const 12 + i32.add + local.get $4 + i32.const 16 + i32.shr_u + local.get $3 + i32.const 16 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 16 + i32.add + local.set $1 + local.get $0 + i32.const 16 + i32.add + local.set $0 + local.get $2 + i32.const 16 + i32.sub + local.set $2 + br $continue|4 + end + unreachable + end + br $break|2 + end + local.get $1 + i32.load + local.set $3 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $2 + i32.const 1 + i32.sub + local.set $2 + block $break|5 + loop $continue|5 + local.get $2 + i32.const 19 + i32.ge_u + i32.eqz + br_if $break|5 + local.get $1 + i32.const 3 + i32.add + i32.load + local.set $4 + local.get $0 + local.get $3 + i32.const 8 + i32.shr_u + local.get $4 + i32.const 24 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 7 + i32.add + i32.load + local.set $3 + local.get $0 + i32.const 4 + i32.add + local.get $4 + i32.const 8 + i32.shr_u + local.get $3 + i32.const 24 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 11 + i32.add + i32.load + local.set $4 + local.get $0 + i32.const 8 + i32.add + local.get $3 + i32.const 8 + i32.shr_u + local.get $4 + i32.const 24 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 15 + i32.add + i32.load + local.set $3 + local.get $0 + i32.const 12 + i32.add + local.get $4 + i32.const 8 + i32.shr_u + local.get $3 + i32.const 24 + i32.shl + i32.or + i32.store + local.get $1 + i32.const 16 + i32.add + local.set $1 + local.get $0 + i32.const 16 + i32.add + local.set $0 + local.get $2 + i32.const 16 + i32.sub + local.set $2 + br $continue|5 + end + unreachable + end + br $break|2 + end + end + local.get $2 + i32.const 16 + i32.and + if + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + end + local.get $2 + i32.const 8 + i32.and + if + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + end + local.get $2 + i32.const 4 + i32.and + if + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + end + local.get $2 + i32.const 2 + i32.and + if + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + end + local.get $2 + i32.const 1 + i32.and + if + local.get $0 + local.tee $5 + i32.const 1 + i32.add + local.set $0 + local.get $5 + local.get $1 + local.tee $5 + i32.const 1 + i32.add + local.set $1 + local.get $5 + i32.load8_u + i32.store8 + end + ) + (func $~lib/memory/memory.copy (; 21 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + block $~lib/util/memory/memmove|inlined.0 + local.get $0 + local.set $5 + local.get $1 + local.set $4 + local.get $2 + local.set $3 + local.get $5 + local.get $4 + i32.eq + if + br $~lib/util/memory/memmove|inlined.0 + end + local.get $4 + local.get $3 + i32.add + local.get $5 + i32.le_u + if (result i32) + i32.const 1 + else + local.get $5 + local.get $3 + i32.add + local.get $4 + i32.le_u + end + if + local.get $5 + local.get $4 + local.get $3 + call $~lib/util/memory/memcpy + br $~lib/util/memory/memmove|inlined.0 + end + local.get $5 + local.get $4 + i32.lt_u + if + local.get $4 + i32.const 7 + i32.and + local.get $5 + i32.const 7 + i32.and + i32.eq + if + block $break|0 + loop $continue|0 + local.get $5 + i32.const 7 + i32.and + i32.eqz + br_if $break|0 + local.get $3 + i32.eqz + if + br $~lib/util/memory/memmove|inlined.0 + end + local.get $3 + i32.const 1 + i32.sub + local.set $3 + local.get $5 + local.tee $6 + i32.const 1 + i32.add + local.set $5 + local.get $6 + local.get $4 + local.tee $6 + i32.const 1 + i32.add + local.set $4 + local.get $6 + i32.load8_u + i32.store8 + br $continue|0 + end + unreachable + end + block $break|1 + loop $continue|1 + local.get $3 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|1 + local.get $5 + local.get $4 + i64.load + i64.store + local.get $3 + i32.const 8 + i32.sub + local.set $3 + local.get $5 + i32.const 8 + i32.add + local.set $5 + local.get $4 + i32.const 8 + i32.add + local.set $4 + br $continue|1 + end + unreachable + end + end + block $break|2 + loop $continue|2 + local.get $3 + i32.eqz + br_if $break|2 + local.get $5 + local.tee $6 + i32.const 1 + i32.add + local.set $5 + local.get $6 + local.get $4 + local.tee $6 + i32.const 1 + i32.add + local.set $4 + local.get $6 + i32.load8_u + i32.store8 + local.get $3 + i32.const 1 + i32.sub + local.set $3 + br $continue|2 + end + unreachable + end + else + local.get $4 + i32.const 7 + i32.and + local.get $5 + i32.const 7 + i32.and + i32.eq + if + block $break|3 + loop $continue|3 + local.get $5 + local.get $3 + i32.add + i32.const 7 + i32.and + i32.eqz + br_if $break|3 + local.get $3 + i32.eqz + if + br $~lib/util/memory/memmove|inlined.0 + end + local.get $5 + local.get $3 + i32.const 1 + i32.sub + local.tee $3 + i32.add + local.get $4 + local.get $3 + i32.add + i32.load8_u + i32.store8 + br $continue|3 + end + unreachable + end + block $break|4 + loop $continue|4 + local.get $3 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|4 + local.get $3 + i32.const 8 + i32.sub + local.set $3 + local.get $5 + local.get $3 + i32.add + local.get $4 + local.get $3 + i32.add + i64.load + i64.store + br $continue|4 + end + unreachable + end + end + block $break|5 + loop $continue|5 + local.get $3 + i32.eqz + br_if $break|5 + local.get $5 + local.get $3 + i32.const 1 + i32.sub + local.tee $3 + i32.add + local.get $4 + local.get $3 + i32.add + i32.load8_u + i32.store8 + br $continue|5 + end + unreachable + end + end + end + ) + (func $~lib/rt/tlsf/__free (; 22 ;) (type $FUNCSIG$vi) (param $0 i32) + global.get $~lib/rt/tlsf/ROOT + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 567 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 0 + i32.ne + if (result i32) + local.get $0 + i32.const 15 + i32.and + i32.eqz + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 568 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/rt/tlsf/ROOT + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/tlsf/freeBlock + ) + (func $~lib/rt/pure/growRoots (; 23 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + global.get $~lib/rt/pure/ROOTS + local.set $0 + global.get $~lib/rt/pure/CUR + local.get $0 + i32.sub + local.set $1 + local.get $1 + i32.const 2 + i32.mul + local.tee $2 + i32.const 64 + i32.const 2 + i32.shl + local.tee $3 + local.get $2 + local.get $3 + i32.gt_u + select + local.set $4 + local.get $4 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.set $5 + local.get $5 + i32.const 16 + i32.sub + call $~lib/rt/rtrace/onfree + local.get $5 + local.get $0 + local.get $1 + call $~lib/memory/memory.copy + local.get $0 + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/rtrace/onalloc + local.get $0 + call $~lib/rt/tlsf/__free + end + local.get $5 + global.set $~lib/rt/pure/ROOTS + local.get $5 + local.get $1 + i32.add + global.set $~lib/rt/pure/CUR + local.get $5 + local.get $4 + i32.add + global.set $~lib/rt/pure/END + ) + (func $~lib/rt/pure/appendRoot (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + global.get $~lib/rt/pure/CUR + local.set $1 + local.get $1 + global.get $~lib/rt/pure/END + i32.ge_u + if + call $~lib/rt/pure/growRoots + global.get $~lib/rt/pure/CUR + local.set $1 + end + local.get $1 + local.get $0 + i32.store + local.get $1 + i32.const 4 + i32.add + global.set $~lib/rt/pure/CUR + ) + (func $~lib/rt/pure/decrement (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const 268435455 + i32.and + local.set $2 + local.get $0 + call $~lib/rt/rtrace/ondecrement + local.get $0 + i32.load + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 232 + i32.const 115 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.const 16 + i32.add + i32.const 1 + call $~lib/rt/__visit_members + local.get $1 + i32.const -2147483648 + i32.and + i32.eqz + if + global.get $~lib/rt/tlsf/ROOT + local.get $0 + call $~lib/rt/tlsf/freeBlock + else + local.get $0 + i32.const -2147483648 + i32.const 0 + i32.or + i32.const 0 + i32.or + i32.store offset=4 + end + else + local.get $2 + i32.const 0 + i32.gt_u + i32.eqz + if + i32.const 0 + i32.const 232 + i32.const 124 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=8 + call $~lib/rt/__typeinfo + i32.const 16 + i32.and + i32.eqz + if + local.get $0 + i32.const -2147483648 + i32.const 805306368 + i32.or + local.get $2 + i32.const 1 + i32.sub + i32.or + i32.store offset=4 + local.get $1 + i32.const -2147483648 + i32.and + i32.eqz + if + local.get $0 + call $~lib/rt/pure/appendRoot + end + else + local.get $0 + local.get $1 + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + local.get $2 + i32.const 1 + i32.sub + i32.or + i32.store offset=4 + end + end + ) + (func $~lib/rt/pure/__release (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) + (func $~lib/arraybuffer/ArrayBufferView#constructor (; 27 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + local.get $1 + i32.const 1073741808 + local.get $2 + i32.shr_u + i32.gt_u + if + i32.const 24 + i32.const 72 + i32.const 14 + i32.const 56 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.get $2 + i32.shl + local.tee $1 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.set $3 + local.get $3 + i32.const 0 + local.get $1 + call $~lib/memory/memory.fill + local.get $0 + i32.eqz + if + i32.const 12 + i32.const 2 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.set $0 + end + local.get $0 + i32.const 0 + i32.store + local.get $0 + i32.const 0 + i32.store offset=4 + local.get $0 + i32.const 0 + i32.store offset=8 + local.get $0 + local.tee $4 + local.get $3 + local.tee $5 + local.get $4 + i32.load + local.tee $4 + i32.ne + if + local.get $5 + call $~lib/rt/pure/__retain + drop + local.get $4 + call $~lib/rt/pure/__release + end + local.get $5 + i32.store + local.get $0 + local.get $3 + i32.store offset=4 + local.get $0 + local.get $1 + i32.store offset=8 + local.get $0 + ) + (func $~lib/typedarray/Uint8Array#constructor (; 28 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + local.get $0 + if (result i32) + local.get $0 + else + i32.const 12 + i32.const 3 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + end + local.get $1 + i32.const 0 + call $~lib/arraybuffer/ArrayBufferView#constructor + local.set $0 + local.get $0 + ) + (func $~lib/buffer/Buffer#constructor (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + local.get $0 + if (result i32) + local.get $0 + else + i32.const 16 + i32.const 4 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + end + local.get $1 + call $~lib/typedarray/Uint8Array#constructor + local.set $0 + local.get $0 + i32.const 0 + i32.store offset=12 + local.get $0 + ) + (func $~lib/typedarray/Uint8Array#__set (; 30 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + local.get $1 + local.get $0 + i32.load offset=8 + i32.ge_u + if + i32.const 280 + i32.const 376 + i32.const 131 + i32.const 44 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=4 + local.get $1 + i32.add + local.get $2 + i32.store8 + ) + (func $~lib/typedarray/Uint8Array#__get (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + local.get $1 + local.get $0 + i32.load offset=8 + i32.ge_u + if + i32.const 280 + i32.const 376 + i32.const 125 + i32.const 44 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=4 + local.get $1 + i32.add + i32.load8_u + ) + (func $~lib/rt/__allocArray (; 32 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + i32.const 16 + local.get $2 + call $~lib/rt/tlsf/__alloc + local.set $4 + local.get $0 + local.get $1 + i32.shl + local.set $5 + local.get $5 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.set $6 + local.get $4 + local.get $6 + call $~lib/rt/pure/__retain + i32.store + local.get $4 + local.get $6 + i32.store offset=4 + local.get $4 + local.get $5 + i32.store offset=8 + local.get $4 + local.get $0 + i32.store offset=12 + local.get $3 + if + local.get $6 + local.get $3 + local.get $5 + call $~lib/memory/memory.copy + end + local.get $4 + ) + (func $~lib/array/Array#get:length (; 33 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.load offset=12 + ) + (func $~lib/array/Array#__unchecked_get (; 34 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 2 + i32.shl + i32.add + i32.load + ) + (func $~lib/array/Array#__get (; 35 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + local.get $1 + local.get $0 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.ge_u + if + i32.const 280 + i32.const 576 + i32.const 109 + i32.const 61 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + call $~lib/array/Array#__unchecked_get + ) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 36 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + local.get $0 + call $~lib/rt/pure/__retain + drop + local.get $1 + call $~lib/rt/pure/__retain + drop + i32.const 5 + call $~lib/rt/__typeinfo + local.set $2 + local.get $2 + i32.const 8192 + i32.and + i32.const 0 + i32.ne + local.set $3 + local.get $3 + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 528 + i32.const 50 + i32.const 6 + call $~lib/builtins/abort + unreachable + end + local.get $0 + call $~lib/array/Array#get:length + local.set $4 + i32.const 0 + local.get $4 + call $~lib/buffer/Buffer#constructor + local.set $5 + block $break|0 + i32.const 0 + local.set $6 + loop $loop|0 + local.get $6 + local.get $4 + i32.lt_s + i32.eqz + br_if $break|0 + local.get $5 + local.get $6 + local.get $0 + local.get $6 + call $~lib/array/Array#__get + i32.const 255 + i32.and + call $~lib/typedarray/Uint8Array#__set + local.get $6 + i32.const 1 + i32.add + local.set $6 + br $loop|0 + end + unreachable + end + local.get $5 + local.set $6 + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $6 + return + ) + (func $~lib/array/Array#get:length (; 37 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.load offset=12 + ) + (func $~lib/array/Array#__unchecked_get (; 38 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 3 + i32.shl + i32.add + f64.load + ) + (func $~lib/array/Array#__get (; 39 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) + local.get $1 + local.get $0 + i32.load offset=8 + i32.const 3 + i32.shr_u + i32.ge_u + if + i32.const 280 + i32.const 576 + i32.const 109 + i32.const 61 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + call $~lib/array/Array#__unchecked_get + ) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 40 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + local.get $0 + call $~lib/rt/pure/__retain + drop + local.get $1 + call $~lib/rt/pure/__retain + drop + i32.const 6 + call $~lib/rt/__typeinfo + local.set $2 + local.get $2 + i32.const 8192 + i32.and + i32.const 0 + i32.ne + local.set $3 + local.get $3 + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 528 + i32.const 50 + i32.const 6 + call $~lib/builtins/abort + unreachable + end + local.get $0 + call $~lib/array/Array#get:length + local.set $4 + i32.const 0 + local.get $4 + call $~lib/buffer/Buffer#constructor + local.set $5 + block $break|0 + i32.const 0 + local.set $6 + loop $loop|0 + local.get $6 + local.get $4 + i32.lt_s + i32.eqz + br_if $break|0 + local.get $5 + local.get $6 + local.get $0 + local.get $6 + call $~lib/array/Array#__get + i32.trunc_f64_u + i32.const 255 + i32.and + call $~lib/typedarray/Uint8Array#__set + local.get $6 + i32.const 1 + i32.add + local.set $6 + br $loop|0 + end + unreachable + end + local.get $5 + local.set $6 + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $6 + return + ) + (func $start:std/buffer (; 41 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + i32.const 0 + i32.const 3 + call $~lib/buffer/Buffer#constructor + local.set $0 + local.get $0 + i32.const 0 + i32.const 0 + call $~lib/typedarray/Uint8Array#__set + local.get $0 + i32.const 1 + i32.const 1 + call $~lib/typedarray/Uint8Array#__set + local.get $0 + i32.const 2 + i32.const 2 + call $~lib/typedarray/Uint8Array#__set + local.get $0 + i32.const 0 + call $~lib/typedarray/Uint8Array#__get + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 8 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 1 + call $~lib/typedarray/Uint8Array#__get + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 9 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 2 + call $~lib/typedarray/Uint8Array#__get + i32.const 2 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 10 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + i32.const 7 + i32.const 2 + i32.const 5 + i32.const 480 + call $~lib/rt/__allocArray + call $~lib/rt/pure/__retain + local.tee $2 + call $~lib/rt/pure/__retain + local.set $1 + local.get $1 + i32.const 624 + call $~lib/buffer/Buffer.from<~lib/array/Array> + local.set $3 + local.get $0 + call $~lib/rt/pure/__release + local.get $3 + local.set $0 + local.get $0 + i32.const 0 + call $~lib/typedarray/Uint8Array#__get + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 14 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 1 + call $~lib/typedarray/Uint8Array#__get + i32.const 2 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 15 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 2 + call $~lib/typedarray/Uint8Array#__get + i32.const 3 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 16 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 3 + call $~lib/typedarray/Uint8Array#__get + i32.const 4 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 17 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 4 + call $~lib/typedarray/Uint8Array#__get + i32.const 5 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 18 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 5 + call $~lib/typedarray/Uint8Array#__get + i32.const 6 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 19 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 6 + call $~lib/typedarray/Uint8Array#__get + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 20 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + i32.const 4 + i32.const 3 + i32.const 6 + i32.const 648 + call $~lib/rt/__allocArray + call $~lib/rt/pure/__retain + local.tee $4 + call $~lib/rt/pure/__retain + local.set $3 + local.get $3 + i32.const 624 + call $~lib/buffer/Buffer.from<~lib/array/Array> + local.set $5 + local.get $0 + call $~lib/rt/pure/__release + local.get $5 + local.set $0 + local.get $0 + i32.const 0 + call $~lib/typedarray/Uint8Array#__get + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 24 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 1 + call $~lib/typedarray/Uint8Array#__get + i32.const 2 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 25 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 2 + call $~lib/typedarray/Uint8Array#__get + i32.const 3 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 26 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 3 + call $~lib/typedarray/Uint8Array#__get + i32.const 4 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 27 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $4 + call $~lib/rt/pure/__release + local.get $3 + call $~lib/rt/pure/__release + ) + (func $start (; 42 ;) (type $FUNCSIG$v) + call $start:std/buffer + ) + (func $~lib/array/Array#__visit_impl (; 43 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + nop + ) + (func $~lib/array/Array#__visit_impl (; 44 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + nop + ) + (func $~lib/rt/pure/markGray (; 45 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const 1879048192 + i32.and + i32.const 268435456 + i32.ne + if + local.get $0 + local.get $1 + i32.const 1879048192 + i32.const -1 + i32.xor + i32.and + i32.const 268435456 + i32.or + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 2 + call $~lib/rt/__visit_members + end + ) + (func $~lib/rt/pure/scanBlack (; 46 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + local.get $0 + i32.load offset=4 + i32.const 1879048192 + i32.const -1 + i32.xor + i32.and + i32.const 0 + i32.or + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 4 + call $~lib/rt/__visit_members + ) + (func $~lib/rt/pure/scan (; 47 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const 1879048192 + i32.and + i32.const 268435456 + i32.eq + if + local.get $1 + i32.const 268435455 + i32.and + i32.const 0 + i32.gt_u + if + local.get $0 + call $~lib/rt/pure/scanBlack + else + local.get $0 + local.get $1 + i32.const 1879048192 + i32.const -1 + i32.xor + i32.and + i32.const 536870912 + i32.or + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 3 + call $~lib/rt/__visit_members + end + end + ) + (func $~lib/rt/pure/collectWhite (; 48 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const 1879048192 + i32.and + i32.const 536870912 + i32.eq + if (result i32) + local.get $1 + i32.const -2147483648 + i32.and + i32.eqz + else + i32.const 0 + end + if + local.get $0 + local.get $1 + i32.const 1879048192 + i32.const -1 + i32.xor + i32.and + i32.const 0 + i32.or + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 5 + call $~lib/rt/__visit_members + global.get $~lib/rt/tlsf/ROOT + local.get $0 + call $~lib/rt/tlsf/freeBlock + end + ) + (func $~lib/rt/pure/__visit (; 49 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.lt_u + if + return + end + local.get $0 + i32.const 16 + i32.sub + local.set $2 + block $break|0 + block $case5|0 + block $case4|0 + block $case3|0 + block $case2|0 + block $case1|0 + block $case0|0 + local.get $1 + local.set $3 + local.get $3 + i32.const 1 + i32.eq + br_if $case0|0 + local.get $3 + i32.const 2 + i32.eq + br_if $case1|0 + local.get $3 + i32.const 3 + i32.eq + br_if $case2|0 + local.get $3 + i32.const 4 + i32.eq + br_if $case3|0 + local.get $3 + i32.const 5 + i32.eq + br_if $case4|0 + br $case5|0 + end + local.get $2 + call $~lib/rt/pure/decrement + br $break|0 + end + local.get $2 + i32.load offset=4 + i32.const 268435455 + i32.and + i32.const 0 + i32.gt_u + i32.eqz + if + i32.const 0 + i32.const 232 + i32.const 75 + i32.const 17 + call $~lib/builtins/abort + unreachable + end + local.get $2 + local.get $2 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $2 + call $~lib/rt/pure/markGray + br $break|0 + end + local.get $2 + call $~lib/rt/pure/scan + br $break|0 + end + local.get $2 + i32.load offset=4 + local.set $3 + local.get $3 + i32.const -268435456 + i32.and + local.get $3 + i32.const 1 + i32.add + i32.const -268435456 + i32.and + i32.eq + i32.eqz + if + i32.const 0 + i32.const 232 + i32.const 86 + i32.const 6 + call $~lib/builtins/abort + unreachable + end + local.get $2 + local.get $3 + i32.const 1 + i32.add + i32.store offset=4 + local.get $3 + i32.const 1879048192 + i32.and + i32.const 0 + i32.ne + if + local.get $2 + call $~lib/rt/pure/scanBlack + end + br $break|0 + end + local.get $2 + call $~lib/rt/pure/collectWhite + br $break|0 + end + i32.const 0 + i32.eqz + if + i32.const 0 + i32.const 232 + i32.const 97 + i32.const 24 + call $~lib/builtins/abort + unreachable + end + end + ) + (func $~lib/rt/__visit_members (; 50 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + block $block$4$break + block $switch$1$default + block $switch$1$case$8 + block $switch$1$case$7 + block $switch$1$case$4 + block $switch$1$case$2 + local.get $0 + i32.const 8 + i32.sub + i32.load + br_table $switch$1$case$2 $switch$1$case$2 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$7 $switch$1$case$8 $switch$1$default + end + return + end + br $block$4$break + end + local.get $0 + local.get $1 + call $~lib/array/Array#__visit_impl + br $block$4$break + end + local.get $0 + local.get $1 + call $~lib/array/Array#__visit_impl + br $block$4$break + end + unreachable + end + local.get $0 + i32.load + local.tee $2 + if + local.get $2 + local.get $1 + call $~lib/rt/pure/__visit + end + return + ) + (func $null (; 51 ;) (type $FUNCSIG$v) + ) +) diff --git a/tests/compiler/std/map.optimized.wat b/tests/compiler/std/map.optimized.wat index 3130e4382a..faf9f41033 100644 --- a/tests/compiler/std/map.optimized.wat +++ b/tests/compiler/std/map.optimized.wat @@ -1308,7 +1308,7 @@ if i32.const 176 i32.const 224 - i32.const 57 + i32.const 58 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/map.untouched.wat b/tests/compiler/std/map.untouched.wat index d7de894877..78492c5a4e 100644 --- a/tests/compiler/std/map.untouched.wat +++ b/tests/compiler/std/map.untouched.wat @@ -1673,7 +1673,7 @@ if i32.const 176 i32.const 224 - i32.const 57 + i32.const 58 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/set.optimized.wat b/tests/compiler/std/set.optimized.wat index eaf2d38dc0..e1d97ef13e 100644 --- a/tests/compiler/std/set.optimized.wat +++ b/tests/compiler/std/set.optimized.wat @@ -1303,7 +1303,7 @@ if i32.const 176 i32.const 224 - i32.const 57 + i32.const 58 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/set.untouched.wat b/tests/compiler/std/set.untouched.wat index 575a000ece..eba1665dfd 100644 --- a/tests/compiler/std/set.untouched.wat +++ b/tests/compiler/std/set.untouched.wat @@ -1671,7 +1671,7 @@ if i32.const 176 i32.const 224 - i32.const 57 + i32.const 58 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index 60d5db95ac..f7ee8226cc 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -356,7 +356,7 @@ if i32.const 96 i32.const 144 - i32.const 57 + i32.const 58 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index cb1393363e..4de2f9666b 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -452,7 +452,7 @@ if i32.const 96 i32.const 144 - i32.const 57 + i32.const 58 i32.const 42 call $~lib/builtins/abort unreachable From 6afd48fba5ab2b873ca548150a78d2efc576378d Mon Sep 17 00:00:00 2001 From: Joshua Tenner Date: Fri, 5 Jul 2019 16:36:09 -0400 Subject: [PATCH 2/3] [Fix] UTF8 tests and implementation --- std/assembly/buffer.ts | 20 +- tests/compiler/std/buffer.optimized.wat | 689 +++++++++++++-- tests/compiler/std/buffer.ts | 9 + tests/compiler/std/buffer.untouched.wat | 1057 +++++++++++++++++++++-- 4 files changed, 1653 insertions(+), 122 deletions(-) diff --git a/std/assembly/buffer.ts b/std/assembly/buffer.ts index 0a1073856e..7c37c584e5 100644 --- a/std/assembly/buffer.ts +++ b/std/assembly/buffer.ts @@ -27,19 +27,15 @@ export class Buffer extends Uint8Array { } else if (source instanceof string) { if (encoding == null) encoding = "utf8"; - if (encoding == "utf8") { - let encoded = String.UTF8.encode(source); + if (encoding == "utf8" || encoding == "utf16") { + let encoded = encoding == "utf8" + ? String.UTF8.encode(source) + : String.UTF16.encode(source); let buffer = changetype(__alloc(offsetof(), idof())); - buffer.buffer = encoded; - buffer.dataStart = 0; - buffer.dataLength = encoded.byteLength; - return buffer; - } else if (encoding == "utf16") { - let encoded = String.UTF16.encode(source); - let buffer = changetype(__alloc(offsetof(), idof())); - buffer.buffer = encoded; - buffer.dataStart = 0; - buffer.dataLength = encoded.byteLength; + store(changetype(buffer), __retain(changetype(encoded)), offsetof("data")); + store(changetype(buffer), changetype(encoded), offsetof("dataStart")); + store(changetype(buffer), encoded.byteLength, offsetof("dataLength")); + return buffer; } assert(false); diff --git a/tests/compiler/std/buffer.optimized.wat b/tests/compiler/std/buffer.optimized.wat index 6de6b15ad2..773c9e9c86 100644 --- a/tests/compiler/std/buffer.optimized.wat +++ b/tests/compiler/std/buffer.optimized.wat @@ -8,11 +8,14 @@ (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32))) (type $FUNCSIG$dii (func (param i32 i32) (result f64))) + (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) + (type $FUNCSIG$i (func (result i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "rtrace" "onalloc" (func $~lib/rt/rtrace/onalloc (param i32))) (import "rtrace" "onincrement" (func $~lib/rt/rtrace/onincrement (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) + (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) (memory $0 1) (data (i32.const 8) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") (data (i32.const 56) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") @@ -28,14 +31,18 @@ (data (i32.const 560) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s") (data (i32.const 608) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00u\00t\00f\008") (data (i32.const 632) " \00\00\00\01\00\00\00\00\00\00\00 \00\00\00\9a\99\99\99\99\99\f1?\9a\99\99\99\99\99\01@ffffff\n@\9a\99\99\99\99\99\11@") - (data (i32.const 680) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\001\00\00\00\02\00\00\001\00\00\00\03\00\00\00\93\04\00\00\02\00\00\00\13\0d\00\00\02") + (data (i32.const 680) "\0c\00\00\00\01\00\00\00\01\00\00\00\0c\00\00\00a\00b\00c\00d\00e\00f") + (data (i32.const 712) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00u\00t\00f\001\006") + (data (i32.const 744) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s") + (data (i32.const 792) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00b\00y\00t\00e\00s") + (data (i32.const 824) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\001\00\00\00\02\00\00\001\00\00\00\03\00\00\00\93\04\00\00\02\00\00\00\13\0d\00\00\02") (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) (global $~lib/rt/pure/CUR (mut i32) (i32.const 0)) (global $~lib/rt/pure/END (mut i32) (i32.const 0)) (global $~lib/rt/pure/ROOTS (mut i32) (i32.const 0)) (export "memory" (memory $0)) (start $start) - (func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/removeBlock (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -201,7 +208,7 @@ end end ) - (func $~lib/rt/tlsf/insertBlock (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/insertBlock (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -486,7 +493,7 @@ i32.or i32.store offset=4 ) - (func $~lib/rt/tlsf/addMemory (; 7 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/rt/tlsf/addMemory (; 8 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) local.get $2 @@ -600,7 +607,7 @@ local.get $1 call $~lib/rt/tlsf/insertBlock ) - (func $~lib/rt/tlsf/initializeRoot (; 8 ;) (type $FUNCSIG$v) + (func $~lib/rt/tlsf/initializeRoot (; 9 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) i32.const 1 @@ -620,10 +627,10 @@ if unreachable end - i32.const 752 + i32.const 896 i32.const 0 i32.store - i32.const 2320 + i32.const 2464 i32.const 0 i32.store i32.const 0 @@ -637,7 +644,7 @@ local.get $0 i32.const 2 i32.shl - i32.const 752 + i32.const 896 i32.add i32.const 0 i32.store offset=4 @@ -656,7 +663,7 @@ i32.add i32.const 2 i32.shl - i32.const 752 + i32.const 896 i32.add i32.const 0 i32.store offset=96 @@ -674,16 +681,16 @@ br $loop|0 end end - i32.const 752 - i32.const 2336 + i32.const 896 + i32.const 2480 memory.size i32.const 16 i32.shl call $~lib/rt/tlsf/addMemory - i32.const 752 + i32.const 896 global.set $~lib/rt/tlsf/ROOT ) - (func $~lib/rt/tlsf/prepareSize (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/tlsf/prepareSize (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 i32.const 1073741808 i32.ge_u @@ -707,7 +714,7 @@ i32.gt_u select ) - (func $~lib/rt/tlsf/searchBlock (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/searchBlock (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $1 i32.const 256 @@ -838,7 +845,7 @@ end end ) - (func $~lib/rt/tlsf/growMemory (; 11 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/growMemory (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) memory.size local.tee $2 @@ -875,7 +882,7 @@ i32.shl call $~lib/rt/tlsf/addMemory ) - (func $~lib/rt/tlsf/prepareBlock (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/rt/tlsf/prepareBlock (; 13 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) local.get $1 @@ -951,7 +958,7 @@ i32.store end ) - (func $~lib/rt/tlsf/allocateBlock (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/allocateBlock (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -1010,7 +1017,7 @@ call $~lib/rt/rtrace/onalloc local.get $2 ) - (func $~lib/rt/tlsf/__alloc (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/__alloc (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) global.get $~lib/rt/tlsf/ROOT local.tee $2 @@ -1029,7 +1036,7 @@ i32.const 16 i32.add ) - (func $~lib/memory/memory.fill (; 15 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/memory/memory.fill (; 16 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) block $~lib/util/memory/memset|inlined.0 local.get $1 @@ -1238,7 +1245,7 @@ end end ) - (func $~lib/rt/pure/increment (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/increment (; 17 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -1279,9 +1286,9 @@ unreachable end ) - (func $~lib/rt/pure/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/pure/__retain (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 - i32.const 740 + i32.const 884 i32.gt_u if local.get $0 @@ -1291,7 +1298,7 @@ end local.get $0 ) - (func $~lib/rt/tlsf/freeBlock (; 18 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/freeBlock (; 19 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) local.get $1 i32.load @@ -1317,9 +1324,9 @@ local.get $1 call $~lib/rt/rtrace/onfree ) - (func $~lib/rt/__typeinfo (; 19 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/__typeinfo (; 20 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 - i32.const 680 + i32.const 824 i32.load i32.gt_u if @@ -1333,11 +1340,11 @@ local.get $0 i32.const 3 i32.shl - i32.const 684 + i32.const 828 i32.add i32.load ) - (func $~lib/memory/memory.copy (; 20 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/memory/memory.copy (; 21 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) block $~lib/util/memory/memmove|inlined.0 @@ -1512,7 +1519,7 @@ end end ) - (func $~lib/rt/tlsf/__free (; 21 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/tlsf/__free (; 22 ;) (type $FUNCSIG$vi) (param $0 i32) global.get $~lib/rt/tlsf/ROOT i32.eqz if @@ -1545,7 +1552,7 @@ i32.sub call $~lib/rt/tlsf/freeBlock ) - (func $~lib/rt/pure/growRoots (; 22 ;) (type $FUNCSIG$v) + (func $~lib/rt/pure/growRoots (; 23 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -1594,7 +1601,7 @@ i32.add global.set $~lib/rt/pure/END ) - (func $~lib/rt/pure/appendRoot (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/appendRoot (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) global.get $~lib/rt/pure/CUR local.tee $1 @@ -1613,7 +1620,7 @@ i32.add global.set $~lib/rt/pure/CUR ) - (func $~lib/rt/pure/decrement (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/decrement (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) (local $2 i32) local.get $0 @@ -1703,9 +1710,9 @@ end end ) - (func $~lib/rt/pure/__release (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/__release (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 - i32.const 740 + i32.const 884 i32.gt_u if local.get $0 @@ -1714,7 +1721,7 @@ call $~lib/rt/pure/decrement end ) - (func $~lib/arraybuffer/ArrayBufferView#constructor (; 26 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/arraybuffer/ArrayBufferView#constructor (; 27 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $1 @@ -1775,7 +1782,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/buffer/Buffer#constructor (; 27 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/buffer/Buffer#constructor (; 28 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) i32.const 16 i32.const 4 @@ -1797,7 +1804,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/typedarray/Uint8Array#__set (; 28 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/typedarray/Uint8Array#__set (; 29 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 local.get $0 i32.load offset=8 @@ -1817,7 +1824,7 @@ local.get $2 i32.store8 ) - (func $~lib/typedarray/Uint8Array#__get (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#__get (; 30 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 i32.load offset=8 @@ -1836,7 +1843,7 @@ i32.add i32.load8_u ) - (func $~lib/rt/__allocArray (; 30 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/rt/__allocArray (; 31 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) i32.const 16 local.get $2 @@ -1869,7 +1876,7 @@ end local.get $2 ) - (func $~lib/array/Array#__get (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 32 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 i32.load offset=8 @@ -1892,7 +1899,7 @@ i32.add i32.load ) - (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 33 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -1909,7 +1916,7 @@ if i32.const 0 i32.const 528 - i32.const 50 + i32.const 46 i32.const 6 call $~lib/builtins/abort unreachable @@ -1947,7 +1954,7 @@ call $~lib/rt/pure/__release local.get $1 ) - (func $~lib/array/Array#__get (; 33 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__get (; 34 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) local.get $1 local.get $0 i32.load offset=8 @@ -1970,7 +1977,7 @@ i32.add f64.load ) - (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 34 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 35 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -1987,7 +1994,7 @@ if i32.const 0 i32.const 528 - i32.const 50 + i32.const 46 i32.const 6 call $~lib/builtins/abort unreachable @@ -2026,7 +2033,467 @@ call $~lib/rt/pure/__release local.get $1 ) - (func $start:std/buffer (; 35 ;) (type $FUNCSIG$v) + (func $~lib/string/String#get:length (; 36 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 16 + i32.sub + i32.load offset=12 + i32.const 1 + i32.shr_u + ) + (func $~lib/util/string/compareImpl (; 37 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + i32.const 624 + call $~lib/rt/pure/__retain + drop + local.get $0 + call $~lib/rt/pure/__retain + drop + i32.const 624 + local.set $2 + local.get $0 + local.set $3 + loop $continue|0 + local.get $1 + if (result i32) + local.get $2 + i32.load16_u + local.get $3 + i32.load16_u + i32.sub + local.tee $4 + i32.eqz + else + i32.const 0 + end + if + local.get $1 + i32.const 1 + i32.sub + local.set $1 + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $3 + i32.const 2 + i32.add + local.set $3 + br $continue|0 + end + end + i32.const 624 + call $~lib/rt/pure/__release + local.get $0 + call $~lib/rt/pure/__release + local.get $4 + ) + (func $~lib/string/String.__eq (; 38 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + i32.const 624 + call $~lib/rt/pure/__retain + drop + local.get $0 + call $~lib/rt/pure/__retain + drop + local.get $0 + i32.const 624 + i32.eq + if + i32.const 624 + call $~lib/rt/pure/__release + local.get $0 + call $~lib/rt/pure/__release + i32.const 1 + return + end + block $folding-inner0 + local.get $0 + i32.eqz + br_if $folding-inner0 + i32.const 624 + call $~lib/string/String#get:length + local.tee $1 + local.get $0 + call $~lib/string/String#get:length + i32.ne + br_if $folding-inner0 + local.get $0 + local.get $1 + call $~lib/util/string/compareImpl + i32.eqz + i32.const 624 + call $~lib/rt/pure/__release + local.get $0 + call $~lib/rt/pure/__release + return + end + i32.const 624 + call $~lib/rt/pure/__release + local.get $0 + call $~lib/rt/pure/__release + i32.const 0 + ) + (func $~lib/string/String.UTF8.byteLength (; 39 ;) (type $FUNCSIG$i) (result i32) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + i32.const 696 + call $~lib/rt/pure/__retain + drop + i32.const 696 + local.set $0 + i32.const 692 + i32.load + i32.const 696 + i32.add + local.set $2 + loop $continue|0 + local.get $0 + local.get $2 + i32.lt_u + if + local.get $0 + i32.load16_u + local.tee $3 + i32.const 128 + i32.lt_u + if (result i32) + local.get $1 + i32.const 1 + i32.add + else + local.get $3 + i32.const 2048 + i32.lt_u + if (result i32) + local.get $1 + i32.const 2 + i32.add + else + local.get $0 + i32.const 2 + i32.add + local.get $2 + i32.lt_u + i32.const 0 + local.get $3 + i32.const 64512 + i32.and + i32.const 55296 + i32.eq + select + if + local.get $0 + i32.load16_u offset=2 + i32.const 64512 + i32.and + i32.const 56320 + i32.eq + if + local.get $0 + i32.const 4 + i32.add + local.set $0 + local.get $1 + i32.const 4 + i32.add + local.set $1 + br $continue|0 + end + end + local.get $1 + i32.const 3 + i32.add + end + end + local.set $1 + local.get $0 + i32.const 2 + i32.add + local.set $0 + br $continue|0 + end + end + i32.const 696 + call $~lib/rt/pure/__release + local.get $1 + ) + (func $~lib/string/String.UTF8.encode (; 40 ;) (type $FUNCSIG$i) (result i32) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + i32.const 696 + call $~lib/rt/pure/__retain + drop + i32.const 696 + local.set $2 + i32.const 692 + i32.load + i32.const 696 + i32.add + local.set $3 + call $~lib/string/String.UTF8.byteLength + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $4 + local.set $0 + loop $continue|0 + local.get $2 + local.get $3 + i32.lt_u + if + local.get $2 + i32.load16_u + local.tee $1 + i32.const 128 + i32.lt_u + if (result i32) + local.get $0 + local.get $1 + i32.store8 + local.get $0 + i32.const 1 + i32.add + else + local.get $1 + i32.const 2048 + i32.lt_u + if (result i32) + local.get $0 + local.get $1 + i32.const 6 + i32.shr_u + i32.const 192 + i32.or + i32.store8 + local.get $0 + local.get $1 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + local.get $0 + i32.const 2 + i32.add + else + local.get $2 + i32.const 2 + i32.add + local.get $3 + i32.lt_u + i32.const 0 + local.get $1 + i32.const 64512 + i32.and + i32.const 55296 + i32.eq + select + if + local.get $2 + i32.load16_u offset=2 + local.tee $5 + i32.const 64512 + i32.and + i32.const 56320 + i32.eq + if + local.get $0 + local.get $1 + i32.const 1023 + i32.and + i32.const 10 + i32.shl + i32.const 65536 + i32.add + local.get $5 + i32.const 1023 + i32.and + i32.add + local.tee $1 + i32.const 18 + i32.shr_u + i32.const 240 + i32.or + i32.store8 + local.get $0 + local.get $1 + i32.const 12 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + local.get $0 + local.get $1 + i32.const 6 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=2 + local.get $0 + local.get $1 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=3 + local.get $2 + i32.const 4 + i32.add + local.set $2 + local.get $0 + i32.const 4 + i32.add + local.set $0 + br $continue|0 + end + end + local.get $0 + local.get $1 + i32.const 12 + i32.shr_u + i32.const 224 + i32.or + i32.store8 + local.get $0 + local.get $1 + i32.const 6 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + local.get $0 + local.get $1 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=2 + local.get $0 + i32.const 3 + i32.add + end + end + local.set $0 + local.get $2 + i32.const 2 + i32.add + local.set $2 + br $continue|0 + end + end + local.get $2 + local.get $3 + i32.ne + if + i32.const 0 + i32.const 760 + i32.const 571 + i32.const 8 + call $~lib/builtins/abort + unreachable + end + local.get $4 + call $~lib/rt/pure/__retain + i32.const 696 + call $~lib/rt/pure/__release + ) + (func $~lib/string/String.UTF16.encode (; 41 ;) (type $FUNCSIG$i) (result i32) + (local $0 i32) + (local $1 i32) + i32.const 696 + call $~lib/rt/pure/__retain + drop + i32.const 692 + i32.load + local.tee $0 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $1 + i32.const 696 + local.get $0 + call $~lib/memory/memory.copy + local.get $1 + call $~lib/rt/pure/__retain + i32.const 696 + call $~lib/rt/pure/__release + ) + (func $~lib/buffer/Buffer.from<~lib/string/String> (; 42 ;) (type $FUNCSIG$i) (result i32) + (local $0 i32) + (local $1 i32) + i32.const 696 + call $~lib/rt/pure/__retain + drop + i32.const 624 + call $~lib/rt/pure/__retain + drop + i32.const 0 + call $~lib/string/String.__eq + drop + i32.const 624 + call $~lib/string/String.__eq + if (result i32) + i32.const 1 + else + i32.const 728 + call $~lib/string/String.__eq + end + if + i32.const 624 + call $~lib/string/String.__eq + if (result i32) + call $~lib/string/String.UTF8.encode + else + call $~lib/string/String.UTF16.encode + end + local.set $0 + i32.const 16 + i32.const 4 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $1 + local.get $0 + call $~lib/rt/pure/__retain + i32.store + local.get $1 + local.get $0 + i32.store offset=4 + local.get $1 + local.get $0 + i32.const 16 + i32.sub + i32.load offset=12 + i32.store offset=8 + local.get $0 + call $~lib/rt/pure/__release + i32.const 696 + call $~lib/rt/pure/__release + i32.const 624 + call $~lib/rt/pure/__release + local.get $1 + return + end + i32.const 0 + i32.const 528 + i32.const 41 + i32.const 6 + call $~lib/builtins/abort + unreachable + ) + (func $start:std/buffer (; 43 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -2198,9 +2665,10 @@ call $~lib/rt/pure/__retain local.tee $5 call $~lib/buffer/Buffer.from<~lib/array/Array> + local.set $1 local.get $0 call $~lib/rt/pure/__release - local.tee $0 + local.get $1 i32.const 0 call $~lib/typedarray/Uint8Array#__get i32.const 1 @@ -2213,7 +2681,7 @@ call $~lib/builtins/abort unreachable end - local.get $0 + local.get $1 i32.const 1 call $~lib/typedarray/Uint8Array#__get i32.const 2 @@ -2226,7 +2694,7 @@ call $~lib/builtins/abort unreachable end - local.get $0 + local.get $1 i32.const 2 call $~lib/typedarray/Uint8Array#__get i32.const 3 @@ -2239,7 +2707,7 @@ call $~lib/builtins/abort unreachable end - local.get $0 + local.get $1 i32.const 3 call $~lib/typedarray/Uint8Array#__get i32.const 4 @@ -2252,6 +2720,111 @@ call $~lib/builtins/abort unreachable end + call $~lib/buffer/Buffer.from<~lib/string/String> + local.set $0 + local.get $1 + call $~lib/rt/pure/__release + i32.const 808 + i32.const 5 + local.get $0 + i32.const 0 + call $~lib/typedarray/Uint8Array#__get + f64.convert_i32_u + local.get $0 + i32.const 1 + call $~lib/typedarray/Uint8Array#__get + f64.convert_i32_u + local.get $0 + i32.const 2 + call $~lib/typedarray/Uint8Array#__get + f64.convert_i32_u + local.get $0 + i32.const 3 + call $~lib/typedarray/Uint8Array#__get + f64.convert_i32_u + local.get $0 + i32.const 4 + call $~lib/typedarray/Uint8Array#__get + f64.convert_i32_u + call $~lib/builtins/trace + local.get $0 + i32.const 0 + call $~lib/typedarray/Uint8Array#__get + i32.const 97 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 31 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 1 + call $~lib/typedarray/Uint8Array#__get + i32.const 98 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 32 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 2 + call $~lib/typedarray/Uint8Array#__get + i32.const 99 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 33 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 3 + call $~lib/typedarray/Uint8Array#__get + i32.const 100 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 34 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 4 + call $~lib/typedarray/Uint8Array#__get + i32.const 101 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 35 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 5 + call $~lib/typedarray/Uint8Array#__get + i32.const 102 + i32.ne + if + i32.const 0 + i32.const 432 + i32.const 36 + i32.const 2 + call $~lib/builtins/abort + unreachable + end local.get $0 call $~lib/rt/pure/__release local.get $2 @@ -2263,10 +2836,10 @@ local.get $5 call $~lib/rt/pure/__release ) - (func $start (; 36 ;) (type $FUNCSIG$v) + (func $start (; 44 ;) (type $FUNCSIG$v) call $start:std/buffer ) - (func $~lib/rt/pure/markGray (; 37 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/markGray (; 45 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -2290,7 +2863,7 @@ call $~lib/rt/__visit_members end ) - (func $~lib/rt/pure/scanBlack (; 38 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/scanBlack (; 46 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 local.get $0 i32.load offset=4 @@ -2303,7 +2876,7 @@ i32.const 4 call $~lib/rt/__visit_members ) - (func $~lib/rt/pure/scan (; 39 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/scan (; 47 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -2337,7 +2910,7 @@ end end ) - (func $~lib/rt/pure/collectWhite (; 40 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/collectWhite (; 48 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -2370,9 +2943,9 @@ call $~lib/rt/tlsf/freeBlock end ) - (func $~lib/rt/pure/__visit (; 41 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/pure/__visit (; 49 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) local.get $0 - i32.const 740 + i32.const 884 i32.lt_u if return @@ -2480,7 +3053,7 @@ unreachable end ) - (func $~lib/rt/__visit_members (; 42 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/__visit_members (; 50 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) block $block$4$break block $switch$1$default block $switch$1$case$2 @@ -2503,7 +3076,7 @@ call $~lib/rt/pure/__visit end ) - (func $null (; 43 ;) (type $FUNCSIG$v) + (func $null (; 51 ;) (type $FUNCSIG$v) nop ) ) diff --git a/tests/compiler/std/buffer.ts b/tests/compiler/std/buffer.ts index caf3c07a73..ad73c4b1bd 100644 --- a/tests/compiler/std/buffer.ts +++ b/tests/compiler/std/buffer.ts @@ -25,4 +25,13 @@ assert(buffer[1] == 2.2); assert(buffer[2] == 3.3); assert(buffer[3] == 4.4); + + buffer = Buffer.from("abcdef"); + trace("bytes", 5, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4]); + assert(buffer[0] == 0x61); + assert(buffer[1] == 0x62); + assert(buffer[2] == 0x63); + assert(buffer[3] == 0x64); + assert(buffer[4] == 0x65); + assert(buffer[5] == 0x66); } diff --git a/tests/compiler/std/buffer.untouched.wat b/tests/compiler/std/buffer.untouched.wat index 71d050843a..0b061704ff 100644 --- a/tests/compiler/std/buffer.untouched.wat +++ b/tests/compiler/std/buffer.untouched.wat @@ -9,11 +9,14 @@ (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32))) (type $FUNCSIG$dii (func (param i32 i32) (result f64))) + (type $FUNCSIG$iiiiii (func (param i32 i32 i32 i32 i32) (result i32))) + (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "rtrace" "onalloc" (func $~lib/rt/rtrace/onalloc (param i32))) (import "rtrace" "onincrement" (func $~lib/rt/rtrace/onincrement (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) + (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) (memory $0 1) (data (i32.const 8) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") (data (i32.const 56) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") @@ -29,7 +32,11 @@ (data (i32.const 560) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s\00") (data (i32.const 608) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00u\00t\00f\008\00") (data (i32.const 632) " \00\00\00\01\00\00\00\00\00\00\00 \00\00\00\9a\99\99\99\99\99\f1?\9a\99\99\99\99\99\01@ffffff\n@\9a\99\99\99\99\99\11@") - (data (i32.const 680) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\001\00\00\00\02\00\00\001\00\00\00\03\00\00\00\93\04\00\00\02\00\00\00\13\0d\00\00\02\00\00\00") + (data (i32.const 680) "\0c\00\00\00\01\00\00\00\01\00\00\00\0c\00\00\00a\00b\00c\00d\00e\00f\00") + (data (i32.const 712) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00u\00t\00f\001\006\00") + (data (i32.const 744) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00") + (data (i32.const 792) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00b\00y\00t\00e\00s\00") + (data (i32.const 824) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\001\00\00\00\02\00\00\001\00\00\00\03\00\00\00\93\04\00\00\02\00\00\00\13\0d\00\00\02\00\00\00") (table $0 1 funcref) (elem (i32.const 0) $null) (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) @@ -40,11 +47,11 @@ (global $~lib/buffer/Buffer.NO_ENCODING (mut i32) (i32.const 0)) (global $~lib/buffer/Buffer.UTF8_ENCODING (mut i32) (i32.const 1)) (global $~lib/buffer/Buffer.UTF16_ENCODING (mut i32) (i32.const 2)) - (global $~lib/rt/__rtti_base i32 (i32.const 680)) - (global $~lib/heap/__heap_base i32 (i32.const 740)) + (global $~lib/rt/__rtti_base i32 (i32.const 824)) + (global $~lib/heap/__heap_base i32 (i32.const 884)) (export "memory" (memory $0)) (start $start) - (func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/removeBlock (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -254,7 +261,7 @@ end end ) - (func $~lib/rt/tlsf/insertBlock (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/insertBlock (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -604,7 +611,7 @@ local.get $7 i32.store offset=4 ) - (func $~lib/rt/tlsf/addMemory (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/rt/tlsf/addMemory (; 8 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -752,7 +759,7 @@ call $~lib/rt/tlsf/insertBlock i32.const 1 ) - (func $~lib/rt/tlsf/initializeRoot (; 8 ;) (type $FUNCSIG$v) + (func $~lib/rt/tlsf/initializeRoot (; 9 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -897,7 +904,7 @@ local.get $3 global.set $~lib/rt/tlsf/ROOT ) - (func $~lib/rt/tlsf/prepareSize (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/tlsf/prepareSize (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 @@ -926,7 +933,7 @@ i32.gt_u select ) - (func $~lib/rt/tlsf/searchBlock (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/searchBlock (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1109,7 +1116,7 @@ end local.get $7 ) - (func $~lib/rt/tlsf/growMemory (; 11 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/growMemory (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1162,7 +1169,7 @@ call $~lib/rt/tlsf/addMemory drop ) - (func $~lib/rt/tlsf/prepareBlock (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/rt/tlsf/prepareBlock (; 13 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1257,7 +1264,7 @@ i32.store end ) - (func $~lib/rt/tlsf/allocateBlock (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/allocateBlock (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $1 @@ -1320,7 +1327,7 @@ call $~lib/rt/rtrace/onalloc local.get $3 ) - (func $~lib/rt/tlsf/__alloc (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/__alloc (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) global.get $~lib/rt/tlsf/ROOT @@ -1343,7 +1350,7 @@ i32.const 16 i32.add ) - (func $~lib/memory/memory.fill (; 15 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/memory/memory.fill (; 16 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1607,7 +1614,7 @@ end end ) - (func $~lib/rt/pure/increment (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/increment (; 17 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -1652,7 +1659,7 @@ unreachable end ) - (func $~lib/rt/pure/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/pure/__retain (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 global.get $~lib/heap/__heap_base i32.gt_u @@ -1664,7 +1671,7 @@ end local.get $0 ) - (func $~lib/rt/tlsf/freeBlock (; 18 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/freeBlock (; 19 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) local.get $1 i32.load @@ -1693,7 +1700,7 @@ local.get $1 call $~lib/rt/rtrace/onfree ) - (func $~lib/rt/__typeinfo (; 19 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/__typeinfo (; 20 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) global.get $~lib/rt/__rtti_base local.set $1 @@ -1718,7 +1725,7 @@ i32.add i32.load ) - (func $~lib/util/memory/memcpy (; 20 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/util/memory/memcpy (; 21 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2746,7 +2753,7 @@ i32.store8 end ) - (func $~lib/memory/memory.copy (; 21 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/memory/memory.copy (; 22 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2971,7 +2978,7 @@ end end ) - (func $~lib/rt/tlsf/__free (; 22 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/tlsf/__free (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) global.get $~lib/rt/tlsf/ROOT i32.eqz if @@ -3008,7 +3015,7 @@ i32.sub call $~lib/rt/tlsf/freeBlock ) - (func $~lib/rt/pure/growRoots (; 23 ;) (type $FUNCSIG$v) + (func $~lib/rt/pure/growRoots (; 24 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -3066,7 +3073,7 @@ i32.add global.set $~lib/rt/pure/END ) - (func $~lib/rt/pure/appendRoot (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/appendRoot (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) global.get $~lib/rt/pure/CUR local.set $1 @@ -3086,7 +3093,7 @@ i32.add global.set $~lib/rt/pure/CUR ) - (func $~lib/rt/pure/decrement (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/decrement (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) (local $2 i32) local.get $0 @@ -3190,7 +3197,7 @@ end end ) - (func $~lib/rt/pure/__release (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/__release (; 27 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 global.get $~lib/heap/__heap_base i32.gt_u @@ -3201,7 +3208,7 @@ call $~lib/rt/pure/decrement end ) - (func $~lib/arraybuffer/ArrayBufferView#constructor (; 27 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/arraybuffer/ArrayBufferView#constructor (; 28 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -3272,7 +3279,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Uint8Array#constructor (; 28 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#constructor (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 if (result i32) local.get $0 @@ -3288,7 +3295,7 @@ local.set $0 local.get $0 ) - (func $~lib/buffer/Buffer#constructor (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/buffer/Buffer#constructor (; 30 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 if (result i32) local.get $0 @@ -3306,7 +3313,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/typedarray/Uint8Array#__set (; 30 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/typedarray/Uint8Array#__set (; 31 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 local.get $0 i32.load offset=8 @@ -3326,7 +3333,7 @@ local.get $2 i32.store8 ) - (func $~lib/typedarray/Uint8Array#__get (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#__get (; 32 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 i32.load offset=8 @@ -3345,7 +3352,7 @@ i32.add i32.load8_u ) - (func $~lib/rt/__allocArray (; 32 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/rt/__allocArray (; 33 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -3383,11 +3390,11 @@ end local.get $4 ) - (func $~lib/array/Array#get:length (; 33 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/array/Array#get:length (; 34 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (; 34 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__unchecked_get (; 35 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -3396,7 +3403,7 @@ i32.add i32.load ) - (func $~lib/array/Array#__get (; 35 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 36 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 i32.load offset=8 @@ -3415,7 +3422,7 @@ local.get $1 call $~lib/array/Array#__unchecked_get ) - (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 36 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 37 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3442,7 +3449,7 @@ if i32.const 0 i32.const 528 - i32.const 50 + i32.const 46 i32.const 6 call $~lib/builtins/abort unreachable @@ -3488,11 +3495,11 @@ local.get $6 return ) - (func $~lib/array/Array#get:length (; 37 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/array/Array#get:length (; 38 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (; 38 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__unchecked_get (; 39 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) local.get $0 i32.load offset=4 local.get $1 @@ -3501,7 +3508,7 @@ i32.add f64.load ) - (func $~lib/array/Array#__get (; 39 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__get (; 40 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) local.get $1 local.get $0 i32.load offset=8 @@ -3520,7 +3527,7 @@ local.get $1 call $~lib/array/Array#__unchecked_get ) - (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 40 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 41 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3547,7 +3554,7 @@ if i32.const 0 i32.const 528 - i32.const 50 + i32.const 46 i32.const 6 call $~lib/builtins/abort unreachable @@ -3594,7 +3601,838 @@ local.get $6 return ) - (func $start:std/buffer (; 41 ;) (type $FUNCSIG$v) + (func $~lib/string/String#get:length (; 42 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 16 + i32.sub + i32.load offset=12 + i32.const 1 + i32.shr_u + ) + (func $~lib/util/string/compareImpl (; 43 ;) (type $FUNCSIG$iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + local.get $0 + call $~lib/rt/pure/__retain + drop + local.get $2 + call $~lib/rt/pure/__retain + drop + i32.const 0 + local.set $5 + local.get $0 + local.get $1 + i32.const 1 + i32.shl + i32.add + local.set $6 + local.get $2 + local.get $3 + i32.const 1 + i32.shl + i32.add + local.set $7 + block $break|0 + loop $continue|0 + local.get $4 + if (result i32) + local.get $6 + i32.load16_u + local.get $7 + i32.load16_u + i32.sub + local.tee $5 + i32.eqz + else + i32.const 0 + end + i32.eqz + br_if $break|0 + local.get $4 + i32.const 1 + i32.sub + local.set $4 + local.get $6 + i32.const 2 + i32.add + local.set $6 + local.get $7 + i32.const 2 + i32.add + local.set $7 + br $continue|0 + end + unreachable + end + local.get $5 + local.set $8 + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $8 + ) + (func $~lib/string/String.__eq (; 44 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + local.get $0 + call $~lib/rt/pure/__retain + drop + local.get $1 + call $~lib/rt/pure/__retain + drop + local.get $0 + local.get $1 + i32.eq + if + i32.const 1 + local.set $2 + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $2 + return + end + local.get $0 + i32.const 0 + i32.eq + if (result i32) + i32.const 1 + else + local.get $1 + i32.const 0 + i32.eq + end + if + i32.const 0 + local.set $2 + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $2 + return + end + local.get $0 + call $~lib/string/String#get:length + local.set $3 + local.get $3 + local.get $1 + call $~lib/string/String#get:length + i32.ne + if + i32.const 0 + local.set $2 + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $2 + return + end + local.get $0 + i32.const 0 + local.get $1 + i32.const 0 + local.get $3 + call $~lib/util/string/compareImpl + i32.eqz + local.set $2 + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $2 + ) + (func $~lib/string/String.UTF8.byteLength (; 45 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + local.get $0 + call $~lib/rt/pure/__retain + drop + local.get $0 + local.set $2 + local.get $2 + local.get $0 + i32.const 16 + i32.sub + i32.load offset=12 + i32.add + local.set $3 + local.get $1 + if (result i32) + i32.const 1 + else + i32.const 0 + end + local.set $4 + block $break|0 + loop $continue|0 + local.get $2 + local.get $3 + i32.lt_u + i32.eqz + br_if $break|0 + local.get $2 + i32.load16_u + local.set $5 + local.get $5 + i32.const 128 + i32.lt_u + if + local.get $1 + if (result i32) + local.get $5 + i32.eqz + else + i32.const 0 + end + if + br $break|0 + end + local.get $4 + i32.const 1 + i32.add + local.set $4 + local.get $2 + i32.const 2 + i32.add + local.set $2 + else + local.get $5 + i32.const 2048 + i32.lt_u + if + local.get $4 + i32.const 2 + i32.add + local.set $4 + local.get $2 + i32.const 2 + i32.add + local.set $2 + else + local.get $5 + i32.const 64512 + i32.and + i32.const 55296 + i32.eq + if (result i32) + local.get $2 + i32.const 2 + i32.add + local.get $3 + i32.lt_u + else + i32.const 0 + end + if + local.get $2 + i32.load16_u offset=2 + i32.const 64512 + i32.and + i32.const 56320 + i32.eq + if + local.get $2 + i32.const 4 + i32.add + local.set $2 + local.get $4 + i32.const 4 + i32.add + local.set $4 + br $continue|0 + end + end + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $4 + i32.const 3 + i32.add + local.set $4 + end + end + br $continue|0 + end + unreachable + end + local.get $4 + local.set $5 + local.get $0 + call $~lib/rt/pure/__release + local.get $5 + ) + (func $~lib/rt/tlsf/reallocateBlock (; 46 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + local.get $2 + call $~lib/rt/tlsf/prepareSize + local.set $3 + local.get $1 + i32.load + local.set $4 + local.get $4 + i32.const 1 + i32.and + i32.eqz + if (result i32) + local.get $1 + i32.load offset=4 + i32.const -268435456 + i32.and + i32.eqz + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 495 + i32.const 4 + call $~lib/builtins/abort + unreachable + end + local.get $3 + local.get $4 + i32.const -4 + i32.and + i32.le_u + if + local.get $0 + local.get $1 + local.get $3 + call $~lib/rt/tlsf/prepareBlock + local.get $1 + local.get $2 + i32.store offset=12 + local.get $1 + return + end + local.get $1 + local.set $5 + local.get $5 + i32.const 16 + i32.add + local.get $5 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + local.set $6 + local.get $6 + i32.load + local.set $7 + local.get $7 + i32.const 1 + i32.and + if + local.get $4 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.add + local.get $7 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + local.set $5 + local.get $5 + local.get $3 + i32.ge_u + if + local.get $0 + local.get $6 + call $~lib/rt/tlsf/removeBlock + local.get $1 + local.get $4 + i32.const 3 + i32.and + local.get $5 + i32.or + i32.store + local.get $1 + local.get $2 + i32.store offset=12 + local.get $0 + local.get $1 + local.get $3 + call $~lib/rt/tlsf/prepareBlock + local.get $1 + return + end + end + local.get $0 + local.get $2 + call $~lib/rt/tlsf/allocateBlock + local.set $8 + local.get $8 + local.get $1 + i32.load offset=8 + i32.store offset=8 + local.get $8 + i32.const 16 + i32.add + local.get $1 + i32.const 16 + i32.add + local.get $2 + call $~lib/memory/memory.copy + local.get $1 + local.get $4 + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $1 + call $~lib/rt/tlsf/insertBlock + local.get $1 + call $~lib/rt/rtrace/onfree + local.get $8 + ) + (func $~lib/rt/tlsf/__realloc (; 47 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + global.get $~lib/rt/tlsf/ROOT + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 559 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 0 + i32.ne + if (result i32) + local.get $0 + i32.const 15 + i32.and + i32.eqz + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 560 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/rt/tlsf/ROOT + local.get $0 + i32.const 16 + i32.sub + local.get $1 + call $~lib/rt/tlsf/reallocateBlock + i32.const 16 + i32.add + ) + (func $~lib/string/String.UTF8.encode (; 48 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + local.get $0 + call $~lib/rt/pure/__retain + drop + local.get $0 + local.set $2 + local.get $0 + local.get $0 + i32.const 16 + i32.sub + i32.load offset=12 + i32.add + local.set $3 + local.get $0 + local.get $1 + call $~lib/string/String.UTF8.byteLength + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.set $4 + local.get $4 + local.set $5 + block $break|0 + loop $continue|0 + local.get $2 + local.get $3 + i32.lt_u + i32.eqz + br_if $break|0 + local.get $2 + i32.load16_u + local.set $6 + local.get $6 + i32.const 128 + i32.lt_u + if + local.get $1 + if (result i32) + local.get $6 + i32.eqz + else + i32.const 0 + end + if + br $break|0 + end + local.get $5 + local.get $6 + i32.store8 + local.get $5 + i32.const 1 + i32.add + local.set $5 + local.get $2 + i32.const 2 + i32.add + local.set $2 + else + local.get $6 + i32.const 2048 + i32.lt_u + if + local.get $5 + local.get $6 + i32.const 6 + i32.shr_u + i32.const 192 + i32.or + i32.store8 + local.get $5 + local.get $6 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $2 + i32.const 2 + i32.add + local.set $2 + else + local.get $6 + i32.const 64512 + i32.and + i32.const 55296 + i32.eq + if (result i32) + local.get $2 + i32.const 2 + i32.add + local.get $3 + i32.lt_u + else + i32.const 0 + end + if + local.get $2 + i32.load16_u offset=2 + local.set $7 + local.get $7 + i32.const 64512 + i32.and + i32.const 56320 + i32.eq + if + i32.const 65536 + local.get $6 + i32.const 1023 + i32.and + i32.const 10 + i32.shl + i32.add + local.get $7 + i32.const 1023 + i32.and + i32.add + local.set $6 + local.get $5 + local.get $6 + i32.const 18 + i32.shr_u + i32.const 240 + i32.or + i32.store8 + local.get $5 + local.get $6 + i32.const 12 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + local.get $5 + local.get $6 + i32.const 6 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=2 + local.get $5 + local.get $6 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=3 + local.get $2 + i32.const 4 + i32.add + local.set $2 + local.get $5 + i32.const 4 + i32.add + local.set $5 + br $continue|0 + end + end + local.get $5 + local.get $6 + i32.const 12 + i32.shr_u + i32.const 224 + i32.or + i32.store8 + local.get $5 + local.get $6 + i32.const 6 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + local.get $5 + local.get $6 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=2 + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $5 + i32.const 3 + i32.add + local.set $5 + end + end + br $continue|0 + end + unreachable + end + local.get $1 + if + local.get $2 + local.get $3 + i32.le_u + i32.eqz + if + i32.const 0 + i32.const 760 + i32.const 567 + i32.const 8 + call $~lib/builtins/abort + unreachable + end + local.get $4 + local.get $5 + local.get $4 + i32.sub + i32.const 1 + i32.add + call $~lib/rt/tlsf/__realloc + local.set $4 + local.get $5 + i32.const 0 + i32.store8 + else + local.get $2 + local.get $3 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 760 + i32.const 571 + i32.const 8 + call $~lib/builtins/abort + unreachable + end + end + local.get $4 + call $~lib/rt/pure/__retain + local.set $6 + local.get $0 + call $~lib/rt/pure/__release + local.get $6 + ) + (func $~lib/string/String.UTF16.encode (; 49 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + call $~lib/rt/pure/__retain + drop + local.get $0 + i32.const 16 + i32.sub + i32.load offset=12 + local.set $1 + local.get $1 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.set $2 + local.get $2 + local.get $0 + local.get $1 + call $~lib/memory/memory.copy + local.get $2 + call $~lib/rt/pure/__retain + local.set $3 + local.get $0 + call $~lib/rt/pure/__release + local.get $3 + ) + (func $~lib/arraybuffer/ArrayBuffer#get:byteLength (; 50 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 16 + i32.sub + i32.load offset=12 + ) + (func $~lib/buffer/Buffer.from<~lib/string/String> (; 51 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + local.get $0 + call $~lib/rt/pure/__retain + drop + local.get $1 + call $~lib/rt/pure/__retain + drop + local.get $1 + i32.const 0 + call $~lib/string/String.__eq + if + i32.const 624 + local.tee $2 + local.get $1 + local.tee $3 + i32.ne + if + local.get $2 + call $~lib/rt/pure/__retain + drop + local.get $3 + call $~lib/rt/pure/__release + end + local.get $2 + local.set $1 + end + local.get $1 + i32.const 624 + call $~lib/string/String.__eq + if (result i32) + i32.const 1 + else + local.get $1 + i32.const 728 + call $~lib/string/String.__eq + end + if + local.get $1 + i32.const 624 + call $~lib/string/String.__eq + if (result i32) + local.get $0 + i32.const 0 + call $~lib/string/String.UTF8.encode + else + local.get $0 + call $~lib/string/String.UTF16.encode + end + local.set $2 + i32.const 16 + i32.const 4 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.set $3 + local.get $3 + local.get $2 + call $~lib/rt/pure/__retain + i32.store + local.get $3 + local.get $2 + i32.store offset=4 + local.get $3 + local.get $2 + call $~lib/arraybuffer/ArrayBuffer#get:byteLength + i32.store offset=8 + local.get $3 + local.set $4 + local.get $2 + call $~lib/rt/pure/__release + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $4 + return + end + i32.const 0 + i32.eqz + if + i32.const 0 + i32.const 528 + i32.const 41 + i32.const 6 + call $~lib/builtins/abort + unreachable + end + i32.const 0 + call $~lib/rt/pure/__retain + local.set $3 + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $3 + return + ) + (func $start:std/buffer (; 52 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -3847,6 +4685,121 @@ call $~lib/builtins/abort unreachable end + i32.const 696 + i32.const 624 + call $~lib/buffer/Buffer.from<~lib/string/String> + local.set $5 + local.get $0 + call $~lib/rt/pure/__release + local.get $5 + local.set $0 + i32.const 808 + i32.const 5 + local.get $0 + i32.const 0 + call $~lib/typedarray/Uint8Array#__get + f64.convert_i32_u + local.get $0 + i32.const 1 + call $~lib/typedarray/Uint8Array#__get + f64.convert_i32_u + local.get $0 + i32.const 2 + call $~lib/typedarray/Uint8Array#__get + f64.convert_i32_u + local.get $0 + i32.const 3 + call $~lib/typedarray/Uint8Array#__get + f64.convert_i32_u + local.get $0 + i32.const 4 + call $~lib/typedarray/Uint8Array#__get + f64.convert_i32_u + call $~lib/builtins/trace + local.get $0 + i32.const 0 + call $~lib/typedarray/Uint8Array#__get + i32.const 97 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 31 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 1 + call $~lib/typedarray/Uint8Array#__get + i32.const 98 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 32 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 2 + call $~lib/typedarray/Uint8Array#__get + i32.const 99 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 33 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 3 + call $~lib/typedarray/Uint8Array#__get + i32.const 100 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 34 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 4 + call $~lib/typedarray/Uint8Array#__get + i32.const 101 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 35 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 5 + call $~lib/typedarray/Uint8Array#__get + i32.const 102 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 432 + i32.const 36 + i32.const 2 + call $~lib/builtins/abort + unreachable + end local.get $0 call $~lib/rt/pure/__release local.get $2 @@ -3858,16 +4811,16 @@ local.get $3 call $~lib/rt/pure/__release ) - (func $start (; 42 ;) (type $FUNCSIG$v) + (func $start (; 53 ;) (type $FUNCSIG$v) call $start:std/buffer ) - (func $~lib/array/Array#__visit_impl (; 43 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/array/Array#__visit_impl (; 54 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) nop ) - (func $~lib/array/Array#__visit_impl (; 44 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/array/Array#__visit_impl (; 55 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) nop ) - (func $~lib/rt/pure/markGray (; 45 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/markGray (; 56 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -3894,7 +4847,7 @@ call $~lib/rt/__visit_members end ) - (func $~lib/rt/pure/scanBlack (; 46 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/scanBlack (; 57 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 local.get $0 i32.load offset=4 @@ -3911,7 +4864,7 @@ i32.const 4 call $~lib/rt/__visit_members ) - (func $~lib/rt/pure/scan (; 47 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/scan (; 58 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -3948,7 +4901,7 @@ end end ) - (func $~lib/rt/pure/collectWhite (; 48 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/collectWhite (; 59 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -3986,7 +4939,7 @@ call $~lib/rt/tlsf/freeBlock end ) - (func $~lib/rt/pure/__visit (; 49 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/pure/__visit (; 60 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) local.get $0 @@ -4116,7 +5069,7 @@ end end ) - (func $~lib/rt/__visit_members (; 50 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/__visit_members (; 61 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) block $block$4$break block $switch$1$default @@ -4156,6 +5109,6 @@ end return ) - (func $null (; 51 ;) (type $FUNCSIG$v) + (func $null (; 62 ;) (type $FUNCSIG$v) ) ) From 0911e04dbfca7d5bb1315d93ba5ad391e09764ff Mon Sep 17 00:00:00 2001 From: Joshua Tenner Date: Fri, 5 Jul 2019 16:55:02 -0400 Subject: [PATCH 3/3] [Fix] ArrayBuffer byref implementation --- std/assembly/buffer.ts | 9 +- tests/compiler/std/buffer.optimized.wat | 176 ++++++++++-------------- tests/compiler/std/buffer.ts | 1 - tests/compiler/std/buffer.untouched.wat | 164 ++++++++++------------ 4 files changed, 148 insertions(+), 202 deletions(-) diff --git a/std/assembly/buffer.ts b/std/assembly/buffer.ts index 7c37c584e5..df2028ed3c 100644 --- a/std/assembly/buffer.ts +++ b/std/assembly/buffer.ts @@ -20,9 +20,10 @@ export class Buffer extends Uint8Array { public static from(source: T, encoding: string = "utf8"): Buffer { if (source instanceof ArrayBuffer) { - let length = source.byteLength; - let buffer = new Buffer(length); - memory.copy(changetype(buffer.buffer), changetype(source), length); + let buffer = changetype(__alloc(offsetof(), idof())); + store(changetype(buffer), __retain(changetype(source)), offsetof("data")); + store(changetype(buffer), changetype(source), offsetof("dataStart")); + store(changetype(buffer), source.byteLength, offsetof("dataLength")); return buffer; } else if (source instanceof string) { if (encoding == null) encoding = "utf8"; @@ -51,7 +52,7 @@ export class Buffer extends Uint8Array { } return buffer; } else { - assert(false, "hit"); + assert(false); return null; } } diff --git a/tests/compiler/std/buffer.optimized.wat b/tests/compiler/std/buffer.optimized.wat index 773c9e9c86..5891f7c384 100644 --- a/tests/compiler/std/buffer.optimized.wat +++ b/tests/compiler/std/buffer.optimized.wat @@ -8,14 +8,12 @@ (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32))) (type $FUNCSIG$dii (func (param i32 i32) (result f64))) - (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) (type $FUNCSIG$i (func (result i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "rtrace" "onalloc" (func $~lib/rt/rtrace/onalloc (param i32))) (import "rtrace" "onincrement" (func $~lib/rt/rtrace/onincrement (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) (memory $0 1) (data (i32.const 8) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") (data (i32.const 56) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") @@ -34,15 +32,14 @@ (data (i32.const 680) "\0c\00\00\00\01\00\00\00\01\00\00\00\0c\00\00\00a\00b\00c\00d\00e\00f") (data (i32.const 712) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00u\00t\00f\001\006") (data (i32.const 744) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s") - (data (i32.const 792) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00b\00y\00t\00e\00s") - (data (i32.const 824) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\001\00\00\00\02\00\00\001\00\00\00\03\00\00\00\93\04\00\00\02\00\00\00\13\0d\00\00\02") + (data (i32.const 792) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\001\00\00\00\02\00\00\001\00\00\00\03\00\00\00\93\04\00\00\02\00\00\00\13\0d\00\00\02") (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) (global $~lib/rt/pure/CUR (mut i32) (i32.const 0)) (global $~lib/rt/pure/END (mut i32) (i32.const 0)) (global $~lib/rt/pure/ROOTS (mut i32) (i32.const 0)) (export "memory" (memory $0)) (start $start) - (func $~lib/rt/tlsf/removeBlock (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -208,7 +205,7 @@ end end ) - (func $~lib/rt/tlsf/insertBlock (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/insertBlock (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -493,7 +490,7 @@ i32.or i32.store offset=4 ) - (func $~lib/rt/tlsf/addMemory (; 8 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/rt/tlsf/addMemory (; 7 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) local.get $2 @@ -607,7 +604,7 @@ local.get $1 call $~lib/rt/tlsf/insertBlock ) - (func $~lib/rt/tlsf/initializeRoot (; 9 ;) (type $FUNCSIG$v) + (func $~lib/rt/tlsf/initializeRoot (; 8 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) i32.const 1 @@ -627,10 +624,10 @@ if unreachable end - i32.const 896 + i32.const 864 i32.const 0 i32.store - i32.const 2464 + i32.const 2432 i32.const 0 i32.store i32.const 0 @@ -644,7 +641,7 @@ local.get $0 i32.const 2 i32.shl - i32.const 896 + i32.const 864 i32.add i32.const 0 i32.store offset=4 @@ -663,7 +660,7 @@ i32.add i32.const 2 i32.shl - i32.const 896 + i32.const 864 i32.add i32.const 0 i32.store offset=96 @@ -681,16 +678,16 @@ br $loop|0 end end - i32.const 896 - i32.const 2480 + i32.const 864 + i32.const 2448 memory.size i32.const 16 i32.shl call $~lib/rt/tlsf/addMemory - i32.const 896 + i32.const 864 global.set $~lib/rt/tlsf/ROOT ) - (func $~lib/rt/tlsf/prepareSize (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/tlsf/prepareSize (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 i32.const 1073741808 i32.ge_u @@ -714,7 +711,7 @@ i32.gt_u select ) - (func $~lib/rt/tlsf/searchBlock (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/searchBlock (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $1 i32.const 256 @@ -845,7 +842,7 @@ end end ) - (func $~lib/rt/tlsf/growMemory (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/growMemory (; 11 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) memory.size local.tee $2 @@ -882,7 +879,7 @@ i32.shl call $~lib/rt/tlsf/addMemory ) - (func $~lib/rt/tlsf/prepareBlock (; 13 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/rt/tlsf/prepareBlock (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) local.get $1 @@ -958,7 +955,7 @@ i32.store end ) - (func $~lib/rt/tlsf/allocateBlock (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/allocateBlock (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -1017,7 +1014,7 @@ call $~lib/rt/rtrace/onalloc local.get $2 ) - (func $~lib/rt/tlsf/__alloc (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/__alloc (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) global.get $~lib/rt/tlsf/ROOT local.tee $2 @@ -1036,7 +1033,7 @@ i32.const 16 i32.add ) - (func $~lib/memory/memory.fill (; 16 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/memory/memory.fill (; 15 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) block $~lib/util/memory/memset|inlined.0 local.get $1 @@ -1245,7 +1242,7 @@ end end ) - (func $~lib/rt/pure/increment (; 17 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/increment (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -1286,9 +1283,9 @@ unreachable end ) - (func $~lib/rt/pure/__retain (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/pure/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 - i32.const 884 + i32.const 852 i32.gt_u if local.get $0 @@ -1298,7 +1295,7 @@ end local.get $0 ) - (func $~lib/rt/tlsf/freeBlock (; 19 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/freeBlock (; 18 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) local.get $1 i32.load @@ -1324,9 +1321,9 @@ local.get $1 call $~lib/rt/rtrace/onfree ) - (func $~lib/rt/__typeinfo (; 20 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/__typeinfo (; 19 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 - i32.const 824 + i32.const 792 i32.load i32.gt_u if @@ -1340,11 +1337,11 @@ local.get $0 i32.const 3 i32.shl - i32.const 828 + i32.const 796 i32.add i32.load ) - (func $~lib/memory/memory.copy (; 21 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/memory/memory.copy (; 20 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) block $~lib/util/memory/memmove|inlined.0 @@ -1519,7 +1516,7 @@ end end ) - (func $~lib/rt/tlsf/__free (; 22 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/tlsf/__free (; 21 ;) (type $FUNCSIG$vi) (param $0 i32) global.get $~lib/rt/tlsf/ROOT i32.eqz if @@ -1552,7 +1549,7 @@ i32.sub call $~lib/rt/tlsf/freeBlock ) - (func $~lib/rt/pure/growRoots (; 23 ;) (type $FUNCSIG$v) + (func $~lib/rt/pure/growRoots (; 22 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -1601,7 +1598,7 @@ i32.add global.set $~lib/rt/pure/END ) - (func $~lib/rt/pure/appendRoot (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/appendRoot (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) global.get $~lib/rt/pure/CUR local.tee $1 @@ -1620,7 +1617,7 @@ i32.add global.set $~lib/rt/pure/CUR ) - (func $~lib/rt/pure/decrement (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/decrement (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) (local $2 i32) local.get $0 @@ -1710,9 +1707,9 @@ end end ) - (func $~lib/rt/pure/__release (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/__release (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 - i32.const 884 + i32.const 852 i32.gt_u if local.get $0 @@ -1721,7 +1718,7 @@ call $~lib/rt/pure/decrement end ) - (func $~lib/arraybuffer/ArrayBufferView#constructor (; 27 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/arraybuffer/ArrayBufferView#constructor (; 26 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $1 @@ -1782,7 +1779,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/buffer/Buffer#constructor (; 28 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/buffer/Buffer#constructor (; 27 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) i32.const 16 i32.const 4 @@ -1804,7 +1801,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/typedarray/Uint8Array#__set (; 29 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/typedarray/Uint8Array#__set (; 28 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 local.get $0 i32.load offset=8 @@ -1824,7 +1821,7 @@ local.get $2 i32.store8 ) - (func $~lib/typedarray/Uint8Array#__get (; 30 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#__get (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 i32.load offset=8 @@ -1843,7 +1840,7 @@ i32.add i32.load8_u ) - (func $~lib/rt/__allocArray (; 31 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/rt/__allocArray (; 30 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) i32.const 16 local.get $2 @@ -1876,7 +1873,7 @@ end local.get $2 ) - (func $~lib/array/Array#__get (; 32 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 i32.load offset=8 @@ -1899,7 +1896,7 @@ i32.add i32.load ) - (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 33 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -1916,7 +1913,7 @@ if i32.const 0 i32.const 528 - i32.const 46 + i32.const 47 i32.const 6 call $~lib/builtins/abort unreachable @@ -1954,7 +1951,7 @@ call $~lib/rt/pure/__release local.get $1 ) - (func $~lib/array/Array#__get (; 34 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__get (; 33 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) local.get $1 local.get $0 i32.load offset=8 @@ -1977,7 +1974,7 @@ i32.add f64.load ) - (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 35 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 34 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -1994,7 +1991,7 @@ if i32.const 0 i32.const 528 - i32.const 46 + i32.const 47 i32.const 6 call $~lib/builtins/abort unreachable @@ -2033,7 +2030,7 @@ call $~lib/rt/pure/__release local.get $1 ) - (func $~lib/string/String#get:length (; 36 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/string/String#get:length (; 35 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 i32.const 16 i32.sub @@ -2041,7 +2038,7 @@ i32.const 1 i32.shr_u ) - (func $~lib/util/string/compareImpl (; 37 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/util/string/compareImpl (; 36 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2090,7 +2087,7 @@ call $~lib/rt/pure/__release local.get $4 ) - (func $~lib/string/String.__eq (; 38 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/string/String.__eq (; 37 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) i32.const 624 call $~lib/rt/pure/__retain @@ -2136,7 +2133,7 @@ call $~lib/rt/pure/__release i32.const 0 ) - (func $~lib/string/String.UTF8.byteLength (; 39 ;) (type $FUNCSIG$i) (result i32) + (func $~lib/string/String.UTF8.byteLength (; 38 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) (local $1 i32) (local $2 i32) @@ -2222,7 +2219,7 @@ call $~lib/rt/pure/__release local.get $1 ) - (func $~lib/string/String.UTF8.encode (; 40 ;) (type $FUNCSIG$i) (result i32) + (func $~lib/string/String.UTF8.encode (; 39 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) (local $1 i32) (local $2 i32) @@ -2411,7 +2408,7 @@ i32.const 696 call $~lib/rt/pure/__release ) - (func $~lib/string/String.UTF16.encode (; 41 ;) (type $FUNCSIG$i) (result i32) + (func $~lib/string/String.UTF16.encode (; 40 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) (local $1 i32) i32.const 696 @@ -2431,7 +2428,7 @@ i32.const 696 call $~lib/rt/pure/__release ) - (func $~lib/buffer/Buffer.from<~lib/string/String> (; 42 ;) (type $FUNCSIG$i) (result i32) + (func $~lib/buffer/Buffer.from<~lib/string/String> (; 41 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) (local $1 i32) i32.const 696 @@ -2488,12 +2485,12 @@ end i32.const 0 i32.const 528 - i32.const 41 + i32.const 42 i32.const 6 call $~lib/builtins/abort unreachable ) - (func $start:std/buffer (; 43 ;) (type $FUNCSIG$v) + (func $start:std/buffer (; 42 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -2665,10 +2662,9 @@ call $~lib/rt/pure/__retain local.tee $5 call $~lib/buffer/Buffer.from<~lib/array/Array> - local.set $1 local.get $0 call $~lib/rt/pure/__release - local.get $1 + local.tee $0 i32.const 0 call $~lib/typedarray/Uint8Array#__get i32.const 1 @@ -2681,7 +2677,7 @@ call $~lib/builtins/abort unreachable end - local.get $1 + local.get $0 i32.const 1 call $~lib/typedarray/Uint8Array#__get i32.const 2 @@ -2694,7 +2690,7 @@ call $~lib/builtins/abort unreachable end - local.get $1 + local.get $0 i32.const 2 call $~lib/typedarray/Uint8Array#__get i32.const 3 @@ -2707,7 +2703,7 @@ call $~lib/builtins/abort unreachable end - local.get $1 + local.get $0 i32.const 3 call $~lib/typedarray/Uint8Array#__get i32.const 4 @@ -2721,33 +2717,9 @@ unreachable end call $~lib/buffer/Buffer.from<~lib/string/String> - local.set $0 - local.get $1 - call $~lib/rt/pure/__release - i32.const 808 - i32.const 5 - local.get $0 - i32.const 0 - call $~lib/typedarray/Uint8Array#__get - f64.convert_i32_u - local.get $0 - i32.const 1 - call $~lib/typedarray/Uint8Array#__get - f64.convert_i32_u - local.get $0 - i32.const 2 - call $~lib/typedarray/Uint8Array#__get - f64.convert_i32_u - local.get $0 - i32.const 3 - call $~lib/typedarray/Uint8Array#__get - f64.convert_i32_u - local.get $0 - i32.const 4 - call $~lib/typedarray/Uint8Array#__get - f64.convert_i32_u - call $~lib/builtins/trace local.get $0 + call $~lib/rt/pure/__release + local.tee $0 i32.const 0 call $~lib/typedarray/Uint8Array#__get i32.const 97 @@ -2755,7 +2727,7 @@ if i32.const 0 i32.const 432 - i32.const 31 + i32.const 30 i32.const 2 call $~lib/builtins/abort unreachable @@ -2768,7 +2740,7 @@ if i32.const 0 i32.const 432 - i32.const 32 + i32.const 31 i32.const 2 call $~lib/builtins/abort unreachable @@ -2781,7 +2753,7 @@ if i32.const 0 i32.const 432 - i32.const 33 + i32.const 32 i32.const 2 call $~lib/builtins/abort unreachable @@ -2794,7 +2766,7 @@ if i32.const 0 i32.const 432 - i32.const 34 + i32.const 33 i32.const 2 call $~lib/builtins/abort unreachable @@ -2807,7 +2779,7 @@ if i32.const 0 i32.const 432 - i32.const 35 + i32.const 34 i32.const 2 call $~lib/builtins/abort unreachable @@ -2820,7 +2792,7 @@ if i32.const 0 i32.const 432 - i32.const 36 + i32.const 35 i32.const 2 call $~lib/builtins/abort unreachable @@ -2836,10 +2808,10 @@ local.get $5 call $~lib/rt/pure/__release ) - (func $start (; 44 ;) (type $FUNCSIG$v) + (func $start (; 43 ;) (type $FUNCSIG$v) call $start:std/buffer ) - (func $~lib/rt/pure/markGray (; 45 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/markGray (; 44 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -2863,7 +2835,7 @@ call $~lib/rt/__visit_members end ) - (func $~lib/rt/pure/scanBlack (; 46 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/scanBlack (; 45 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 local.get $0 i32.load offset=4 @@ -2876,7 +2848,7 @@ i32.const 4 call $~lib/rt/__visit_members ) - (func $~lib/rt/pure/scan (; 47 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/scan (; 46 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -2910,7 +2882,7 @@ end end ) - (func $~lib/rt/pure/collectWhite (; 48 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/collectWhite (; 47 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -2943,9 +2915,9 @@ call $~lib/rt/tlsf/freeBlock end ) - (func $~lib/rt/pure/__visit (; 49 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/pure/__visit (; 48 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) local.get $0 - i32.const 884 + i32.const 852 i32.lt_u if return @@ -3053,7 +3025,7 @@ unreachable end ) - (func $~lib/rt/__visit_members (; 50 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/__visit_members (; 49 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) block $block$4$break block $switch$1$default block $switch$1$case$2 @@ -3076,7 +3048,7 @@ call $~lib/rt/pure/__visit end ) - (func $null (; 51 ;) (type $FUNCSIG$v) + (func $null (; 50 ;) (type $FUNCSIG$v) nop ) ) diff --git a/tests/compiler/std/buffer.ts b/tests/compiler/std/buffer.ts index ad73c4b1bd..23ab9f566b 100644 --- a/tests/compiler/std/buffer.ts +++ b/tests/compiler/std/buffer.ts @@ -27,7 +27,6 @@ assert(buffer[3] == 4.4); buffer = Buffer.from("abcdef"); - trace("bytes", 5, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4]); assert(buffer[0] == 0x61); assert(buffer[1] == 0x62); assert(buffer[2] == 0x63); diff --git a/tests/compiler/std/buffer.untouched.wat b/tests/compiler/std/buffer.untouched.wat index 0b061704ff..87fa9893a7 100644 --- a/tests/compiler/std/buffer.untouched.wat +++ b/tests/compiler/std/buffer.untouched.wat @@ -10,13 +10,11 @@ (type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32))) (type $FUNCSIG$dii (func (param i32 i32) (result f64))) (type $FUNCSIG$iiiiii (func (param i32 i32 i32 i32 i32) (result i32))) - (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "rtrace" "onalloc" (func $~lib/rt/rtrace/onalloc (param i32))) (import "rtrace" "onincrement" (func $~lib/rt/rtrace/onincrement (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) (memory $0 1) (data (i32.const 8) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") (data (i32.const 56) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") @@ -35,8 +33,7 @@ (data (i32.const 680) "\0c\00\00\00\01\00\00\00\01\00\00\00\0c\00\00\00a\00b\00c\00d\00e\00f\00") (data (i32.const 712) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00u\00t\00f\001\006\00") (data (i32.const 744) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00") - (data (i32.const 792) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00b\00y\00t\00e\00s\00") - (data (i32.const 824) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\001\00\00\00\02\00\00\001\00\00\00\03\00\00\00\93\04\00\00\02\00\00\00\13\0d\00\00\02\00\00\00") + (data (i32.const 792) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\001\00\00\00\02\00\00\001\00\00\00\03\00\00\00\93\04\00\00\02\00\00\00\13\0d\00\00\02\00\00\00") (table $0 1 funcref) (elem (i32.const 0) $null) (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) @@ -47,11 +44,11 @@ (global $~lib/buffer/Buffer.NO_ENCODING (mut i32) (i32.const 0)) (global $~lib/buffer/Buffer.UTF8_ENCODING (mut i32) (i32.const 1)) (global $~lib/buffer/Buffer.UTF16_ENCODING (mut i32) (i32.const 2)) - (global $~lib/rt/__rtti_base i32 (i32.const 824)) - (global $~lib/heap/__heap_base i32 (i32.const 884)) + (global $~lib/rt/__rtti_base i32 (i32.const 792)) + (global $~lib/heap/__heap_base i32 (i32.const 852)) (export "memory" (memory $0)) (start $start) - (func $~lib/rt/tlsf/removeBlock (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/removeBlock (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -261,7 +258,7 @@ end end ) - (func $~lib/rt/tlsf/insertBlock (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/insertBlock (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -611,7 +608,7 @@ local.get $7 i32.store offset=4 ) - (func $~lib/rt/tlsf/addMemory (; 8 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/rt/tlsf/addMemory (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -759,7 +756,7 @@ call $~lib/rt/tlsf/insertBlock i32.const 1 ) - (func $~lib/rt/tlsf/initializeRoot (; 9 ;) (type $FUNCSIG$v) + (func $~lib/rt/tlsf/initializeRoot (; 8 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -904,7 +901,7 @@ local.get $3 global.set $~lib/rt/tlsf/ROOT ) - (func $~lib/rt/tlsf/prepareSize (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/tlsf/prepareSize (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 @@ -933,7 +930,7 @@ i32.gt_u select ) - (func $~lib/rt/tlsf/searchBlock (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/searchBlock (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1116,7 +1113,7 @@ end local.get $7 ) - (func $~lib/rt/tlsf/growMemory (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/growMemory (; 11 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1169,7 +1166,7 @@ call $~lib/rt/tlsf/addMemory drop ) - (func $~lib/rt/tlsf/prepareBlock (; 13 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/rt/tlsf/prepareBlock (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1264,7 +1261,7 @@ i32.store end ) - (func $~lib/rt/tlsf/allocateBlock (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/allocateBlock (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $1 @@ -1327,7 +1324,7 @@ call $~lib/rt/rtrace/onalloc local.get $3 ) - (func $~lib/rt/tlsf/__alloc (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/__alloc (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) global.get $~lib/rt/tlsf/ROOT @@ -1350,7 +1347,7 @@ i32.const 16 i32.add ) - (func $~lib/memory/memory.fill (; 16 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/memory/memory.fill (; 15 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1614,7 +1611,7 @@ end end ) - (func $~lib/rt/pure/increment (; 17 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/increment (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -1659,7 +1656,7 @@ unreachable end ) - (func $~lib/rt/pure/__retain (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/pure/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 global.get $~lib/heap/__heap_base i32.gt_u @@ -1671,7 +1668,7 @@ end local.get $0 ) - (func $~lib/rt/tlsf/freeBlock (; 19 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/freeBlock (; 18 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) local.get $1 i32.load @@ -1700,7 +1697,7 @@ local.get $1 call $~lib/rt/rtrace/onfree ) - (func $~lib/rt/__typeinfo (; 20 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/__typeinfo (; 19 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) global.get $~lib/rt/__rtti_base local.set $1 @@ -1725,7 +1722,7 @@ i32.add i32.load ) - (func $~lib/util/memory/memcpy (; 21 ;) (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) @@ -2753,7 +2750,7 @@ i32.store8 end ) - (func $~lib/memory/memory.copy (; 22 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/memory/memory.copy (; 21 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2978,7 +2975,7 @@ end end ) - (func $~lib/rt/tlsf/__free (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/tlsf/__free (; 22 ;) (type $FUNCSIG$vi) (param $0 i32) global.get $~lib/rt/tlsf/ROOT i32.eqz if @@ -3015,7 +3012,7 @@ i32.sub call $~lib/rt/tlsf/freeBlock ) - (func $~lib/rt/pure/growRoots (; 24 ;) (type $FUNCSIG$v) + (func $~lib/rt/pure/growRoots (; 23 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -3073,7 +3070,7 @@ i32.add global.set $~lib/rt/pure/END ) - (func $~lib/rt/pure/appendRoot (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/appendRoot (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) global.get $~lib/rt/pure/CUR local.set $1 @@ -3093,7 +3090,7 @@ i32.add global.set $~lib/rt/pure/CUR ) - (func $~lib/rt/pure/decrement (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/decrement (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) (local $2 i32) local.get $0 @@ -3197,7 +3194,7 @@ end end ) - (func $~lib/rt/pure/__release (; 27 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/__release (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 global.get $~lib/heap/__heap_base i32.gt_u @@ -3208,7 +3205,7 @@ call $~lib/rt/pure/decrement end ) - (func $~lib/arraybuffer/ArrayBufferView#constructor (; 28 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/arraybuffer/ArrayBufferView#constructor (; 27 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -3279,7 +3276,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Uint8Array#constructor (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#constructor (; 28 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 if (result i32) local.get $0 @@ -3295,7 +3292,7 @@ local.set $0 local.get $0 ) - (func $~lib/buffer/Buffer#constructor (; 30 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/buffer/Buffer#constructor (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 if (result i32) local.get $0 @@ -3313,7 +3310,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/typedarray/Uint8Array#__set (; 31 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/typedarray/Uint8Array#__set (; 30 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 local.get $0 i32.load offset=8 @@ -3333,7 +3330,7 @@ local.get $2 i32.store8 ) - (func $~lib/typedarray/Uint8Array#__get (; 32 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#__get (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 i32.load offset=8 @@ -3352,7 +3349,7 @@ i32.add i32.load8_u ) - (func $~lib/rt/__allocArray (; 33 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/rt/__allocArray (; 32 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -3390,11 +3387,11 @@ end local.get $4 ) - (func $~lib/array/Array#get:length (; 34 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/array/Array#get:length (; 33 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (; 35 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__unchecked_get (; 34 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -3403,7 +3400,7 @@ i32.add i32.load ) - (func $~lib/array/Array#__get (; 36 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 35 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 i32.load offset=8 @@ -3422,7 +3419,7 @@ local.get $1 call $~lib/array/Array#__unchecked_get ) - (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 37 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 36 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3449,7 +3446,7 @@ if i32.const 0 i32.const 528 - i32.const 46 + i32.const 47 i32.const 6 call $~lib/builtins/abort unreachable @@ -3495,11 +3492,11 @@ local.get $6 return ) - (func $~lib/array/Array#get:length (; 38 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/array/Array#get:length (; 37 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (; 39 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__unchecked_get (; 38 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) local.get $0 i32.load offset=4 local.get $1 @@ -3508,7 +3505,7 @@ i32.add f64.load ) - (func $~lib/array/Array#__get (; 40 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__get (; 39 ;) (type $FUNCSIG$dii) (param $0 i32) (param $1 i32) (result f64) local.get $1 local.get $0 i32.load offset=8 @@ -3527,7 +3524,7 @@ local.get $1 call $~lib/array/Array#__unchecked_get ) - (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 41 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/buffer/Buffer.from<~lib/array/Array> (; 40 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3554,7 +3551,7 @@ if i32.const 0 i32.const 528 - i32.const 46 + i32.const 47 i32.const 6 call $~lib/builtins/abort unreachable @@ -3601,7 +3598,7 @@ local.get $6 return ) - (func $~lib/string/String#get:length (; 42 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/string/String#get:length (; 41 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 i32.const 16 i32.sub @@ -3609,7 +3606,7 @@ i32.const 1 i32.shr_u ) - (func $~lib/util/string/compareImpl (; 43 ;) (type $FUNCSIG$iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) + (func $~lib/util/string/compareImpl (; 42 ;) (type $FUNCSIG$iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) (local $5 i32) (local $6 i32) (local $7 i32) @@ -3674,7 +3671,7 @@ call $~lib/rt/pure/__release local.get $8 ) - (func $~lib/string/String.__eq (; 44 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__eq (; 43 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -3747,7 +3744,7 @@ call $~lib/rt/pure/__release local.get $2 ) - (func $~lib/string/String.UTF8.byteLength (; 45 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.UTF8.byteLength (; 44 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3870,7 +3867,7 @@ call $~lib/rt/pure/__release local.get $5 ) - (func $~lib/rt/tlsf/reallocateBlock (; 46 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/rt/tlsf/reallocateBlock (; 45 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4008,7 +4005,7 @@ call $~lib/rt/rtrace/onfree local.get $8 ) - (func $~lib/rt/tlsf/__realloc (; 47 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/__realloc (; 46 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) global.get $~lib/rt/tlsf/ROOT i32.eqz if @@ -4048,7 +4045,7 @@ i32.const 16 i32.add ) - (func $~lib/string/String.UTF8.encode (; 48 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.UTF8.encode (; 47 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4300,7 +4297,7 @@ call $~lib/rt/pure/__release local.get $6 ) - (func $~lib/string/String.UTF16.encode (; 49 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/string/String.UTF16.encode (; 48 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -4327,13 +4324,13 @@ call $~lib/rt/pure/__release local.get $3 ) - (func $~lib/arraybuffer/ArrayBuffer#get:byteLength (; 50 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer#get:byteLength (; 49 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 i32.const 16 i32.sub i32.load offset=12 ) - (func $~lib/buffer/Buffer.from<~lib/string/String> (; 51 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/buffer/Buffer.from<~lib/string/String> (; 50 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4417,7 +4414,7 @@ if i32.const 0 i32.const 528 - i32.const 41 + i32.const 42 i32.const 6 call $~lib/builtins/abort unreachable @@ -4432,7 +4429,7 @@ local.get $3 return ) - (func $start:std/buffer (; 52 ;) (type $FUNCSIG$v) + (func $start:std/buffer (; 51 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -4693,29 +4690,6 @@ call $~lib/rt/pure/__release local.get $5 local.set $0 - i32.const 808 - i32.const 5 - local.get $0 - i32.const 0 - call $~lib/typedarray/Uint8Array#__get - f64.convert_i32_u - local.get $0 - i32.const 1 - call $~lib/typedarray/Uint8Array#__get - f64.convert_i32_u - local.get $0 - i32.const 2 - call $~lib/typedarray/Uint8Array#__get - f64.convert_i32_u - local.get $0 - i32.const 3 - call $~lib/typedarray/Uint8Array#__get - f64.convert_i32_u - local.get $0 - i32.const 4 - call $~lib/typedarray/Uint8Array#__get - f64.convert_i32_u - call $~lib/builtins/trace local.get $0 i32.const 0 call $~lib/typedarray/Uint8Array#__get @@ -4725,7 +4699,7 @@ if i32.const 0 i32.const 432 - i32.const 31 + i32.const 30 i32.const 2 call $~lib/builtins/abort unreachable @@ -4739,7 +4713,7 @@ if i32.const 0 i32.const 432 - i32.const 32 + i32.const 31 i32.const 2 call $~lib/builtins/abort unreachable @@ -4753,7 +4727,7 @@ if i32.const 0 i32.const 432 - i32.const 33 + i32.const 32 i32.const 2 call $~lib/builtins/abort unreachable @@ -4767,7 +4741,7 @@ if i32.const 0 i32.const 432 - i32.const 34 + i32.const 33 i32.const 2 call $~lib/builtins/abort unreachable @@ -4781,7 +4755,7 @@ if i32.const 0 i32.const 432 - i32.const 35 + i32.const 34 i32.const 2 call $~lib/builtins/abort unreachable @@ -4795,7 +4769,7 @@ if i32.const 0 i32.const 432 - i32.const 36 + i32.const 35 i32.const 2 call $~lib/builtins/abort unreachable @@ -4811,16 +4785,16 @@ local.get $3 call $~lib/rt/pure/__release ) - (func $start (; 53 ;) (type $FUNCSIG$v) + (func $start (; 52 ;) (type $FUNCSIG$v) call $start:std/buffer ) - (func $~lib/array/Array#__visit_impl (; 54 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/array/Array#__visit_impl (; 53 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) nop ) - (func $~lib/array/Array#__visit_impl (; 55 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/array/Array#__visit_impl (; 54 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) nop ) - (func $~lib/rt/pure/markGray (; 56 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/markGray (; 55 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -4847,7 +4821,7 @@ call $~lib/rt/__visit_members end ) - (func $~lib/rt/pure/scanBlack (; 57 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/scanBlack (; 56 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 local.get $0 i32.load offset=4 @@ -4864,7 +4838,7 @@ i32.const 4 call $~lib/rt/__visit_members ) - (func $~lib/rt/pure/scan (; 58 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/scan (; 57 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -4901,7 +4875,7 @@ end end ) - (func $~lib/rt/pure/collectWhite (; 59 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/pure/collectWhite (; 58 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -4939,7 +4913,7 @@ call $~lib/rt/tlsf/freeBlock end ) - (func $~lib/rt/pure/__visit (; 60 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/pure/__visit (; 59 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) local.get $0 @@ -5069,7 +5043,7 @@ end end ) - (func $~lib/rt/__visit_members (; 61 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/__visit_members (; 60 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) block $block$4$break block $switch$1$default @@ -5109,6 +5083,6 @@ end return ) - (func $null (; 62 ;) (type $FUNCSIG$v) + (func $null (; 61 ;) (type $FUNCSIG$v) ) )