Yet more timing logger cleanup
Some cleanup of timing logger placement, additional systrace placement for
threaded compilation work, tweaking/hiding of some type names per previous
review comments.
Change-Id: Ic7db2e02747282ac7f474b9a060df9803bfdfa5e
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index ae00100..144271d 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -16,8 +16,10 @@
#include "compiler_driver.h"
-#include <vector>
+#define ATRACE_TAG ATRACE_TAG_DALVIK
+#include <utils/Trace.h>
+#include <vector>
#include <unistd.h>
#include "base/stl_util.h"
@@ -1562,14 +1564,14 @@
static void VerifyClass(const ParallelCompilationManager* manager, size_t class_def_index)
LOCKS_EXCLUDED(Locks::mutator_lock_) {
+ ATRACE_CALL();
ScopedObjectAccess soa(Thread::Current());
const DexFile::ClassDef& class_def = manager->GetDexFile()->GetClassDef(class_def_index);
const char* descriptor = manager->GetDexFile()->GetClassDescriptor(class_def);
mirror::Class* klass =
manager->GetClassLinker()->FindClass(descriptor,
soa.Decode<mirror::ClassLoader*>(manager->GetClassLoader()));
- if (klass == NULL) {
- CHECK(soa.Self()->IsExceptionPending());
+ if (klass == NULL) { CHECK(soa.Self()->IsExceptionPending());
soa.Self()->ClearException();
/*
@@ -1600,6 +1602,7 @@
soa.Self()->ClearException();
}
+
CHECK(klass->IsCompileTimeVerified() || klass->IsErroneous())
<< PrettyDescriptor(klass) << ": state=" << klass->GetStatus();
soa.Self()->AssertNoPendingException();
@@ -2135,6 +2138,7 @@
}
void CompilerDriver::CompileClass(const ParallelCompilationManager* manager, size_t class_def_index) {
+ ATRACE_CALL();
jobject jclass_loader = manager->GetClassLoader();
const DexFile& dex_file = *manager->GetDexFile();
const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
@@ -2155,6 +2159,7 @@
// empty class, probably a marker interface
return;
}
+
// Can we run DEX-to-DEX compiler on this class ?
DexToDexCompilationLevel dex_to_dex_compilation_level = kDontDexToDexCompile;
{
diff --git a/runtime/base/timing_logger.cc b/runtime/base/timing_logger.cc
index 1dcad0e..11dc542 100644
--- a/runtime/base/timing_logger.cc
+++ b/runtime/base/timing_logger.cc
@@ -77,7 +77,7 @@
void CumulativeLogger::AddLogger(const base::TimingLogger &logger) {
MutexLock mu(Thread::Current(), lock_);
const base::TimingLogger::SplitTimings& splits = logger.GetSplits();
- for (base::TimingLogger::SplitsIterator it = splits.begin(), end = splits.end();
+ for (base::TimingLogger::SplitTimingsIterator it = splits.begin(), end = splits.end();
it != end; ++it) {
base::TimingLogger::SplitTiming split = *it;
uint64_t split_time = split.first;
@@ -155,7 +155,7 @@
uint64_t TimingLogger::GetTotalNs() const {
uint64_t total_ns = 0;
- for (base::TimingLogger::SplitsIterator it = splits_.begin(), end = splits_.end();
+ for (base::TimingLogger::SplitTimingsIterator it = splits_.begin(), end = splits_.end();
it != end; ++it) {
base::TimingLogger::SplitTiming split = *it;
total_ns += split.first;
@@ -166,7 +166,7 @@
void TimingLogger::Dump(std::ostream &os) const {
uint64_t longest_split = 0;
uint64_t total_ns = 0;
- for (base::TimingLogger::SplitsIterator it = splits_.begin(), end = splits_.end();
+ for (base::TimingLogger::SplitTimingsIterator it = splits_.begin(), end = splits_.end();
it != end; ++it) {
base::TimingLogger::SplitTiming split = *it;
uint64_t split_time = split.first;
@@ -177,7 +177,7 @@
TimeUnit tu = GetAppropriateTimeUnit(longest_split);
uint64_t divisor = GetNsToTimeUnitDivisor(tu);
// Print formatted splits.
- for (base::TimingLogger::SplitsIterator it = splits_.begin(), end = splits_.end();
+ for (base::TimingLogger::SplitTimingsIterator it = splits_.begin(), end = splits_.end();
it != end; ++it) {
base::TimingLogger::SplitTiming split = *it;
uint64_t split_time = split.first;
diff --git a/runtime/base/timing_logger.h b/runtime/base/timing_logger.h
index 777d3f0..07d1ee0 100644
--- a/runtime/base/timing_logger.h
+++ b/runtime/base/timing_logger.h
@@ -33,9 +33,6 @@
class CumulativeLogger {
public:
- typedef std::map<std::string, Histogram<uint64_t> *> Histograms;
- typedef std::map<std::string, Histogram<uint64_t> *>::const_iterator HistogramsIterator;
-
explicit CumulativeLogger(const std::string& name);
void prepare_stats();
~CumulativeLogger();
@@ -50,6 +47,9 @@
void AddLogger(const base::TimingLogger& logger) LOCKS_EXCLUDED(lock_);
private:
+ typedef std::map<std::string, Histogram<uint64_t> *> Histograms;
+ typedef std::map<std::string, Histogram<uint64_t> *>::const_iterator HistogramsIterator;
+
void AddPair(const std::string &label, uint64_t delta_time)
EXCLUSIVE_LOCKS_REQUIRED(lock_);
void DumpHistogram(std::ostream &os) EXCLUSIVE_LOCKS_REQUIRED(lock_);
@@ -73,7 +73,7 @@
// Splits are nanosecond times and split names.
typedef std::pair<uint64_t, const char*> SplitTiming;
typedef std::vector<SplitTiming> SplitTimings;
- typedef std::vector<SplitTiming>::const_iterator SplitsIterator;
+ typedef std::vector<SplitTiming>::const_iterator SplitTimingsIterator;
explicit TimingLogger(const char* name, bool precise, bool verbose);
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 6dcdab9..df1f3fe 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -1171,6 +1171,12 @@
}
}
+
+const char* gc_cause_and_type_strings[3][4] = {
+ {"", "GC Alloc Sticky", "GC Alloc Partial", "GC Alloc Full"},
+ {"", "GC Background Sticky", "GC Background Partial", "GC Background Full"},
+ {"", "GC Explicit Sticky", "GC Explicit Partial", "GC Explicit Full"}};
+
collector::GcType Heap::CollectGarbageInternal(collector::GcType gc_type, GcCause gc_cause,
bool clear_soft_references) {
Thread* self = Thread::Current();
@@ -1225,20 +1231,12 @@
gc_type = collector::kGcTypePartial;
}
- switch (gc_cause) {
- case kGcCauseForAlloc:
- ATRACE_BEGIN("GC (alloc)");
- break;
- case kGcCauseBackground:
- ATRACE_BEGIN("GC (background)");
- break;
- case kGcCauseExplicit:
- ATRACE_BEGIN("GC (explicit)");
- break;
- }
-
DCHECK_LT(gc_type, collector::kGcTypeMax);
DCHECK_NE(gc_type, collector::kGcTypeNone);
+ DCHECK_LE(gc_cause, kGcCauseExplicit);
+
+ ATRACE_BEGIN(gc_cause_and_type_strings[gc_cause][gc_type]);
+
collector::MarkSweep* collector = NULL;
typedef std::vector<collector::MarkSweep*>::iterator It;
for (It it = mark_sweep_collectors_.begin(), end = mark_sweep_collectors_.end();
@@ -1658,11 +1656,10 @@
}
void Heap::PreSweepingGcVerification(collector::GarbageCollector* gc) {
- ThreadList* thread_list = Runtime::Current()->GetThreadList();
-
// Called before sweeping occurs since we want to make sure we are not going so reclaim any
// reachable objects.
if (verify_post_gc_heap_) {
+ ThreadList* thread_list = Runtime::Current()->GetThreadList();
Thread* self = Thread::Current();
CHECK_NE(self->GetState(), kRunnable);
Locks::mutator_lock_->SharedUnlock(self);
@@ -1682,9 +1679,8 @@
}
void Heap::PostGcVerification(collector::GarbageCollector* gc) {
- Thread* self = Thread::Current();
-
if (verify_system_weaks_) {
+ Thread* self = Thread::Current();
ReaderMutexLock mu(self, *Locks::heap_bitmap_lock_);
collector::MarkSweep* mark_sweep = down_cast<collector::MarkSweep*>(gc);
mark_sweep->VerifySystemWeaks();