diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-04-04 10:26:13 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-04-04 10:26:13 -0700 |
commit | 61cab495da3dd69cc46bef0ae8786ecec8050481 (patch) | |
tree | 048b3c5120e3052fd6b1e80cb819606ebe536872 | |
parent | cbc15905a139ba81249aed4c8f3d5196e89a0784 (diff) |
refactor vtable extension
-rw-r--r-- | src/jsifier.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 97a25188..a583da1e 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -311,20 +311,17 @@ function JSify(data, functionsOnly, givenFunctions) { if (!LibraryManager.library[item.ident.slice(1)]) return ret; } + // 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(constant.length + QUANTUM_SIZE) - constant.length)); + } + // 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 + ';'; } |