ART: Fix Runtime::GetStat
Return uint64_t, as data is actually stored as such. Remove ns
to us conversion. Fix sensitive callers.
Test: m test-art-host
Change-Id: I506c90dbb179ffe010bb9cd6cc795edc280a9bc8
diff --git a/runtime/native/dalvik_system_VMDebug.cc b/runtime/native/dalvik_system_VMDebug.cc
index 83398ec..2a5ab11 100644
--- a/runtime/native/dalvik_system_VMDebug.cc
+++ b/runtime/native/dalvik_system_VMDebug.cc
@@ -83,7 +83,7 @@
}
static jint VMDebug_getAllocCount(JNIEnv*, jclass, jint kind) {
- return Runtime::Current()->GetStat(kind);
+ return static_cast<jint>(Runtime::Current()->GetStat(kind));
}
static void VMDebug_resetAllocCount(JNIEnv*, jclass, jint kinds) {
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 984ea4c..dbc2f6d 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -2020,7 +2020,7 @@
Thread::Current()->GetStats()->Clear(kinds >> 16);
}
-int32_t Runtime::GetStat(int kind) {
+uint64_t Runtime::GetStat(int kind) {
RuntimeStats* stats;
if (kind < (1<<16)) {
stats = GetStats();
@@ -2042,8 +2042,7 @@
case KIND_CLASS_INIT_COUNT:
return stats->class_init_count;
case KIND_CLASS_INIT_TIME:
- // Convert ns to us, reduce to 32 bits.
- return static_cast<int>(stats->class_init_time_ns / 1000);
+ return stats->class_init_time_ns;
case KIND_EXT_ALLOCATED_OBJECTS:
case KIND_EXT_ALLOCATED_BYTES:
case KIND_EXT_FREED_OBJECTS:
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 82f7d57..9dd7493 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -451,7 +451,7 @@
ArtMethod* CreateCalleeSaveMethod() REQUIRES_SHARED(Locks::mutator_lock_);
- int32_t GetStat(int kind);
+ uint64_t GetStat(int kind);
RuntimeStats* GetStats() {
return &stats_;
diff --git a/runtime/trace.cc b/runtime/trace.cc
index faea146..63d72d8 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -650,9 +650,9 @@
os << StringPrintf("vm=art\n");
os << StringPrintf("pid=%d\n", getpid());
if ((flags_ & kTraceCountAllocs) != 0) {
- os << StringPrintf("alloc-count=%d\n", Runtime::Current()->GetStat(KIND_ALLOCATED_OBJECTS));
- os << StringPrintf("alloc-size=%d\n", Runtime::Current()->GetStat(KIND_ALLOCATED_BYTES));
- os << StringPrintf("gc-count=%d\n", Runtime::Current()->GetStat(KIND_GC_INVOCATIONS));
+ os << "alloc-count=" << Runtime::Current()->GetStat(KIND_ALLOCATED_OBJECTS) << "\n";
+ os << "alloc-size=" << Runtime::Current()->GetStat(KIND_ALLOCATED_BYTES) << "\n";
+ os << "gc-count=" << Runtime::Current()->GetStat(KIND_GC_INVOCATIONS) << "\n";
}
os << StringPrintf("%cthreads\n", kTraceTokenChar);
DumpThreadList(os);