more consistent naming, move libm

This commit is contained in:
dcode 2019-06-02 18:05:14 +02:00
parent 5b41c1f2fa
commit adc2f7e26a
25 changed files with 19961 additions and 936 deletions

11
lib/libm/README.md Normal file
View File

@ -0,0 +1,11 @@
# ![AS](https://avatars1.githubusercontent.com/u/28916798?s=48) libm
AssemblyScript's math routines for double and single precision as a library.
```ts
const libm = require("@assemblyscript/libm");
const libmf = libm.libmf;
...
```
Both `libm` and `libmf` have the same general interface as JavaScript's `Math`, with `libmf` doing single precision math.

144
lib/libm/assembly/libm.ts Normal file
View File

@ -0,0 +1,144 @@
export const E = Math.E;
export const LN10 = Math.LN10;
export const LN2 = Math.LN2;
export const LOG10E = Math.LOG10E;
export const LOG2E = Math.LOG2E;
export const PI = Math.PI;
export const SQRT1_2 = Math.SQRT1_2;
export const SQRT2 = Math.SQRT2;
export function abs(x: f64): f64 {
return Math.abs(x);
}
export function acos(x: f64): f64 {
return Math.acos(x);
}
export function acosh(x: f64): f64 {
return Math.acosh(x);
}
export function asin(x: f64): f64 {
return Math.asin(x);
}
export function asinh(x: f64): f64 {
return Math.asinh(x);
}
export function atan(x: f64): f64 {
return Math.atan(x);
}
export function atanh(x: f64): f64 {
return Math.atanh(x);
}
export function atan2(y: f64, x: f64): f64 {
return Math.atan2(y, x);
}
export function cbrt(x: f64): f64 {
return Math.cbrt(x);
}
export function ceil(x: f64): f64 {
return Math.ceil(x);
}
export function clz32(x: f64): f64 {
return Math.clz32(x);
}
export function cos(x: f64): f64 {
return Math.cos(x);
}
export function cosh(x: f64): f64 {
return Math.cosh(x);
}
export function exp(x: f64): f64 {
return Math.exp(x);
}
export function expm1(x: f64): f64 {
return Math.expm1(x);
}
export function floor(x: f64): f64 {
return Math.floor(x);
}
export function fround(x: f64): f64 {
return Math.fround(x);
}
export function hypot(a: f64, b: f64): f64 {
return Math.hypot(a, b);
}
export function imul(a: f64, b: f64): f64 {
return Math.imul(a, b);
}
export function log(x: f64): f64 {
return Math.log(x);
}
export function log10(x: f64): f64 {
return Math.log10(x);
}
export function log1p(x: f64): f64 {
return Math.log1p(x);
}
export function log2(x: f64): f64 {
return Math.log2(x);
}
export function max(a: f64, b: f64): f64 {
return Math.max(a, b);
}
export function min(a: f64, b: f64): f64 {
return Math.min(a, b);
}
export function pow(x: f64, y: f64): f64 {
return Math.pow(x, y);
}
export function round(x: f64): f64 {
return Math.round(x);
}
export function sign(x: f64): f64 {
return Math.sign(x);
}
export function sin(x: f64): f64 {
return Math.sin(x);
}
export function sinh(x: f64): f64 {
return Math.sinh(x);
}
export function sqrt(x: f64): f64 {
return Math.sqrt(x);
}
export function tan(x: f64): f64 {
return Math.tan(x);
}
export function tanh(x: f64): f64 {
return Math.tanh(x);
}
export function trunc(x: f64): f64 {
return Math.trunc(x);
}

144
lib/libm/assembly/libmf.ts Normal file
View File

@ -0,0 +1,144 @@
export const E = Mathf.E;
export const LN10 = Mathf.LN10;
export const LN2 = Mathf.LN2;
export const LOG10E = Mathf.LOG10E;
export const LOG2E = Mathf.LOG2E;
export const PI = Mathf.PI;
export const SQRT1_2 = Mathf.SQRT1_2;
export const SQRT2 = Mathf.SQRT2;
export function abs(x: f32): f32 {
return Mathf.abs(x);
}
export function acos(x: f32): f32 {
return Mathf.acos(x);
}
export function acosh(x: f32): f32 {
return Mathf.acosh(x);
}
export function asin(x: f32): f32 {
return Mathf.asin(x);
}
export function asinh(x: f32): f32 {
return Mathf.asinh(x);
}
export function atan(x: f32): f32 {
return Mathf.atan(x);
}
export function atanh(x: f32): f32 {
return Mathf.atanh(x);
}
export function atan2(y: f32, x: f32): f32 {
return Mathf.atan2(y, x);
}
export function cbrt(x: f32): f32 {
return Mathf.cbrt(x);
}
export function ceil(x: f32): f32 {
return Mathf.ceil(x);
}
export function clz32(x: f32): f32 {
return Mathf.clz32(x);
}
export function cos(x: f32): f32 {
return Mathf.cos(x);
}
export function cosh(x: f32): f32 {
return Mathf.cosh(x);
}
export function exp(x: f32): f32 {
return Mathf.exp(x);
}
export function expm1(x: f32): f32 {
return Mathf.expm1(x);
}
export function floor(x: f32): f32 {
return Mathf.floor(x);
}
export function fround(x: f32): f32 {
return Mathf.fround(x);
}
export function hypot(a: f32, b: f32): f32 {
return Mathf.hypot(a, b);
}
export function imul(a: f32, b: f32): f32 {
return Mathf.imul(a, b);
}
export function log(x: f32): f32 {
return Mathf.log(x);
}
export function log10(x: f32): f32 {
return Mathf.log10(x);
}
export function log1p(x: f32): f32 {
return Mathf.log1p(x);
}
export function log2(x: f32): f32 {
return Mathf.log2(x);
}
export function max(a: f32, b: f32): f32 {
return Mathf.max(a, b);
}
export function min(a: f32, b: f32): f32 {
return Mathf.min(a, b);
}
export function pow(x: f32, y: f32): f32 {
return Mathf.pow(x, y);
}
export function round(x: f32): f32 {
return Mathf.round(x);
}
export function sign(x: f32): f32 {
return Mathf.sign(x);
}
export function sin(x: f32): f32 {
return Mathf.sin(x);
}
export function sinh(x: f32): f32 {
return Mathf.sinh(x);
}
export function sqrt(x: f32): f32 {
return Mathf.sqrt(x);
}
export function tan(x: f32): f32 {
return Mathf.tan(x);
}
export function tanh(x: f32): f32 {
return Mathf.tanh(x);
}
export function trunc(x: f32): f32 {
return Mathf.trunc(x);
}

View File

@ -0,0 +1,6 @@
{
"extends": "../../../std/assembly.json",
"include": [
"./**/*.ts"
]
}

2
lib/libm/build/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.wasm
*.wasm.map

3934
lib/libm/build/libm.wat Normal file

File diff suppressed because it is too large Load Diff

4763
lib/libm/build/libmf.wat Normal file

File diff suppressed because it is too large Load Diff

2
lib/libm/index.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
declare const libm: typeof Math & { libm: typeof Math, libmf: typeof Math };
export = libm;

7
lib/libm/index.js Normal file
View File

@ -0,0 +1,7 @@
const fs = require("fs");
const libm = new WebAssembly.Instance(new WebAssembly.Module(fs.readFileSync("./build/libm.wasm")), { Math }).exports;
const libmf = new WebAssembly.Instance(new WebAssembly.Module(fs.readFileSync("./build/libmf.wasm")), {}).exports;
module.exports = Object.create(libm, {
libm: { value: libm, enumerable: true },
libmf: { value: libmf, enumerable: true }
});

23
lib/libm/package.json Normal file
View File

@ -0,0 +1,23 @@
{
"name": "@assemblyscript/libm",
"version": "1.0.0",
"license": "Apache-2.0",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"asbuild": "npm run asbuild:libm && npm run asbuild:libmf",
"asbuild:libm": "asc assembly/libm.ts -O3 -b build/libm.wasm -t build/libm.wat --runtime none --validate",
"asbuild:libmf": "asc assembly/libmf.ts -O3 -b build/libmf.wasm -t build/libmf.wat --runtime none --validate"
},
"files": [
"package.json",
"index.d.ts",
"index.js",
"build/*.wasm",
"README.md"
],
"dependencies": {},
"devDependencies": {
"assemblyscript": "AssemblyScript/assemblyscript"
}
}

View File

@ -366,14 +366,14 @@ export class Array<T> extends ArrayBufferView {
return newLength; return newLength;
} }
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Array<T> { slice(start: i32 = 0, end: i32 = i32.MAX_VALUE): Array<T> {
var length = this.length_; var length = this.length_;
begin = begin < 0 ? max(begin + length, 0) : min(begin, length); start = start < 0 ? max(start + length, 0) : min(start, length);
end = end < 0 ? max(end + length, 0) : min(end , length); end = end < 0 ? max(end + length, 0) : min(end , length);
length = max(end - begin, 0); length = max(end - start, 0);
var slice = changetype<Array<T>>(__allocArray(length, alignof<T>(), idof<Array<T>>())); // retains var slice = changetype<Array<T>>(__allocArray(length, alignof<T>(), idof<Array<T>>())); // retains
var sliceBase = slice.dataStart; var sliceBase = slice.dataStart;
var thisBase = this.dataStart + (<usize>begin << alignof<T>()); var thisBase = this.dataStart + (<usize>start << alignof<T>());
if (isManaged<T>()) { if (isManaged<T>()) {
let off = <usize>0; let off = <usize>0;
let end = <usize>length << alignof<usize>(); let end = <usize>length << alignof<usize>();

View File

@ -1351,7 +1351,7 @@ interface IMath<T> {
acos(x: T): T; acos(x: T): T;
/** Returns the hyperbolic arc-cosine of `x`. */ /** Returns the hyperbolic arc-cosine of `x`. */
acosh(x: T): T; acosh(x: T): T;
/** Returns the arcsine (in radians) of `x` */ /** Returns the arcsine (in radians) of `x`. */
asin(x: T): T; asin(x: T): T;
/** Returns the hyperbolic arcsine of `x`. */ /** Returns the hyperbolic arcsine of `x`. */
asinh(x: T): T; asinh(x: T): T;
@ -1378,7 +1378,7 @@ interface IMath<T> {
/** Returns the largest integer less than or equal to `x`. */ /** Returns the largest integer less than or equal to `x`. */
floor(x: T): T; floor(x: T): T;
/** Returns the nearest 32-bit single precision float representation of `x`. */ /** Returns the nearest 32-bit single precision float representation of `x`. */
fround(x: T): f32; fround(x: T): T;
/** Returns the square root of the sum of squares of its arguments. */ /** Returns the square root of the sum of squares of its arguments. */
hypot(value1: T, value2: T): T; // TODO: rest hypot(value1: T, value2: T): T; // TODO: rest
/** Returns the result of the C-like 32-bit multiplication of `a` and `b`. */ /** Returns the result of the C-like 32-bit multiplication of `a` and `b`. */
@ -1403,7 +1403,7 @@ interface IMath<T> {
round(x: T): T; round(x: T): T;
/** Returns the sign of `x`, indicating whether the number is positive, negative or zero. */ /** Returns the sign of `x`, indicating whether the number is positive, negative or zero. */
sign(x: T): T; sign(x: T): T;
/** Returns whether the sign bit of `x` is set */ /** Returns whether the sign bit of `x` is set. */
signbit(x: T): bool; signbit(x: T): bool;
/** Returns the sine of `x`. */ /** Returns the sine of `x`. */
sin(x: T): T; sin(x: T): T;

View File

@ -404,8 +404,7 @@ export namespace NativeMath {
} }
export function cos(x: f64): f64 { // TODO export function cos(x: f64): f64 { // TODO
unreachable(); return JSMath.cos(x);
return 0;
} }
export function cosh(x: f64): f64 { // see: musl/src/math/cosh.c export function cosh(x: f64): f64 { // see: musl/src/math/cosh.c
@ -544,7 +543,7 @@ export namespace NativeMath {
// @ts-ignore: decorator // @ts-ignore: decorator
@inline @inline
export function fround(x: f64): f32 { export function fround(x: f64): f64 {
return <f32>x; return <f32>x;
} }
@ -1065,8 +1064,7 @@ export namespace NativeMath {
} }
export function sin(x: f64): f64 { // TODO export function sin(x: f64): f64 { // TODO
unreachable(); return JSMath.sin(x);
return 0;
} }
export function sinh(x: f64): f64 { // see: musl/src/math/sinh.c export function sinh(x: f64): f64 { // see: musl/src/math/sinh.c
@ -1094,8 +1092,7 @@ export namespace NativeMath {
} }
export function tan(x: f64): f64 { // TODO export function tan(x: f64): f64 { // TODO
unreachable(); return JSMath.tan(x);
return 0;
} }
export function tanh(x: f64): f64 { // see: musl/src/math/tanh.c export function tanh(x: f64): f64 { // see: musl/src/math/tanh.c
@ -1703,7 +1700,7 @@ export namespace NativeMathf {
export function clz32(x: f32): f32 { export function clz32(x: f32): f32 {
if (!isFinite(x)) return 32; if (!isFinite(x)) return 32;
return builtin_clz( return <f32>builtin_clz(
<i32><i64>(x - 4294967296 * builtin_floor(x * (1.0 / 4294967296))) <i32><i64>(x - 4294967296 * builtin_floor(x * (1.0 / 4294967296)))
); );
} }
@ -1931,7 +1928,7 @@ export namespace NativeMathf {
*/ */
if (!isFinite(x + y)) return 0; if (!isFinite(x + y)) return 0;
const inv32 = 1.0 / 4294967296; const inv32 = 1.0 / 4294967296;
return ( return <f32>(
<i32><i64>(x - 4294967296 * builtin_floor(x * inv32)) * <i32><i64>(x - 4294967296 * builtin_floor(x * inv32)) *
<i32><i64>(y - 4294967296 * builtin_floor(y * inv32)) <i32><i64>(y - 4294967296 * builtin_floor(y * inv32))
); );

View File

@ -10,10 +10,16 @@ import { idof } from "./builtins";
@lazy static readonly MAX_LENGTH: i32 = BLOCK_MAXSIZE >>> alignof<u16>(); @lazy static readonly MAX_LENGTH: i32 = BLOCK_MAXSIZE >>> alignof<u16>();
// TODO Add and handle second argument static fromCharCode(unit: i32, surr: i32 = -1): string {
static fromCharCode(code: i32): string { var out: usize;
var out = __alloc(2, idof<string>()); if (~surr) {
store<u16>(out, <u16>code); out = __alloc(4, idof<string>());
store<u16>(out, <u16>unit);
store<u16>(out, <u16>surr, 2);
} else {
out = __alloc(2, idof<string>());
store<u16>(out, <u16>unit);
}
return changetype<string>(out); // retains return changetype<string>(out); // retains
} }
@ -74,15 +80,15 @@ import { idof } from "./builtins";
return out; return out;
} }
endsWith(searchString: String, endPosition: i32 = String.MAX_LENGTH): bool { endsWith(search: String, end: i32 = String.MAX_LENGTH): bool {
assert(this !== null); assert(this !== null);
if (searchString === null) return false; if (search === null) return false;
var end = min(max(endPosition, 0), this.length); end = min(max(end, 0), this.length);
var searchLength: isize = searchString.length; var searchLength = <isize>search.length;
var start: isize = end - searchLength; var searchStart = <isize>end - searchLength;
if (start < 0) return false; if (searchStart < 0) return false;
// @ts-ignore: string <-> String // @ts-ignore: string <-> String
return !compareImpl(this, start, searchString, 0, searchLength); return !compareImpl(this, searchStart, search, 0, searchLength);
} }
@operator("==") private static __eq(left: String | null, right: String | null): bool { @operator("==") private static __eq(left: String | null, right: String | null): bool {
@ -132,54 +138,48 @@ import { idof } from "./builtins";
return !this.__gt(left, right); return !this.__gt(left, right);
} }
@inline includes(searchString: String, position: i32 = 0): bool { includes(search: String, start: i32 = 0): bool {
return this.indexOf(searchString, position) != -1; return this.indexOf(search, start) != -1;
} }
indexOf(searchString: String, fromIndex: i32 = 0): i32 { indexOf(search: String, start: i32 = 0): i32 {
assert(this !== null); var searchLen = <isize>search.length;
if (searchString === null) searchString = changetype<String>("null");
var searchLen: isize = searchString.length;
if (!searchLen) return 0; if (!searchLen) return 0;
var len: isize = this.length; var len = <isize>this.length;
if (!len) return -1; if (!len) return -1;
var start = min<isize>(max<isize>(fromIndex, 0), len); var searchStart = min(max(<isize>start, 0), len);
len -= searchLen; for (len -= searchLen; searchStart <= len; ++searchStart) {
for (let k: isize = start; k <= len; ++k) {
// @ts-ignore: string <-> String // @ts-ignore: string <-> String
if (!compareImpl(this, k, searchString, 0, searchLen)) return <i32>k; if (!compareImpl(this, searchStart, search, 0, searchLen)) return <i32>searchStart;
} }
return -1; return -1;
} }
lastIndexOf(searchString: String, fromIndex: i32 = i32.MAX_VALUE): i32 { lastIndexOf(search: String, start: i32 = i32.MAX_VALUE): i32 {
assert(this !== null); var searchLen = <isize>search.length;
if (searchString === null) searchString = changetype<String>("null"); if (!searchLen) return this.length;
var len: isize = this.length; var len = this.length;
var searchLen: isize = searchString.length;
if (!searchLen) return len;
if (!len) return -1; if (!len) return -1;
var start = min<isize>(max(fromIndex, 0), len - searchLen); var searchStart = min(max(<isize>start, 0), <isize>len - searchLen);
for (let k = start; k >= 0; --k) { for (; searchStart >= 0; --searchStart) {
// @ts-ignore: string <-> String // @ts-ignore: string <-> String
if (!compareImpl(this, k, searchString, 0, searchLen)) return <i32>k; if (!compareImpl(this, searchStart, search, 0, searchLen)) return <i32>searchStart;
} }
return -1; return -1;
} }
startsWith(searchString: String, position: i32 = 0): bool { startsWith(search: String, start: i32 = 0): bool {
assert(this !== null); assert(this !== null);
if (searchString === null) searchString = changetype<String>("null"); if (search === null) search = changetype<String>("null");
var pos: isize = position; var len = <isize>this.length;
var len: isize = this.length; var searchStart = min(max(<isize>start, 0), len);
var start = min(max(pos, 0), len); var searchLength = <isize>search.length;
var searchLength: isize = searchString.length; if (searchLength + searchStart > len) return false;
if (searchLength + start > len) return false;
// @ts-ignore: string <-> String // @ts-ignore: string <-> String
return !compareImpl(this, start, searchString, 0, searchLength); return !compareImpl(this, searchStart, search, 0, searchLength);
} }
substr(start: i32, length: i32 = i32.MAX_VALUE): String { substr(start: i32, length: i32 = i32.MAX_VALUE): String { // legacy
assert(this !== null); assert(this !== null);
var intStart: isize = start; var intStart: isize = start;
var end: isize = length; var end: isize = length;
@ -284,11 +284,11 @@ import { idof } from "./builtins";
return changetype<String>(out); // retains return changetype<String>(out); // retains
} }
padStart(targetLength: i32, padString: string = " "): String { padStart(length: i32, pad: string = " "): String {
assert(this !== null); assert(this !== null);
var thisSize = <usize>this.length << 1; var thisSize = <usize>this.length << 1;
var targetSize = <usize>targetLength << 1; var targetSize = <usize>length << 1;
var padSize = <usize>padString.length << 1; var padSize = <usize>pad.length << 1;
if (targetSize < thisSize || !padSize) return this; if (targetSize < thisSize || !padSize) return this;
var prependSize = targetSize - thisSize; var prependSize = targetSize - thisSize;
var out = __alloc(targetSize, idof<String>()); var out = __alloc(targetSize, idof<String>());
@ -296,20 +296,20 @@ import { idof } from "./builtins";
let repeatCount = (prependSize - 2) / padSize; let repeatCount = (prependSize - 2) / padSize;
let restBase = repeatCount * padSize; let restBase = repeatCount * padSize;
let restSize = prependSize - restBase; let restSize = prependSize - restBase;
memory.repeat(out, changetype<usize>(padString), padSize, repeatCount); memory.repeat(out, changetype<usize>(pad), padSize, repeatCount);
memory.copy(out + restBase, changetype<usize>(padString), restSize); memory.copy(out + restBase, changetype<usize>(pad), restSize);
} else { } else {
memory.copy(out, changetype<usize>(padString), prependSize); memory.copy(out, changetype<usize>(pad), prependSize);
} }
memory.copy(out + prependSize, changetype<usize>(this), thisSize); memory.copy(out + prependSize, changetype<usize>(this), thisSize);
return changetype<String>(out); // retains return changetype<String>(out); // retains
} }
padEnd(targetLength: i32, padString: string = " "): String { padEnd(length: i32, pad: string = " "): String {
assert(this !== null); assert(this !== null);
var thisSize = <usize>this.length << 1; var thisSize = <usize>this.length << 1;
var targetSize = <usize>targetLength << 1; var targetSize = <usize>length << 1;
var padSize = <usize>padString.length << 1; var padSize = <usize>pad.length << 1;
if (targetSize < thisSize || !padSize) return this; if (targetSize < thisSize || !padSize) return this;
var appendSize = targetSize - thisSize; var appendSize = targetSize - thisSize;
var out = __alloc(targetSize, idof<String>()); var out = __alloc(targetSize, idof<String>());
@ -318,10 +318,10 @@ import { idof } from "./builtins";
let repeatCount = (appendSize - 2) / padSize; let repeatCount = (appendSize - 2) / padSize;
let restBase = repeatCount * padSize; let restBase = repeatCount * padSize;
let restSize = appendSize - restBase; let restSize = appendSize - restBase;
memory.repeat(out + thisSize, changetype<usize>(padString), padSize, repeatCount); memory.repeat(out + thisSize, changetype<usize>(pad), padSize, repeatCount);
memory.copy(out + thisSize + restBase, changetype<usize>(padString), restSize); memory.copy(out + thisSize + restBase, changetype<usize>(pad), restSize);
} else { } else {
memory.copy(out + thisSize, changetype<usize>(padString), appendSize); memory.copy(out + thisSize, changetype<usize>(pad), appendSize);
} }
return changetype<String>(out); // retains return changetype<String>(out); // retains
} }
@ -342,14 +342,14 @@ import { idof } from "./builtins";
return changetype<String>(out); // retains return changetype<String>(out); // retains
} }
slice(beginIndex: i32, endIndex: i32 = i32.MAX_VALUE): String { slice(start: i32, end: i32 = i32.MAX_VALUE): String {
var len = this.length; var len = this.length;
var begin = beginIndex < 0 ? max(beginIndex + len, 0) : min(beginIndex, len); start = start < 0 ? max(start + len, 0) : min(start, len);
var end = endIndex < 0 ? max(endIndex + len, 0) : min(endIndex, len); end = end < 0 ? max(end + len, 0) : min(end, len);
len = end - begin; len = end - start;
if (len <= 0) return changetype<String>(""); if (len <= 0) return changetype<String>("");
var out = __alloc(len << 1, idof<String>()); var out = __alloc(len << 1, idof<String>());
memory.copy(out, changetype<usize>(this) + (<usize>begin << 1), <usize>len << 1); memory.copy(out, changetype<usize>(this) + (<usize>start << 1), <usize>len << 1);
return changetype<String>(out); // retains return changetype<String>(out); // retains
} }

View File

@ -145,7 +145,7 @@
if if
i32.const 0 i32.const 0
i32.const 256 i32.const 256
i32.const 171 i32.const 172
i32.const 4 i32.const 4
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable

View File

@ -253,7 +253,6 @@
(local $5 i32) (local $5 i32)
(local $6 i32) (local $6 i32)
(local $7 i32) (local $7 i32)
(local $8 i32)
local.get $1 local.get $1
call $~lib/rt/stub/__retain call $~lib/rt/stub/__retain
drop drop
@ -264,7 +263,7 @@
if if
i32.const 0 i32.const 0
i32.const 256 i32.const 256
i32.const 171 i32.const 172
i32.const 4 i32.const 4
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -290,12 +289,10 @@
end end
local.set $1 local.set $1
end end
local.get $2
local.set $5
local.get $0 local.get $0
call $~lib/string/String#get:length call $~lib/string/String#get:length
local.set $6 local.set $5
local.get $5 local.get $2
local.tee $3 local.tee $3
i32.const 0 i32.const 0
local.tee $4 local.tee $4
@ -304,20 +301,20 @@
i32.gt_s i32.gt_s
select select
local.tee $3 local.tee $3
local.get $6 local.get $5
local.tee $4 local.tee $4
local.get $3 local.get $3
local.get $4 local.get $4
i32.lt_s i32.lt_s
select select
local.set $7 local.set $6
local.get $1 local.get $1
call $~lib/string/String#get:length call $~lib/string/String#get:length
local.set $8 local.set $7
local.get $8
local.get $7 local.get $7
i32.add
local.get $6 local.get $6
i32.add
local.get $5
i32.gt_s i32.gt_s
if if
i32.const 0 i32.const 0
@ -328,10 +325,10 @@
return return
end end
local.get $0 local.get $0
local.get $7 local.get $6
local.get $1 local.get $1
i32.const 0 i32.const 0
local.get $8 local.get $7
call $~lib/util/string/compareImpl call $~lib/util/string/compareImpl
i32.eqz i32.eqz
local.set $3 local.set $3

View File

@ -4417,7 +4417,7 @@
if if
i32.const 0 i32.const 0
i32.const 3160 i32.const 3160
i32.const 1021 i32.const 1020
i32.const 4 i32.const 4
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -5970,7 +5970,7 @@
if if
i32.const 3936 i32.const 3936
i32.const 3160 i32.const 3160
i32.const 1030 i32.const 1029
i32.const 24 i32.const 24
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable

View File

@ -7105,7 +7105,7 @@
if if
i32.const 0 i32.const 0
i32.const 3160 i32.const 3160
i32.const 1021 i32.const 1020
i32.const 4 i32.const 4
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -9460,7 +9460,7 @@
if if
i32.const 3936 i32.const 3936
i32.const 3160 i32.const 3160
i32.const 1030 i32.const 1029
i32.const 24 i32.const 24
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -11392,7 +11392,7 @@
if if
i32.const 0 i32.const 0
i32.const 4360 i32.const 4360
i32.const 40 i32.const 46
i32.const 4 i32.const 4
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable

File diff suppressed because it is too large Load Diff

View File

@ -1,144 +1,3 @@
export const E = Math.E; import * as libm from "../../../lib/libm/assembly/libm";
export const LN10 = Math.LN10; import * as libmf from "../../../lib/libm/assembly/libmf";
export const LN2 = Math.LN2; export { libm, libmf };
export const LOG10E = Math.LOG10E;
export const LOG2E = Math.LOG2E;
export const PI = Math.PI;
export const SQRT1_2 = Math.SQRT1_2;
export const SQRT2 = Math.SQRT2;
export function abs(x: f64): f64 {
return Math.abs(x);
}
export function acos(x: f64): f64 {
return Math.acos(x);
}
export function acosh(x: f64): f64 {
return Math.acosh(x);
}
export function asin(x: f64): f64 {
return Math.asin(x);
}
export function asinh(x: f64): f64 {
return Math.asinh(x);
}
export function atan(x: f64): f64 {
return Math.atan(x);
}
export function atanh(x: f64): f64 {
return Math.atanh(x);
}
export function atan2(y: f64, x: f64): f64 {
return Math.atan2(y, x);
}
export function cbrt(x: f64): f64 {
return Math.cbrt(x);
}
export function ceil(x: f64): f64 {
return Math.ceil(x);
}
export function clz32(x: f64): f64 {
return Math.clz32(x);
}
export function cos(x: f64): f64 {
return Math.cos(x);
}
export function cosh(x: f64): f64 {
return Math.cosh(x);
}
export function exp(x: f64): f64 {
return Math.exp(x);
}
export function expm1(x: f64): f64 {
return Math.expm1(x);
}
export function floor(x: f64): f64 {
return Math.floor(x);
}
export function fround(x: f64): f32 {
return Math.fround(x);
}
export function hypot(a: f64, b: f64): f64 {
return Math.hypot(a, b);
}
export function imul(a: f64, b: f64): f64 {
return Math.imul(a, b);
}
export function log(x: f64): f64 {
return Math.log(x);
}
export function log10(x: f64): f64 {
return Math.log10(x);
}
export function log1p(x: f64): f64 {
return Math.log1p(x);
}
export function log2(x: f64): f64 {
return Math.log2(x);
}
export function max(a: f64, b: f64): f64 {
return Math.max(a, b);
}
export function min(a: f64, b: f64): f64 {
return Math.min(a, b);
}
export function pow(x: f64, y: f64): f64 {
return Math.pow(x, y);
}
export function round(x: f64): f64 {
return Math.round(x);
}
export function sign(x: f64): f64 {
return Math.sign(x);
}
export function sin(x: f64): f64 {
return Math.sin(x);
}
export function sinh(x: f64): f64 {
return Math.sinh(x);
}
export function sqrt(x: f64): f64 {
return Math.sqrt(x);
}
export function tan(x: f64): f64 {
return Math.tan(x);
}
export function tanh(x: f64): f64 {
return Math.tanh(x);
}
export function trunc(x: f64): f64 {
return Math.trunc(x);
}

File diff suppressed because it is too large Load Diff

View File

@ -8056,7 +8056,7 @@
if if
i32.const 0 i32.const 0
i32.const 144 i32.const 144
i32.const 1021 i32.const 1020
i32.const 4 i32.const 4
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -8087,7 +8087,7 @@
if if
i32.const 184 i32.const 184
i32.const 144 i32.const 144
i32.const 1030 i32.const 1029
i32.const 24 i32.const 24
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -8134,7 +8134,7 @@
if if
i32.const 184 i32.const 184
i32.const 144 i32.const 144
i32.const 2312 i32.const 2309
i32.const 24 i32.const 24
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable

View File

@ -10211,7 +10211,7 @@
if if
i32.const 0 i32.const 0
i32.const 144 i32.const 144
i32.const 1021 i32.const 1020
i32.const 4 i32.const 4
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -10243,7 +10243,7 @@
if if
i32.const 184 i32.const 184
i32.const 144 i32.const 144
i32.const 1030 i32.const 1029
i32.const 24 i32.const 24
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -10300,7 +10300,7 @@
if if
i32.const 184 i32.const 184
i32.const 144 i32.const 144
i32.const 2312 i32.const 2309
i32.const 24 i32.const 24
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff