Update Binaryen and add optimize levels to asc

This commit is contained in:
dcodeIO
2018-01-18 05:56:45 +01:00
parent 9cdfa35938
commit fc40ed80f7
9 changed files with 105 additions and 24 deletions

View File

@ -20,6 +20,8 @@ class ObjectHeader {
///////////////////////////////// Fields ////////////////////////////////////
// the next and prev pointer with tags in the least significant two bits that
// would otherwise be zero (blocks are guaranteed to be aligned to 4/8 bytes)
tagged_next: usize;
tagged_prev: usize;
@ -173,13 +175,13 @@ class Control {
gc_scan_fn(this, obj);
} else {
gc_scan_fn(this, null);
obj = this.iterator.next;
obj = this.iterator.next; // already strips tags, see *
if (obj == this.to) {
var from = this.from;
this.from = this.to;
this.to = from;
this.white = white ^ 1;
this.iterator = from.next;
this.iterator = changetype<ObjectHeader>(from.tagged_next); // *
this.state = SWEEP;
}
}
@ -233,10 +235,10 @@ class Control {
}
}
// TODO: should happen dynamically so it DCE's if all objects are unmanaged
var GC = Control.create(HEAP_BASE);
var GC_BASE = HEAP_BASE + Control.SIZE;
GC.register(changetype<ObjectHeader>(GC_BASE));
// var someObject = allocate_memory(64);
// GC.register(changetype<ObjectHeader>(someObject));
// Exported interface
@ -259,7 +261,7 @@ export function gc_collect(): void {
}
// TODO: these functions must be generated by the compiler and combined by
// any potential linker. They live here for now to document their structure.
// a potential linker. They live here for now to document their structure.
function gc_scan_fn(control: Control, header: ObjectHeader | null): void {
if (!header) {

View File

@ -5,7 +5,7 @@
"scripts": {
"build": "npm run build:untouched && npm run build:optimized",
"build:untouched": "asc assembly/ugc.ts -t ugc.untouched.wast -b ugc.untouched.wasm --validate",
"build:optimized": "asc -O assembly/ugc.ts -b ugc.optimized.wasm -t ugc.optimized.wast --validate --noAssert --runPasses inlining",
"build:optimized": "asc -O3 assembly/ugc.ts -b ugc.optimized.wasm -t ugc.optimized.wast --validate --noDebug --noAssert",
"test": "node tests"
}
}