aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/CppBackend/CPPBackend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r--lib/Target/CppBackend/CPPBackend.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp
index 234d5f6292..2433a36ad5 100644
--- a/lib/Target/CppBackend/CPPBackend.cpp
+++ b/lib/Target/CppBackend/CPPBackend.cpp
@@ -2436,6 +2436,10 @@ void CppWriter::printModuleBody() {
for (FunctionTableMap::iterator I = FunctionTables.begin(), E = FunctionTables.end(); I != E; ++I) {
Out << " \"" + I->first + "\": \"var FUNCTION_TABLE_" + I->first + " = [";
FunctionTable &Table = I->second;
+ // ensure power of two
+ unsigned Size = 1;
+ while (Size < Table.size()) Size <<= 1;
+ while (Table.size() < Size) Table.push_back("0");
for (unsigned i = 0; i < Table.size(); i++) {
Out << Table[i];
if (i < Table.size()-1) Out << ",";