mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-26 13:11:52 +00:00
New ArrayBuffer/TypedArray; Stdlib restructure; Fix importing stdlib in stdlib; Traverse constructors; Allow initialization of readonly instance fields in constructors
This commit is contained in:
bin
dist
src
std
assembly.d.ts
assembly
tests/compiler/std
allocator_arena.untouched.watarray-access.optimized.watarray-access.untouched.watarray.optimized.watarray.untouched.watarraybuffer.optimized.watarraybuffer.tsarraybuffer.untouched.watcarray.optimized.watcarray.tscarray.untouched.watconstructor.untouched.watnew.untouched.watoperator-overloading.untouched.watset.untouched.watstatic-array.optimized.watstatic-array.untouched.watstring.optimized.watstring.untouched.wattypedarray.optimized.wattypedarray.tstypedarray.untouched.wat
96
bin/asc.js
96
bin/asc.js
@ -187,16 +187,54 @@ exports.main = function main(argv, options, callback) {
|
||||
// Set up base directory
|
||||
const baseDir = args.baseDir ? path.resolve(args.baseDir) : ".";
|
||||
|
||||
// Include custom library components (with or without stdlib)
|
||||
const customLibDirs = [];
|
||||
if (args.lib) {
|
||||
if (typeof args.lib === "string") args.lib = args.lib.split(",");
|
||||
Array.prototype.push.apply(customLibDirs, args.lib.map(lib => lib.trim()));
|
||||
}
|
||||
|
||||
// Begin parsing
|
||||
var parser = null;
|
||||
|
||||
// Include library files
|
||||
if (!args.noLib) { // bundled
|
||||
Object.keys(exports.libraryFiles).forEach(libPath => {
|
||||
if (libPath.indexOf("/") >= 0) return; // in sub-directory: imported on demand
|
||||
stats.parseCount++;
|
||||
stats.parseTime += measure(() => {
|
||||
parser = assemblyscript.parseFile(
|
||||
exports.libraryFiles[libPath],
|
||||
exports.libraryPrefix + libPath + ".ts",
|
||||
false,
|
||||
parser
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
if (args.lib) {
|
||||
const customLibDirs = [];
|
||||
if (typeof args.lib === "string") args.lib = args.lib.split(",");
|
||||
Array.prototype.push.apply(customLibDirs, args.lib.map(lib => lib.trim()));
|
||||
for (let i = 0, k = customLibDirs.length; i < k; ++i) { // custom
|
||||
let libDir = customLibDirs[i];
|
||||
let libFiles;
|
||||
if (libDir.endsWith(".ts")) {
|
||||
libFiles = [ path.basename(libDir) ];
|
||||
libDir = path.dirname(libDir);
|
||||
} else {
|
||||
libFiles = listFiles(libDir);
|
||||
}
|
||||
for (let j = 0, l = libFiles.length; j < l; ++j) {
|
||||
let libPath = libFiles[j];
|
||||
let libText = readFile(path.join(libDir, libPath));
|
||||
if (libText === null) return callback(Error("Library file '" + libPath + "' not found."));
|
||||
stats.parseCount++;
|
||||
stats.parseTime += measure(() => {
|
||||
parser = assemblyscript.parseFile(
|
||||
libText,
|
||||
exports.libraryPrefix + libPath,
|
||||
false,
|
||||
parser
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Include entry files
|
||||
for (let i = 0, k = args._.length; i < k; ++i) {
|
||||
const filename = args._[i];
|
||||
@ -221,6 +259,7 @@ exports.main = function main(argv, options, callback) {
|
||||
parser = assemblyscript.parseFile(sourceText, sourcePath, true, parser);
|
||||
});
|
||||
|
||||
// Process backlog
|
||||
while ((sourcePath = parser.nextFile()) != null) {
|
||||
let found = false;
|
||||
|
||||
@ -240,12 +279,10 @@ exports.main = function main(argv, options, callback) {
|
||||
sourceText = readFile(path.join(dir, plainName + ".ts"));
|
||||
if (sourceText !== null) {
|
||||
sourcePath = exports.libraryPrefix + plainName + ".ts";
|
||||
break;
|
||||
} else {
|
||||
sourceText = readFile(path.join(dir, indexName + ".ts"));
|
||||
if (sourceText !== null) {
|
||||
sourcePath = exports.libraryPrefix + indexName + ".ts";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -275,12 +312,10 @@ exports.main = function main(argv, options, callback) {
|
||||
sourceText = readFile(path.join(dir, plainName + ".ts"));
|
||||
if (sourceText !== null) {
|
||||
sourcePath = exports.libraryPrefix + plainName + ".ts";
|
||||
break;
|
||||
} else {
|
||||
sourceText = readFile(path.join(dir, indexName + ".ts"));
|
||||
if (sourceText !== null) {
|
||||
sourcePath = exports.libraryPrefix + indexName + ".ts";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -301,45 +336,6 @@ exports.main = function main(argv, options, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
// Include (other) library components
|
||||
if (!args.noLib) // bundled
|
||||
Object.keys(exports.libraryFiles).forEach(libPath => {
|
||||
if (libPath.indexOf("/") >= 0) return; // in sub-directory: imported on demand
|
||||
stats.parseCount++;
|
||||
stats.parseTime += measure(() => {
|
||||
parser = assemblyscript.parseFile(
|
||||
exports.libraryFiles[libPath],
|
||||
exports.libraryPrefix + libPath + ".ts",
|
||||
false,
|
||||
parser
|
||||
);
|
||||
});
|
||||
});
|
||||
for (let i = 0, k = customLibDirs.length; i < k; ++i) { // custom
|
||||
let libDir = customLibDirs[i];
|
||||
let libFiles;
|
||||
if (libDir.endsWith(".ts")) {
|
||||
libFiles = [ path.basename(libDir) ];
|
||||
libDir = path.dirname(libDir);
|
||||
} else {
|
||||
libFiles = listFiles(libDir);
|
||||
}
|
||||
for (let j = 0, l = libFiles.length; j < l; ++j) {
|
||||
let libPath = libFiles[j];
|
||||
let libText = readFile(path.join(libDir, libPath));
|
||||
if (libText === null) return callback(Error("Library file '" + libPath + "' not found."));
|
||||
stats.parseCount++;
|
||||
stats.parseTime += measure(() => {
|
||||
parser = assemblyscript.parseFile(
|
||||
libText,
|
||||
exports.libraryPrefix + libPath,
|
||||
false,
|
||||
parser
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Finish parsing
|
||||
const program = assemblyscript.finishParsing(parser);
|
||||
|
||||
|
2
dist/asc.js
vendored
2
dist/asc.js
vendored
File diff suppressed because one or more lines are too long
2
dist/asc.js.map
vendored
2
dist/asc.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/assemblyscript.js
vendored
2
dist/assemblyscript.js
vendored
File diff suppressed because one or more lines are too long
2
dist/assemblyscript.js.map
vendored
2
dist/assemblyscript.js.map
vendored
File diff suppressed because one or more lines are too long
@ -46,10 +46,10 @@ import {
|
||||
FlowFlags,
|
||||
CommonFlags,
|
||||
ConstantValueKind,
|
||||
Flow,
|
||||
|
||||
PATH_DELIMITER,
|
||||
LIBRARY_PREFIX,
|
||||
Flow
|
||||
INNER_DELIMITER
|
||||
} from "./program";
|
||||
|
||||
import {
|
||||
@ -220,8 +220,6 @@ export class Compiler extends DiagnosticEmitter {
|
||||
functionTable: Function[] = new Array();
|
||||
/** Argument count helper global. */
|
||||
argumentCountRef: GlobalRef = 0;
|
||||
/** Already processed file names. */
|
||||
files: Set<string> = new Set();
|
||||
|
||||
/** Compiles a {@link Program} to a {@link Module} using the specified options. */
|
||||
static compile(program: Program, options: Options | null = null): Module {
|
||||
@ -272,16 +270,14 @@ export class Compiler extends DiagnosticEmitter {
|
||||
var startFunctionBody = this.startFunctionBody;
|
||||
if (startFunctionBody.length) {
|
||||
let typeRef = this.ensureFunctionType(startFunctionInstance.signature);
|
||||
let funcRef: FunctionRef;
|
||||
module.setStart(
|
||||
funcRef = module.addFunction(
|
||||
let funcRef = module.addFunction(
|
||||
startFunctionInstance.internalName,
|
||||
typeRef,
|
||||
typesToNativeTypes(startFunctionInstance.additionalLocals),
|
||||
module.createBlock(null, startFunctionBody)
|
||||
)
|
||||
);
|
||||
startFunctionInstance.finalize(module, funcRef);
|
||||
module.setStart(funcRef);
|
||||
}
|
||||
|
||||
// set up static memory segments and the heap base pointer
|
||||
@ -319,13 +315,12 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
|
||||
// import memory if requested
|
||||
if (options.importMemory) {
|
||||
module.addMemoryImport("0", "env", "memory");
|
||||
}
|
||||
if (options.importMemory) module.addMemoryImport("0", "env", "memory");
|
||||
|
||||
// set up function table
|
||||
var functionTable = this.functionTable;
|
||||
var functionTableSize = functionTable.length;
|
||||
var functionTableExported = false;
|
||||
if (functionTableSize) {
|
||||
let entries = new Array<FunctionRef>(functionTableSize);
|
||||
for (let i = 0; i < functionTableSize; ++i) {
|
||||
@ -333,12 +328,13 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
module.setFunctionTable(entries);
|
||||
module.addTableExport("0", "table");
|
||||
functionTableExported = true;
|
||||
}
|
||||
|
||||
// import table if requested
|
||||
if (options.importTable) {
|
||||
module.addTableImport("0", "env", "table");
|
||||
if (!functionTableSize) module.addTableExport("0", "table");
|
||||
if (!functionTableExported) module.addTableExport("0", "table");
|
||||
}
|
||||
|
||||
return module;
|
||||
@ -347,49 +343,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
// sources
|
||||
|
||||
compileSourceByPath(normalizedPathWithoutExtension: string, reportNode: Node): void {
|
||||
var sources = this.program.sources;
|
||||
|
||||
// try file.ts
|
||||
var expected = normalizedPathWithoutExtension + ".ts";
|
||||
for (let i = 0, k = sources.length; i < k; ++i) {
|
||||
let source = sources[i];
|
||||
if (source.normalizedPath == expected) {
|
||||
this.compileSource(source);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// try file/index.ts
|
||||
expected = normalizedPathWithoutExtension + "/index.ts";
|
||||
for (let i = 0, k = sources.length; i < k; ++i) {
|
||||
let source = sources[i];
|
||||
if (source.normalizedPath == expected) {
|
||||
this.compileSource(source);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// try ~lib/file.ts
|
||||
expected = LIBRARY_PREFIX + normalizedPathWithoutExtension + ".ts";
|
||||
for (let i = 0, k = sources.length; i < k; ++i) {
|
||||
let source = sources[i];
|
||||
if (source.normalizedPath == expected) {
|
||||
this.compileSource(source);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var source = this.program.lookupSourceByPath(normalizedPathWithoutExtension);
|
||||
if (!source) {
|
||||
this.error(
|
||||
DiagnosticCode.File_0_not_found,
|
||||
reportNode.range, normalizedPathWithoutExtension
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.compileSource(source);
|
||||
}
|
||||
|
||||
compileSource(source: Source): void {
|
||||
var files = this.files;
|
||||
var normalizedPath = source.normalizedPath;
|
||||
if (files.has(normalizedPath)) return;
|
||||
files.add(normalizedPath);
|
||||
if (source.is(CommonFlags.COMPILED)) return;
|
||||
source.set(CommonFlags.COMPILED);
|
||||
|
||||
// compile top-level statements
|
||||
var noTreeShaking = this.options.noTreeShaking;
|
||||
@ -1294,11 +1261,11 @@ export class Compiler extends DiagnosticEmitter {
|
||||
// otherwise fall-through
|
||||
}
|
||||
default: {
|
||||
assert(false);
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
statement.range
|
||||
);
|
||||
assert(false);
|
||||
expr = module.createUnreachable();
|
||||
break;
|
||||
}
|
||||
@ -4161,7 +4128,15 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
}
|
||||
case ElementKind.FIELD: {
|
||||
if ((<Field>target).is(CommonFlags.READONLY)) {
|
||||
const declaration = (<Field>target).declaration;
|
||||
if (
|
||||
(<Field>target).is(CommonFlags.READONLY) &&
|
||||
!(
|
||||
this.currentFunction.is(CommonFlags.CONSTRUCTOR) ||
|
||||
declaration == null ||
|
||||
declaration.initializer != null
|
||||
)
|
||||
) {
|
||||
this.error(
|
||||
DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property,
|
||||
expression.range, (<Field>target).internalName
|
||||
@ -4863,7 +4838,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
var prototype = new FunctionPrototype(
|
||||
this.program,
|
||||
simpleName,
|
||||
currentFunction.internalName + "~" + simpleName,
|
||||
currentFunction.internalName + INNER_DELIMITER + simpleName,
|
||||
declaration
|
||||
);
|
||||
var instance = this.compileFunctionUsingTypeArguments(
|
||||
@ -5385,7 +5360,13 @@ export class Compiler extends DiagnosticEmitter {
|
||||
if (!classInstance) return module.createUnreachable();
|
||||
|
||||
var expr: ExpressionRef;
|
||||
|
||||
// traverse to the first matching constructor
|
||||
var currentClassInstance: Class | null = classInstance;
|
||||
var constructorInstance = classInstance.constructorInstance;
|
||||
while (!constructorInstance && (currentClassInstance = classInstance.base)) {
|
||||
constructorInstance = currentClassInstance.constructorInstance;
|
||||
}
|
||||
|
||||
// if a constructor is present, call it with a zero `this`
|
||||
if (constructorInstance) {
|
||||
|
@ -41,10 +41,7 @@ import {
|
||||
export function parseFile(text: string, path: string, isEntry: bool = false,
|
||||
parser: Parser | null = null
|
||||
): Parser {
|
||||
if (!parser) {
|
||||
parser = new Parser();
|
||||
isEntry = true;
|
||||
}
|
||||
if (!parser) parser = new Parser();
|
||||
parser.parseFile(text, path, isEntry);
|
||||
return parser;
|
||||
}
|
||||
|
@ -85,6 +85,8 @@ export const SETTER_PREFIX = "set:";
|
||||
export const INSTANCE_DELIMITER = "#";
|
||||
/** Delimiter used between class and namespace names and static members. */
|
||||
export const STATIC_DELIMITER = ".";
|
||||
/** Delimiter used between a function and its inner elements. */
|
||||
export const INNER_DELIMITER = "~";
|
||||
/** Substitution used to indicate a library directory. */
|
||||
export const LIBRARY_SUBST = "~lib";
|
||||
/** Library directory prefix. */
|
||||
@ -148,6 +150,26 @@ export class Program extends DiagnosticEmitter {
|
||||
this.sources = [];
|
||||
}
|
||||
|
||||
/** Gets a source by its exact path. */
|
||||
getSource(normalizedPath: string): Source | null {
|
||||
var sources = this.sources;
|
||||
for (let i = 0, k = sources.length; i < k; ++i) {
|
||||
let source = sources[i];
|
||||
if (source.normalizedPath == normalizedPath) return source;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Looks up the source for the specified possibly ambiguous path. */
|
||||
lookupSourceByPath(normalizedPathWithoutExtension: string): Source | null {
|
||||
return (
|
||||
this.getSource(normalizedPathWithoutExtension + ".ts") ||
|
||||
this.getSource(normalizedPathWithoutExtension + "/index.ts") ||
|
||||
this.getSource(LIBRARY_PREFIX + normalizedPathWithoutExtension + ".ts") ||
|
||||
this.getSource(LIBRARY_PREFIX + normalizedPathWithoutExtension + "/index.ts")
|
||||
);
|
||||
}
|
||||
|
||||
/** Initializes the program and its elements prior to compilation. */
|
||||
initialize(options: Options): void {
|
||||
this.options = options;
|
||||
@ -2524,21 +2546,23 @@ export class FunctionPrototype extends Element {
|
||||
/** Resolves this prototype partially by applying the specified inherited class type arguments. */
|
||||
resolvePartial(classTypeArguments: Type[] | null): FunctionPrototype | null {
|
||||
assert(this.is(CommonFlags.INSTANCE));
|
||||
assert(this.classPrototype);
|
||||
if (classTypeArguments && classTypeArguments.length) {
|
||||
let partialPrototype = new FunctionPrototype(
|
||||
var classPrototype = assert(this.classPrototype);
|
||||
|
||||
if (!(classTypeArguments && classTypeArguments.length)) return this; // no need to clone
|
||||
|
||||
var simpleName = this.simpleName;
|
||||
var partialKey = typesToString(classTypeArguments);
|
||||
var partialPrototype = new FunctionPrototype(
|
||||
this.program,
|
||||
this.simpleName,
|
||||
this.internalName,
|
||||
simpleName,
|
||||
classPrototype.internalName + "<" + partialKey + ">" + INSTANCE_DELIMITER + simpleName,
|
||||
this.declaration,
|
||||
this.classPrototype
|
||||
classPrototype
|
||||
);
|
||||
partialPrototype.flags = this.flags;
|
||||
partialPrototype.classTypeArguments = classTypeArguments;
|
||||
return partialPrototype;
|
||||
}
|
||||
return this; // no need to clone
|
||||
}
|
||||
|
||||
/** Resolves the specified type arguments prior to resolving this prototype to an instance. */
|
||||
resolveUsingTypeArguments(
|
||||
@ -3079,10 +3103,7 @@ export class ClassPrototype extends Element {
|
||||
|
||||
if (this.constructorPrototype) {
|
||||
let partialConstructor = this.constructorPrototype.resolvePartial(typeArguments); // reports
|
||||
if (partialConstructor) {
|
||||
instance.constructorInstance = partialConstructor.resolve(); // reports
|
||||
}
|
||||
// TODO: ^ doesn't know the return type, hence returns null
|
||||
if (partialConstructor) instance.constructorInstance = partialConstructor.resolve(); // reports
|
||||
}
|
||||
|
||||
if (this.instanceMembers) {
|
||||
@ -3487,7 +3508,7 @@ export class Flow {
|
||||
// scopedGlobal = new Global(
|
||||
// scopedLocal.program,
|
||||
// scopedLocal.simpleName,
|
||||
// this.currentFunction.internalName + "~" + scopedLocal.internalName,
|
||||
// this.currentFunction.internalName + INNER_DELIMITER + scopedLocal.internalName,
|
||||
// scopedLocal.type,
|
||||
// assert(scopedLocal.declaration)
|
||||
// );
|
||||
|
40
std/assembly.d.ts
vendored
40
std/assembly.d.ts
vendored
@ -273,7 +273,7 @@ declare class ArrayBuffer {
|
||||
}
|
||||
|
||||
/** Interface for a typed view on an array buffer. */
|
||||
declare interface ArrayBufferView<T> {
|
||||
interface ArrayBufferView<T> {
|
||||
[key: number]: T;
|
||||
/** The {@link ArrayBuffer} referenced by this view. */
|
||||
readonly buffer: ArrayBuffer;
|
||||
@ -283,6 +283,44 @@ declare interface ArrayBufferView<T> {
|
||||
readonly byteLength: i32;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
declare abstract class TypedArray<T> implements ArrayBufferView<T> {
|
||||
[key: number]: T;
|
||||
/** Number of bytes per element. */
|
||||
static readonly BYTES_PER_ELEMENT: usize;
|
||||
/** Constructs a new typed array. */
|
||||
constructor(length: i32);
|
||||
/** The {@link ArrayBuffer} referenced by this view. */
|
||||
readonly buffer: ArrayBuffer;
|
||||
/** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */
|
||||
readonly byteOffset: i32;
|
||||
/** The length in bytes from the start of the referenced {@link ArrayBuffer}. */
|
||||
readonly byteLength: i32;
|
||||
/** The length (in elements). */
|
||||
readonly length: i32;
|
||||
}
|
||||
|
||||
/** An array of twos-complement 8-bit signed integers. */
|
||||
declare class Int8Array extends TypedArray<i8> {}
|
||||
/** An array of 8-bit unsigned integers. */
|
||||
declare class Uint8Array extends TypedArray<u8> {}
|
||||
/** An array of twos-complement 16-bit signed integers. */
|
||||
declare class Int16Array extends TypedArray<i16> {}
|
||||
/** An array of 16-bit unsigned integers. */
|
||||
declare class Uint16Array extends TypedArray<u16> {}
|
||||
/** An array of twos-complement 32-bit signed integers. */
|
||||
declare class Int32Array extends TypedArray<i32> {}
|
||||
/** An array of 32-bit unsigned integers. */
|
||||
declare class Uint32Array extends TypedArray<u32> {}
|
||||
/** An array of twos-complement 64-bit signed integers. */
|
||||
declare class Int64Array extends TypedArray<i64> {}
|
||||
/** An array of 64-bit unsigned integers. */
|
||||
declare class Uint64Array extends TypedArray<u64> {}
|
||||
/** An array of 32-bit floating point numbers. */
|
||||
declare class Float32Array extends TypedArray<f32> {}
|
||||
/** An array of 64-bit floating point numbers. */
|
||||
declare class Float64Array extends TypedArray<f64> {}
|
||||
|
||||
/** Class representing a sequence of values of type `T`. */
|
||||
declare class Array<T> {
|
||||
[key: number]: T;
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @module std/assembly/allocator/arena
|
||||
*//***/
|
||||
|
||||
import { AL_MASK } from "./common";
|
||||
import { AL_MASK } from "../internal/allocator";
|
||||
|
||||
var startOffset: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK;
|
||||
var offset: usize = startOffset;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Buddy Memory Allocator.
|
||||
* @module stdd/assembly/allocator/buddy
|
||||
* @module std/assembly/allocator/buddy
|
||||
*//***/
|
||||
|
||||
/*
|
||||
|
@ -19,7 +19,7 @@ import {
|
||||
AL_BITS,
|
||||
AL_SIZE,
|
||||
AL_MASK
|
||||
} from "./common";
|
||||
} from "../internal/allocator";
|
||||
|
||||
const SL_BITS: u32 = 5;
|
||||
const SL_SIZE: usize = 1 << <usize>SL_BITS;
|
||||
|
@ -1,29 +1,35 @@
|
||||
import {
|
||||
defaultComparator,
|
||||
insertionSort,
|
||||
weakHeapSort
|
||||
} from "./internal/array";
|
||||
|
||||
export class Array<T> {
|
||||
|
||||
private __memory: usize;
|
||||
private __capacity: i32; // capped to [0, 0x7fffffff]
|
||||
private __length: i32; // capped to [0, __capacity]
|
||||
__memory: usize;
|
||||
__capacity: i32; // capped to [0, 0x7fffffff]
|
||||
__length: i32; // capped to [0, __capacity]
|
||||
|
||||
private __grow(newCapacity: i32): void {
|
||||
assert(newCapacity > this.__capacity);
|
||||
var oldMemory = this.__memory;
|
||||
var oldCapacity = this.__capacity;
|
||||
assert(newCapacity > oldCapacity);
|
||||
var newMemory = allocate_memory(<usize>newCapacity * sizeof<T>());
|
||||
if (this.__memory) {
|
||||
move_memory(newMemory, this.__memory, <usize>this.__capacity * sizeof<T>());
|
||||
free_memory(this.__memory);
|
||||
if (oldMemory) {
|
||||
move_memory(newMemory, oldMemory, <usize>oldCapacity * sizeof<T>());
|
||||
free_memory(oldMemory);
|
||||
}
|
||||
this.__memory = newMemory;
|
||||
this.__capacity = newCapacity;
|
||||
}
|
||||
|
||||
constructor(capacity: i32 = 0) {
|
||||
if (capacity < 0) {
|
||||
throw new RangeError("Invalid array length");
|
||||
}
|
||||
if (capacity < 0) throw new RangeError("Invalid array length");
|
||||
this.__memory = capacity
|
||||
? allocate_memory(<usize>capacity * sizeof<T>())
|
||||
: 0;
|
||||
this.__capacity = this.__length = capacity;
|
||||
this.__capacity = capacity;
|
||||
this.__length = capacity;
|
||||
}
|
||||
|
||||
every(callbackfn: (element: T, index: i32, array: Array<T>) => bool): bool {
|
||||
@ -55,103 +61,93 @@ export class Array<T> {
|
||||
}
|
||||
|
||||
set length(length: i32) {
|
||||
if (length < 0) {
|
||||
throw new RangeError("Invalid array length");
|
||||
}
|
||||
if (length > this.__capacity) {
|
||||
this.__grow(max(length, this.__capacity << 1));
|
||||
}
|
||||
if (length < 0) throw new RangeError("Invalid array length");
|
||||
if (length > this.__capacity) this.__grow(max(length, this.__capacity << 1));
|
||||
this.__length = length;
|
||||
}
|
||||
|
||||
@operator("[]")
|
||||
private __get(index: i32): T {
|
||||
if (<u32>index >= <u32>this.__capacity) {
|
||||
throw new Error("Index out of bounds"); // return changetype<T>(0) ?
|
||||
}
|
||||
if (<u32>index >= <u32>this.__capacity) throw new Error("Index out of bounds");
|
||||
return load<T>(this.__memory + <usize>index * sizeof<T>());
|
||||
}
|
||||
|
||||
@operator("[]=")
|
||||
private __set(index: i32, value: T): void {
|
||||
if (index < 0) {
|
||||
throw new Error("Index out of bounds");
|
||||
}
|
||||
if (index >= this.__capacity) {
|
||||
this.__grow(max(index + 1, this.__capacity << 1));
|
||||
}
|
||||
if (index < 0) throw new Error("Index out of bounds");
|
||||
var capacity = this.__capacity;
|
||||
if (index >= capacity) this.__grow(max(index + 1, capacity << 1));
|
||||
store<T>(this.__memory + <usize>index * sizeof<T>(), value);
|
||||
}
|
||||
|
||||
includes(searchElement: T, fromIndex: i32 = 0): bool {
|
||||
if (this.__length == 0 || fromIndex >= this.__length) {
|
||||
return false;
|
||||
}
|
||||
var length = this.__length;
|
||||
if (length == 0 || fromIndex >= length) return false;
|
||||
if (fromIndex < 0) {
|
||||
fromIndex = this.__length + fromIndex;
|
||||
fromIndex = length + fromIndex;
|
||||
if (fromIndex < 0) {
|
||||
fromIndex = 0;
|
||||
}
|
||||
}
|
||||
while (<u32>fromIndex < <u32>this.__length) {
|
||||
if (load<T>(this.__memory + <usize>fromIndex * sizeof<T>()) == searchElement) {
|
||||
return true;
|
||||
}
|
||||
while (fromIndex < length) {
|
||||
if (load<T>(this.__memory + <usize>fromIndex * sizeof<T>()) == searchElement) return true;
|
||||
++fromIndex;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
indexOf(searchElement: T, fromIndex: i32 = 0): i32 {
|
||||
if (this.__length == 0 || fromIndex >= this.__length) {
|
||||
var length = this.__length;
|
||||
if (length == 0 || fromIndex >= length) {
|
||||
return -1;
|
||||
}
|
||||
if (fromIndex < 0) {
|
||||
fromIndex = this.__length + fromIndex;
|
||||
fromIndex = length + fromIndex;
|
||||
if (fromIndex < 0) {
|
||||
fromIndex = 0;
|
||||
}
|
||||
}
|
||||
while (<u32>fromIndex < <u32>this.__length) {
|
||||
if (load<T>(this.__memory + <usize>fromIndex * sizeof<T>()) == searchElement) {
|
||||
return fromIndex;
|
||||
}
|
||||
var memory = this.__memory;
|
||||
while (fromIndex < length) {
|
||||
if (load<T>(memory + <usize>fromIndex * sizeof<T>()) == searchElement) return fromIndex;
|
||||
++fromIndex;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
lastIndexOf(searchElement: T, fromIndex: i32 = this.__length): i32 {
|
||||
if (this.__length == 0) {
|
||||
return -1;
|
||||
}
|
||||
var length = this.__length;
|
||||
if (length == 0) return -1;
|
||||
if (fromIndex < 0) {
|
||||
fromIndex = this.__length + fromIndex;
|
||||
} else if (fromIndex >= this.__length) {
|
||||
fromIndex = this.__length - 1;
|
||||
fromIndex = length + fromIndex;
|
||||
} else if (fromIndex >= length) {
|
||||
fromIndex = length - 1;
|
||||
}
|
||||
var memory = this.__memory;
|
||||
while (fromIndex >= 0) {
|
||||
if (load<T>(this.__memory + <usize>fromIndex * sizeof<T>()) == searchElement) {
|
||||
return fromIndex;
|
||||
}
|
||||
if (load<T>(memory + <usize>fromIndex * sizeof<T>()) == searchElement) return fromIndex;
|
||||
--fromIndex;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
push(element: T): i32 {
|
||||
if (this.__length == this.__capacity) {
|
||||
this.__grow(this.__capacity ? this.__capacity << 1 : 1);
|
||||
var capacity = this.__capacity;
|
||||
var length = this.__length;
|
||||
if (length == capacity) {
|
||||
this.__grow(capacity ? capacity << 1 : 1);
|
||||
}
|
||||
store<T>(this.__memory + <usize>this.__length * sizeof<T>(), element);
|
||||
return ++this.__length;
|
||||
store<T>(this.__memory + <usize>length * sizeof<T>(), element);
|
||||
this.__length = ++length;
|
||||
return length;
|
||||
}
|
||||
|
||||
pop(): T {
|
||||
if (this.__length < 1) {
|
||||
throw new RangeError("Array is empty"); // return changetype<T>(0) ?
|
||||
}
|
||||
return load<T>(this.__memory + <usize>--this.__length * sizeof<T>());
|
||||
var length = this.__length;
|
||||
if (length < 1) throw new RangeError("Array is empty");
|
||||
var element = load<T>(this.__memory + <usize>--length * sizeof<T>());
|
||||
this.__length = length;
|
||||
return element;
|
||||
}
|
||||
|
||||
reduce<U>(
|
||||
@ -161,7 +157,7 @@ export class Array<T> {
|
||||
var accumulator: U = initialValue;
|
||||
var toIndex: i32 = this.__length;
|
||||
var i: i32 = 0;
|
||||
while (i < toIndex && i < this.__length) {
|
||||
while (i < toIndex && i < /* might change */ this.__length) {
|
||||
accumulator = callbackfn(accumulator, load<T>(this.__memory + <usize>i * sizeof<T>()), i, this);
|
||||
i += 1;
|
||||
}
|
||||
@ -169,77 +165,81 @@ export class Array<T> {
|
||||
}
|
||||
|
||||
shift(): T {
|
||||
if (this.__length < 1) {
|
||||
throw new RangeError("Array is empty"); // return changetype<T>(0) ?
|
||||
}
|
||||
var element = load<T>(this.__memory);
|
||||
var length = this.__length;
|
||||
if (length < 1) throw new RangeError("Array is empty");
|
||||
var memory = this.__memory;
|
||||
var capacity = this.__capacity;
|
||||
var element = load<T>(memory);
|
||||
move_memory(
|
||||
this.__memory,
|
||||
this.__memory + sizeof<T>(),
|
||||
<usize>(this.__capacity - 1) * sizeof<T>()
|
||||
memory,
|
||||
memory + sizeof<T>(),
|
||||
<usize>(capacity - 1) * sizeof<T>()
|
||||
);
|
||||
set_memory(
|
||||
this.__memory + <usize>(this.__capacity - 1) * sizeof<T>(),
|
||||
memory + <usize>(capacity - 1) * sizeof<T>(),
|
||||
0,
|
||||
sizeof<T>()
|
||||
);
|
||||
--this.__length;
|
||||
this.__length = length - 1;
|
||||
return element;
|
||||
}
|
||||
|
||||
some(callbackfn: (element: T, index: i32, array: Array<T>) => bool): bool {
|
||||
var toIndex: i32 = this.__length;
|
||||
var i: i32 = 0;
|
||||
while (i < toIndex && i < this.__length) {
|
||||
if (callbackfn(load<T>(this.__memory + <usize>i * sizeof<T>()), i, this)) {
|
||||
return true;
|
||||
}
|
||||
while (i < toIndex && i < /* might change */ this.__length) {
|
||||
if (callbackfn(load<T>(this.__memory + <usize>i * sizeof<T>()), i, this)) return true;
|
||||
i += 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
unshift(element: T): i32 {
|
||||
var oldCapacity = this.__capacity;
|
||||
if (this.__length == oldCapacity) {
|
||||
var memory = this.__memory;
|
||||
var capacity = this.__capacity;
|
||||
var length = this.__length;
|
||||
if (this.__length == capacity) {
|
||||
// inlined __grow (avoids moving twice)
|
||||
let newCapacity: i32 = oldCapacity ? oldCapacity << 1 : 1;
|
||||
assert(newCapacity > this.__capacity);
|
||||
let newCapacity: i32 = capacity ? capacity << 1 : 1;
|
||||
assert(newCapacity > capacity);
|
||||
let newMemory = allocate_memory(<usize>newCapacity * sizeof<T>());
|
||||
if (this.__memory) {
|
||||
if (memory) {
|
||||
move_memory(
|
||||
newMemory + sizeof<T>(),
|
||||
this.__memory,
|
||||
<usize>oldCapacity * sizeof<T>()
|
||||
memory,
|
||||
<usize>capacity * sizeof<T>()
|
||||
);
|
||||
free_memory(this.__memory);
|
||||
free_memory(memory);
|
||||
}
|
||||
this.__memory = newMemory;
|
||||
this.__capacity = newCapacity;
|
||||
memory = newMemory;
|
||||
} else {
|
||||
move_memory(
|
||||
this.__memory + sizeof<T>(),
|
||||
this.__memory,
|
||||
<usize>oldCapacity * sizeof<T>()
|
||||
memory + sizeof<T>(),
|
||||
memory,
|
||||
<usize>capacity * sizeof<T>()
|
||||
);
|
||||
}
|
||||
store<T>(this.__memory, element);
|
||||
return ++this.__length;
|
||||
store<T>(memory, element);
|
||||
this.__length = ++length;
|
||||
return length;
|
||||
}
|
||||
|
||||
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Array<T> {
|
||||
var length = this.__length;
|
||||
if (begin < 0) {
|
||||
begin = this.__length + begin;
|
||||
begin = length + begin;
|
||||
if (begin < 0) {
|
||||
begin = 0;
|
||||
}
|
||||
} else if (begin > this.__length) {
|
||||
begin = this.__length;
|
||||
} else if (begin > length) {
|
||||
begin = length;
|
||||
}
|
||||
if (end < 0) {
|
||||
end = this.__length + end;
|
||||
} else if (end > this.__length) {
|
||||
end = this.__length;
|
||||
end = length + end;
|
||||
} else if (end > length) {
|
||||
end = length;
|
||||
}
|
||||
if (end < begin) {
|
||||
end = begin;
|
||||
@ -261,194 +261,52 @@ export class Array<T> {
|
||||
if (deleteCount < 1) {
|
||||
return;
|
||||
}
|
||||
var length = this.__length;
|
||||
if (start < 0) {
|
||||
start = this.__length + start;
|
||||
start = length + start;
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
} else if (start >= this.__length) {
|
||||
} else if (start >= length) {
|
||||
return;
|
||||
}
|
||||
} else if (start >= this.__length) {
|
||||
} else if (start >= length) {
|
||||
return;
|
||||
}
|
||||
deleteCount = min(deleteCount, this.__length - start);
|
||||
deleteCount = min(deleteCount, length - start);
|
||||
var memory = this.__memory;
|
||||
move_memory(
|
||||
this.__memory + <usize>start * sizeof<T>(),
|
||||
this.__memory + <usize>(start + deleteCount) * sizeof<T>(),
|
||||
memory + <usize>start * sizeof<T>(),
|
||||
memory + <usize>(start + deleteCount) * sizeof<T>(),
|
||||
<usize>deleteCount * sizeof<T>()
|
||||
);
|
||||
this.__length -= deleteCount;
|
||||
this.__length = length - deleteCount;
|
||||
}
|
||||
|
||||
reverse(): Array<T> {
|
||||
var memory = this.__memory;
|
||||
for (let front: usize = 0, back: usize = <usize>this.__length - 1; front < back; ++front, --back) {
|
||||
let temp = load<T>(this.__memory + front * sizeof<T>());
|
||||
store<T>(this.__memory + front * sizeof<T>(), load<T>(this.__memory + back * sizeof<T>()));
|
||||
store<T>(this.__memory + back * sizeof<T>(), temp);
|
||||
let temp = load<T>(memory + front * sizeof<T>());
|
||||
store<T>(memory + front * sizeof<T>(), load<T>(memory + back * sizeof<T>()));
|
||||
store<T>(memory + back * sizeof<T>(), temp);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
sort(comparator: (a: T, b: T) => i32 = createDefaultComparator<T>()): Array<T> {
|
||||
return sort<T>(this, comparator);
|
||||
}
|
||||
}
|
||||
|
||||
@unmanaged
|
||||
@sealed
|
||||
export class CArray<T> {
|
||||
|
||||
private constructor() {}
|
||||
|
||||
@operator("[]")
|
||||
private __get(index: i32): T {
|
||||
if (index < 0) {
|
||||
throw new RangeError("Index out of range");
|
||||
}
|
||||
return load<T>(changetype<usize>(this) + <usize>index * sizeof<T>());
|
||||
}
|
||||
|
||||
@operator("[]=")
|
||||
private __set(index: i32, value: T): void {
|
||||
if (index < 0) {
|
||||
throw new RangeError("Index out of range");
|
||||
}
|
||||
store<T>(changetype<usize>(this) + <usize>index * sizeof<T>(), value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal methods
|
||||
*/
|
||||
|
||||
// TODO remove this wrapper when indirect table landed
|
||||
function createDefaultComparator<T>(): (a: T, b: T) => i32 {
|
||||
return (a: T, b: T): i32 => (
|
||||
<i32>(a > b) - <i32>(a < b)
|
||||
);
|
||||
}
|
||||
|
||||
function insertionSort<T>(arr: Array<T>, comparator: (a: T, b: T) => i32): Array<T> {
|
||||
var a: T, b: T, j: i32;
|
||||
const typeShift = alignof<T>();
|
||||
|
||||
for (let i: i32 = 0, len: i32 = arr.length; i < len; i++) {
|
||||
a = load<T>(arr.__memory + (i << typeShift)); // a = <T>arr[i];
|
||||
j = i - 1;
|
||||
while (j >= 0) {
|
||||
b = load<T>(arr.__memory + (j << typeShift)); // b = <T>arr[j];
|
||||
if (comparator(a, b) < 0) {
|
||||
store<T>(arr.__memory + ((j + 1) << typeShift), b); // arr[j + 1] = b;
|
||||
j--;
|
||||
} else break;
|
||||
}
|
||||
|
||||
store<T>(arr.__memory + ((j + 1) << typeShift), a); // arr[j + 1] = a;
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
/* Weak Heap Sort implementation based on paper:
|
||||
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.1863&rep=rep1&type=pdf
|
||||
*/
|
||||
function weakHeapSort<T>(arr: Array<T>, comparator: (a: T, b: T) => i32): Array<T> {
|
||||
var len: i32 = arr.length;
|
||||
var i: i32, j: i32, y: i32, p: i32, a: T, b: T;
|
||||
|
||||
const typeShift = alignof<T>();
|
||||
const intShift = alignof<i32>();
|
||||
|
||||
var blen = (len + 7) >> 3;
|
||||
var bitset = allocate_memory(blen << intShift);
|
||||
|
||||
set_memory(bitset, 0, blen << intShift);
|
||||
|
||||
for (i = len - 1; i > 0; i--) {
|
||||
j = i;
|
||||
while ((j & 1) == ((load<i32>(bitset + ((j >> 4) << intShift)) >> ((j >> 1) & 7)) & 1)) {
|
||||
j >>= 1;
|
||||
}
|
||||
|
||||
p = j >> 1;
|
||||
|
||||
a = load<T>(arr.__memory + (p << typeShift)); // a = <T>arr[p];
|
||||
b = load<T>(arr.__memory + (i << typeShift)); // b = <T>arr[i];
|
||||
|
||||
if (comparator(a, b) < 0) {
|
||||
store<i32>(
|
||||
bitset + ((i >> 3) << intShift),
|
||||
load<i32>(bitset + ((i >> 3) << intShift)) ^ (1 << (i & 7))
|
||||
);
|
||||
store<T>(arr.__memory + (i << typeShift), a); // arr[i] = a;
|
||||
store<T>(arr.__memory + (p << typeShift), b); // arr[p] = b;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = len - 1; i >= 2; i--) {
|
||||
/*
|
||||
a = <T>arr[0];
|
||||
arr[0] = <T>arr[i];
|
||||
arr[i] = a;
|
||||
*/
|
||||
a = load<T>(arr.__memory, 0);
|
||||
store<T>(arr.__memory, load<T>(arr.__memory + (i << typeShift)), 0);
|
||||
store<T>(arr.__memory + (i << typeShift), a);
|
||||
|
||||
let x = 1;
|
||||
while ((y = (x << 1) + ((load<i32>(bitset + ((x >> 3) << intShift)) >> (x & 7)) & 1)) < i) {
|
||||
x = y;
|
||||
}
|
||||
|
||||
while (x > 0) {
|
||||
a = load<T>(arr.__memory, 0); // a = <T>arr[0];
|
||||
b = load<T>(arr.__memory + (x << typeShift)); // b = <T>arr[x];
|
||||
|
||||
if (comparator(a, b) < 0) {
|
||||
store<i32>(
|
||||
bitset + ((x >> 3) << intShift),
|
||||
load<i32>(bitset + ((x >> 3) << intShift)) ^ (1 << (x & 7))
|
||||
);
|
||||
|
||||
store<T>(arr.__memory + (x << typeShift), a); // arr[x] = a;
|
||||
store<T>(arr.__memory, b, 0); // arr[0] = b;
|
||||
}
|
||||
x >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
free_memory(bitset);
|
||||
|
||||
/*
|
||||
let t = <T>arr[1];
|
||||
arr[1] = <T>arr[0];
|
||||
arr[0] = t;
|
||||
*/
|
||||
var t = load<T>(arr.__memory, sizeof<T>());
|
||||
store<T>(arr.__memory, load<T>(arr.__memory, 0), sizeof<T>());
|
||||
store<T>(arr.__memory, t, 0);
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function sort<T>(arr: Array<T>, comparator: (a: T, b: T) => i32): Array<T> {
|
||||
var len = arr.length;
|
||||
|
||||
if (len <= 1) return arr;
|
||||
|
||||
sort(comparator: (a: T, b: T) => i32 = defaultComparator<T>()): Array<T> {
|
||||
var len = this.length;
|
||||
if (len <= 1) return this;
|
||||
if (len == 2) {
|
||||
let a = load<T>(arr.__memory, sizeof<T>()); // var a = <T>arr[1];
|
||||
let b = load<T>(arr.__memory, 0); // var b = <T>arr[0];
|
||||
let memory = this.__memory;
|
||||
let a = load<T>(memory, sizeof<T>()); // var a = <T>arr[1];
|
||||
let b = load<T>(memory, 0); // var b = <T>arr[0];
|
||||
if (comparator(a, b) < 0) {
|
||||
store<T>(arr.__memory, b, sizeof<T>()); // arr[1] = b;
|
||||
store<T>(arr.__memory, a, 0); // arr[0] = a;
|
||||
store<T>(memory, b, sizeof<T>()); // arr[1] = b;
|
||||
store<T>(memory, a, 0); // arr[0] = a;
|
||||
}
|
||||
return arr;
|
||||
return this;
|
||||
}
|
||||
|
||||
if (len <= 256) {
|
||||
return insertionSort<T>(arr, comparator);
|
||||
return len <= 256
|
||||
? insertionSort<T>(this, comparator)
|
||||
: weakHeapSort<T>(this, comparator);
|
||||
}
|
||||
|
||||
return weakHeapSort<T>(arr, comparator);
|
||||
}
|
||||
|
@ -1,38 +1,30 @@
|
||||
const HEADER_SIZE: usize = sizeof<i32>();
|
||||
import {
|
||||
HEADER_SIZE,
|
||||
MAX_BLENGTH,
|
||||
allocate
|
||||
} from "./internal/arraybuffer";
|
||||
|
||||
@sealed
|
||||
export class ArrayBuffer {
|
||||
|
||||
readonly byteLength: i32; // capped to [0, 0x7fffffff]
|
||||
readonly byteLength: i32; // capped to [0, MAX_LENGTH]
|
||||
|
||||
constructor(length: i32) {
|
||||
if (<u32>length > 0x7fffffff) throw new RangeError("Invalid array buffer length");
|
||||
var buffer = allocate_memory(HEADER_SIZE + <usize>length);
|
||||
store<i32>(buffer, length);
|
||||
return changetype<ArrayBuffer>(buffer);
|
||||
if (<u32>length > <u32>MAX_BLENGTH) throw new RangeError("Invalid array buffer length");
|
||||
var buffer = allocate(length);
|
||||
set_memory(changetype<usize>(buffer) + HEADER_SIZE, 0, <usize>length);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
slice(begin: i32 = 0, end: i32 = 0x7fffffff): ArrayBuffer {
|
||||
slice(begin: i32 = 0, end: i32 = MAX_BLENGTH): ArrayBuffer {
|
||||
var len = this.byteLength;
|
||||
if (begin < 0) begin = max(len + begin, 0);
|
||||
else begin = min(begin, len);
|
||||
if (end < 0) end = max(len + end, 0);
|
||||
else end = min(end, len);
|
||||
var newLen = max(end - begin, 0);
|
||||
var buffer = allocate_memory(HEADER_SIZE + <usize>newLen);
|
||||
store<i32>(buffer, newLen);
|
||||
move_memory(buffer + HEADER_SIZE, changetype<usize>(this) + HEADER_SIZE + begin, newLen);
|
||||
return changetype<ArrayBuffer>(buffer);
|
||||
var buffer = allocate(newLen);
|
||||
move_memory(changetype<usize>(buffer) + HEADER_SIZE, changetype<usize>(this) + HEADER_SIZE + begin, newLen);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// TODO: built-in isView?
|
||||
// TODO: built-in transfer?
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export declare interface ArrayBufferView<T> {
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly byteOffset: i32;
|
||||
readonly byteLength: i32;
|
||||
readonly length: i32;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
export class Error {
|
||||
|
||||
name: string = "Error";
|
||||
message: string;
|
||||
stack: string = ""; // TODO
|
||||
|
||||
@ -9,10 +8,5 @@ export class Error {
|
||||
}
|
||||
}
|
||||
|
||||
export class RangeError extends Error {
|
||||
name: string = "RangeError";
|
||||
}
|
||||
|
||||
export class TypeError extends Error {
|
||||
name: string = "TypeError";
|
||||
}
|
||||
export class RangeError extends Error {}
|
||||
export class TypeError extends Error {}
|
||||
|
@ -1,8 +1,3 @@
|
||||
/**
|
||||
* Shared allocator constants.
|
||||
* @module std/assembly/allocator/common
|
||||
*//***/
|
||||
|
||||
/** Number of alignment bits. */
|
||||
export const AL_BITS: u32 = 3;
|
||||
|
109
std/assembly/internal/array.ts
Normal file
109
std/assembly/internal/array.ts
Normal file
@ -0,0 +1,109 @@
|
||||
import { Array } from "../array";
|
||||
|
||||
/** Obtains the default comparator for the specified type. */
|
||||
export function defaultComparator<T>(): (a: T, b: T) => i32 {
|
||||
return (a: T, b: T): i32 => (<i32>(a > b) - <i32>(a < b)); // compiles to a constant function index
|
||||
}
|
||||
|
||||
/** Sorts an Array with the 'Insertion Sort' algorithm. */
|
||||
export function insertionSort<T>(arr: Array<T>, comparator: (a: T, b: T) => i32): Array<T> {
|
||||
var a: T, b: T, j: i32;
|
||||
const typeShift = alignof<T>();
|
||||
|
||||
for (let i: i32 = 0, len: i32 = arr.length; i < len; i++) {
|
||||
a = load<T>(arr.__memory + (i << typeShift)); // a = <T>arr[i];
|
||||
j = i - 1;
|
||||
while (j >= 0) {
|
||||
b = load<T>(arr.__memory + (j << typeShift)); // b = <T>arr[j];
|
||||
if (comparator(a, b) < 0) {
|
||||
store<T>(arr.__memory + ((j + 1) << typeShift), b); // arr[j + 1] = b;
|
||||
j--;
|
||||
} else break;
|
||||
}
|
||||
|
||||
store<T>(arr.__memory + ((j + 1) << typeShift), a); // arr[j + 1] = a;
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
/** Sorts an Array with the 'Weak Heap Sort' algorithm. */
|
||||
export function weakHeapSort<T>(arr: Array<T>, comparator: (a: T, b: T) => i32): Array<T> {
|
||||
// see: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.1863&rep=rep1&type=pdf
|
||||
var len: i32 = arr.length;
|
||||
var i: i32, j: i32, y: i32, p: i32, a: T, b: T;
|
||||
|
||||
const typeShift = alignof<T>();
|
||||
const intShift = alignof<i32>();
|
||||
|
||||
var blen = (len + 7) >> 3;
|
||||
var bitset = allocate_memory(blen << intShift);
|
||||
|
||||
set_memory(bitset, 0, blen << intShift);
|
||||
|
||||
for (i = len - 1; i > 0; i--) {
|
||||
j = i;
|
||||
while ((j & 1) == ((load<i32>(bitset + ((j >> 4) << intShift)) >> ((j >> 1) & 7)) & 1)) {
|
||||
j >>= 1;
|
||||
}
|
||||
|
||||
p = j >> 1;
|
||||
|
||||
a = load<T>(arr.__memory + (p << typeShift)); // a = <T>arr[p];
|
||||
b = load<T>(arr.__memory + (i << typeShift)); // b = <T>arr[i];
|
||||
|
||||
if (comparator(a, b) < 0) {
|
||||
store<i32>(
|
||||
bitset + ((i >> 3) << intShift),
|
||||
load<i32>(bitset + ((i >> 3) << intShift)) ^ (1 << (i & 7))
|
||||
);
|
||||
store<T>(arr.__memory + (i << typeShift), a); // arr[i] = a;
|
||||
store<T>(arr.__memory + (p << typeShift), b); // arr[p] = b;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = len - 1; i >= 2; i--) {
|
||||
/*
|
||||
a = <T>arr[0];
|
||||
arr[0] = <T>arr[i];
|
||||
arr[i] = a;
|
||||
*/
|
||||
a = load<T>(arr.__memory, 0);
|
||||
store<T>(arr.__memory, load<T>(arr.__memory + (i << typeShift)), 0);
|
||||
store<T>(arr.__memory + (i << typeShift), a);
|
||||
|
||||
let x = 1;
|
||||
while ((y = (x << 1) + ((load<i32>(bitset + ((x >> 3) << intShift)) >> (x & 7)) & 1)) < i) {
|
||||
x = y;
|
||||
}
|
||||
|
||||
while (x > 0) {
|
||||
a = load<T>(arr.__memory, 0); // a = <T>arr[0];
|
||||
b = load<T>(arr.__memory + (x << typeShift)); // b = <T>arr[x];
|
||||
|
||||
if (comparator(a, b) < 0) {
|
||||
store<i32>(
|
||||
bitset + ((x >> 3) << intShift),
|
||||
load<i32>(bitset + ((x >> 3) << intShift)) ^ (1 << (x & 7))
|
||||
);
|
||||
|
||||
store<T>(arr.__memory + (x << typeShift), a); // arr[x] = a;
|
||||
store<T>(arr.__memory, b, 0); // arr[0] = b;
|
||||
}
|
||||
x >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
free_memory(bitset);
|
||||
|
||||
/*
|
||||
let t = <T>arr[1];
|
||||
arr[1] = <T>arr[0];
|
||||
arr[0] = t;
|
||||
*/
|
||||
var t = load<T>(arr.__memory, sizeof<T>());
|
||||
store<T>(arr.__memory, load<T>(arr.__memory, 0), sizeof<T>());
|
||||
store<T>(arr.__memory, t, 0);
|
||||
|
||||
return arr;
|
||||
}
|
34
std/assembly/internal/arraybuffer.ts
Normal file
34
std/assembly/internal/arraybuffer.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { AL_MASK, MAX_SIZE_32 } from "./allocator";
|
||||
|
||||
/** Size of an ArrayBuffer header. */
|
||||
export const HEADER_SIZE: usize = (offsetof<ArrayBuffer>() + AL_MASK) & ~AL_MASK;
|
||||
|
||||
/** Maximum byte length of an ArrayBuffer. */
|
||||
export const MAX_BLENGTH: i32 = <i32>MAX_SIZE_32 - HEADER_SIZE;
|
||||
|
||||
/** Computes an ArrayBuffer's size in memory. */
|
||||
export function computeSize(byteLength: i32): usize {
|
||||
// round up to power of 2, with HEADER_SIZE=8:
|
||||
// 0 -> 2^3 = 8
|
||||
// 1..8 -> 2^4 = 16
|
||||
// 9..24 -> 2^5 = 32
|
||||
// ...
|
||||
// MAX_LENGTH -> 2^30 = 0x40000000 (MAX_SIZE_32)
|
||||
return <usize>1 << <usize>(<u32>32 - clz<u32>(byteLength + HEADER_SIZE - 1));
|
||||
}
|
||||
|
||||
/** Allocates a raw ArrayBuffer with uninitialized contents. */
|
||||
export function allocate(byteLength: i32): ArrayBuffer {
|
||||
assert(<u32>byteLength <= <u32>MAX_BLENGTH);
|
||||
var buffer = allocate_memory(computeSize(byteLength));
|
||||
store<i32>(buffer, byteLength, offsetof<ArrayBuffer>("byteLength"));
|
||||
return changetype<ArrayBuffer>(buffer);
|
||||
}
|
||||
|
||||
/** Common typed array interface. Not a global object. */
|
||||
// export declare interface ArrayBufferView<T> {
|
||||
// readonly buffer: ArrayBuffer;
|
||||
// readonly byteOffset: i32;
|
||||
// readonly byteLength: i32;
|
||||
// readonly length: i32;
|
||||
// }
|
149
std/assembly/internal/string.ts
Normal file
149
std/assembly/internal/string.ts
Normal file
@ -0,0 +1,149 @@
|
||||
import {
|
||||
MAX_SIZE_32
|
||||
} from "./allocator";
|
||||
|
||||
import {
|
||||
String
|
||||
} from "../string";
|
||||
|
||||
/** Size of a String header. */
|
||||
export const HEADER_SIZE = (offsetof<String>() + 1) & ~1; // 2 byte aligned
|
||||
|
||||
/** Maximum length of a String. */
|
||||
export const MAX_LENGTH = (<i32>MAX_SIZE_32 - HEADER_SIZE) >>> 1;
|
||||
|
||||
/** Singleton empty String. */
|
||||
export const EMPTY = changetype<String>(""); // TODO: is this a bad idea with '===' in place?
|
||||
|
||||
/** Allocates a raw String with uninitialized contents. */
|
||||
export function allocate(length: i32): String {
|
||||
assert(length > 0 && length <= MAX_LENGTH);
|
||||
var buffer = allocate_memory(HEADER_SIZE + (<usize>length << 1));
|
||||
store<i32>(buffer, length);
|
||||
return changetype<String>(buffer);
|
||||
}
|
||||
|
||||
export function isWhiteSpaceOrLineTerminator(c: u16): bool {
|
||||
switch (c) {
|
||||
case 10: // <LF>
|
||||
case 13: // <CR>
|
||||
case 8232: // <LS>
|
||||
case 8233: // <PS>
|
||||
case 9: // <TAB>
|
||||
case 11: // <VT>
|
||||
case 12: // <FF>
|
||||
case 32: // <SP>
|
||||
case 160: // <NBSP>
|
||||
case 65279: { // <ZWNBSP>
|
||||
return true;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const enum CharCode {
|
||||
PLUS = 0x2B,
|
||||
MINUS = 0x2D,
|
||||
DOT = 0x2E,
|
||||
_0 = 0x30,
|
||||
_1 = 0x31,
|
||||
_2 = 0x32,
|
||||
_3 = 0x33,
|
||||
_4 = 0x34,
|
||||
_5 = 0x35,
|
||||
_6 = 0x36,
|
||||
_7 = 0x37,
|
||||
_8 = 0x38,
|
||||
_9 = 0x39,
|
||||
A = 0x41,
|
||||
B = 0x42,
|
||||
E = 0x45,
|
||||
O = 0x4F,
|
||||
X = 0x58,
|
||||
Z = 0x5a,
|
||||
a = 0x61,
|
||||
b = 0x62,
|
||||
e = 0x65,
|
||||
o = 0x6F,
|
||||
x = 0x78,
|
||||
z = 0x7A
|
||||
}
|
||||
|
||||
export function parse<T>(str: String, radix: i32 = 0): T {
|
||||
var len: i32 = str.length;
|
||||
if (!len) {
|
||||
return <T>NaN;
|
||||
}
|
||||
var ptr = changetype<usize>(str) /* + HEAD -> offset */;
|
||||
var code = <i32>load<u16>(ptr, HEADER_SIZE);
|
||||
|
||||
// determine sign
|
||||
var sign: T;
|
||||
if (code == CharCode.MINUS) {
|
||||
if (!--len) {
|
||||
return <T>NaN;
|
||||
}
|
||||
code = <i32>load<u16>(ptr += 2, HEADER_SIZE);
|
||||
sign = -1;
|
||||
} else if (code == CharCode.PLUS) {
|
||||
if (!--len) {
|
||||
return <T>NaN;
|
||||
}
|
||||
code = <i32>load<u16>(ptr += 2, HEADER_SIZE);
|
||||
sign = 1;
|
||||
} else {
|
||||
sign = 1;
|
||||
}
|
||||
|
||||
// determine radix
|
||||
if (!radix) {
|
||||
if (code == CharCode._0 && len > 2) {
|
||||
switch (<i32>load<u16>(ptr + 2, HEADER_SIZE)) {
|
||||
case CharCode.B:
|
||||
case CharCode.b: {
|
||||
ptr += 4; len -= 2;
|
||||
radix = 2;
|
||||
break;
|
||||
}
|
||||
case CharCode.O:
|
||||
case CharCode.o: {
|
||||
ptr += 4; len -= 2;
|
||||
radix = 8;
|
||||
break;
|
||||
}
|
||||
case CharCode.X:
|
||||
case CharCode.x: {
|
||||
ptr += 4; len -= 2;
|
||||
radix = 16;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
radix = 10;
|
||||
}
|
||||
}
|
||||
} else radix = 10;
|
||||
} else if (radix < 2 || radix > 36) {
|
||||
return <T>NaN;
|
||||
}
|
||||
|
||||
// calculate value
|
||||
var num: T = 0;
|
||||
while (len--) {
|
||||
code = <i32>load<u16>(ptr, HEADER_SIZE);
|
||||
if (code >= CharCode._0 && code <= CharCode._9) {
|
||||
code -= CharCode._0;
|
||||
} else if (code >= CharCode.A && code <= CharCode.Z) {
|
||||
code -= CharCode.A - 10;
|
||||
} else if (code >= CharCode.a && code <= CharCode.z) {
|
||||
code -= CharCode.a - 10;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (code >= radix) {
|
||||
break;
|
||||
}
|
||||
num = (num * radix) + code;
|
||||
ptr += 2;
|
||||
}
|
||||
return sign * num;
|
||||
}
|
34
std/assembly/internal/typedarray.ts
Normal file
34
std/assembly/internal/typedarray.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import {
|
||||
MAX_BLENGTH,
|
||||
allocate
|
||||
// ArrayBufferView
|
||||
} from "./arraybuffer";
|
||||
|
||||
/** Typed array base class. Not a global object. */
|
||||
export abstract class TypedArray<T> /* implements ArrayBufferView<T> */ {
|
||||
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly byteOffset: i32;
|
||||
readonly byteLength: i32;
|
||||
|
||||
constructor(length: i32) {
|
||||
const MAX_LENGTH = <u32>MAX_BLENGTH / sizeof<T>();
|
||||
if (<u32>length > MAX_LENGTH) throw new RangeError("Invalid typed array length");
|
||||
var byteLength = length << alignof<T>();
|
||||
this.buffer = allocate(byteLength);
|
||||
this.byteOffset = 0;
|
||||
this.byteLength = byteLength;
|
||||
}
|
||||
|
||||
get length(): i32 {
|
||||
return this.byteLength >> alignof<T>();
|
||||
}
|
||||
|
||||
// @operator("[]") - maybe injected through ArrayBufferView?
|
||||
|
||||
// @operator("[]=") - maybe injected through ArrayBufferView?
|
||||
|
||||
// copyWithin(target: i32, start: i32, end: i32 = 0x7fffffff): TypedArray<T>
|
||||
|
||||
// subarray(begin: i32 = 0, end: i32 = 0x7fffffff): TypedArray<T>
|
||||
}
|
@ -1,20 +1,17 @@
|
||||
// singleton empty string
|
||||
const EMPTY: String = changetype<String>("");
|
||||
|
||||
// number of bytes preceeding string data
|
||||
const HEADER_SIZE: usize = 4;
|
||||
|
||||
function allocate(length: i32): String {
|
||||
assert(length > 0); // 0 -> EMPTY
|
||||
var ptr = allocate_memory(HEADER_SIZE + (<usize>length << 1));
|
||||
store<i32>(ptr, length);
|
||||
return changetype<String>(ptr);
|
||||
}
|
||||
import {
|
||||
HEADER_SIZE,
|
||||
MAX_LENGTH,
|
||||
EMPTY,
|
||||
allocate,
|
||||
isWhiteSpaceOrLineTerminator,
|
||||
CharCode,
|
||||
parse
|
||||
} from "./internal/string";
|
||||
|
||||
@sealed
|
||||
export class String {
|
||||
|
||||
readonly length: i32; // capped to [0, 0x7fffffff]
|
||||
readonly length: i32; // capped to [0, MAX_LENGTH]
|
||||
|
||||
@operator("[]")
|
||||
charAt(pos: i32): String {
|
||||
@ -97,7 +94,7 @@ export class String {
|
||||
return out;
|
||||
}
|
||||
|
||||
endsWith(searchString: String, endPosition: i32 = 0x7fffffff): bool {
|
||||
endsWith(searchString: String, endPosition: i32 = MAX_LENGTH): bool {
|
||||
assert(this !== null);
|
||||
if (searchString === null) return false;
|
||||
var end: isize = <isize>min(max(endPosition, 0), this.length);
|
||||
@ -382,52 +379,6 @@ export class String {
|
||||
}
|
||||
}
|
||||
|
||||
function isWhiteSpaceOrLineTerminator(c: u16): bool {
|
||||
switch (c) {
|
||||
case 10: // <LF>
|
||||
case 13: // <CR>
|
||||
case 8232: // <LS>
|
||||
case 8233: // <PS>
|
||||
case 9: // <TAB>
|
||||
case 11: // <VT>
|
||||
case 12: // <FF>
|
||||
case 32: // <SP>
|
||||
case 160: // <NBSP>
|
||||
case 65279: { // <ZWNBSP>
|
||||
return true;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
const enum CharCode {
|
||||
PLUS = 0x2B,
|
||||
MINUS = 0x2D,
|
||||
DOT = 0x2E,
|
||||
_0 = 0x30,
|
||||
_1 = 0x31,
|
||||
_2 = 0x32,
|
||||
_3 = 0x33,
|
||||
_4 = 0x34,
|
||||
_5 = 0x35,
|
||||
_6 = 0x36,
|
||||
_7 = 0x37,
|
||||
_8 = 0x38,
|
||||
_9 = 0x39,
|
||||
A = 0x41,
|
||||
B = 0x42,
|
||||
E = 0x45,
|
||||
O = 0x4F,
|
||||
X = 0x58,
|
||||
Z = 0x5a,
|
||||
a = 0x61,
|
||||
b = 0x62,
|
||||
e = 0x65,
|
||||
o = 0x6F,
|
||||
x = 0x78,
|
||||
z = 0x7A
|
||||
}
|
||||
|
||||
export function parseInt(str: String, radix: i32 = 0): f64 {
|
||||
return parse<f64>(str, radix);
|
||||
}
|
||||
@ -440,85 +391,6 @@ export function parseI64(str: String, radix: i32 = 0): i64 {
|
||||
return parse<i64>(str, radix);
|
||||
}
|
||||
|
||||
function parse<T>(str: String, radix: i32 = 0): T {
|
||||
var len: i32 = str.length;
|
||||
if (!len) {
|
||||
return <T>NaN;
|
||||
}
|
||||
var ptr = changetype<usize>(str) /* + HEAD -> offset */;
|
||||
var code = <i32>load<u16>(ptr, HEADER_SIZE);
|
||||
|
||||
// determine sign
|
||||
var sign: T;
|
||||
if (code == CharCode.MINUS) {
|
||||
if (!--len) {
|
||||
return <T>NaN;
|
||||
}
|
||||
code = <i32>load<u16>(ptr += 2, HEADER_SIZE);
|
||||
sign = -1;
|
||||
} else if (code == CharCode.PLUS) {
|
||||
if (!--len) {
|
||||
return <T>NaN;
|
||||
}
|
||||
code = <i32>load<u16>(ptr += 2, HEADER_SIZE);
|
||||
sign = 1;
|
||||
} else {
|
||||
sign = 1;
|
||||
}
|
||||
|
||||
// determine radix
|
||||
if (!radix) {
|
||||
if (code == CharCode._0 && len > 2) {
|
||||
switch (<i32>load<u16>(ptr + 2, HEADER_SIZE)) {
|
||||
case CharCode.B:
|
||||
case CharCode.b: {
|
||||
ptr += 4; len -= 2;
|
||||
radix = 2;
|
||||
break;
|
||||
}
|
||||
case CharCode.O:
|
||||
case CharCode.o: {
|
||||
ptr += 4; len -= 2;
|
||||
radix = 8;
|
||||
break;
|
||||
}
|
||||
case CharCode.X:
|
||||
case CharCode.x: {
|
||||
ptr += 4; len -= 2;
|
||||
radix = 16;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
radix = 10;
|
||||
}
|
||||
}
|
||||
} else radix = 10;
|
||||
} else if (radix < 2 || radix > 36) {
|
||||
return <T>NaN;
|
||||
}
|
||||
|
||||
// calculate value
|
||||
var num: T = 0;
|
||||
while (len--) {
|
||||
code = <i32>load<u16>(ptr, HEADER_SIZE);
|
||||
if (code >= CharCode._0 && code <= CharCode._9) {
|
||||
code -= CharCode._0;
|
||||
} else if (code >= CharCode.A && code <= CharCode.Z) {
|
||||
code -= CharCode.A - 10;
|
||||
} else if (code >= CharCode.a && code <= CharCode.z) {
|
||||
code -= CharCode.a - 10;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (code >= radix) {
|
||||
break;
|
||||
}
|
||||
num = (num * radix) + code;
|
||||
ptr += 2;
|
||||
}
|
||||
return sign * num;
|
||||
}
|
||||
|
||||
// FIXME: naive implementation
|
||||
export function parseFloat(str: String): f64 {
|
||||
var len: i32 = str.length;
|
||||
|
@ -1,67 +1,43 @@
|
||||
/** @internal */
|
||||
abstract class TypedArray<T> /* implements ArrayBufferView<T> */ {
|
||||
import {
|
||||
TypedArray
|
||||
} from "./internal/typedarray";
|
||||
|
||||
readonly buffer: ArrayBuffer;
|
||||
readonly byteOffset: i32;
|
||||
readonly byteLength: i32;
|
||||
get length(): i32 { return this.byteLength >> alignof<T>(); }
|
||||
|
||||
constructor(length: i32) {
|
||||
const maxLength = <u32>0x7fffffff >> alignof<T>();
|
||||
if (<u32>length > maxLength) throw new RangeError("Invalid typed array length");
|
||||
var byteLength = length << alignof<T>();
|
||||
this.buffer = new ArrayBuffer(byteLength);
|
||||
this.byteOffset = 0;
|
||||
this.byteLength = byteLength;
|
||||
}
|
||||
export class Int8Array extends TypedArray<i8> {
|
||||
static readonly BYTES_PER_ELEMENT: usize = sizeof<i8>();
|
||||
}
|
||||
|
||||
// export class Int8Array extends TypedArray<i8> {
|
||||
// static readonly BYTES_PER_ELEMENT: usize = sizeof<i8>();
|
||||
// static readonly name: string = "Int8Array";
|
||||
// }
|
||||
export class Uint8Array extends TypedArray<u8> {
|
||||
static readonly BYTES_PER_ELEMENT: usize = sizeof<u8>();
|
||||
}
|
||||
|
||||
// export class Uint8Array extends TypedArray<u8> {
|
||||
// static readonly BYTES_PER_ELEMENT: usize = sizeof<u8>();
|
||||
// static readonly name: string = "Uint8Array";
|
||||
// }
|
||||
export class Int16Array extends TypedArray<i16> {
|
||||
static readonly BYTES_PER_ELEMENT: usize = sizeof<i16>();
|
||||
}
|
||||
|
||||
// export class Int16Array extends TypedArray<i16> {
|
||||
// static readonly BYTES_PER_ELEMENT: usize = sizeof<i16>();
|
||||
// static readonly name: string = "Int16Array";
|
||||
// }
|
||||
export class Uint16Array extends TypedArray<u16> {
|
||||
static readonly BYTES_PER_ELEMENT: usize = sizeof<u16>();
|
||||
}
|
||||
|
||||
// export class Uint16Array extends TypedArray<u16> {
|
||||
// static readonly BYTES_PER_ELEMENT: usize = sizeof<u16>();
|
||||
// static readonly name: string = "Uint16Array";
|
||||
// }
|
||||
export class Int32Array extends TypedArray<i32> {
|
||||
static readonly BYTES_PER_ELEMENT: usize = sizeof<i32>();
|
||||
}
|
||||
|
||||
// export class Int32Array extends TypedArray<i32> {
|
||||
// static readonly BYTES_PER_ELEMENT: usize = sizeof<i32>();
|
||||
// static readonly name: string = "Int32Array";
|
||||
// }
|
||||
export class Uint32Array extends TypedArray<u32> {
|
||||
static readonly BYTES_PER_ELEMENT: usize = sizeof<u32>();
|
||||
}
|
||||
|
||||
// export class Uint32Array extends TypedArray<u32> {
|
||||
// static readonly BYTES_PER_ELEMENT: usize = sizeof<u32>();
|
||||
// static readonly name: string = "Uint32Array";
|
||||
// }
|
||||
export class Int64Array extends TypedArray<i64> {
|
||||
static readonly BYTES_PER_ELEMENT: usize = sizeof<i64>();
|
||||
}
|
||||
|
||||
// export class Int64Array extends TypedArray<i64> {
|
||||
// static readonly BYTES_PER_ELEMENT: usize = sizeof<i64>();
|
||||
// static readonly name: string = "Int64Array";
|
||||
// }
|
||||
export class Uint64Array extends TypedArray<u64> {
|
||||
static readonly BYTES_PER_ELEMENT: usize = sizeof<u64>();
|
||||
}
|
||||
|
||||
// export class Uint64Array extends TypedArray<u64> {
|
||||
// static readonly BYTES_PER_ELEMENT: usize = sizeof<u64>();
|
||||
// static readonly name: string = "Uint64Array";
|
||||
// }
|
||||
export class Float32Array extends TypedArray<f32> {
|
||||
static readonly BYTES_PER_ELEMENT: usize = sizeof<f32>();
|
||||
}
|
||||
|
||||
// export class Float32Array extends TypedArray<f32> {
|
||||
// static readonly BYTES_PER_ELEMENT: usize = sizeof<f32>();
|
||||
// static readonly name: string = "Float32Array";
|
||||
// }
|
||||
|
||||
// export class Float64Array extends TypedArray<f64> {
|
||||
// static readonly BYTES_PER_ELEMENT: usize = sizeof<f64>();
|
||||
// static readonly name: string = "Float64Array";
|
||||
// }
|
||||
export class Float64Array extends TypedArray<f64> {
|
||||
static readonly BYTES_PER_ELEMENT: usize = sizeof<f64>();
|
||||
}
|
||||
|
@ -7,10 +7,10 @@
|
||||
(type $iv (func (param i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $~lib/allocator/common/index/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/allocator/common/index/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/allocator/common/index/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/allocator/common/index/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/internal/allocator/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(global $std/allocator_arena/size i32 (i32.const 42))
|
||||
|
@ -125,7 +125,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 235)
|
||||
(i32.const 232)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -5,7 +5,7 @@
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $~lib/string/HEADER_SIZE i32 (i32.const 4))
|
||||
(global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4))
|
||||
(global $argumentCount (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 52))
|
||||
(memory $0 1)
|
||||
@ -195,7 +195,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 235)
|
||||
(i32.const 232)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -2080,24 +2080,33 @@
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__grow (; 9 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.le_s
|
||||
(get_local $1)
|
||||
(tee_local $4
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 60)
|
||||
(i32.const 9)
|
||||
(i32.const 16)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $3
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
@ -2106,32 +2115,24 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(block
|
||||
(call $~lib/memory/move_memory
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $4)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(call $~lib/allocator/arena/free_memory
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
@ -2140,28 +2141,29 @@
|
||||
)
|
||||
(func $~lib/array/Array<i32>#push (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
(i32.eq
|
||||
(tee_local $2
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(tee_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $~lib/array/Array<i32>#__grow
|
||||
(get_local $0)
|
||||
(if (result i32)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(select
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2171,9 +2173,7 @@
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.shl
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
@ -2183,9 +2183,7 @@
|
||||
(get_local $0)
|
||||
(tee_local $2
|
||||
(i32.add
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -2216,50 +2214,64 @@
|
||||
)
|
||||
(func $~lib/array/Array<i32>#pop (; 12 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(tee_local $1
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(block (result i32)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(tee_local $1
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#unshift (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(tee_local $2
|
||||
(tee_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
@ -2268,106 +2280,93 @@
|
||||
(block
|
||||
(if
|
||||
(i32.le_s
|
||||
(tee_local $4
|
||||
(tee_local $6
|
||||
(select
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 60)
|
||||
(i32.const 207)
|
||||
(i32.const 204)
|
||||
(i32.const 6)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(set_local $5
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.shl
|
||||
(get_local $4)
|
||||
(get_local $6)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(block
|
||||
(call $~lib/memory/move_memory
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(get_local $5)
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(call $~lib/allocator/arena/free_memory
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $3)
|
||||
(get_local $5)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(get_local $4)
|
||||
(get_local $6)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
(call $~lib/memory/move_memory
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
)
|
||||
(func $~lib/memory/set_memory (; 14 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i64)
|
||||
@ -2704,37 +2703,42 @@
|
||||
)
|
||||
(func $~lib/array/Array<i32>#shift (; 15 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(tee_local $2
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $1
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(tee_local $1
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $~lib/memory/move_memory
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.shl
|
||||
(i32.sub
|
||||
(tee_local $4
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 2)
|
||||
@ -2742,14 +2746,10 @@
|
||||
)
|
||||
(call $~lib/memory/set_memory
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.shl
|
||||
(i32.sub
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 2)
|
||||
@ -2761,18 +2761,22 @@
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(get_local $3)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#reverse (; 16 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
@ -2788,52 +2792,44 @@
|
||||
(get_local $2)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(set_local $4
|
||||
(i32.load
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(i32.load
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(i32.load
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
@ -2855,22 +2851,23 @@
|
||||
)
|
||||
(func $~lib/array/Array<i32>#indexOf (; 17 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.eqz
|
||||
(tee_local $3
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(get_local $4)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
@ -2888,9 +2885,7 @@
|
||||
(i32.lt_s
|
||||
(tee_local $2
|
||||
(i32.add
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
@ -2901,22 +2896,23 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(i32.load offset=8
|
||||
(set_local $0
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
@ -2966,22 +2962,23 @@
|
||||
)
|
||||
(func $~lib/array/Array<i32>#includes (; 19 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.eqz
|
||||
(tee_local $3
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(get_local $4)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
@ -2999,9 +2996,7 @@
|
||||
(i32.lt_s
|
||||
(tee_local $2
|
||||
(i32.add
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
@ -3014,11 +3009,9 @@
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
@ -3076,6 +3069,8 @@
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#splice (; 21 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
@ -3083,6 +3078,11 @@
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
@ -3092,9 +3092,7 @@
|
||||
(i32.lt_s
|
||||
(tee_local $1
|
||||
(i32.add
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
@ -3106,9 +3104,7 @@
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
@ -3116,27 +3112,25 @@
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
)
|
||||
(call $~lib/memory/move_memory
|
||||
(i32.add
|
||||
(tee_local $4
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $4)
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
@ -3145,9 +3139,7 @@
|
||||
(get_local $2)
|
||||
(tee_local $1
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
@ -3169,9 +3161,7 @@
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
@ -3189,30 +3179,30 @@
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(tee_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $~lib/array/Array<i32>#__grow
|
||||
(get_local $0)
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $4
|
||||
(tee_local $3
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -3677,7 +3667,7 @@
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array#constructor (; 47 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i32>#constructor (; 47 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
@ -3723,22 +3713,20 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(tee_local $2
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $std/array/createReverseOrderedArray (; 48 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(set_local $1
|
||||
(call $~lib/array/Array#constructor
|
||||
(call $~lib/array/Array<i32>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
@ -3844,7 +3832,7 @@
|
||||
(func $std/array/createRandomOrderedArray (; 50 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(set_local $0
|
||||
(call $~lib/array/Array#constructor
|
||||
(call $~lib/array/Array<i32>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
@ -3899,7 +3887,7 @@
|
||||
(func $std/array/createDefaultComparator<i32> (; 52 ;) (type $i) (result i32)
|
||||
(i32.const 23)
|
||||
)
|
||||
(func $~lib/array/insertionSort<i32> (; 53 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/internal/array/insertionSort<i32> (; 53 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
@ -4023,7 +4011,7 @@
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/array/weakHeapSort<i32> (; 54 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/internal/array/weakHeapSort<i32> (; 54 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
@ -4467,9 +4455,10 @@
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/array/sort<i32> (; 55 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/array/Array<i32>#sort (; 55 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
(i32.le_s
|
||||
(tee_local $2
|
||||
@ -4489,20 +4478,20 @@
|
||||
(i32.const 2)
|
||||
)
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.load offset=4
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(i32.load offset=4
|
||||
(tee_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.load
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(block (result i32)
|
||||
(set_global $argumentCount
|
||||
@ -4510,8 +4499,8 @@
|
||||
)
|
||||
(i32.lt_s
|
||||
(call_indirect (type $iii)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 0)
|
||||
@ -4519,16 +4508,12 @@
|
||||
)
|
||||
(block
|
||||
(i32.store offset=4
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -4537,30 +4522,22 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(if (result i32)
|
||||
(i32.le_s
|
||||
(get_local $2)
|
||||
(i32.const 256)
|
||||
)
|
||||
(return
|
||||
(call $~lib/array/insertionSort<i32>
|
||||
(call $~lib/internal/array/insertionSort<i32>
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(call $~lib/internal/array/weakHeapSort<i32>
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $~lib/array/weakHeapSort<i32>
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#sort (; 56 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(call $~lib/array/sort<i32>
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $std/array/isSorted<i32> (; 57 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $std/array/isSorted<i32> (; 56 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(set_local $2
|
||||
@ -4617,7 +4594,7 @@
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(func $std/array/assertSorted<i32> (; 58 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(func $std/array/assertSorted<i32> (; 57 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(call $std/array/isSorted<i32>
|
||||
@ -4639,13 +4616,13 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/array/assertSortedDefault<i32> (; 59 ;) (type $iv) (param $0 i32)
|
||||
(func $std/array/assertSortedDefault<i32> (; 58 ;) (type $iv) (param $0 i32)
|
||||
(call $std/array/assertSorted<i32>
|
||||
(get_local $0)
|
||||
(call $std/array/createDefaultComparator<i32>)
|
||||
)
|
||||
)
|
||||
(func $std/array/isArraysEqual<i32> (; 60 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(func $std/array/isArraysEqual<i32> (; 59 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(set_local $3
|
||||
(get_local $2)
|
||||
@ -4712,7 +4689,7 @@
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(func $std/array/isArraysEqual<i32>|trampoline (; 61 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(func $std/array/isArraysEqual<i32>|trampoline (; 60 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(block $1of1
|
||||
(block $0of1
|
||||
(block $oob
|
||||
@ -4735,19 +4712,19 @@
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $start~anonymous|24 (; 62 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $start~anonymous|24 (; 61 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $start~anonymous|25 (; 63 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $start~anonymous|25 (; 62 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $start (; 64 ;) (type $v)
|
||||
(func $start (; 63 ;) (type $v)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
(i32.and
|
||||
(i32.add
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,8 +2,8 @@
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
@ -11,12 +11,27 @@
|
||||
(global $std/arraybuffer/buffer (mut i32) (i32.const 0))
|
||||
(global $argumentCount (mut i32) (i32.const 0))
|
||||
(global $std/arraybuffer/sliced (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 44))
|
||||
(global $HEAP_BASE i32 (i32.const 104))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\12\00\00\00s\00t\00d\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(data (i32.const 4) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(data (i32.const 64) "\12\00\00\00s\00t\00d\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/allocator/arena/allocate_memory (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shl
|
||||
(i32.const 1)
|
||||
(i32.sub
|
||||
(i32.const 32)
|
||||
(i32.clz
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 7)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/allocate_memory (; 2 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
@ -105,29 +120,392 @@
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#constructor (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/allocate (; 3 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $0)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 22)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(tee_local $1
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(call $~lib/internal/arraybuffer/computeSize
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $~lib/memory/set_memory (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i64)
|
||||
(local $4 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $2)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(i32.store8
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 6)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 3)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 4)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 8)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(i32.store
|
||||
(tee_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(tee_local $4
|
||||
(i32.and
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(tee_local $1
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(i32.const 16843009)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(tee_local $2
|
||||
(i32.and
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const -4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 4)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 8)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 4)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 12)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 8)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 24)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 12)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 16)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 20)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 24)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 28)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 20)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i64.or
|
||||
(i64.extend_u/i32
|
||||
(get_local $1)
|
||||
)
|
||||
(i64.shl
|
||||
(i64.extend_u/i32
|
||||
(get_local $1)
|
||||
)
|
||||
(i64.const 32)
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $2)
|
||||
(i32.const 32)
|
||||
)
|
||||
(block
|
||||
(i64.store
|
||||
(get_local $0)
|
||||
(get_local $3)
|
||||
)
|
||||
(i64.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(i64.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 16)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(i64.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 24)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 32)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 32)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#constructor (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $1)
|
||||
(i32.const 2147483647)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.store
|
||||
(tee_local $2
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(call $~lib/memory/set_memory
|
||||
(i32.add
|
||||
(tee_local $2
|
||||
(call $~lib/internal/arraybuffer/allocate
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.const 0)
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(func $~lib/memory/copy_memory (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/memory/copy_memory (; 6 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(loop $continue|0
|
||||
@ -1703,7 +2081,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/memory/move_memory (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/memory/move_memory (; 7 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
(i32.eq
|
||||
@ -1993,7 +2371,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#slice (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#slice (; 8 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
@ -2035,10 +2413,10 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(tee_local $3
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(call $~lib/memory/move_memory
|
||||
(i32.add
|
||||
(tee_local $3
|
||||
(call $~lib/internal/arraybuffer/allocate
|
||||
(tee_local $2
|
||||
(select
|
||||
(tee_local $3
|
||||
@ -2090,21 +2468,14 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(call $~lib/memory/move_memory
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 4)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 4)
|
||||
(i32.const 8)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
@ -2112,7 +2483,7 @@
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#slice|trampoline (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#slice|trampoline (; 9 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(block $2of2
|
||||
(block $1of2
|
||||
(block $0of2
|
||||
@ -2128,7 +2499,7 @@
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.const 2147483647)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
)
|
||||
(call $~lib/arraybuffer/ArrayBuffer#slice
|
||||
@ -2137,7 +2508,7 @@
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $start (; 7 ;) (type $v)
|
||||
(func $start (; 10 ;) (type $v)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
(i32.and
|
||||
(i32.add
|
||||
@ -2166,7 +2537,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 5)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2195,7 +2566,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 9)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2210,7 +2581,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 10)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2239,7 +2610,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 14)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2268,7 +2639,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 18)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2292,7 +2663,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 22)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2316,7 +2687,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 26)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2340,7 +2711,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 30)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2364,7 +2735,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 34)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2390,7 +2761,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 38)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2404,7 +2775,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 39)
|
||||
(i32.const 0)
|
||||
)
|
||||
|
@ -7,7 +7,7 @@ assert(buffer.byteLength == 8);
|
||||
var sliced = buffer.slice();
|
||||
|
||||
assert(sliced.byteLength == 8);
|
||||
assert(sliced != buffer);
|
||||
assert(sliced !== buffer);
|
||||
|
||||
sliced = buffer.slice(1);
|
||||
|
||||
|
@ -3,26 +3,47 @@
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $~lib/allocator/common/index/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/allocator/common/index/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/allocator/common/index/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/allocator/common/index/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/internal/allocator/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(global $~lib/arraybuffer/HEADER_SIZE i32 (i32.const 4))
|
||||
(global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8))
|
||||
(global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816))
|
||||
(global $std/arraybuffer/buffer (mut i32) (i32.const 0))
|
||||
(global $argumentCount (mut i32) (i32.const 0))
|
||||
(global $std/arraybuffer/sliced (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 44))
|
||||
(global $HEAP_BASE i32 (i32.const 104))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\12\00\00\00s\00t\00d\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(data (i32.const 4) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(data (i32.const 64) "\12\00\00\00s\00t\00d\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/allocator/arena/allocate_memory (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(i32.shl
|
||||
(i32.const 1)
|
||||
(i32.sub
|
||||
(i32.const 32)
|
||||
(i32.clz
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/allocate_memory (; 2 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
@ -133,32 +154,416 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#constructor (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(func $~lib/internal/arraybuffer/allocate (; 3 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $1)
|
||||
(i32.const 2147483647)
|
||||
(i32.eqz
|
||||
(i32.le_u
|
||||
(get_local $0)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 22)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $2
|
||||
)
|
||||
(set_local $1
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.add
|
||||
(i32.const 4)
|
||||
(get_local $1)
|
||||
(call $~lib/internal/arraybuffer/computeSize
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $1)
|
||||
(get_local $0)
|
||||
)
|
||||
(return
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $~lib/memory/set_memory (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i64)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $2)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(i32.store8
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 6)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 3)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 4)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 8)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.and
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.and
|
||||
(get_local $2)
|
||||
(i32.const -4)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.mul
|
||||
(i32.div_u
|
||||
(i32.const -1)
|
||||
(i32.const 255)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 4)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 8)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 4)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 12)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 8)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(if
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 24)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 12)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 16)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 20)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 24)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 28)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 20)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.add
|
||||
(i32.const 24)
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(set_local $5
|
||||
(i64.or
|
||||
(i64.extend_u/i32
|
||||
(get_local $4)
|
||||
)
|
||||
(i64.shl
|
||||
(i64.extend_u/i32
|
||||
(get_local $4)
|
||||
)
|
||||
(i64.const 32)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|0
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $2)
|
||||
(i32.const 32)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(i64.store
|
||||
(get_local $0)
|
||||
(get_local $5)
|
||||
)
|
||||
(i64.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
(i64.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 16)
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
(i64.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 24)
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 32)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 32)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#constructor (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $1)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $2
|
||||
(call $~lib/internal/arraybuffer/allocate
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(call $~lib/memory/set_memory
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.const 0)
|
||||
(get_local $1)
|
||||
)
|
||||
(return
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $~lib/memory/copy_memory (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/memory/copy_memory (; 6 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
@ -1961,7 +2366,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/memory/move_memory (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $~lib/memory/move_memory (; 7 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
(i32.eq
|
||||
@ -2284,7 +2689,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#slice (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#slice (; 8 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
@ -2387,26 +2792,19 @@
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.add
|
||||
(i32.const 4)
|
||||
(call $~lib/internal/arraybuffer/allocate
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $7)
|
||||
(get_local $6)
|
||||
)
|
||||
(call $~lib/memory/move_memory
|
||||
(i32.add
|
||||
(get_local $7)
|
||||
(i32.const 4)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 4)
|
||||
(i32.const 8)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
@ -2416,7 +2814,7 @@
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#slice|trampoline (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(func $~lib/arraybuffer/ArrayBuffer#slice|trampoline (; 9 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(block $2of2
|
||||
(block $1of2
|
||||
(block $0of2
|
||||
@ -2432,7 +2830,7 @@
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.const 2147483647)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
)
|
||||
(call $~lib/arraybuffer/ArrayBuffer#slice
|
||||
@ -2441,7 +2839,7 @@
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $start (; 7 ;) (type $v)
|
||||
(func $start (; 10 ;) (type $v)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
(i32.and
|
||||
(i32.add
|
||||
@ -2475,7 +2873,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 5)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2506,7 +2904,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 9)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2523,7 +2921,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 10)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2554,7 +2952,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 14)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2585,7 +2983,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 18)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2611,7 +3009,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 22)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2637,7 +3035,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 26)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2663,7 +3061,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 30)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2689,7 +3087,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 34)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2720,7 +3118,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 38)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2737,7 +3135,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 39)
|
||||
(i32.const 0)
|
||||
)
|
||||
|
@ -1,268 +0,0 @@
|
||||
(module
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $std/carray/arr (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 36))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\0d\00\00\00s\00t\00d\00/\00c\00a\00r\00r\00a\00y\00.\00t\00s")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/array/CArray<i32>#__get (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.load
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/CArray<i32>#__set (; 2 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $start (; 3 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(set_global $std/carray/arr
|
||||
(get_global $HEAP_BASE)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_global $HEAP_BASE)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 8)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(i32.add
|
||||
(get_global $HEAP_BASE)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 9)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 11)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 12)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(call $~lib/array/CArray<i32>#__set
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 0)
|
||||
(i32.const 42)
|
||||
)
|
||||
(call $~lib/array/CArray<i32>#__set
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 1)
|
||||
(i32.const 24)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load
|
||||
(get_global $HEAP_BASE)
|
||||
)
|
||||
(i32.const 42)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 17)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load
|
||||
(i32.add
|
||||
(get_global $HEAP_BASE)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 18)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const 42)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 20)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 21)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(block (result i32)
|
||||
(call $~lib/array/CArray<i32>#__set
|
||||
(tee_local $0
|
||||
(get_global $std/carray/arr)
|
||||
)
|
||||
(tee_local $1
|
||||
(i32.const 3)
|
||||
)
|
||||
(i32.const 9000)
|
||||
)
|
||||
(i32.ne
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 9000)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 23)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load
|
||||
(i32.add
|
||||
(get_global $HEAP_BASE)
|
||||
(i32.const 12)
|
||||
)
|
||||
)
|
||||
(i32.const 9000)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 25)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 3)
|
||||
)
|
||||
(i32.const 9000)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 26)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@ -1,26 +0,0 @@
|
||||
// TBD: While this is useful as long as the pointer is just a local or global,
|
||||
// things go haywire, compared to C, as soon as the CArray is a member of a
|
||||
// class. Also, multi dimensional arrays cannot be implemented C-like because
|
||||
// their length isn't known at compile time.
|
||||
|
||||
var arr: CArray<i32> = changetype<CArray<i32>>(HEAP_BASE);
|
||||
|
||||
assert(load<i32>(HEAP_BASE) == 0);
|
||||
assert(load<i32>(HEAP_BASE + 4) == 0);
|
||||
|
||||
assert(arr[0] == 0);
|
||||
assert(arr[1] == 0);
|
||||
|
||||
arr[0] = 42;
|
||||
arr[1] = 24;
|
||||
|
||||
assert(load<i32>(HEAP_BASE) == 42);
|
||||
assert(load<i32>(HEAP_BASE + 4) == 24);
|
||||
|
||||
assert(arr[0] == 42);
|
||||
assert(arr[1] == 24);
|
||||
|
||||
assert((arr[3] = 9000) == 9000);
|
||||
|
||||
assert(load<i32>(HEAP_BASE + 12) == 9000);
|
||||
assert(arr[3] == 9000);
|
@ -1,305 +0,0 @@
|
||||
(module
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $std/carray/arr (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 36))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\0d\00\00\00s\00t\00d\00/\00c\00a\00r\00r\00a\00y\00.\00t\00s\00")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/array/CArray<i32>#__get (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(return
|
||||
(i32.load
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/CArray<i32>#__set (; 2 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $start (; 3 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(set_global $std/carray/arr
|
||||
(get_global $HEAP_BASE)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $HEAP_BASE)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 8)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(i32.add
|
||||
(get_global $HEAP_BASE)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 9)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 11)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 12)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(call $~lib/array/CArray<i32>#__set
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 0)
|
||||
(i32.const 42)
|
||||
)
|
||||
(call $~lib/array/CArray<i32>#__set
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 1)
|
||||
(i32.const 24)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $HEAP_BASE)
|
||||
)
|
||||
(i32.const 42)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 17)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(i32.add
|
||||
(get_global $HEAP_BASE)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 18)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const 42)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 20)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 21)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(block (result i32)
|
||||
(call $~lib/array/CArray<i32>#__set
|
||||
(tee_local $0
|
||||
(get_global $std/carray/arr)
|
||||
)
|
||||
(tee_local $1
|
||||
(i32.const 3)
|
||||
)
|
||||
(i32.const 9000)
|
||||
)
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i32.const 9000)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 23)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(i32.add
|
||||
(get_global $HEAP_BASE)
|
||||
(i32.const 12)
|
||||
)
|
||||
)
|
||||
(i32.const 9000)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 25)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/array/CArray<i32>#__get
|
||||
(get_global $std/carray/arr)
|
||||
(i32.const 3)
|
||||
)
|
||||
(i32.const 9000)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 26)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@ -2,10 +2,10 @@
|
||||
(type $i (func (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $v (func))
|
||||
(global $~lib/allocator/common/index/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/allocator/common/index/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/allocator/common/index/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/allocator/common/index/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/internal/allocator/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(global $std/constructor/emptyCtor (mut i32) (i32.const 0))
|
||||
|
@ -3,10 +3,10 @@
|
||||
(type $ifi (func (param i32 f32) (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $v (func))
|
||||
(global $~lib/allocator/common/index/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/allocator/common/index/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/allocator/common/index/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/allocator/common/index/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/internal/allocator/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(global $std/new/aClass (mut i32) (i32.const 0))
|
||||
|
@ -6,10 +6,10 @@
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $~lib/allocator/common/index/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/allocator/common/index/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/allocator/common/index/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/allocator/common/index/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/internal/allocator/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/a1 (mut i32) (i32.const 0))
|
||||
|
@ -7,10 +7,10 @@
|
||||
(type $iv (func (param i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $~lib/allocator/common/index/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/allocator/common/index/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/allocator/common/index/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/allocator/common/index/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/internal/allocator/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(global $std/set/set (mut i32) (i32.const 0))
|
||||
|
@ -2013,24 +2013,33 @@
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__grow (; 7 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.le_s
|
||||
(get_local $1)
|
||||
(tee_local $4
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 160)
|
||||
(i32.const 9)
|
||||
(i32.const 16)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $3
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
@ -2039,32 +2048,24 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(block
|
||||
(call $~lib/memory/move_memory
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $4)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(call $~lib/allocator/arena/free_memory
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
@ -2084,30 +2085,30 @@
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(tee_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $~lib/array/Array<i32>#__grow
|
||||
(get_local $0)
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $4
|
||||
(tee_local $3
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2149,24 +2150,33 @@
|
||||
)
|
||||
(func $~lib/array/Array<i64>#__grow (; 10 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.le_s
|
||||
(get_local $1)
|
||||
(tee_local $4
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 160)
|
||||
(i32.const 9)
|
||||
(i32.const 16)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $3
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
@ -2175,32 +2185,24 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(block
|
||||
(call $~lib/memory/move_memory
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $4)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(call $~lib/allocator/arena/free_memory
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
@ -2220,30 +2222,30 @@
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(tee_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $~lib/array/Array<i64>#__grow
|
||||
(get_local $0)
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $4
|
||||
(tee_local $3
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2296,30 +2298,30 @@
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(tee_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $~lib/array/Array<i32>#__grow
|
||||
(get_local $0)
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $4
|
||||
(tee_local $3
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2372,30 +2374,30 @@
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(tee_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $~lib/array/Array<i64>#__grow
|
||||
(get_local $0)
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $4
|
||||
(tee_local $3
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -17,10 +17,10 @@
|
||||
(type $iiFv (func (param i32 i32 f64)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $~lib/allocator/common/index/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/allocator/common/index/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/allocator/common/index/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/allocator/common/index/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/internal/allocator/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(global $std/static-array/i i32 (i32.const 8))
|
||||
@ -2309,26 +2309,36 @@
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__grow (; 7 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.gt_s
|
||||
(get_local $1)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 160)
|
||||
(i32.const 9)
|
||||
(i32.const 16)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $4
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
@ -2337,32 +2347,24 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(block
|
||||
(call $~lib/memory/move_memory
|
||||
(get_local $4)
|
||||
(get_local $2)
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.mul
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(call $~lib/allocator/arena/free_memory
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
@ -2372,6 +2374,7 @@
|
||||
(func $~lib/array/Array<i32>#__set (; 8 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
@ -2379,33 +2382,34 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(set_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(get_local $3)
|
||||
)
|
||||
(call $~lib/array/Array<i32>#__grow
|
||||
(get_local $0)
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $4
|
||||
(tee_local $5
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2456,26 +2460,36 @@
|
||||
)
|
||||
(func $~lib/array/Array<i64>#__grow (; 11 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.gt_s
|
||||
(get_local $1)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 160)
|
||||
(i32.const 9)
|
||||
(i32.const 16)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $4
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
@ -2484,32 +2498,24 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(block
|
||||
(call $~lib/memory/move_memory
|
||||
(get_local $4)
|
||||
(get_local $2)
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.mul
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 8)
|
||||
)
|
||||
)
|
||||
(call $~lib/allocator/arena/free_memory
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
@ -2519,6 +2525,7 @@
|
||||
(func $~lib/array/Array<i64>#__set (; 12 ;) (type $iiIv) (param $0 i32) (param $1 i32) (param $2 i64)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
@ -2526,33 +2533,34 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(set_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(get_local $3)
|
||||
)
|
||||
(call $~lib/array/Array<i64>#__grow
|
||||
(get_local $0)
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $4
|
||||
(tee_local $5
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2603,26 +2611,36 @@
|
||||
)
|
||||
(func $~lib/array/Array<f32>#__grow (; 15 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.gt_s
|
||||
(get_local $1)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 160)
|
||||
(i32.const 9)
|
||||
(i32.const 16)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $4
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
@ -2631,32 +2649,24 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(block
|
||||
(call $~lib/memory/move_memory
|
||||
(get_local $4)
|
||||
(get_local $2)
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.mul
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(call $~lib/allocator/arena/free_memory
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
@ -2666,6 +2676,7 @@
|
||||
(func $~lib/array/Array<f32>#__set (; 16 ;) (type $iifv) (param $0 i32) (param $1 i32) (param $2 f32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
@ -2673,33 +2684,34 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(set_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(get_local $3)
|
||||
)
|
||||
(call $~lib/array/Array<f32>#__grow
|
||||
(get_local $0)
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $4
|
||||
(tee_local $5
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2750,26 +2762,36 @@
|
||||
)
|
||||
(func $~lib/array/Array<f64>#__grow (; 19 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.gt_s
|
||||
(get_local $1)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 160)
|
||||
(i32.const 9)
|
||||
(i32.const 16)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $4
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
@ -2778,32 +2800,24 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
(block
|
||||
(call $~lib/memory/move_memory
|
||||
(get_local $4)
|
||||
(get_local $2)
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.mul
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 8)
|
||||
)
|
||||
)
|
||||
(call $~lib/allocator/arena/free_memory
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
@ -2813,6 +2827,7 @@
|
||||
(func $~lib/array/Array<f64>#__set (; 20 ;) (type $iiFv) (param $0 i32) (param $1 i32) (param $2 f64)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
@ -2820,33 +2835,34 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(set_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(get_local $3)
|
||||
)
|
||||
(call $~lib/array/Array<f64>#__grow
|
||||
(get_local $0)
|
||||
(select
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $4
|
||||
(tee_local $5
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $4)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -15,7 +15,7 @@
|
||||
(global $std/string/nullStr (mut i32) (i32.const 0))
|
||||
(global $argumentCount (mut i32) (i32.const 0))
|
||||
(global $std/string/c (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 384))
|
||||
(global $HEAP_BASE i32 (i32.const 436))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\10\00\00\00h\00i\00,\00 \00I\00\'\00m\00 \00a\00 \00s\00t\00r\00i\00n\00g")
|
||||
(data (i32.const 40) "\0d\00\00\00s\00t\00d\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s")
|
||||
@ -39,11 +39,12 @@
|
||||
(data (i32.const 296) "\08\00\00\00.\001\00f\00o\00o\00b\00a\00r")
|
||||
(data (i32.const 316) "\01\00\00\00a")
|
||||
(data (i32.const 324) "\01\00\00\00b")
|
||||
(data (i32.const 336) "\02\00\00\00a\00b")
|
||||
(data (i32.const 344) "\02\00\00\00b\00a")
|
||||
(data (i32.const 352) "\02\00\00\00a\00a")
|
||||
(data (i32.const 360) "\03\00\00\00a\00b\00c")
|
||||
(data (i32.const 372) "\03\00\00\001\002\003")
|
||||
(data (i32.const 336) "\17\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s")
|
||||
(data (i32.const 388) "\02\00\00\00a\00b")
|
||||
(data (i32.const 396) "\02\00\00\00b\00a")
|
||||
(data (i32.const 404) "\02\00\00\00a\00a")
|
||||
(data (i32.const 412) "\03\00\00\00a\00b\00c")
|
||||
(data (i32.const 424) "\03\00\00\001\002\003")
|
||||
(export "getString" (func $std/string/getString))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
@ -56,7 +57,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 40)
|
||||
(i32.const 37)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -155,7 +156,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 235)
|
||||
(i32.const 232)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -265,7 +266,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 101)
|
||||
(i32.const 98)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -354,7 +355,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.const 2147483647)
|
||||
(i32.const 536870910)
|
||||
)
|
||||
)
|
||||
(call $~lib/string/String#endsWith
|
||||
@ -375,7 +376,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 214)
|
||||
(i32.const 211)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -527,7 +528,7 @@
|
||||
(func $std/string/getString (; 11 ;) (type $i) (result i32)
|
||||
(get_global $std/string/str)
|
||||
)
|
||||
(func $~lib/string/parse<f64> (; 12 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
|
||||
(func $~lib/internal/string/parse<f64> (; 12 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
@ -893,7 +894,7 @@
|
||||
)
|
||||
)
|
||||
(func $~lib/string/parseInt (; 13 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
|
||||
(call $~lib/string/parse<f64>
|
||||
(call $~lib/internal/string/parse<f64>
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
@ -1086,7 +1087,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 559)
|
||||
(i32.const 431)
|
||||
(i32.const 10)
|
||||
)
|
||||
(unreachable)
|
||||
@ -1261,18 +1262,32 @@
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(func $~lib/string/allocate (; 17 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/string/allocate (; 17 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.le_s
|
||||
(i32.eqz
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.gt_s
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(i32.le_s
|
||||
(get_local $0)
|
||||
(i32.const 536870910)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 8)
|
||||
(i32.const 336)
|
||||
(i32.const 20)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3172,7 +3187,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 77)
|
||||
(i32.const 74)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3210,7 +3225,7 @@
|
||||
(call $~lib/memory/move_memory
|
||||
(i32.add
|
||||
(tee_local $2
|
||||
(call $~lib/string/allocate
|
||||
(call $~lib/internal/string/allocate
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
@ -4075,7 +4090,7 @@
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__eq
|
||||
(get_global $std/string/c)
|
||||
(i32.const 336)
|
||||
(i32.const 388)
|
||||
)
|
||||
)
|
||||
(block
|
||||
@ -4159,7 +4174,7 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__gt
|
||||
(i32.const 344)
|
||||
(i32.const 396)
|
||||
(i32.const 316)
|
||||
)
|
||||
)
|
||||
@ -4176,8 +4191,8 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__gte
|
||||
(i32.const 344)
|
||||
(i32.const 352)
|
||||
(i32.const 396)
|
||||
(i32.const 404)
|
||||
)
|
||||
)
|
||||
(block
|
||||
@ -4193,8 +4208,8 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__gt
|
||||
(i32.const 344)
|
||||
(i32.const 336)
|
||||
(i32.const 396)
|
||||
(i32.const 388)
|
||||
)
|
||||
)
|
||||
(block
|
||||
@ -4209,8 +4224,8 @@
|
||||
)
|
||||
(if
|
||||
(call $~lib/string/String.__lt
|
||||
(i32.const 344)
|
||||
(i32.const 336)
|
||||
(i32.const 396)
|
||||
(i32.const 388)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
@ -4255,7 +4270,7 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__gt
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
(i32.const 332)
|
||||
)
|
||||
)
|
||||
@ -4273,7 +4288,7 @@
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__lt
|
||||
(i32.const 332)
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
)
|
||||
)
|
||||
(block
|
||||
@ -4289,7 +4304,7 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__gte
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
(i32.const 332)
|
||||
)
|
||||
)
|
||||
@ -4307,7 +4322,7 @@
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__lte
|
||||
(i32.const 332)
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
)
|
||||
)
|
||||
(block
|
||||
@ -4322,7 +4337,7 @@
|
||||
)
|
||||
(if
|
||||
(call $~lib/string/String.__lt
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
(i32.const 332)
|
||||
)
|
||||
(block
|
||||
@ -4338,7 +4353,7 @@
|
||||
(if
|
||||
(call $~lib/string/String.__gt
|
||||
(i32.const 332)
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
@ -4417,7 +4432,7 @@
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load
|
||||
(i32.const 372)
|
||||
(i32.const 424)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
|
@ -9,44 +9,45 @@
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $~lib/allocator/common/index/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/allocator/common/index/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/allocator/common/index/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/allocator/common/index/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
|
||||
(global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8))
|
||||
(global $~lib/internal/allocator/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(global $std/string/str (mut i32) (i32.const 4))
|
||||
(global $std/string/nullStr (mut i32) (i32.const 0))
|
||||
(global $~lib/string/HEADER_SIZE i32 (i32.const 4))
|
||||
(global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4))
|
||||
(global $argumentCount (mut i32) (i32.const 0))
|
||||
(global $~lib/string/CharCode.PLUS i32 (i32.const 43))
|
||||
(global $~lib/string/CharCode.MINUS i32 (i32.const 45))
|
||||
(global $~lib/string/CharCode.DOT i32 (i32.const 46))
|
||||
(global $~lib/string/CharCode._0 i32 (i32.const 48))
|
||||
(global $~lib/string/CharCode._1 i32 (i32.const 49))
|
||||
(global $~lib/string/CharCode._2 i32 (i32.const 50))
|
||||
(global $~lib/string/CharCode._3 i32 (i32.const 51))
|
||||
(global $~lib/string/CharCode._4 i32 (i32.const 52))
|
||||
(global $~lib/string/CharCode._5 i32 (i32.const 53))
|
||||
(global $~lib/string/CharCode._6 i32 (i32.const 54))
|
||||
(global $~lib/string/CharCode._7 i32 (i32.const 55))
|
||||
(global $~lib/string/CharCode._8 i32 (i32.const 56))
|
||||
(global $~lib/string/CharCode._9 i32 (i32.const 57))
|
||||
(global $~lib/string/CharCode.A i32 (i32.const 65))
|
||||
(global $~lib/string/CharCode.B i32 (i32.const 66))
|
||||
(global $~lib/string/CharCode.E i32 (i32.const 69))
|
||||
(global $~lib/string/CharCode.O i32 (i32.const 79))
|
||||
(global $~lib/string/CharCode.X i32 (i32.const 88))
|
||||
(global $~lib/string/CharCode.Z i32 (i32.const 90))
|
||||
(global $~lib/string/CharCode.a i32 (i32.const 97))
|
||||
(global $~lib/string/CharCode.b i32 (i32.const 98))
|
||||
(global $~lib/string/CharCode.e i32 (i32.const 101))
|
||||
(global $~lib/string/CharCode.o i32 (i32.const 111))
|
||||
(global $~lib/string/CharCode.x i32 (i32.const 120))
|
||||
(global $~lib/string/CharCode.z i32 (i32.const 122))
|
||||
(global $~lib/string/EMPTY i32 (i32.const 332))
|
||||
(global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910))
|
||||
(global $~lib/internal/string/CharCode.PLUS i32 (i32.const 43))
|
||||
(global $~lib/internal/string/CharCode.MINUS i32 (i32.const 45))
|
||||
(global $~lib/internal/string/CharCode.DOT i32 (i32.const 46))
|
||||
(global $~lib/internal/string/CharCode._0 i32 (i32.const 48))
|
||||
(global $~lib/internal/string/CharCode._1 i32 (i32.const 49))
|
||||
(global $~lib/internal/string/CharCode._2 i32 (i32.const 50))
|
||||
(global $~lib/internal/string/CharCode._3 i32 (i32.const 51))
|
||||
(global $~lib/internal/string/CharCode._4 i32 (i32.const 52))
|
||||
(global $~lib/internal/string/CharCode._5 i32 (i32.const 53))
|
||||
(global $~lib/internal/string/CharCode._6 i32 (i32.const 54))
|
||||
(global $~lib/internal/string/CharCode._7 i32 (i32.const 55))
|
||||
(global $~lib/internal/string/CharCode._8 i32 (i32.const 56))
|
||||
(global $~lib/internal/string/CharCode._9 i32 (i32.const 57))
|
||||
(global $~lib/internal/string/CharCode.A i32 (i32.const 65))
|
||||
(global $~lib/internal/string/CharCode.B i32 (i32.const 66))
|
||||
(global $~lib/internal/string/CharCode.E i32 (i32.const 69))
|
||||
(global $~lib/internal/string/CharCode.O i32 (i32.const 79))
|
||||
(global $~lib/internal/string/CharCode.X i32 (i32.const 88))
|
||||
(global $~lib/internal/string/CharCode.Z i32 (i32.const 90))
|
||||
(global $~lib/internal/string/CharCode.a i32 (i32.const 97))
|
||||
(global $~lib/internal/string/CharCode.b i32 (i32.const 98))
|
||||
(global $~lib/internal/string/CharCode.e i32 (i32.const 101))
|
||||
(global $~lib/internal/string/CharCode.o i32 (i32.const 111))
|
||||
(global $~lib/internal/string/CharCode.x i32 (i32.const 120))
|
||||
(global $~lib/internal/string/CharCode.z i32 (i32.const 122))
|
||||
(global $~lib/internal/string/EMPTY i32 (i32.const 332))
|
||||
(global $std/string/c (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 384))
|
||||
(global $HEAP_BASE i32 (i32.const 436))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\10\00\00\00h\00i\00,\00 \00I\00\'\00m\00 \00a\00 \00s\00t\00r\00i\00n\00g\00")
|
||||
(data (i32.const 40) "\0d\00\00\00s\00t\00d\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00")
|
||||
@ -71,11 +72,12 @@
|
||||
(data (i32.const 316) "\01\00\00\00a\00")
|
||||
(data (i32.const 324) "\01\00\00\00b\00")
|
||||
(data (i32.const 332) "\00\00\00\00")
|
||||
(data (i32.const 336) "\02\00\00\00a\00b\00")
|
||||
(data (i32.const 344) "\02\00\00\00b\00a\00")
|
||||
(data (i32.const 352) "\02\00\00\00a\00a\00")
|
||||
(data (i32.const 360) "\03\00\00\00a\00b\00c\00")
|
||||
(data (i32.const 372) "\03\00\00\001\002\003\00")
|
||||
(data (i32.const 336) "\17\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00")
|
||||
(data (i32.const 388) "\02\00\00\00a\00b\00")
|
||||
(data (i32.const 396) "\02\00\00\00b\00a\00")
|
||||
(data (i32.const 404) "\02\00\00\00a\00a\00")
|
||||
(data (i32.const 412) "\03\00\00\00a\00b\00c\00")
|
||||
(data (i32.const 424) "\03\00\00\001\002\003\00")
|
||||
(export "getString" (func $std/string/getString))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
@ -91,7 +93,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 40)
|
||||
(i32.const 37)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -204,7 +206,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 235)
|
||||
(i32.const 232)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -334,7 +336,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 101)
|
||||
(i32.const 98)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -435,7 +437,7 @@
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.const 2147483647)
|
||||
(i32.const 536870910)
|
||||
)
|
||||
)
|
||||
(call $~lib/string/String#endsWith
|
||||
@ -462,7 +464,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 214)
|
||||
(i32.const 211)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -636,7 +638,7 @@
|
||||
(get_global $std/string/str)
|
||||
)
|
||||
)
|
||||
(func $~lib/string/parse<f64> (; 12 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
|
||||
(func $~lib/internal/string/parse<f64> (; 12 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
@ -1048,7 +1050,7 @@
|
||||
)
|
||||
(func $~lib/string/parseInt (; 13 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
|
||||
(return
|
||||
(call $~lib/string/parse<f64>
|
||||
(call $~lib/internal/string/parse<f64>
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
@ -1264,7 +1266,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 559)
|
||||
(i32.const 431)
|
||||
(i32.const 10)
|
||||
)
|
||||
(unreachable)
|
||||
@ -1470,26 +1472,39 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(func $~lib/string/allocate (; 17 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $~lib/internal/string/allocate (; 17 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.gt_s
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(i32.le_s
|
||||
(get_local $0)
|
||||
(i32.const 536870910)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 8)
|
||||
(i32.const 336)
|
||||
(i32.const 20)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(set_local $2
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.add
|
||||
(i32.const 4)
|
||||
@ -1501,11 +1516,11 @@
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
(get_local $0)
|
||||
)
|
||||
(return
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $~lib/memory/copy_memory (; 18 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
@ -3650,7 +3665,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 77)
|
||||
(i32.const 74)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3691,7 +3706,7 @@
|
||||
)
|
||||
)
|
||||
(set_local $5
|
||||
(call $~lib/string/allocate
|
||||
(call $~lib/internal/string/allocate
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
@ -4676,7 +4691,7 @@
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__eq
|
||||
(get_global $std/string/c)
|
||||
(i32.const 336)
|
||||
(i32.const 388)
|
||||
)
|
||||
)
|
||||
(block
|
||||
@ -4760,7 +4775,7 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__gt
|
||||
(i32.const 344)
|
||||
(i32.const 396)
|
||||
(i32.const 316)
|
||||
)
|
||||
)
|
||||
@ -4777,8 +4792,8 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__gte
|
||||
(i32.const 344)
|
||||
(i32.const 352)
|
||||
(i32.const 396)
|
||||
(i32.const 404)
|
||||
)
|
||||
)
|
||||
(block
|
||||
@ -4794,8 +4809,8 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__gt
|
||||
(i32.const 344)
|
||||
(i32.const 336)
|
||||
(i32.const 396)
|
||||
(i32.const 388)
|
||||
)
|
||||
)
|
||||
(block
|
||||
@ -4812,8 +4827,8 @@
|
||||
(i32.eqz
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__lt
|
||||
(i32.const 344)
|
||||
(i32.const 336)
|
||||
(i32.const 396)
|
||||
(i32.const 388)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -4868,7 +4883,7 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__gt
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
(i32.const 332)
|
||||
)
|
||||
)
|
||||
@ -4886,7 +4901,7 @@
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__lt
|
||||
(i32.const 332)
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
)
|
||||
)
|
||||
(block
|
||||
@ -4902,7 +4917,7 @@
|
||||
(if
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__gte
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
(i32.const 332)
|
||||
)
|
||||
)
|
||||
@ -4920,7 +4935,7 @@
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__lte
|
||||
(i32.const 332)
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
)
|
||||
)
|
||||
(block
|
||||
@ -4937,7 +4952,7 @@
|
||||
(i32.eqz
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__lt
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
(i32.const 332)
|
||||
)
|
||||
)
|
||||
@ -4957,7 +4972,7 @@
|
||||
(i32.eqz
|
||||
(call $~lib/string/String.__gt
|
||||
(i32.const 332)
|
||||
(i32.const 360)
|
||||
(i32.const 412)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -5047,7 +5062,7 @@
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(i32.const 372)
|
||||
(i32.const 424)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
|
962
tests/compiler/std/typedarray.optimized.wat
Normal file
962
tests/compiler/std/typedarray.optimized.wat
Normal file
@ -0,0 +1,962 @@
|
||||
(module
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iv (func (param i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 104))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\11\00\00\00s\00t\00d\00/\00t\00y\00p\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s")
|
||||
(data (i32.const 44) "\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/internal/arraybuffer/computeSize (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shl
|
||||
(i32.const 1)
|
||||
(i32.sub
|
||||
(i32.const 32)
|
||||
(i32.clz
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 7)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/allocate_memory (; 2 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
(select
|
||||
(i32.lt_u
|
||||
(get_local $0)
|
||||
(i32.const 1073741824)
|
||||
)
|
||||
(get_local $0)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.gt_u
|
||||
(tee_local $2
|
||||
(i32.and
|
||||
(i32.add
|
||||
(i32.add
|
||||
(tee_local $1
|
||||
(get_global $~lib/allocator/arena/offset)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 7)
|
||||
)
|
||||
(i32.const -8)
|
||||
)
|
||||
)
|
||||
(i32.shl
|
||||
(tee_local $0
|
||||
(current_memory)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(grow_memory
|
||||
(select
|
||||
(get_local $0)
|
||||
(tee_local $4
|
||||
(tee_local $3
|
||||
(i32.shr_u
|
||||
(i32.and
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 65535)
|
||||
)
|
||||
(i32.const -65536)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $0)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(grow_memory
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $~lib/allocator/arena/offset
|
||||
(get_local $2)
|
||||
)
|
||||
(return
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(func $~lib/internal/arraybuffer/allocate (; 3 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $0)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(tee_local $1
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(call $~lib/internal/arraybuffer/computeSize
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i8>#constructor (; 4 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $1)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.store
|
||||
(if (result i32)
|
||||
(get_local $0)
|
||||
(get_local $0)
|
||||
(block (result i32)
|
||||
(i32.store
|
||||
(tee_local $0
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.const 12)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(call $~lib/internal/arraybuffer/allocate
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i8>#get:length (; 5 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i16>#constructor (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $1)
|
||||
(i32.const 536870908)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(if (result i32)
|
||||
(get_local $0)
|
||||
(get_local $0)
|
||||
(block (result i32)
|
||||
(i32.store
|
||||
(tee_local $0
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.const 12)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(call $~lib/internal/arraybuffer/allocate
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i16>#get:length (; 7 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i32>#constructor (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $1)
|
||||
(i32.const 268435454)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(if (result i32)
|
||||
(get_local $0)
|
||||
(get_local $0)
|
||||
(block (result i32)
|
||||
(i32.store
|
||||
(tee_local $0
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.const 12)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(call $~lib/internal/arraybuffer/allocate
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i32>#get:length (; 9 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i64>#constructor (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $1)
|
||||
(i32.const 134217727)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(if (result i32)
|
||||
(get_local $0)
|
||||
(get_local $0)
|
||||
(block (result i32)
|
||||
(i32.store
|
||||
(tee_local $0
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.const 12)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(call $~lib/internal/arraybuffer/allocate
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i64>#get:length (; 11 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(func $std/typedarray/testInstantiate (; 12 ;) (type $iv) (param $0 i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.load offset=4
|
||||
(tee_local $1
|
||||
(call $~lib/internal/typedarray/TypedArray<i8>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 17)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 18)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i8>#get:length
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 19)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load offset=4
|
||||
(tee_local $1
|
||||
(call $~lib/internal/typedarray/TypedArray<i8>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 22)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 23)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i8>#get:length
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 24)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load offset=4
|
||||
(tee_local $1
|
||||
(call $~lib/internal/typedarray/TypedArray<i16>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 27)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 28)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i16>#get:length
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 29)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load offset=4
|
||||
(tee_local $1
|
||||
(call $~lib/internal/typedarray/TypedArray<i16>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 32)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 33)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i16>#get:length
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 34)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load offset=4
|
||||
(tee_local $1
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 37)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 38)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#get:length
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 39)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load offset=4
|
||||
(tee_local $1
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 42)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 43)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#get:length
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 44)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load offset=4
|
||||
(tee_local $1
|
||||
(call $~lib/internal/typedarray/TypedArray<i64>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 47)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 48)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i64>#get:length
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 49)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load offset=4
|
||||
(tee_local $1
|
||||
(call $~lib/internal/typedarray/TypedArray<i64>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 52)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 53)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i64>#get:length
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 54)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load offset=4
|
||||
(tee_local $1
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 57)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 58)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#get:length
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 59)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load offset=4
|
||||
(tee_local $1
|
||||
(call $~lib/internal/typedarray/TypedArray<i64>#constructor
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 62)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 63)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i64>#get:length
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 13 ;) (type $v)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
(i32.and
|
||||
(i32.add
|
||||
(get_global $HEAP_BASE)
|
||||
(i32.const 7)
|
||||
)
|
||||
(i32.const -8)
|
||||
)
|
||||
)
|
||||
(set_global $~lib/allocator/arena/offset
|
||||
(get_global $~lib/allocator/arena/startOffset)
|
||||
)
|
||||
(call $std/typedarray/testInstantiate
|
||||
(i32.const 0)
|
||||
)
|
||||
(call $std/typedarray/testInstantiate
|
||||
(i32.const 5)
|
||||
)
|
||||
(drop
|
||||
(call $~lib/internal/typedarray/TypedArray<i64>#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 134217727)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
74
tests/compiler/std/typedarray.ts
Normal file
74
tests/compiler/std/typedarray.ts
Normal file
@ -0,0 +1,74 @@
|
||||
assert(Int8Array.BYTES_PER_ELEMENT == 1);
|
||||
assert(Uint8Array.BYTES_PER_ELEMENT == 1);
|
||||
assert(Int16Array.BYTES_PER_ELEMENT == 2);
|
||||
assert(Uint16Array.BYTES_PER_ELEMENT == 2);
|
||||
assert(Int32Array.BYTES_PER_ELEMENT == 4);
|
||||
assert(Uint32Array.BYTES_PER_ELEMENT == 4);
|
||||
assert(Int64Array.BYTES_PER_ELEMENT == 8);
|
||||
assert(Uint64Array.BYTES_PER_ELEMENT == 8);
|
||||
assert(Float32Array.BYTES_PER_ELEMENT == 4);
|
||||
assert(Float64Array.BYTES_PER_ELEMENT == 8);
|
||||
|
||||
import "allocator/arena";
|
||||
|
||||
function testInstantiate(len: i32): void {
|
||||
|
||||
var i8a = new Int8Array(len);
|
||||
assert(i8a.byteOffset == 0);
|
||||
assert(i8a.byteLength == len * Int8Array.BYTES_PER_ELEMENT);
|
||||
assert(i8a.length == len);
|
||||
|
||||
var u8a = new Uint8Array(len);
|
||||
assert(u8a.byteOffset == 0);
|
||||
assert(u8a.byteLength == len * Uint8Array.BYTES_PER_ELEMENT);
|
||||
assert(u8a.length == len);
|
||||
|
||||
var i16a = new Int16Array(len);
|
||||
assert(i16a.byteOffset == 0);
|
||||
assert(i16a.byteLength == len * Int16Array.BYTES_PER_ELEMENT);
|
||||
assert(i16a.length == len);
|
||||
|
||||
var u16a = new Uint16Array(len);
|
||||
assert(u16a.byteOffset == 0);
|
||||
assert(u16a.byteLength == len * Uint16Array.BYTES_PER_ELEMENT);
|
||||
assert(u16a.length == len);
|
||||
|
||||
var i32a = new Int32Array(len);
|
||||
assert(i32a.byteOffset == 0);
|
||||
assert(i32a.byteLength == len * Int32Array.BYTES_PER_ELEMENT);
|
||||
assert(i32a.length == len);
|
||||
|
||||
var u32a = new Uint32Array(len);
|
||||
assert(u32a.byteOffset == 0);
|
||||
assert(u32a.byteLength == len * Uint32Array.BYTES_PER_ELEMENT);
|
||||
assert(u32a.length == len);
|
||||
|
||||
var i64a = new Int64Array(len);
|
||||
assert(i64a.byteOffset == 0);
|
||||
assert(i64a.byteLength == len * Int64Array.BYTES_PER_ELEMENT);
|
||||
assert(i64a.length == len);
|
||||
|
||||
var u64a = new Uint64Array(len);
|
||||
assert(u64a.byteOffset == 0);
|
||||
assert(u64a.byteLength == len * Uint64Array.BYTES_PER_ELEMENT);
|
||||
assert(u64a.length == len);
|
||||
|
||||
var f32a = new Float32Array(len);
|
||||
assert(f32a.byteOffset == 0);
|
||||
assert(f32a.byteLength == len * Float32Array.BYTES_PER_ELEMENT);
|
||||
assert(f32a.length == len);
|
||||
|
||||
var f64a = new Float64Array(len);
|
||||
assert(f64a.byteOffset == 0);
|
||||
assert(f64a.byteLength == len * Float64Array.BYTES_PER_ELEMENT);
|
||||
assert(f64a.length == len);
|
||||
}
|
||||
|
||||
testInstantiate(0);
|
||||
testInstantiate(5);
|
||||
|
||||
import { MAX_BLENGTH } from "internal/arraybuffer";
|
||||
|
||||
const MAX_F64LENGTH = <u32>MAX_BLENGTH >> alignof<f64>();
|
||||
new Float64Array(MAX_F64LENGTH); // 1GB
|
||||
// new Float64Array(MAX_F64 + 1); // throws
|
1779
tests/compiler/std/typedarray.untouched.wat
Normal file
1779
tests/compiler/std/typedarray.untouched.wat
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user