mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-26 15:32:16 +00:00
capabilities to detect half/full runtime header
This commit is contained in:
parent
ba4c00efbd
commit
c147e98a55
@ -54,7 +54,8 @@ function postInstantiate(baseModule, instance) {
|
|||||||
var memory_fill = rawExports["memory.fill"];
|
var memory_fill = rawExports["memory.fill"];
|
||||||
var memory_free = rawExports["memory.free"];
|
var memory_free = rawExports["memory.free"];
|
||||||
var table = rawExports.table;
|
var table = rawExports.table;
|
||||||
var setargc = rawExports._setargc || function() {};
|
var capabilities = rawExports[".capabilities"] || 0;
|
||||||
|
var setargc = rawExports[".setargc"] || function() {};
|
||||||
|
|
||||||
// Provide views for all sorts of basic values
|
// Provide views for all sorts of basic values
|
||||||
var buffer, I8, U8, I16, U16, I32, U32, F32, F64, I64, U64;
|
var buffer, I8, U8, I16, U16, I32, U32, F32, F64, I64, U64;
|
||||||
@ -245,7 +246,7 @@ exports.instantiateStreaming = instantiateStreaming;
|
|||||||
/** Demangles an AssemblyScript module's exports to a friendly object structure. */
|
/** Demangles an AssemblyScript module's exports to a friendly object structure. */
|
||||||
function demangle(exports, baseModule) {
|
function demangle(exports, baseModule) {
|
||||||
var module = baseModule ? Object.create(baseModule) : {};
|
var module = baseModule ? Object.create(baseModule) : {};
|
||||||
var setargc = exports._setargc || function() {};
|
var setargc = exports[".setargc"] || function() {};
|
||||||
function hasOwnProperty(elem, prop) {
|
function hasOwnProperty(elem, prop) {
|
||||||
return Object.prototype.hasOwnProperty.call(elem, prop);
|
return Object.prototype.hasOwnProperty.call(elem, prop);
|
||||||
}
|
}
|
||||||
|
@ -252,6 +252,16 @@ export const enum Feature {
|
|||||||
THREADS = 1 << 4 // see: https://github.com/WebAssembly/threads
|
THREADS = 1 << 4 // see: https://github.com/WebAssembly/threads
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Indicates module capabilities. */
|
||||||
|
export const enum Capability {
|
||||||
|
/** No specific capabilities. */
|
||||||
|
NONE = 0,
|
||||||
|
/** Uses WebAssembly with 64-bit pointers. */
|
||||||
|
WASM64 = 1 << 0,
|
||||||
|
/** Garbage collector is present (full runtime header). */
|
||||||
|
GC = 1 << 1
|
||||||
|
}
|
||||||
|
|
||||||
/** Indicates the desired kind of a conversion. */
|
/** Indicates the desired kind of a conversion. */
|
||||||
export const enum ConversionKind {
|
export const enum ConversionKind {
|
||||||
/** No conversion. */
|
/** No conversion. */
|
||||||
@ -440,6 +450,14 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
// set up gc
|
// set up gc
|
||||||
if (this.needsIterateRoots) compileIterateRoots(this);
|
if (this.needsIterateRoots) compileIterateRoots(this);
|
||||||
|
|
||||||
|
// expose module capabilities
|
||||||
|
var capabilities = Capability.NONE;
|
||||||
|
if (program.options.isWasm64) capabilities |= Capability.WASM64;
|
||||||
|
if (program.gcImplemented) capabilities |= Capability.GC;
|
||||||
|
if (capabilities != 0) {
|
||||||
|
module.addGlobal(CompilerSymbols.capabilities, NativeType.I32, false, module.createI32(capabilities));
|
||||||
|
module.addGlobalExport(CompilerSymbols.capabilities, ".capabilities");
|
||||||
|
}
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5758,7 +5776,7 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
module.createGetLocal(0, NativeType.I32)
|
module.createGetLocal(0, NativeType.I32)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
module.addFunctionExport(internalName, "_setargc");
|
module.addFunctionExport(internalName, ".setargc");
|
||||||
}
|
}
|
||||||
return internalName;
|
return internalName;
|
||||||
}
|
}
|
||||||
@ -8088,4 +8106,6 @@ namespace CompilerSymbols {
|
|||||||
export const argc = "~lib/argc";
|
export const argc = "~lib/argc";
|
||||||
/** Argument count setter. Exported for use by host calls. */
|
/** Argument count setter. Exported for use by host calls. */
|
||||||
export const setargc = "~lib/setargc";
|
export const setargc = "~lib/setargc";
|
||||||
|
/** Module capabilities. Exported for evaluation by the host. */
|
||||||
|
export const capabilities = "~lib/capabilities";
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
(export "memory" (memory $0))
|
(export "memory" (memory $0))
|
||||||
(export "table" (table $0))
|
(export "table" (table $0))
|
||||||
(export "add" (func $exports/add))
|
(export "add" (func $exports/add))
|
||||||
(export "_setargc" (func $~lib/setargc))
|
(export ".setargc" (func $~lib/setargc))
|
||||||
(export "subOpt" (func $exports/subOpt|trampoline))
|
(export "subOpt" (func $exports/subOpt|trampoline))
|
||||||
(export "math.sub" (func $exports/subOpt))
|
(export "math.sub" (func $exports/subOpt))
|
||||||
(export "Animal.CAT" (global $exports/Animal.CAT))
|
(export "Animal.CAT" (global $exports/Animal.CAT))
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
(export "memory" (memory $0))
|
(export "memory" (memory $0))
|
||||||
(export "table" (table $0))
|
(export "table" (table $0))
|
||||||
(export "add" (func $exports/add))
|
(export "add" (func $exports/add))
|
||||||
(export "_setargc" (func $~lib/setargc))
|
(export ".setargc" (func $~lib/setargc))
|
||||||
(export "subOpt" (func $exports/subOpt|trampoline))
|
(export "subOpt" (func $exports/subOpt|trampoline))
|
||||||
(export "math.sub" (func $exports/math.sub))
|
(export "math.sub" (func $exports/math.sub))
|
||||||
(export "Animal.CAT" (global $exports/Animal.CAT))
|
(export "Animal.CAT" (global $exports/Animal.CAT))
|
||||||
|
@ -38,8 +38,10 @@
|
|||||||
(global $std/runtime/ref4 (mut i32) (i32.const 0))
|
(global $std/runtime/ref4 (mut i32) (i32.const 0))
|
||||||
(global $std/runtime/header4 (mut i32) (i32.const 0))
|
(global $std/runtime/header4 (mut i32) (i32.const 0))
|
||||||
(global $std/runtime/ref5 (mut i32) (i32.const 0))
|
(global $std/runtime/ref5 (mut i32) (i32.const 0))
|
||||||
|
(global $~lib/capabilities i32 (i32.const 2))
|
||||||
(export "memory" (memory $0))
|
(export "memory" (memory $0))
|
||||||
(export "table" (table $0))
|
(export "table" (table $0))
|
||||||
|
(export ".capabilities" (global $~lib/capabilities))
|
||||||
(start $start)
|
(start $start)
|
||||||
(func $~lib/allocator/tlsf/Root#setSLMap (; 2 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
|
(func $~lib/allocator/tlsf/Root#setSLMap (; 2 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||||
local.get $1
|
local.get $1
|
||||||
|
@ -55,8 +55,10 @@
|
|||||||
(global $std/runtime/header4 (mut i32) (i32.const 0))
|
(global $std/runtime/header4 (mut i32) (i32.const 0))
|
||||||
(global $std/runtime/ref5 (mut i32) (i32.const 0))
|
(global $std/runtime/ref5 (mut i32) (i32.const 0))
|
||||||
(global $~lib/memory/HEAP_BASE i32 (i32.const 264))
|
(global $~lib/memory/HEAP_BASE i32 (i32.const 264))
|
||||||
|
(global $~lib/capabilities i32 (i32.const 2))
|
||||||
(export "memory" (memory $0))
|
(export "memory" (memory $0))
|
||||||
(export "table" (table $0))
|
(export "table" (table $0))
|
||||||
|
(export ".capabilities" (global $~lib/capabilities))
|
||||||
(start $start)
|
(start $start)
|
||||||
(func $start:~lib/allocator/tlsf (; 2 ;) (type $FUNCSIG$v)
|
(func $start:~lib/allocator/tlsf (; 2 ;) (type $FUNCSIG$v)
|
||||||
i32.const 1
|
i32.const 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user