summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRichard Uhler <ruhler@google.com>2015-04-07 10:56:50 -0700
committerMathieu Chartier <mathieuc@google.com>2015-06-04 16:05:02 -0700
commit7fabaa6ba1927d21a317c03499b705cbde4f6a47 (patch)
treeff5d5abd880d24305699e5600be3ba7a6d19329a /runtime
parent1c8bef4a71612f10b89b102434f70de5a127cc74 (diff)
downloadart-7fabaa6ba1927d21a317c03499b705cbde4f6a47.zip
art-7fabaa6ba1927d21a317c03499b705cbde4f6a47.tar.gz
art-7fabaa6ba1927d21a317c03499b705cbde4f6a47.tar.bz2
Add atrace calls to runtime start and heap create
Bug: 20727525 Change-Id: I91a74b793fb9eda8ed580244a6a5fd313ef2eb27
Diffstat (limited to 'runtime')
-rw-r--r--runtime/gc/heap.cc17
-rw-r--r--runtime/java_vm_ext.cc7
-rw-r--r--runtime/runtime.cc19
3 files changed, 38 insertions, 5 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 20e791d..d344d81 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -232,10 +232,11 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max
requested_alloc_space_begin = reinterpret_cast<uint8_t*>(300 * MB) - non_moving_space_capacity;
}
if (!image_file_name.empty()) {
+ ATRACE_BEGIN("ImageSpace::Create");
std::string error_msg;
- space::ImageSpace* image_space = space::ImageSpace::Create(image_file_name.c_str(),
- image_instruction_set,
- &error_msg);
+ auto* image_space = space::ImageSpace::Create(image_file_name.c_str(), image_instruction_set,
+ &error_msg);
+ ATRACE_END();
if (image_space != nullptr) {
AddSpace(image_space);
// Oat files referenced by image files immediately follow them in memory, ensure alloc space
@@ -287,6 +288,7 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max
}
std::string error_str;
std::unique_ptr<MemMap> non_moving_space_mem_map;
+ ATRACE_BEGIN("Create heap maps");
if (separate_non_moving_space) {
// If we are the zygote, the non moving space becomes the zygote space when we run
// PreZygoteFork the first time. In this case, call the map "zygote space" since we can't
@@ -323,6 +325,8 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max
capacity_, &error_str));
CHECK(main_mem_map_2.get() != nullptr) << error_str;
}
+ ATRACE_END();
+ ATRACE_BEGIN("Create spaces");
// Create the non moving space first so that bitmaps don't take up the address range.
if (separate_non_moving_space) {
// Non moving space is always dlmalloc since we currently don't have support for multiple
@@ -340,7 +344,8 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max
if (foreground_collector_type_ == kCollectorTypeCC) {
region_space_ = space::RegionSpace::Create("Region space", capacity_ * 2, request_begin);
AddSpace(region_space_);
- } else if (IsMovingGc(foreground_collector_type_) && foreground_collector_type_ != kCollectorTypeGSS) {
+ } else if (IsMovingGc(foreground_collector_type_) &&
+ foreground_collector_type_ != kCollectorTypeGSS) {
// Create bump pointer spaces.
// We only to create the bump pointer if the foreground collector is a compacting GC.
// TODO: Place bump-pointer spaces somewhere to minimize size of card table.
@@ -411,10 +416,12 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max
if (main_space_backup_.get() != nullptr) {
RemoveSpace(main_space_backup_.get());
}
+ ATRACE_END();
// Allocate the card table.
+ ATRACE_BEGIN("Create card table");
card_table_.reset(accounting::CardTable::Create(heap_begin, heap_capacity));
CHECK(card_table_.get() != nullptr) << "Failed to create card table";
-
+ ATRACE_END();
if (foreground_collector_type_ == kCollectorTypeCC && kUseTableLookupReadBarrier) {
rb_table_.reset(new accounting::ReadBarrierTable());
DCHECK(rb_table_->IsAllCleared());
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index 2d3d19c..eb9c32d 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -16,6 +16,8 @@
#include "jni_internal.h"
+#define ATRACE_TAG ATRACE_TAG_DALVIK
+#include <cutils/trace.h>
#include <dlfcn.h>
#include "art_method.h"
@@ -788,9 +790,11 @@ void JavaVMExt::VisitRoots(RootVisitor* visitor) {
// JNI Invocation interface.
extern "C" jint JNI_CreateJavaVM(JavaVM** p_vm, JNIEnv** p_env, void* vm_args) {
+ ATRACE_BEGIN(__FUNCTION__);
const JavaVMInitArgs* args = static_cast<JavaVMInitArgs*>(vm_args);
if (IsBadJniVersion(args->version)) {
LOG(ERROR) << "Bad JNI version passed to CreateJavaVM: " << args->version;
+ ATRACE_END();
return JNI_EVERSION;
}
RuntimeOptions options;
@@ -800,6 +804,7 @@ extern "C" jint JNI_CreateJavaVM(JavaVM** p_vm, JNIEnv** p_env, void* vm_args) {
}
bool ignore_unrecognized = args->ignoreUnrecognized;
if (!Runtime::Create(options, ignore_unrecognized)) {
+ ATRACE_END();
return JNI_ERR;
}
Runtime* runtime = Runtime::Current();
@@ -808,10 +813,12 @@ extern "C" jint JNI_CreateJavaVM(JavaVM** p_vm, JNIEnv** p_env, void* vm_args) {
delete Thread::Current()->GetJniEnv();
delete runtime->GetJavaVM();
LOG(WARNING) << "CreateJavaVM failed";
+ ATRACE_END();
return JNI_ERR;
}
*p_env = Thread::Current()->GetJniEnv();
*p_vm = runtime->GetJavaVM();
+ ATRACE_END();
return JNI_OK;
}
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 65ea77a..9d651bf 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -22,6 +22,8 @@
#include <linux/fs.h>
#endif
+#define ATRACE_TAG ATRACE_TAG_DALVIK
+#include <cutils/trace.h>
#include <signal.h>
#include <sys/syscall.h>
#include <valgrind.h>
@@ -492,8 +494,12 @@ bool Runtime::Start() {
ScopedObjectAccess soa(self);
gc::space::ImageSpace* image_space = heap_->GetImageSpace();
if (image_space != nullptr) {
+ ATRACE_BEGIN("AddImageStringsToTable");
GetInternTable()->AddImageStringsToTable(image_space);
+ ATRACE_END();
+ ATRACE_BEGIN("MoveImageClassesToClassTable");
GetClassLinker()->MoveImageClassesToClassTable();
+ ATRACE_END();
}
}
@@ -512,7 +518,9 @@ bool Runtime::Start() {
// InitNativeMethods needs to be after started_ so that the classes
// it touches will have methods linked to the oat file if necessary.
+ ATRACE_BEGIN("InitNativeMethods");
InitNativeMethods();
+ ATRACE_END();
// Initialize well known thread group values that may be accessed threads while attaching.
InitThreadGroups(self);
@@ -533,7 +541,9 @@ bool Runtime::Start() {
GetInstructionSetString(kRuntimeISA));
}
+ ATRACE_BEGIN("StartDaemonThreads");
StartDaemonThreads();
+ ATRACE_END();
{
ScopedObjectAccess soa(self);
@@ -763,6 +773,7 @@ static size_t OpenDexFiles(const std::vector<std::string>& dex_filenames,
}
bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized) {
+ ATRACE_BEGIN("Runtime::Init");
CHECK_EQ(sysconf(_SC_PAGE_SIZE), kPageSize);
MemMap::Init();
@@ -773,6 +784,7 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized)
ParsedOptions::Create(raw_options, ignore_unrecognized, &runtime_options));
if (parsed_options.get() == nullptr) {
LOG(ERROR) << "Failed to parse options";
+ ATRACE_END();
return false;
}
VLOG(startup) << "Runtime::Init -verbose:startup enabled";
@@ -826,6 +838,7 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized)
zygote_max_failed_boots_ = runtime_options.GetOrDefault(Opt::ZygoteMaxFailedBoots);
XGcOption xgc_option = runtime_options.GetOrDefault(Opt::GcOption);
+ ATRACE_BEGIN("CreateHeap");
heap_ = new gc::Heap(runtime_options.GetOrDefault(Opt::MemoryInitialSize),
runtime_options.GetOrDefault(Opt::HeapGrowthLimit),
runtime_options.GetOrDefault(Opt::HeapMinFree),
@@ -855,9 +868,11 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized)
xgc_option.verify_post_gc_rosalloc_,
runtime_options.GetOrDefault(Opt::EnableHSpaceCompactForOOM),
runtime_options.GetOrDefault(Opt::HSpaceCompactForOOMMinIntervalsMs));
+ ATRACE_END();
if (heap_->GetImageSpace() == nullptr && !allow_dex_file_fallback_) {
LOG(ERROR) << "Dex file fallback disabled, cannot continue without image.";
+ ATRACE_END();
return false;
}
@@ -957,7 +972,9 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized)
CHECK_GE(GetHeap()->GetContinuousSpaces().size(), 1U);
class_linker_ = new ClassLinker(intern_table_);
if (GetHeap()->HasImageSpace()) {
+ ATRACE_BEGIN("InitFromImage");
class_linker_->InitFromImage();
+ ATRACE_END();
if (kIsDebugBuild) {
GetHeap()->GetImageSpace()->VerifyImageAllocations();
}
@@ -1090,6 +1107,8 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized)
VLOG(startup) << "Runtime::Init exiting";
+ ATRACE_END();
+
return true;
}