Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: src/IceELFObjectWriter.cpp

Issue 1300993002: Use separate random number generator for each randomization pass (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Minor change in GlobalContext::getJumpTables(), make jump tables in deterministic order even pooled… Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceELFObjectWriter.cpp
diff --git a/src/IceELFObjectWriter.cpp b/src/IceELFObjectWriter.cpp
index f32a2b6671bb9b2857cfa77387f7f68c6edbd6e8..25c2bf3aebb48acece2797e5268b1cd65ff50a0f 100644
--- a/src/IceELFObjectWriter.cpp
+++ b/src/IceELFObjectWriter.cpp
@@ -512,11 +512,15 @@ template <typename ConstType> void ELFObjectWriter::writeConstantPool(Type Ty) {
// If the -reorder-pooled-constant option is set to true, we should shuffle
// the constants before we emit them.
- auto *CtxPtr = &Ctx;
- if (Ctx.getFlags().shouldReorderPooledConstants())
- RandomShuffle(Pool.begin(), Pool.end(), [CtxPtr](uint64_t N) {
- return (uint32_t)CtxPtr->getRNG().next(N);
- });
+ if (Ctx.getFlags().shouldReorderPooledConstants() && !Pool.empty()) {
+ // Use the constant's kind value as the salt for creating random number
+ // generator.
+ Operand::OperandKind K = (*Pool.begin())->getKind();
+ RandomNumberGenerator RNG(Ctx.getFlags().getRandomSeed(),
+ RPE_PooledConstantReordering, K);
+ RandomShuffle(Pool.begin(), Pool.end(),
+ [&RNG](uint64_t N) { return (uint32_t)RNG.next(N); });
+ }
// Write the data.
for (Constant *C : Pool) {
if (!C->getShouldBePooled())
« no previous file with comments | « src/IceDefs.h ('k') | src/IceGlobalContext.h » ('j') | src/IceGlobalContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698