faster boot by refactor qbe_emit
This commit is contained in:
@@ -147,21 +147,38 @@ function compile_native_cached(name, source_path) {
|
||||
return
|
||||
}
|
||||
|
||||
var t0 = null
|
||||
var t1 = null
|
||||
|
||||
os.print("bootstrap: compiling native: " + name + "\n")
|
||||
t0 = os.now()
|
||||
ast = analyze(src, source_path)
|
||||
compiled = streamline_mod(mcode_mod(ast))
|
||||
t1 = os.now()
|
||||
os.print(" [" + name + "] pipeline (tok+parse+fold+mcode+streamline): " + text((t1 - t0) / 1000000) + "ms\n")
|
||||
|
||||
t0 = os.now()
|
||||
il_parts = _qbe_emit_mod(compiled, _qbe_mod, null)
|
||||
t1 = os.now()
|
||||
os.print(" [" + name + "] qbe_emit: " + text((t1 - t0) / 1000000) + "ms\n")
|
||||
|
||||
helpers_il = (il_parts.helpers && length(il_parts.helpers) > 0)
|
||||
? text(il_parts.helpers, "\n") : ""
|
||||
all_fns = text(il_parts.functions, "\n")
|
||||
full_il = il_parts.data + "\n\n" + helpers_il + "\n\n" + all_fns
|
||||
|
||||
t0 = os.now()
|
||||
asm_text = os.qbe(full_il)
|
||||
t1 = os.now()
|
||||
os.print(" [" + name + "] os.qbe (QBE compile): " + text((t1 - t0) / 1000000) + "ms\n")
|
||||
|
||||
tmp = '/tmp/cell_boot_' + name
|
||||
fd.slurpwrite(tmp + '.s', stone(blob(asm_text)))
|
||||
|
||||
t0 = os.now()
|
||||
rc = os.system(_cc + ' -c ' + tmp + '.s -o ' + tmp + '.o')
|
||||
t1 = os.now()
|
||||
os.print(" [" + name + "] clang -c: " + text((t1 - t0) / 1000000) + "ms\n")
|
||||
if (rc != 0) {
|
||||
os.print("error: assembly failed for " + name + "\n")
|
||||
disrupt
|
||||
@@ -186,7 +203,10 @@ function compile_native_cached(name, source_path) {
|
||||
link_cmd = link_cmd + ' -undefined dynamic_lookup'
|
||||
link_cmd = link_cmd + ' ' + tmp + '.o ' + rt_o + ' -o ' + dylib_path
|
||||
|
||||
t0 = os.now()
|
||||
rc = os.system(link_cmd)
|
||||
t1 = os.now()
|
||||
os.print(" [" + name + "] clang -shared (link): " + text((t1 - t0) / 1000000) + "ms\n")
|
||||
if (rc != 0) {
|
||||
os.print("error: linking failed for " + name + "\n")
|
||||
disrupt
|
||||
|
||||
Reference in New Issue
Block a user