modules/emscripten/src/compiler.js in webruby-0.2.2 vs modules/emscripten/src/compiler.js in webruby-0.2.4

- old
+ new

@@ -204,16 +204,16 @@ } if (VERBOSE) printErr('VERBOSE is on, this generates a lot of output and can slow down compilation'); // Load struct and define information. -try { +//try { var temp = JSON.parse(read(STRUCT_INFO)); -} catch(e) { - printErr('cannot load struct info at ' + STRUCT_INFO + ' : ' + e + ', trying in current dir'); - temp = JSON.parse(read('struct_info.compiled.json')); -} +//} catch(e) { +// printErr('cannot load struct info at ' + STRUCT_INFO + ' : ' + e + ', trying in current dir'); +// temp = JSON.parse(read('struct_info.compiled.json')); +//} C_STRUCTS = temp.structs; C_DEFINES = temp.defines; // Load compiler code @@ -222,16 +222,16 @@ load('intertyper.js'); load('analyzer.js'); load('jsifier.js'); if (phase == 'funcs' && RELOOP) { // XXX handle !singlePhase RelooperModule = { TOTAL_MEMORY: ceilPowerOfTwo(2*RELOOPER_BUFFER_SIZE) }; - try { + //try { load(RELOOPER); - } catch(e) { - printErr('cannot load relooper at ' + RELOOPER + ' : ' + e + ', trying in current dir'); - load('relooper.js'); - } + //} catch(e) { + // printErr('cannot load relooper at ' + RELOOPER + ' : ' + e + ', trying in current dir'); + // load('relooper.js'); + //} assert(typeof Relooper != 'undefined'); } globalEval(processMacros(preprocess(read('runtime.js')))); Runtime.QUANTUM_SIZE = QUANTUM_SIZE; @@ -265,11 +265,11 @@ Debugging.handleMetadata(lines); function runPhase(currPhase) { //printErr('// JS compiler in action, phase ' + currPhase + typeof lines + (lines === null)); phase = currPhase; - if (phase != 'pre') { + if (phase != 'pre' && phase != 'glue') { if (singlePhase) PassManager.load(read(forwardedDataFile)); if (phase == 'funcs') { PreProcessor.eliminateUnneededIntrinsics(lines); } @@ -283,10 +283,11 @@ intertyped = null; JSify(analyzed); //dumpInterProf(); //printErr(phase + ' paths (fast, slow): ' + [fastPaths, slowPaths]); + B.print(phase); phase = null; if (DEBUG_MEMORY) { print('zzz. last gc: ' + gc()); @@ -306,15 +307,23 @@ runPhase('funcs'); runPhase('post'); } } -if (ll_file) { - if (ll_file.indexOf(String.fromCharCode(10)) == -1) { - compile(read(ll_file)); - } else { - compile(ll_file); // we are given raw .ll +B = new Benchmarker(); + +try { + if (ll_file) { + if (phase === 'glue') { + compile(';'); + } else if (ll_file.indexOf(String.fromCharCode(10)) == -1) { + compile(read(ll_file)); + } else { + compile(ll_file); // we are given raw .ll + } } +} catch(err) { + printErr('aborting from js compiler due to exception: ' + err + ' | ' + err.stack); } //var M = keys(tokenCacheMisses).map(function(m) { return [m, misses[m]] }).sort(function(a, b) { return a[1] - b[1] }); //printErr(dump(M.slice(M.length-10))); //printErr('hits: ' + hits);