diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-09-29 17:27:56 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-09-29 17:27:56 -0700 |
commit | be253460d4a75a79b62c7ad0e4f3fc2b7c6b8e0e (patch) | |
tree | 1091e8fab3a6794d7f55d9e7ffee8dc4aa303004 /src | |
parent | c68516a8088824578a6097a96afaff19728fcfb1 (diff) | |
parent | dc78d7d7b57919adfd7fd0480213e0950feb75fe (diff) |
Merge pull request #594 from larsxschneider/lars/add-split-option
Add emcc option "--split <size>" to split javascript file.
Diffstat (limited to 'src')
-rw-r--r-- | src/jsifier.js | 17 | ||||
-rw-r--r-- | src/modules.js | 5 | ||||
-rw-r--r-- | src/settings.js | 2 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 92b39b7d..8021f8a1 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -522,6 +522,11 @@ function JSify(data, functionsOnly, givenFunctions) { func.JS += ' */\n'; } + if (PRINT_SPLIT_FILE_MARKER) { + func.JS += '\n//FUNCTION_BEGIN_MARKER\n' + var associatedSourceFile = "NO_SOURCE"; + } + func.JS += 'function ' + func.ident + '(' + paramIdents.join(', ') + ') {\n'; if (PROFILE) { @@ -572,6 +577,13 @@ function JSify(data, functionsOnly, givenFunctions) { if (EXECUTION_TIMEOUT > 0) { ret += indent + 'if (Date.now() - START_TIME >= ' + (EXECUTION_TIMEOUT*1000) + ') throw "Timed out!" + (new Error().stack);\n'; } + + if (PRINT_SPLIT_FILE_MARKER && Debugging.on && Debugging.getAssociatedSourceFile(line.lineNum)) { + // Overwrite the associated source file for every line. The last line should contain the source file associated to + // the return value/address of outer most block (the marked function). + associatedSourceFile = Debugging.getAssociatedSourceFile(line.lineNum); + } + // for special labels we care about (for phi), mark that we visited them return ret + label.lines.map(function(line) { return line.JS + (Debugging.on ? Debugging.getComment(line.lineNum) : '') }) .join('\n') @@ -653,6 +665,11 @@ function JSify(data, functionsOnly, givenFunctions) { func.JS += ' return' + (func.returnType !== 'void' ? ' null' : '') + ';\n'; } func.JS += '}\n'; + + if (PRINT_SPLIT_FILE_MARKER) { + func.JS += '\n//FUNCTION_END_MARKER_OF_SOURCE_FILE_' + associatedSourceFile + '\n'; + } + if (func.ident in EXPORTED_FUNCTIONS) { func.JS += 'Module["' + func.ident + '"] = ' + func.ident + ';'; } diff --git a/src/modules.js b/src/modules.js index 0f3b483b..cf1b072e 100644 --- a/src/modules.js +++ b/src/modules.js @@ -127,6 +127,11 @@ var Debugging = { this.llvmLineToSourceFile[lineNum] + '"' : ''; }, + getAssociatedSourceFile: function(lineNum) { + if (!this.on) return null; + return lineNum in this.llvmLineToSourceLine ? this.llvmLineToSourceFile[lineNum] : null; + }, + getIdentifier: function(lineNum) { if (!this.on) return null; if (lineNum === undefined) { diff --git a/src/settings.js b/src/settings.js index 9d0ccc05..5970737c 100644 --- a/src/settings.js +++ b/src/settings.js @@ -202,6 +202,8 @@ var SHELL_FILE = 0; // set this to a string to override the shell file used var SHOW_LABELS = 0; // Show labels in the generated code +var PRINT_SPLIT_FILE_MARKER = 0; // Prints markers in Javascript generation to split the file later on. See emcc --split option. + var BUILD_AS_SHARED_LIB = 0; // Whether to build the code as a shared library, which // must be loaded dynamically using dlopen(). // 0 here means this is not a shared lib: It is a main file. |