mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
Implement <TypedArray>#sort and improve default comparator (#208)
This commit is contained in:
parent
7965776133
commit
947cee08c7
@ -32,6 +32,7 @@ export class Array<T> {
|
||||
);
|
||||
}
|
||||
|
||||
@inline
|
||||
get length(): i32 {
|
||||
return this.length_;
|
||||
}
|
||||
@ -324,12 +325,15 @@ export class Array<T> {
|
||||
|
||||
if (isReference<T>()) {
|
||||
// TODO replace this to faster stable sort (TimSort) when it implemented
|
||||
return changetype<this>(insertionSort<T>(this, comparator));
|
||||
insertionSort<T>(buffer, 0, length, comparator);
|
||||
return this;
|
||||
} else {
|
||||
return changetype<this>(length < 256
|
||||
? insertionSort<T>(this, comparator)
|
||||
: weakHeapSort<T>(this, comparator)
|
||||
);
|
||||
if (length < 256) {
|
||||
insertionSort<T>(buffer, 0, length, comparator);
|
||||
} else {
|
||||
weakHeapSort<T>(buffer, 0, length, comparator);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,75 +1,120 @@
|
||||
import { loadUnsafe, storeUnsafe } from "./arraybuffer";
|
||||
import { Array } from "../array";
|
||||
import {
|
||||
loadUnsafeWithOffset,
|
||||
storeUnsafeWithOffset
|
||||
} from "./arraybuffer";
|
||||
|
||||
import {
|
||||
compareUnsafe,
|
||||
} from "./string";
|
||||
|
||||
/** Obtains the default comparator for the specified type. */
|
||||
@inline
|
||||
export function defaultComparator<T>(): (a: T, b: T) => i32 {
|
||||
return function compare(a: T, b: T): i32 {
|
||||
return (<i32>(a > b) - <i32>(a < b));
|
||||
};
|
||||
if (isInteger<T>()) {
|
||||
if (isSigned<T>() && sizeof<T>() <= 4) {
|
||||
return (a: T, b: T): i32 => (<i32>(a - b));
|
||||
} else {
|
||||
return (a: T, b: T): i32 => (<i32>(a > b) - <i32>(a < b));
|
||||
}
|
||||
} else if (isFloat<T>()) {
|
||||
if (sizeof<T>() == 4) {
|
||||
return (a: T, b: T): i32 => {
|
||||
var ia = reinterpret<i32>(a);
|
||||
var ib = reinterpret<i32>(b);
|
||||
ia ^= (ia >> 31) >>> 1;
|
||||
ib ^= (ib >> 31) >>> 1;
|
||||
return <i32>(ia > ib) - <i32>(ia < ib);
|
||||
};
|
||||
} else {
|
||||
return (a: T, b: T): i32 => {
|
||||
var ia = reinterpret<i64>(a);
|
||||
var ib = reinterpret<i64>(b);
|
||||
ia ^= (ia >> 63) >>> 1;
|
||||
ib ^= (ib >> 63) >>> 1;
|
||||
return <i32>(ia > ib) - <i32>(ia < ib);
|
||||
};
|
||||
}
|
||||
} else if (isString<T>()) {
|
||||
return (a: T, b: T): i32 => {
|
||||
var sa = <string>a, sb = <string>b;
|
||||
return compareUnsafe(sa, 0, sb, 0, min(sa.length, sb.length));
|
||||
};
|
||||
} else {
|
||||
return (a: T, b: T): i32 => (<i32>(a > b) - <i32>(a < b));
|
||||
}
|
||||
}
|
||||
|
||||
export function insertionSort<T>(arr: Array<T>, comparator: (a: T, b: T) => i32): Array<T> {
|
||||
var buffer = arr.buffer_;
|
||||
for (let i: i32 = 0, length: i32 = arr.length; i < length; i++) {
|
||||
let a = loadUnsafe<T,T>(buffer, i); // a = arr[i]
|
||||
/** Sorts an Array with the 'Insertion Sort' algorithm. */
|
||||
export function insertionSort<T>(
|
||||
buffer: ArrayBuffer,
|
||||
byteOffset: i32,
|
||||
length: i32,
|
||||
comparator: (a: T, b: T) => i32
|
||||
): void {
|
||||
for (let i = 0; i < length; i++) {
|
||||
let a = loadUnsafeWithOffset<T,T>(buffer, i, byteOffset); // a = arr[i]
|
||||
let j = i - 1;
|
||||
while (j >= 0) {
|
||||
let b = loadUnsafe<T,T>(buffer, j); // b = arr[j]
|
||||
let b = loadUnsafeWithOffset<T,T>(buffer, j, byteOffset); // b = arr[j]
|
||||
if (comparator(a, b) < 0) {
|
||||
storeUnsafe<T,T>(buffer, j-- + 1, b); // arr[j + 1] = b
|
||||
storeUnsafeWithOffset<T,T>(buffer, j-- + 1, b, byteOffset); // arr[j + 1] = b
|
||||
} else break;
|
||||
}
|
||||
storeUnsafe<T,T>(buffer, j + 1, a); // arr[j + 1] = a
|
||||
storeUnsafeWithOffset<T,T>(buffer, j + 1, a, byteOffset); // arr[j + 1] = a
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
export function weakHeapSort<T>(arr: Array<T>, comparator: (a: T, b: T) => i32): Array<T> {
|
||||
/** Sorts an Array with the 'Weak Heap Sort' algorithm. */
|
||||
export function weakHeapSort<T>(
|
||||
buffer: ArrayBuffer,
|
||||
byteOffset: i32,
|
||||
length: i32,
|
||||
comparator: (a: T, b: T) => i32
|
||||
): void {
|
||||
const shift32 = alignof<u32>();
|
||||
|
||||
var length = arr.length;
|
||||
var bitsetSize = (length + 31) >> 5 << shift32;
|
||||
var bitset = memory.allocate(bitsetSize); // indexed in 32-bit chunks below
|
||||
memory.fill(bitset, 0, bitsetSize);
|
||||
|
||||
// see: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.1863&rep=rep1&type=pdf
|
||||
|
||||
var buffer = arr.buffer_;
|
||||
for (let i = length - 1; i > 0; i--) {
|
||||
let j = i;
|
||||
while ((j & 1) == (load<u32>(bitset + (j >> 6 << shift32)) >> (j >> 1 & 31) & 1)) j >>= 1;
|
||||
|
||||
let p = j >> 1;
|
||||
let a = loadUnsafe<T,T>(buffer, p); // a = arr[p]
|
||||
let b = loadUnsafe<T,T>(buffer, i); // b = arr[i]
|
||||
let a = loadUnsafeWithOffset<T,T>(buffer, p, byteOffset); // a = arr[p]
|
||||
let b = loadUnsafeWithOffset<T,T>(buffer, i, byteOffset); // b = arr[i]
|
||||
if (comparator(a, b) < 0) {
|
||||
store<u32>(
|
||||
bitset + (i >> 5 << shift32),
|
||||
load<u32>(bitset + (i >> 5 << shift32)) ^ (1 << (i & 31))
|
||||
);
|
||||
storeUnsafe<T,T>(buffer, i, a); // arr[i] = a
|
||||
storeUnsafe<T,T>(buffer, p, b); // arr[p] = b
|
||||
storeUnsafeWithOffset<T,T>(buffer, i, a, byteOffset); // arr[i] = a
|
||||
storeUnsafeWithOffset<T,T>(buffer, p, b, byteOffset); // arr[p] = b
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = length - 1; i >= 2; i--) {
|
||||
let a = loadUnsafe<T,T>(buffer, 0); // a = arr[0]
|
||||
storeUnsafe<T,T>(buffer, 0, loadUnsafe<T,T>(buffer, i)); // arr[0] = arr[i]
|
||||
storeUnsafe<T,T>(buffer, i, a); // arr[i] = a
|
||||
let a = loadUnsafeWithOffset<T,T>(buffer, 0, byteOffset);
|
||||
storeUnsafeWithOffset<T,T>(buffer, 0, loadUnsafeWithOffset<T,T>(buffer, i, byteOffset), byteOffset);
|
||||
storeUnsafeWithOffset<T,T>(buffer, i, a, byteOffset);
|
||||
|
||||
let x = 1, y: i32;
|
||||
while ((y = (x << 1) + ((load<u32>(bitset + (x >> 5 << shift32)) >> (x & 31)) & 1)) < i) x = y;
|
||||
|
||||
while (x > 0) {
|
||||
a = loadUnsafe<T,T>(buffer, 0); // a = arr[0]
|
||||
let b = loadUnsafe<T,T>(buffer, x); // b = arr[x]
|
||||
a = loadUnsafeWithOffset<T,T>(buffer, 0, byteOffset); // a = arr[0]
|
||||
let b = loadUnsafeWithOffset<T,T>(buffer, x, byteOffset); // b = arr[x]
|
||||
|
||||
if (comparator(a, b) < 0) {
|
||||
store<u32>(
|
||||
bitset + (x >> 5 << shift32),
|
||||
load<u32>(bitset + (x >> 5 << shift32)) ^ (1 << (x & 31))
|
||||
);
|
||||
storeUnsafe<T,T>(buffer, x, a); // arr[x] = a
|
||||
storeUnsafe<T,T>(buffer, 0, b); // arr[0] = b
|
||||
storeUnsafeWithOffset<T,T>(buffer, x, a, byteOffset); // arr[x] = a
|
||||
storeUnsafeWithOffset<T,T>(buffer, 0, b, byteOffset); // arr[0] = b
|
||||
}
|
||||
x >>= 1;
|
||||
}
|
||||
@ -77,8 +122,7 @@ export function weakHeapSort<T>(arr: Array<T>, comparator: (a: T, b: T) => i32):
|
||||
|
||||
memory.free(bitset);
|
||||
|
||||
var t = loadUnsafe<T,T>(buffer, 1); // t = arr[1]
|
||||
storeUnsafe<T,T>(buffer, 1, loadUnsafe<T,T>(buffer, 0)); // arr[1] = arr[0]
|
||||
storeUnsafe<T,T>(buffer, 0, t); // arr[0] = t
|
||||
return arr;
|
||||
var t = loadUnsafeWithOffset<T,T>(buffer, 1, byteOffset); // t = arr[1]
|
||||
storeUnsafeWithOffset<T,T>(buffer, 1, loadUnsafeWithOffset<T,T>(buffer, 0, byteOffset), byteOffset);
|
||||
storeUnsafeWithOffset<T,T>(buffer, 0, t, byteOffset); // arr[0] = t
|
||||
}
|
||||
|
@ -6,6 +6,12 @@ import {
|
||||
storeUnsafeWithOffset
|
||||
} from "./arraybuffer";
|
||||
|
||||
import {
|
||||
insertionSort,
|
||||
weakHeapSort,
|
||||
defaultComparator
|
||||
} from "./array";
|
||||
|
||||
/** Typed array base class. Not a global object. */
|
||||
export abstract class TypedArray<T,V> {
|
||||
|
||||
@ -70,4 +76,33 @@ export abstract class TypedArray<T,V> {
|
||||
store<i32>(slice, end << alignof<T>(), offsetof<this>("byteLength"));
|
||||
return changetype<this>(slice);
|
||||
}
|
||||
|
||||
sort(comparator: (a: T, b: T) => i32 = defaultComparator<T>()): this {
|
||||
var byteOffset = this.byteOffset;
|
||||
var length = this.length;
|
||||
if (length <= 1) return this;
|
||||
var buffer = this.buffer;
|
||||
if (length == 2) {
|
||||
let a = loadUnsafeWithOffset<T,T>(buffer, 1, byteOffset);
|
||||
let b = loadUnsafeWithOffset<T,T>(buffer, 0, byteOffset);
|
||||
if (comparator(a, b) < 0) {
|
||||
storeUnsafeWithOffset<T,T>(buffer, 1, b, byteOffset);
|
||||
storeUnsafeWithOffset<T,T>(buffer, 0, a, byteOffset);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
if (isReference<T>()) {
|
||||
// TODO replace this to faster stable sort (TimSort) when it implemented
|
||||
insertionSort<T>(buffer, byteOffset, length, comparator);
|
||||
return this;
|
||||
} else {
|
||||
if (length < 256) {
|
||||
insertionSort<T>(buffer, byteOffset, length, comparator);
|
||||
} else {
|
||||
weakHeapSort<T>(buffer, byteOffset, length, comparator);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
|
||||
@ -24,12 +24,7 @@
|
||||
(data (i32.const 168) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/array/Array<i8>#get:length (; 1 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i8>#__get (; 2 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i8>#__get (; 1 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(tee_local $0
|
||||
(if (result i32)
|
||||
(i32.lt_u
|
||||
@ -52,7 +47,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__get (; 3 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i32>#__get (; 2 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(tee_local $0
|
||||
(if (result i32)
|
||||
(i32.lt_u
|
||||
@ -81,7 +76,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 4 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 3 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shl
|
||||
(i32.const 1)
|
||||
(i32.sub
|
||||
@ -95,7 +90,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/__memory_allocate (; 5 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/allocator/arena/__memory_allocate (; 4 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
@ -180,7 +175,7 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $~lib/internal/arraybuffer/allocateUnsafe (; 6 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/allocateUnsafe (; 5 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
@ -209,12 +204,12 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $~lib/memory/memory.allocate (; 7 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/memory/memory.allocate (; 6 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(call $~lib/allocator/arena/__memory_allocate
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/memory/memset (; 8 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/internal/memory/memset (; 7 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i64)
|
||||
(if
|
||||
@ -544,7 +539,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i8>#constructor (; 9 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i8>#constructor (; 8 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
@ -603,7 +598,7 @@
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/array/Array<i8>#__unchecked_set (; 10 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/array/Array<i8>#__unchecked_set (; 9 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(i32.store8 offset=8
|
||||
(i32.add
|
||||
(i32.load
|
||||
@ -614,7 +609,7 @@
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#constructor (; 11 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i32>#constructor (; 10 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
@ -679,7 +674,7 @@
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__unchecked_set (; 12 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/array/Array<i32>#__unchecked_set (; 11 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(i32.store offset=8
|
||||
(i32.add
|
||||
(i32.load
|
||||
@ -693,7 +688,7 @@
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $start (; 13 ;) (; has Stack IR ;) (type $v)
|
||||
(func $start (; 12 ;) (; has Stack IR ;) (type $v)
|
||||
(local $0 i32)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
(i32.const 232)
|
||||
@ -703,8 +698,8 @@
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/array/Array<i8>#get:length
|
||||
(i32.const 24)
|
||||
(i32.load
|
||||
(i32.const 28)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
@ -780,8 +775,8 @@
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/array/Array<i8>#get:length
|
||||
(i32.const 112)
|
||||
(i32.load
|
||||
(i32.const 116)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
@ -847,7 +842,7 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(call $~lib/array/Array<i8>#get:length
|
||||
(i32.load offset=4
|
||||
(get_global $std/array-literal/emptyArrayI32)
|
||||
)
|
||||
(block
|
||||
@ -897,7 +892,7 @@
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/array/Array<i8>#get:length
|
||||
(i32.load offset=4
|
||||
(get_global $std/array-literal/dynamicArrayI8)
|
||||
)
|
||||
(i32.const 3)
|
||||
@ -1012,7 +1007,7 @@
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/array/Array<i8>#get:length
|
||||
(i32.load offset=4
|
||||
(get_global $std/array-literal/dynamicArrayI32)
|
||||
)
|
||||
(i32.const 3)
|
||||
|
@ -1,7 +1,7 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
|
||||
@ -32,12 +32,7 @@
|
||||
(data (i32.const 168) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/array/Array<i8>#get:length (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i8>#__get (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i8>#__get (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
@ -68,12 +63,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#get:length (; 3 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__get (; 4 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i32>#__get (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
@ -104,7 +94,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 5 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 3 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shl
|
||||
(i32.const 1)
|
||||
(i32.sub
|
||||
@ -121,7 +111,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/__memory_allocate (; 6 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/allocator/arena/__memory_allocate (; 4 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
@ -232,7 +222,7 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $~lib/internal/arraybuffer/allocateUnsafe (; 7 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/allocateUnsafe (; 5 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
@ -272,14 +262,14 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $~lib/memory/memory.allocate (; 8 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/memory/memory.allocate (; 6 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(call $~lib/allocator/arena/__memory_allocate
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/memory/memset (; 9 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/internal/memory/memset (; 7 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i64)
|
||||
@ -631,7 +621,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i8>#constructor (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i8>#constructor (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
@ -711,7 +701,7 @@
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/array/Array<i8>#__unchecked_set (; 11 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/array/Array<i8>#__unchecked_set (; 9 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(block $~lib/internal/arraybuffer/storeUnsafe<i8,i8>|inlined.0
|
||||
(set_local $3
|
||||
@ -731,7 +721,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#constructor (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i32>#constructor (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
@ -811,7 +801,7 @@
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__unchecked_set (; 13 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/array/Array<i32>#__unchecked_set (; 11 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(block $~lib/internal/arraybuffer/storeUnsafe<i32,i32>|inlined.0
|
||||
(set_local $3
|
||||
@ -831,7 +821,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 14 ;) (type $v)
|
||||
(func $start (; 12 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
(i32.and
|
||||
@ -851,8 +841,13 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/Array<i8>#get:length
|
||||
(get_global $std/array-literal/staticArrayI8)
|
||||
(block $~lib/array/Array<i8>#get:length|inlined.0 (result i32)
|
||||
(set_local $0
|
||||
(get_global $std/array-literal/staticArrayI8)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
@ -948,8 +943,13 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/Array<i32>#get:length
|
||||
(get_global $std/array-literal/staticArrayI32)
|
||||
(block $~lib/array/Array<i32>#get:length|inlined.0 (result i32)
|
||||
(set_local $0
|
||||
(get_global $std/array-literal/staticArrayI32)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
@ -1027,8 +1027,13 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/Array<i32>#get:length
|
||||
(get_global $std/array-literal/emptyArrayI32)
|
||||
(block $~lib/array/Array<i32>#get:length|inlined.1 (result i32)
|
||||
(set_local $0
|
||||
(get_global $std/array-literal/emptyArrayI32)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -1088,8 +1093,13 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/Array<i8>#get:length
|
||||
(get_global $std/array-literal/dynamicArrayI8)
|
||||
(block $~lib/array/Array<i8>#get:length|inlined.1 (result i32)
|
||||
(set_local $0
|
||||
(get_global $std/array-literal/dynamicArrayI8)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
@ -1230,8 +1240,13 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/Array<i32>#get:length
|
||||
(get_global $std/array-literal/dynamicArrayI32)
|
||||
(block $~lib/array/Array<i32>#get:length|inlined.2 (result i32)
|
||||
(set_local $0
|
||||
(get_global $std/array-literal/dynamicArrayI32)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -538,6 +538,9 @@ function isArraysEqual<T>(a: Array<T>, b: Array<T>, len: i32 = 0): bool {
|
||||
len = a.length;
|
||||
}
|
||||
for (let i = 0; i < len; i++) {
|
||||
if (isFloat<T>()) {
|
||||
if (isNaN(a[i]) && isNaN(a[i]) == isNaN(b[i])) continue;
|
||||
}
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
@ -609,12 +612,29 @@ function assertSortedDefault<T>(arr: Array<T>): void {
|
||||
assertSorted<T>(arr, defaultComparator<T>());
|
||||
}
|
||||
|
||||
var reversed0: Array<i32> = [];
|
||||
var reversed1: Array<i32> = [1];
|
||||
var reversed2: Array<i32> = [2, 1];
|
||||
var reversed4: Array<i32> = [3, 2, 1, 0];
|
||||
// Tests for default comparator
|
||||
|
||||
var expected4: Array<i32> = [0, 1, 2, 3];
|
||||
var f32ArrayTyped: f32[] = [1.0, NaN, -Infinity, 1.00000001, 0.0, -1.0, -2.0, +Infinity];
|
||||
f32ArrayTyped.sort();
|
||||
assert(isArraysEqual<f32>(f32ArrayTyped, [-Infinity, -2.0, -1.0, 0.0, 1.0, 1.00000001, Infinity, NaN]));
|
||||
|
||||
var f64ArrayTyped: f64[] = [1.0, NaN, -Infinity, 1.000000000000001, 0.0, -1.0, -2.0, +Infinity];
|
||||
f64ArrayTyped.sort();
|
||||
assert(isArraysEqual<f64>(f64ArrayTyped, [-Infinity, -2.0, -1.0, 0.0, 1.0, 1.000000000000001, Infinity, NaN]));
|
||||
|
||||
var i32ArrayTyped: i32[] = [1, -2, -1, 0, 2];
|
||||
i32ArrayTyped.sort();
|
||||
assert(isArraysEqual<i32>(i32ArrayTyped, [-2, -1, 0, 1, 2]));
|
||||
|
||||
var u32ArrayTyped: u32[] = [1, 4294967295, 4294967294, 0, 2];
|
||||
u32ArrayTyped.sort();
|
||||
assert(isArraysEqual<u32>(u32ArrayTyped, [0, 1, 2, 4294967294, 4294967295]));
|
||||
|
||||
var reversed0: i32[] = [];
|
||||
var reversed1: i32[] = [1];
|
||||
var reversed2: i32[] = [2, 1];
|
||||
var reversed4: i32[] = [3, 2, 1, 0];
|
||||
var expected4: i32[] = [0, 1, 2, 3];
|
||||
|
||||
var reversed64 = createReverseOrderedArray(64);
|
||||
var reversed128 = createReverseOrderedArray(128);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2802,7 +2802,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 86)
|
||||
(i32.const 87)
|
||||
(i32.const 41)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -3478,7 +3478,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 86)
|
||||
(i32.const 87)
|
||||
(i32.const 41)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -1,8 +1,8 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiI (func (param i32 i32) (result i64)))
|
||||
(type $iiIv (func (param i32 i32 i64)))
|
||||
(type $iif (func (param i32 i32) (result f32)))
|
||||
@ -29,12 +29,7 @@
|
||||
(data (i32.const 216) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/array/Array<i32>#get:length (; 1 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__get (; 2 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i32>#__get (; 1 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(tee_local $0
|
||||
(if (result i32)
|
||||
(i32.lt_u
|
||||
@ -63,7 +58,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 3 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 2 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shl
|
||||
(i32.const 1)
|
||||
(i32.sub
|
||||
@ -77,7 +72,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/memory/memset (; 4 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/internal/memory/memset (; 3 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i64)
|
||||
(if
|
||||
@ -407,7 +402,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/__memory_allocate (; 5 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/allocator/arena/__memory_allocate (; 4 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
@ -492,7 +487,7 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $~lib/internal/arraybuffer/allocateUnsafe (; 6 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/allocateUnsafe (; 5 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
@ -521,7 +516,7 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $~lib/internal/memory/memcpy (; 7 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/internal/memory/memcpy (; 6 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
@ -1907,7 +1902,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/memory/memmove (; 8 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/internal/memory/memmove (; 7 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
@ -2199,7 +2194,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/arraybuffer/reallocateUnsafe (; 9 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/reallocateUnsafe (; 8 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
@ -2323,7 +2318,7 @@
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__set (; 10 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/array/Array<i32>#__set (; 9 ;) (; has Stack IR ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
@ -2350,7 +2345,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 184)
|
||||
(i32.const 86)
|
||||
(i32.const 87)
|
||||
(i32.const 41)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2390,7 +2385,7 @@
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i64>#__get (; 11 ;) (; has Stack IR ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64)
|
||||
(func $~lib/array/Array<i64>#__get (; 10 ;) (; has Stack IR ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64)
|
||||
(if (result i64)
|
||||
(i32.lt_u
|
||||
(get_local $1)
|
||||
@ -2417,7 +2412,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i64>#__set (; 12 ;) (; has Stack IR ;) (type $iiIv) (param $0 i32) (param $1 i32) (param $2 i64)
|
||||
(func $~lib/array/Array<i64>#__set (; 11 ;) (; has Stack IR ;) (type $iiIv) (param $0 i32) (param $1 i32) (param $2 i64)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
@ -2444,7 +2439,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 184)
|
||||
(i32.const 86)
|
||||
(i32.const 87)
|
||||
(i32.const 41)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2484,7 +2479,7 @@
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<f32>#__get (; 13 ;) (; has Stack IR ;) (type $iif) (param $0 i32) (param $1 i32) (result f32)
|
||||
(func $~lib/array/Array<f32>#__get (; 12 ;) (; has Stack IR ;) (type $iif) (param $0 i32) (param $1 i32) (result f32)
|
||||
(if (result f32)
|
||||
(i32.lt_u
|
||||
(get_local $1)
|
||||
@ -2511,7 +2506,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<f32>#__set (; 14 ;) (; has Stack IR ;) (type $iifv) (param $0 i32) (param $1 i32) (param $2 f32)
|
||||
(func $~lib/array/Array<f32>#__set (; 13 ;) (; has Stack IR ;) (type $iifv) (param $0 i32) (param $1 i32) (param $2 f32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
@ -2538,7 +2533,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 184)
|
||||
(i32.const 86)
|
||||
(i32.const 87)
|
||||
(i32.const 41)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2578,7 +2573,7 @@
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<f64>#__get (; 15 ;) (; has Stack IR ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
|
||||
(func $~lib/array/Array<f64>#__get (; 14 ;) (; has Stack IR ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
|
||||
(if (result f64)
|
||||
(i32.lt_u
|
||||
(get_local $1)
|
||||
@ -2605,7 +2600,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<f64>#__set (; 16 ;) (; has Stack IR ;) (type $iiFv) (param $0 i32) (param $1 i32) (param $2 f64)
|
||||
(func $~lib/array/Array<f64>#__set (; 15 ;) (; has Stack IR ;) (type $iiFv) (param $0 i32) (param $1 i32) (param $2 f64)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
@ -2632,7 +2627,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 184)
|
||||
(i32.const 86)
|
||||
(i32.const 87)
|
||||
(i32.const 41)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2672,7 +2667,7 @@
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $start (; 17 ;) (; has Stack IR ;) (type $v)
|
||||
(func $start (; 16 ;) (; has Stack IR ;) (type $v)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
(i32.const 280)
|
||||
)
|
||||
@ -2681,8 +2676,8 @@
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/array/Array<i32>#get:length
|
||||
(i32.const 24)
|
||||
(i32.load
|
||||
(i32.const 28)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -2757,8 +2752,8 @@
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/array/Array<i32>#get:length
|
||||
(i32.const 64)
|
||||
(i32.load
|
||||
(i32.const 68)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -2833,8 +2828,8 @@
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/array/Array<i32>#get:length
|
||||
(i32.const 88)
|
||||
(i32.load
|
||||
(i32.const 92)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -2909,8 +2904,8 @@
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/array/Array<i32>#get:length
|
||||
(i32.const 128)
|
||||
(i32.load
|
||||
(i32.const 132)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiI (func (param i32 i32) (result i64)))
|
||||
(type $iiIv (func (param i32 i32 i64)))
|
||||
(type $iif (func (param i32 i32) (result f32)))
|
||||
@ -38,12 +38,7 @@
|
||||
(data (i32.const 216) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/array/Array<i32>#get:length (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__get (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i32>#__get (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
@ -74,7 +69,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 3 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 2 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shl
|
||||
(i32.const 1)
|
||||
(i32.sub
|
||||
@ -91,7 +86,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/memory/memset (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/internal/memory/memset (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i64)
|
||||
@ -443,7 +438,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/__memory_allocate (; 5 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/allocator/arena/__memory_allocate (; 4 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
@ -554,7 +549,7 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $~lib/internal/arraybuffer/allocateUnsafe (; 6 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/allocateUnsafe (; 5 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
@ -594,7 +589,7 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $~lib/internal/memory/memcpy (; 7 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/internal/memory/memcpy (; 6 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
@ -2396,7 +2391,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/memory/memmove (; 8 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/internal/memory/memmove (; 7 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
(i32.eq
|
||||
@ -2714,7 +2709,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/arraybuffer/reallocateUnsafe (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/reallocateUnsafe (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
@ -2877,7 +2872,7 @@
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__set (; 10 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/array/Array<i32>#__set (; 9 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $3
|
||||
@ -2908,7 +2903,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 184)
|
||||
(i32.const 86)
|
||||
(i32.const 87)
|
||||
(i32.const 41)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2952,12 +2947,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i64>#get:length (; 11 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i64>#__get (; 12 ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64)
|
||||
(func $~lib/array/Array<i64>#__get (; 10 ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64)
|
||||
(local $2 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
@ -2988,7 +2978,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i64>#__set (; 13 ;) (type $iiIv) (param $0 i32) (param $1 i32) (param $2 i64)
|
||||
(func $~lib/array/Array<i64>#__set (; 11 ;) (type $iiIv) (param $0 i32) (param $1 i32) (param $2 i64)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $3
|
||||
@ -3019,7 +3009,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 184)
|
||||
(i32.const 86)
|
||||
(i32.const 87)
|
||||
(i32.const 41)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3063,12 +3053,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<f32>#get:length (; 14 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<f32>#__get (; 15 ;) (type $iif) (param $0 i32) (param $1 i32) (result f32)
|
||||
(func $~lib/array/Array<f32>#__get (; 12 ;) (type $iif) (param $0 i32) (param $1 i32) (result f32)
|
||||
(local $2 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
@ -3099,7 +3084,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<f32>#__set (; 16 ;) (type $iifv) (param $0 i32) (param $1 i32) (param $2 f32)
|
||||
(func $~lib/array/Array<f32>#__set (; 13 ;) (type $iifv) (param $0 i32) (param $1 i32) (param $2 f32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $3
|
||||
@ -3130,7 +3115,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 184)
|
||||
(i32.const 86)
|
||||
(i32.const 87)
|
||||
(i32.const 41)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3174,12 +3159,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<f64>#get:length (; 17 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<f64>#__get (; 18 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
|
||||
(func $~lib/array/Array<f64>#__get (; 14 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
|
||||
(local $2 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
@ -3210,7 +3190,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<f64>#__set (; 19 ;) (type $iiFv) (param $0 i32) (param $1 i32) (param $2 f64)
|
||||
(func $~lib/array/Array<f64>#__set (; 15 ;) (type $iiFv) (param $0 i32) (param $1 i32) (param $2 f64)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $3
|
||||
@ -3241,7 +3221,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 184)
|
||||
(i32.const 86)
|
||||
(i32.const 87)
|
||||
(i32.const 41)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3285,7 +3265,8 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 20 ;) (type $v)
|
||||
(func $start (; 16 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
(i32.and
|
||||
(i32.add
|
||||
@ -3304,8 +3285,13 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/Array<i32>#get:length
|
||||
(get_global $std/static-array/i)
|
||||
(block $~lib/array/Array<i32>#get:length|inlined.0 (result i32)
|
||||
(set_local $0
|
||||
(get_global $std/static-array/i)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -3388,8 +3374,13 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/Array<i64>#get:length
|
||||
(get_global $std/static-array/I)
|
||||
(block $~lib/array/Array<i64>#get:length|inlined.0 (result i32)
|
||||
(set_local $0
|
||||
(get_global $std/static-array/I)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -3472,8 +3463,13 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/Array<f32>#get:length
|
||||
(get_global $std/static-array/f)
|
||||
(block $~lib/array/Array<f32>#get:length|inlined.0 (result i32)
|
||||
(set_local $0
|
||||
(get_global $std/static-array/f)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -3556,8 +3552,13 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/Array<f64>#get:length
|
||||
(get_global $std/static-array/F)
|
||||
(block $~lib/array/Array<f64>#get:length|inlined.0 (result i32)
|
||||
(set_local $0
|
||||
(get_global $std/static-array/F)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -90,6 +90,22 @@ assert(arr.byteOffset == 1 * sizeof<i32>());
|
||||
assert(arr.byteLength == 2 * sizeof<i32>());
|
||||
assert(arr[0] == 2);
|
||||
|
||||
var af64 = new Float64Array(8);
|
||||
af64[0] = 1;
|
||||
af64[1] = 2;
|
||||
|
||||
af64[2] = 7;
|
||||
af64[3] = 6;
|
||||
af64[4] = 5;
|
||||
af64[5] = 4;
|
||||
|
||||
af64[6] = 3;
|
||||
af64[7] = 8;
|
||||
af64 = af64.subarray(2, 6);
|
||||
assert(af64.length == 4);
|
||||
af64.sort();
|
||||
assert(af64[0] == 4 && af64[1] == 5 && af64[2] == 6 && af64[3] == 7);
|
||||
|
||||
var clampedArr = new Uint8ClampedArray(3);
|
||||
clampedArr[0] = -32;
|
||||
clampedArr[1] = 2;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user