diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-03 19:39:22 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-03 19:39:22 -0500 |
commit | 250b2388a583b81841f62d459f85b6b75f69512f (patch) | |
tree | d04b0e5bcb31f21a4fabc044e1ad88792c30ac36 /lib/Target/CppBackend/CPPBackend.cpp | |
parent | 0f7c126b9ff549f96746f79139f369ac3c276557 (diff) |
ensure power-of-two function tables
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 4 |
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 << ","; |