diff options
Diffstat (limited to 'src/jsifier.js')
-rw-r--r-- | src/jsifier.js | 18 |
1 files changed, 9 insertions, 9 deletions
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 + ';'; } |