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

Unified Diff: src/IceGlobalContext.h

Issue 1185703004: Add constant blinding/pooling option for X8632 code translation (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: reformat Created 5 years, 6 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/IceGlobalContext.h
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index 763a75b487ced3554f3bf53127106f792eabdf31..a632253f801fb70e7eee71349b8a093f4be91d1f 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -72,7 +72,8 @@ class GlobalContext {
X("Regs Saved ", RegsSaved) \
X("Frame Bytes ", FrameByte) \
X("Spills ", NumSpills) \
- X("Fills ", NumFills)
+ X("Fills ", NumFills) \
+ X("R/P Imms ", NumRPImms)
//#define X(str, tag)
public:
@@ -263,6 +264,15 @@ public:
Tls->StatsCumulative.update(CodeStats::CS_NumFills);
}
+ // Number of Randomized or Pooled Immediates
+ void statsUpdateRPImms() {
+ if (!getFlags().getDumpStats())
+ return;
+ ThreadContext *Tls = ICE_TLS_GET_FIELD(TLS);
+ Tls->StatsFunction.update(CodeStats::CS_NumRPImms);
+ Tls->StatsCumulative.update(CodeStats::CS_NumRPImms);
+ }
+
// These are predefined TimerStackIdT values.
enum TimerStackKind { TSK_Default = 0, TSK_Funcs, TSK_Num };
@@ -391,6 +401,21 @@ public:
return Match.empty() || Match == SymbolName;
}
+ // Return the randomization cookie for diversification.
+ // Initialize the cookie if necessary
+ uint32_t getRandomizationCookie() {
+ if (RandomizationCookie != 0)
+ return RandomizationCookie;
JF 2015/06/17 11:29:18 This technically needs to be an atomic read, thoug
qining 2015/06/17 18:20:36 Do you mean using std::atomic<int> for the randomi
+ RandomizationCookieLock.lock();
+ while (RandomizationCookie == 0) {
+ RandomNumberGenerator &RNG = getRNG();
+ RandomizationCookie = (uint32_t)RNG.next(
+ (uint64_t)std::numeric_limits<uint32_t>::max() + 1);
+ }
+ RandomizationCookieLock.unlock();
+ return RandomizationCookie;
+ }
qining 2015/06/17 04:28:55 Method to initialize the randomization cookie and
+
private:
// Try to ensure mutexes are allocated on separate cache lines.
@@ -460,6 +485,11 @@ private:
typedef llvm::SmallVector<char, 32> ManglerVector;
void incrementSubstitutions(ManglerVector &OldName) const;
+ // Randomization Cookie
+ // Managed by getRandomizationCookie()
+ GlobalLockType RandomizationCookieLock;
+ uint32_t RandomizationCookie;
qining 2015/06/17 04:28:55 Move the Randomization cookie to here from TargetX
+
public:
static void TlsInit() { ICE_TLS_INIT_FIELD(TLS); }
};

Powered by Google App Engine
This is Rietveld 408576698