mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-07-29 13:12:08 +00:00
Rename memory instructions; Rework constant handling
This commit is contained in:
examples
i64-polyfill
mandelbrot
build
n-body
ugc
assembly
lib/loader/tests/assembly
package-lock.jsonpackage.jsonsnap
src
binary.tsbuiltins.tscompiler.tsdecompiler.tsdefinitions.tsdiagnosticMessages.generated.tsdiagnosticMessages.json
glue
module.tsprogram.tsstd
assembly
portable
tests
allocators
binaryen
compiler
abi.optimized.watabi.untouched.watasc-constants.untouched.watbuiltins.optimized.watbuiltins.tsbuiltins.untouched.watcall-optional.optimized.watcall-optional.untouched.watclass-extends.optimized.watclass-extends.untouched.watclass-overloading.optimized.watclass-overloading.untouched.watclass-with-boolean-field.optimized.watclass-with-boolean-field.untouched.watclass.optimized.watclass.untouched.watenum.optimized.watenum.tsenum.untouched.watexport.optimized.watexport.untouched.watexports.optimized.watexports.tsexports.untouched.watexternal.optimized.watexternal.untouched.watfunction-types.optimized.watfunction-types.untouched.wati64-polyfill.optimized.wati64-polyfill.untouched.watif.optimized.watif.untouched.watimport.untouched.watinfer-type.untouched.watinlining-recursive.optimized.watinlining-recursive.untouched.watinlining.optimized.watinlining.untouched.watlimits.untouched.watmain.optimized.watmain.untouched.watmandelbrot.optimized.watmandelbrot.untouched.watmany-locals.optimized.watmany-locals.untouched.watmemcpy.optimized.watmemcpy.untouched.watmemmove.untouched.watmemset.optimized.watnamed-export-default.optimized.watnamed-export-default.untouched.watnamed-import-default.optimized.watnamed-import-default.untouched.watnamespace.tsnamespace.untouched.watnew-without-allocator.optimized.watnew-without-allocator.tsnew-without-allocator.untouched.watobject-literal.optimized.watobject-literal.untouched.watrecursive.optimized.watrecursive.untouched.watreexport.optimized.watreexport.untouched.watretain-i32.untouched.wat
std
allocator_arena.optimized.watallocator_arena.tsallocator_arena.untouched.watarray-access.optimized.watarray-access.untouched.watarray-literal.optimized.watarray-literal.untouched.watarray.optimized.watarray.untouched.watarraybuffer.optimized.watarraybuffer.untouched.watconstructor.optimized.watconstructor.tsconstructor.untouched.watgc-integration.optimized.watgc-integration.tsgc-integration.untouched.watgc.optimized.watgc.tsgc.untouched.wathash.untouched.watlibm.optimized.watlibm.untouched.watmap.optimized.watmap.untouched.watmath.untouched.watmod.untouched.watnew.optimized.watnew.untouched.watoperator-overloading.optimized.watoperator-overloading.untouched.watpointer.optimized.watpointer.untouched.watset.optimized.watset.untouched.watstatic-array.optimized.watstatic-array.untouched.watstring-utf8.optimized.watstring-utf8.tsstring-utf8.untouched.watstring.optimized.watstring.untouched.watsymbol.optimized.watsymbol.untouched.wattypedarray.optimized.wattypedarray.untouched.wat
typealias.optimized.wattypealias.untouched.wat
9
src/glue/js/binaryen.d.ts
vendored
9
src/glue/js/binaryen.d.ts
vendored
@@ -2,5 +2,10 @@
|
||||
|
||||
/// <reference path="../binaryen.d.ts" />
|
||||
|
||||
declare function allocate_memory(size: usize): usize;
|
||||
declare function free_memory(ptr: usize): void;
|
||||
declare namespace binaryen {
|
||||
class Module {
|
||||
constructor(ref: number);
|
||||
emitText(): string;
|
||||
emitAsmjs(): string;
|
||||
}
|
||||
}
|
||||
|
@@ -1,42 +1,16 @@
|
||||
// Copy Binaryen exports to global scope
|
||||
|
||||
const binaryen = global.Binaryen || require("binaryen");
|
||||
global.binaryen = binaryen;
|
||||
|
||||
for (var key in binaryen)
|
||||
if (key.startsWith("_Binaryen") || key.startsWith("_Relooper"))
|
||||
global[key] = binaryen[key];
|
||||
for (var key in binaryen) {
|
||||
if (key.startsWith("_Binaryen") || key.startsWith("_Relooper")) global[key] = binaryen[key];
|
||||
}
|
||||
|
||||
// Utilize Binaryen's heap
|
||||
|
||||
global.allocate_memory = function(size) {
|
||||
if (!size) return 0; // should be safe in our case
|
||||
return binaryen._malloc(size);
|
||||
};
|
||||
|
||||
global.free_memory = function(ptr) {
|
||||
if (ptr) binaryen._free(ptr);
|
||||
};
|
||||
|
||||
global.move_memory = function(dest, src, n) {
|
||||
return binaryen._memmove(dest, src, n);
|
||||
};
|
||||
|
||||
global.store = function(ptr, val) {
|
||||
binaryen.HEAPU8[ptr] = val;
|
||||
};
|
||||
|
||||
global.load = function(ptr) {
|
||||
return binaryen.HEAPU8[ptr];
|
||||
};
|
||||
|
||||
// Implement module stubs
|
||||
|
||||
const Module = require("../../module").Module;
|
||||
|
||||
Module.prototype.toText = function() {
|
||||
return new binaryen.Module(this.ref).emitText();
|
||||
};
|
||||
|
||||
Module.prototype.toAsmjs = function() {
|
||||
return new binaryen.Module(this.ref).emitAsmjs();
|
||||
};
|
||||
global.__memory_allocate = binaryen._malloc;
|
||||
global.__memory_free = binaryen._free;
|
||||
global.__memory_copy = binaryen._memmove;
|
||||
global.__store = function(ptr, val) { binaryen.HEAPU8[ptr] = val; };
|
||||
global.__load = function(ptr) { return binaryen.HEAPU8[ptr]; };
|
||||
|
@@ -6,7 +6,17 @@
|
||||
|
||||
/// <reference path="./node.d.ts" />
|
||||
|
||||
import "./binaryen"; // must be first so portable can pick up the memory implementation
|
||||
import "../../../std/portable/index";
|
||||
import "./binaryen";
|
||||
import "./float";
|
||||
import "./i64";
|
||||
|
||||
import { Module } from "../../module";
|
||||
|
||||
Module.prototype.toText = function(this: Module) {
|
||||
return new binaryen.Module(this.ref).emitText();
|
||||
};
|
||||
|
||||
Module.prototype.toAsmjs = function(this: Module) {
|
||||
return new binaryen.Module(this.ref).emitAsmjs();
|
||||
};
|
||||
|
Reference in New Issue
Block a user