Chromium Code Reviews| Index: src/IceGlobalContext.cpp |
| diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp |
| index 8bfc5dd5022aa126edeedf0b8db9b698f3b8ea1a..81fbf3c54c5205303732b46aea0b8a7b69ecb5c6 100644 |
| --- a/src/IceGlobalContext.cpp |
| +++ b/src/IceGlobalContext.cpp |
| @@ -878,11 +878,30 @@ ConstantList GlobalContext::getConstantExternSyms() { |
| return getConstPool()->ExternRelocatables.getConstantPool(); |
| } |
| +JumpTableDataList GlobalContext::getJumpTables() { |
| + JumpTableDataList JumpTables(*getJumpTableList()); |
| + if (getFlags().shouldReorderPooledConstants()) { |
| + // If reorder-pooled-constants option is set to true, we need to shuffle the |
| + // constant pool before emitting it. |
| + RandomShuffle(JumpTables.begin(), JumpTables.end(), [this](uint64_t N) { |
| + return (uint32_t)getRNG().next(N); |
| + }); |
| + } else { |
| + // Make order deterministic by sorting into functions and then ID of the |
| + // jump table within that function. |
| + std::sort(JumpTables.begin(), JumpTables.end(), [](const JumpTableData &A, |
| + const JumpTableData &B) { |
| + return A.getFunctionName() < B.getFunctionName() || A.getId() < B.getId(); |
|
Jim Stichnoth
2015/08/04 20:22:52
Is this the right comparison function?
Usually wh
ascull
2015/08/04 20:36:38
Done.
|
| + }); |
| + } |
| + return JumpTables; |
| +} |
| + |
| JumpTableData &GlobalContext::addJumpTable(IceString FuncName, SizeT Id, |
| SizeT NumTargets) { |
| - auto JumpTables = getJumpTables(); |
| - JumpTables->emplace_back(FuncName, Id, NumTargets); |
| - return JumpTables->back(); |
| + auto JumpTableList = getJumpTableList(); |
| + JumpTableList->emplace_back(FuncName, Id, NumTargets); |
| + return JumpTableList->back(); |
| } |
| TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) { |