ART: Clean up ATRACE use
Remove old ATRACE_BEGIN & _END pairs, where possible. Remove
ATRACE_CALL and replace it with ScopedTrace.
Remove utils/Trace.h include.
Test: m
Change-Id: I3a5123202f4e373074bfe0f7359ee6c60a70352a
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 3bba9ef..129c5d8 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -1612,7 +1612,7 @@
: manager_(manager) {}
void Visit(size_t class_def_index) OVERRIDE REQUIRES(!Locks::mutator_lock_) {
- ATRACE_CALL();
+ ScopedTrace trace(__FUNCTION__);
Thread* const self = Thread::Current();
jobject jclass_loader = manager_->GetClassLoader();
const DexFile& dex_file = *manager_->GetDexFile();
@@ -1957,7 +1957,7 @@
: manager_(manager), log_level_(log_level) {}
virtual void Visit(size_t class_def_index) REQUIRES(!Locks::mutator_lock_) OVERRIDE {
- ATRACE_CALL();
+ ScopedTrace trace(__FUNCTION__);
ScopedObjectAccess soa(Thread::Current());
const DexFile& dex_file = *manager_->GetDexFile();
const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
@@ -2086,7 +2086,7 @@
explicit SetVerifiedClassVisitor(const ParallelCompilationManager* manager) : manager_(manager) {}
virtual void Visit(size_t class_def_index) REQUIRES(!Locks::mutator_lock_) OVERRIDE {
- ATRACE_CALL();
+ ScopedTrace trace(__FUNCTION__);
ScopedObjectAccess soa(Thread::Current());
const DexFile& dex_file = *manager_->GetDexFile();
const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
@@ -2150,7 +2150,7 @@
explicit InitializeClassVisitor(const ParallelCompilationManager* manager) : manager_(manager) {}
void Visit(size_t class_def_index) OVERRIDE {
- ATRACE_CALL();
+ ScopedTrace trace(__FUNCTION__);
jobject jclass_loader = manager_->GetClassLoader();
const DexFile& dex_file = *manager_->GetDexFile();
const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
@@ -2666,7 +2666,7 @@
explicit CompileClassVisitor(const ParallelCompilationManager* manager) : manager_(manager) {}
virtual void Visit(size_t class_def_index) REQUIRES(!Locks::mutator_lock_) OVERRIDE {
- ATRACE_CALL();
+ ScopedTrace trace(__FUNCTION__);
const DexFile& dex_file = *manager_->GetDexFile();
const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
ClassLinker* class_linker = manager_->GetClassLinker();
diff --git a/runtime/base/systrace.h b/runtime/base/systrace.h
index 08ab93d..dc2206e 100644
--- a/runtime/base/systrace.h
+++ b/runtime/base/systrace.h
@@ -19,7 +19,6 @@
#define ATRACE_TAG ATRACE_TAG_DALVIK
#include <cutils/trace.h>
-#include <utils/Trace.h>
#include <sstream>
#include <string>
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 91f1ff6..f7be4c8 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -800,12 +800,11 @@
bool has_waited = false;
uint64_t wait_start = NanoTime();
if (thread_flip_running_) {
- ATRACE_BEGIN("IncrementDisableThreadFlip");
+ ScopedTrace trace("IncrementDisableThreadFlip");
while (thread_flip_running_) {
has_waited = true;
thread_flip_cond_->Wait(self);
}
- ATRACE_END();
}
++disable_thread_flip_count_;
if (has_waited) {
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index 8754819..e43b9f4 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -365,11 +365,11 @@
// Run the checkpoint on the suspended threads.
for (const auto& thread : suspended_count_modified_threads) {
if (!thread->IsSuspended()) {
- if (ATRACE_ENABLED()) {
+ ScopedTrace trace([&]() {
std::ostringstream oss;
thread->ShortDump(oss);
- ATRACE_BEGIN((std::string("Waiting for suspension of thread ") + oss.str()).c_str());
- }
+ return std::string("Waiting for suspension of thread ") + oss.str();
+ });
// Busy wait until the thread is suspended.
const uint64_t start_time = NanoTime();
do {
@@ -378,7 +378,6 @@
const uint64_t total_delay = NanoTime() - start_time;
// Shouldn't need to wait for longer than 1000 microseconds.
constexpr uint64_t kLongWaitThreshold = MsToNs(1);
- ATRACE_END();
if (UNLIKELY(total_delay > kLongWaitThreshold)) {
LOG(WARNING) << "Long wait of " << PrettyDuration(total_delay) << " for "
<< *thread << " suspension!";