modules/emscripten/src/compiler.js in webruby-0.1.2 vs modules/emscripten/src/compiler.js in webruby-0.2.1

- old
+ new

@@ -119,10 +119,12 @@ this['print'] = printErr; } // *** Environment setup code *** +DEBUG_MEMORY = false; + // Basic utilities load('utility.js'); // Load settings, can be overridden by commandline @@ -181,14 +183,12 @@ // Settings sanity checks assert(!(USE_TYPED_ARRAYS === 2 && QUANTUM_SIZE !== 4), 'For USE_TYPED_ARRAYS == 2, must have normal QUANTUM_SIZE of 4'); if (ASM_JS) { assert(!ALLOW_MEMORY_GROWTH, 'Cannot grow asm.js heap'); - assert((TOTAL_MEMORY&(TOTAL_MEMORY-1)) == 0, 'asm.js heap must be power of 2'); } -assert(!BUILD_AS_SHARED_LIB, 'shared libs are deprecated'); -//assert(!(!NAMED_GLOBALS && BUILD_AS_SHARED_LIB), 'shared libraries must have named globals'); +assert(!(!NAMED_GLOBALS && BUILD_AS_SHARED_LIB), 'shared libraries must have named globals'); // Output some info and warnings based on settings if (phase == 'pre') { if (!MICRO_OPTS || !RELOOP || ASSERTIONS || CHECK_SIGNS || CHECK_OVERFLOWS || INIT_HEAP || @@ -201,20 +201,37 @@ if (DOUBLE_MODE || CORRECT_SIGNS || CORRECT_OVERFLOWS || CORRECT_ROUNDINGS || CHECK_HEAP_ALIGN) { print('// Note: Some Emscripten settings may limit the speed of the generated code.'); } } +if (VERBOSE) printErr('VERBOSE is on, this generates a lot of output and can slow down compilation'); + +// Load struct and define information. +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')); +} +C_STRUCTS = temp.structs; +C_DEFINES = temp.defines; + // Load compiler code -load('framework.js'); load('modules.js'); load('parseTools.js'); load('intertyper.js'); load('analyzer.js'); load('jsifier.js'); -if (RELOOP) { - load(RELOOPER); +if (phase == 'funcs' && RELOOP) { // XXX handle !singlePhase + RelooperModule = { TOTAL_MEMORY: ceilPowerOfTwo(2*RELOOPER_BUFFER_SIZE) }; + try { + load(RELOOPER); + } 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; @@ -264,10 +281,13 @@ if (singlePhase) lines = null; var analyzed = analyzer(intertyped); intertyped = null; JSify(analyzed); + //dumpInterProf(); + //printErr(phase + ' paths (fast, slow): ' + [fastPaths, slowPaths]); + phase = null; if (DEBUG_MEMORY) { print('zzz. last gc: ' + gc()); MemoryDebugger.dump(); @@ -293,6 +313,10 @@ compile(read(ll_file)); } else { compile(ll_file); // we are given raw .ll } } + +//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);