mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-26 15:32:16 +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.setNoTreeShaking(compilerOptions, !!args.noTreeShaking);
|
||||||
assemblyscript.setNoAssert(compilerOptions, !!args.noAssert);
|
assemblyscript.setNoAssert(compilerOptions, !!args.noAssert);
|
||||||
assemblyscript.setNoMemory(compilerOptions, !!args.noMemory);
|
assemblyscript.setNoMemory(compilerOptions, !!args.noMemory);
|
||||||
|
assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);
|
||||||
assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);
|
assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);
|
||||||
|
|
||||||
var module;
|
var module;
|
||||||
|
@ -89,6 +89,10 @@
|
|||||||
"desc": "Does not set up a memory. Useful for low-level WebAssembly.",
|
"desc": "Does not set up a memory. Useful for low-level WebAssembly.",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"memoryBase": {
|
||||||
|
"desc": "Sets the start offset of compiler-generated static memory.",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
"noLib": {
|
"noLib": {
|
||||||
"desc": "Does not include the shipped standard library.",
|
"desc": "Does not include the shipped standard library.",
|
||||||
"type": "boolean"
|
"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;
|
noAssert: bool = false;
|
||||||
/** If true, does not set up a memory. */
|
/** If true, does not set up a memory. */
|
||||||
noMemory: bool = false;
|
noMemory: bool = false;
|
||||||
|
/** Static memory start offset. */
|
||||||
|
memoryBase: u32 = 0;
|
||||||
/** Memory allocation implementation to use. */
|
/** Memory allocation implementation to use. */
|
||||||
allocateImpl: string = "allocate_memory";
|
allocateImpl: string = "allocate_memory";
|
||||||
/** Memory freeing implementation to use. */
|
/** Memory freeing implementation to use. */
|
||||||
@ -210,7 +212,7 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
super(program.diagnostics);
|
super(program.diagnostics);
|
||||||
this.program = program;
|
this.program = program;
|
||||||
this.options = options ? options : new Options();
|
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();
|
this.module = Module.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +97,11 @@ export function setSourceMap(options: Options, sourceMap: bool): void {
|
|||||||
options.sourceMap = sourceMap;
|
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. */
|
/** Compiles the sources computed by the parser to a module. */
|
||||||
export function compile(parser: Parser, options: Options | null = null): Module {
|
export function compile(parser: Parser, options: Options | null = null): Module {
|
||||||
var program = parser.finish();
|
var program = parser.finish();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user