diff options
-rwxr-xr-x | emscripten.py | 18 | ||||
-rw-r--r-- | src/jsifier.js | 18 | ||||
-rw-r--r-- | src/parseTools.js | 30 |
3 files changed, 33 insertions, 33 deletions
diff --git a/emscripten.py b/emscripten.py index d41aaa2c..c6a08e6a 100755 --- a/emscripten.py +++ b/emscripten.py @@ -20,6 +20,15 @@ def path_from_root(*pathelems): """ return os.path.join(__rootpath__, *pathelems) +def get_configuration(): + if hasattr(get_configuration, 'configuration'): + return get_configuration.configuration + + from tools import shared + configuration = shared.Configuration(environ=os.environ) + get_configuration.configuration = configuration + return configuration + def scan(ll, settings): # blockaddress(@main, %23) blockaddrs = [] @@ -683,15 +692,6 @@ WARNING: You should normally never use this! Use emcc instead. else: relooper = None # use the cache - def get_configuration(): - if hasattr(get_configuration, 'configuration'): - return get_configuration.configuration - - from tools import shared - configuration = shared.Configuration(environ=os.environ) - get_configuration.configuration = configuration - return configuration - if keywords.temp_dir is None: temp_files = get_configuration().get_temp_files() else: diff --git a/src/jsifier.js b/src/jsifier.js index 97a25188..88f86d5b 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -311,20 +311,20 @@ function JSify(data, functionsOnly, givenFunctions) { if (!LibraryManager.library[item.ident.slice(1)]) return ret; } + // ensure alignment + constant = constant.concat(zeros(Runtime.alignMemory(constant.length) - constant.length)); + + // Special case: class vtables. We make sure they are null-terminated, to allow easy runtime operations + if (item.ident.substr(0, 5) == '__ZTV') { + constant = constant.concat(zeros(Runtime.alignMemory(QUANTUM_SIZE))); + } + // NOTE: This is the only place that could potentially create static // allocations in a shared library. constant = makePointer(constant, null, allocator, item.type, index); - var js; - js = (index !== null ? '' : item.ident + '=') + constant + ';'; + var js = (index !== null ? '' : item.ident + '=') + constant + ';'; - // Special case: class vtables. We make sure they are null-terminated, to allow easy runtime operations - if (item.ident.substr(0, 5) == '__ZTV') { - if (index !== null) { - index = getFastValue(index, '+', Runtime.alignMemory(calcAllocatedSize(Variables.globals[item.ident].type))); - } - js += '\n' + makePointer([0], null, allocator, ['void*'], index) + ';'; - } if (!ASM_JS && (EXPORT_ALL || (item.ident in EXPORTED_GLOBALS))) { js += '\nModule["' + item.ident + '"] = ' + item.ident + ';'; } diff --git a/src/parseTools.js b/src/parseTools.js index 6818e442..2d0be302 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1472,19 +1472,19 @@ function makePointer(slab, pos, allocator, type, ptr) { } } // compress type info and data if possible - var de; - try { - // compress all-zeros into a number (which will become zeros(..)). - // note that we cannot always eval the slab, e.g., if it contains ident,0,0 etc. In that case, no compression TODO: ensure we get arrays here, not str - var evaled = typeof slab === 'string' ? eval(slab) : slab; - de = dedup(evaled); - if (de.length === 1 && de[0] == 0) { - slab = types.length; - } - // TODO: if not all zeros, at least filter out items with type === 0. requires cleverness to know how to skip at runtime though. also - // be careful of structure padding - } catch(e){} if (USE_TYPED_ARRAYS != 2) { + var de; + try { + // compress all-zeros into a number (which will become zeros(..)). + // note that we cannot always eval the slab, e.g., if it contains ident,0,0 etc. In that case, no compression TODO: ensure we get arrays here, not str + var evaled = typeof slab === 'string' ? eval(slab) : slab; + de = dedup(evaled); + if (de.length === 1 && de[0] == 0) { + slab = types.length; + } + // TODO: if not all zeros, at least filter out items with type === 0. requires cleverness to know how to skip at runtime though. also + // be careful of structure padding + } catch(e){} de = dedup(types); if (de.length === 1) { types = de[0]; @@ -1539,7 +1539,6 @@ function makePointer(slab, pos, allocator, type, ptr) { } if (!fail) types = 'i8'; } - if (typeof slab == 'object') slab = '[' + slab.join(',') + ']'; // JS engines sometimes say array initializers are too large. Work around that by chunking and calling concat to combine at runtime var chunkSize = 10240; function chunkify(array) { @@ -1552,9 +1551,10 @@ function makePointer(slab, pos, allocator, type, ptr) { } return ret; } - if (typeof slab == 'string' && evaled && evaled.length > chunkSize && slab.length > chunkSize) { - slab = chunkify(evaled); + if (typeof slab == 'object' && slab.length > chunkSize) { + slab = chunkify(slab); } + if (typeof slab == 'object') slab = '[' + slab.join(',') + ']'; if (typeof types != 'string' && types.length > chunkSize) { types = chunkify(types); } else { |