diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-21 20:43:10 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-21 20:43:10 -0800 |
commit | 8aa6919b7acf0b4034735ac7ee597e946fefaf4d (patch) | |
tree | 3ba77ead655e88db79243d4e00abcc73df5d3402 /src | |
parent | 06bfe6541d88fda62a6b531e16250c63d85dcfe6 (diff) | |
parent | 160cc728e0839e441897d951fa61020bc2176717 (diff) |
merge incoming
Diffstat (limited to 'src')
-rw-r--r-- | src/jsifier.js | 21 | ||||
-rw-r--r-- | src/library.js | 20 | ||||
-rw-r--r-- | src/library_sdl.js | 8 | ||||
-rw-r--r-- | src/settings.js | 13 |
4 files changed, 54 insertions, 8 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 5c083a2e..a7b5a9ec 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -501,6 +501,19 @@ function JSify(data, functionsOnly, givenFunctions) { } }); + // function for filtering functions for label debugging + if (LABEL_FUNCTION_FILTERS.length > 0) { + var LABEL_FUNCTION_FILTER_SET = set(LABEL_FUNCTION_FILTERS); + var functionNameFilterTest = function(ident) { + return (ident in LABEL_FUNCTION_FILTER_SET); + }; + } else { + // no filters are specified, all function names are printed + var functionNameFilterTest = function(ident) { + return true; + } + } + // function reconstructor & post-JS optimizer substrate.addActor('FunctionReconstructor', { funcs: {}, @@ -624,7 +637,7 @@ function JSify(data, functionsOnly, givenFunctions) { } }); - if (LABEL_DEBUG) func.JS += " Module.print(INDENT + ' Entering: " + func.ident + ": ' + Array.prototype.slice.call(arguments)); INDENT += ' ';\n"; + if (LABEL_DEBUG && functionNameFilterTest(func.ident)) func.JS += " Module.print(INDENT + ' Entering: " + func.ident + ": ' + Array.prototype.slice.call(arguments)); INDENT += ' ';\n"; // Walk function blocks and generate JS function walkBlock(block, indent) { @@ -633,7 +646,7 @@ function JSify(data, functionsOnly, givenFunctions) { function getLabelLines(label, indent, relooping) { if (!label) return ''; var ret = ''; - if (LABEL_DEBUG >= 2) { + if ((LABEL_DEBUG >= 2) && functionNameFilterTest(func.ident)) { ret += indent + "Module.print(INDENT + '" + func.ident + ":" + label.ident + "');\n"; } if (EXECUTION_TIMEOUT > 0) { @@ -745,7 +758,7 @@ function JSify(data, functionsOnly, givenFunctions) { } func.JS += walkBlock(func.block, ' '); // Finalize function - if (LABEL_DEBUG) func.JS += " INDENT = INDENT.substr(0, INDENT.length-2);\n"; + if (LABEL_DEBUG && functionNameFilterTest(func.ident)) func.JS += " INDENT = INDENT.substr(0, INDENT.length-2);\n"; // Add an unneeded return, needed for strict mode to not throw warnings in some cases. // If we are not relooping, then switches make it unimportant to have this (and, we lack hasReturn anyhow) if (RELOOP && func.lines.length > 0 && func.labels.filter(function(label) { return label.hasReturn }).length > 0) { @@ -1079,7 +1092,7 @@ function JSify(data, functionsOnly, givenFunctions) { + 'PROFILING_NODE = __parentProfilingNode__ ' + '}\n'; } - if (LABEL_DEBUG) { + if (LABEL_DEBUG && functionNameFilterTest(item.funcData.ident)) { ret += "Module.print(INDENT + 'Exiting: " + item.funcData.ident + "');\n" + "INDENT = INDENT.substr(0, INDENT.length-2);\n"; } diff --git a/src/library.js b/src/library.js index 1f2d46aa..0e5919ad 100644 --- a/src/library.js +++ b/src/library.js @@ -5867,6 +5867,26 @@ LibraryManager.library = { }, // ========================================================================== + // sys/timeb.h + // ========================================================================== + + __timeb_struct_layout: Runtime.generateStructInfo([ + ['i32', 'time'], + ['i16', 'millitm'], + ['i16', 'timezone'], + ['i16', 'dstflag'] + ]), + ftime__deps: ['__timeb_struct_layout'], + ftime: function(p) { + var millis = Date.now(); + {{{ makeSetValue('p', '___timeb_struct_layout.time', 'Math.floor(millis/1000)', 'i32') }}}; + {{{ makeSetValue('p', '___timeb_struct_layout.millitm', 'millis % 1000', 'i16') }}}; + {{{ makeSetValue('p', '___timeb_struct_layout.timezone', '0', 'i16') }}}; // TODO + {{{ makeSetValue('p', '___timeb_struct_layout.dstflag', '0', 'i16') }}}; // TODO + return 0; + }, + + // ========================================================================== // sys/times.h // ========================================================================== diff --git a/src/library_sdl.js b/src/library_sdl.js index cd27648a..f8d252fb 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -898,7 +898,7 @@ var LibrarySDL = { }, SDL_GetError: function() { - return allocate(intArrayFromString("SDL is cool"), 'i8'); + return allocate(intArrayFromString("unknown SDL-emscripten error"), 'i8'); }, SDL_CreateRGBSurface: function(flags, width, height, depth, rmask, gmask, bmask, amask) { @@ -1537,6 +1537,12 @@ var LibrarySDL = { SDL_GL_SwapBuffers: function() {}, + // TODO + + SDL_SetGamma: function(r, g, b) { + return -1; + }, + // Misc SDL_InitSubSystem: function(flags) { return 0 }, diff --git a/src/settings.js b/src/settings.js index af2e8082..3d32db9e 100644 --- a/src/settings.js +++ b/src/settings.js @@ -132,6 +132,12 @@ var SAFE_HEAP_LOG = 0; // Log out all SAFE_HEAP operations var LABEL_DEBUG = 0; // 1: Print out functions as we enter them // 2: Also print out each label as we enter it +var LABEL_FUNCTION_FILTERS = []; // Filters for function label debug. + // The items for this array will be used + // as filters for function names. Only the + // labels of functions that is equaled to + // one of the filters are printed out + // When the array is empty, the filter is disabled. var EXCEPTION_DEBUG = 1; // Print out exceptions in emscriptened code var LIBRARY_DEBUG = 0; // Print out when we enter a library call (library*.js). You can also unset @@ -201,9 +207,10 @@ var NAMED_GLOBALS = 0; // If 1, we use global variables for globals. Otherwise var PROFILE = 0; // Enables runtime profiling. See test_profiling for a usage example. var EXPORT_ALL = 0; // If true, we export all the symbols -var EXPORTED_FUNCTIONS = ['_main', '_malloc', '_free']; // Functions that are explicitly exported, so they are guaranteed to - // be accessible outside of the generated code even after running closure compiler. - // Note the necessary prefix of "_". +var EXPORTED_FUNCTIONS = ['_main']; // Functions that are explicitly exported. These functions are kept alive + // through LLVM dead code elimination, and also made accessible outside of + // the generated code even after running closure compiler (on "Module"). + // Note the necessary prefix of "_". var DEFAULT_LIBRARY_FUNCS_TO_INCLUDE = ['memcpy', 'memset', 'malloc', 'free', '$Browser']; // JS library functions (C functions implemented in JS) // that we include by default. If you want to make sure |