Add sampling profiler
This adds a sampling profiler thread that runs every so often, gathering
profiling data and writing the results to a file in /data/data (specific to
app running). The intention is to use these files as input to the compiler
so that it can determine the best methods to compile.
Bug: 11539952
Change-Id: I0bfbb4146fb7966673c792f017ffac8107b6272d
diff --git a/runtime/barrier.cc b/runtime/barrier.cc
index a644998..5f43bec 100644
--- a/runtime/barrier.cc
+++ b/runtime/barrier.cc
@@ -44,11 +44,27 @@
void Barrier::Increment(Thread* self, int delta) {
MutexLock mu(self, lock_);
SetCountLocked(self, count_ + delta);
+
+ // Increment the count. If it becomes zero after the increment
+ // then all the threads have already passed the barrier. If
+ // it is non-zero then there is still one or more threads
+ // that have not yet called the Pass function. When the
+ // Pass function is called by the last thread, the count will
+ // be decremented to zero and a Broadcast will be made on the
+ // condition variable, thus waking this up.
if (count_ != 0) {
condition_.Wait(self);
}
}
+void Barrier::Increment(Thread* self, int delta, uint32_t timeout_ms) {
+ MutexLock mu(self, lock_);
+ SetCountLocked(self, count_ + delta);
+ if (count_ != 0) {
+ condition_.TimedWait(self, timeout_ms, 0);
+ }
+}
+
void Barrier::SetCountLocked(Thread* self, int count) {
count_ = count;
if (count_ == 0) {