mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
Add memoryBase compiler option
This allows having fixed-size application-specific memory in front, followed by compiler-generated static memory and the heap.
This commit is contained in:
parent
48cbbbbd68
commit
6b459259f9
@ -277,6 +277,7 @@ exports.main = function main(argv, options, callback) {
|
||||
assemblyscript.setNoTreeShaking(compilerOptions, !!args.noTreeShaking);
|
||||
assemblyscript.setNoAssert(compilerOptions, !!args.noAssert);
|
||||
assemblyscript.setNoMemory(compilerOptions, !!args.noMemory);
|
||||
assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);
|
||||
assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);
|
||||
|
||||
var module;
|
||||
|
@ -89,6 +89,10 @@
|
||||
"desc": "Does not set up a memory. Useful for low-level WebAssembly.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"memoryBase": {
|
||||
"desc": "Sets the start offset of compiler-generated static memory.",
|
||||
"type": "number"
|
||||
},
|
||||
"noLib": {
|
||||
"desc": "Does not include the shipped standard library.",
|
||||
"type": "boolean"
|
||||
|
4
dist/asc.js
vendored
4
dist/asc.js
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
@ -141,6 +141,8 @@ export class Options {
|
||||
noAssert: bool = false;
|
||||
/** If true, does not set up a memory. */
|
||||
noMemory: bool = false;
|
||||
/** Static memory start offset. */
|
||||
memoryBase: u32 = 0;
|
||||
/** Memory allocation implementation to use. */
|
||||
allocateImpl: string = "allocate_memory";
|
||||
/** Memory freeing implementation to use. */
|
||||
@ -210,7 +212,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
super(program.diagnostics);
|
||||
this.program = program;
|
||||
this.options = options ? options : new Options();
|
||||
this.memoryOffset = i64_new(this.options.usizeType.byteSize, 0); // leave space for `null`
|
||||
this.memoryOffset = i64_new(max(this.options.memoryBase, this.options.usizeType.byteSize), 0); // leave space for `null`
|
||||
this.module = Module.create();
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,11 @@ export function setSourceMap(options: Options, sourceMap: bool): void {
|
||||
options.sourceMap = sourceMap;
|
||||
}
|
||||
|
||||
/** Sets the `memoryBase` option. */
|
||||
export function setMemoryBase(options: Options, memoryBase: u32): void {
|
||||
options.memoryBase = memoryBase;
|
||||
}
|
||||
|
||||
/** Compiles the sources computed by the parser to a module. */
|
||||
export function compile(parser: Parser, options: Options | null = null): Module {
|
||||
var program = parser.finish();
|
||||
|
Loading…
x
Reference in New Issue
Block a user