summaryrefslogtreecommitdiff
path: root/src/compiler/driver/compiler_driver.cc
diff options
context:
space:
mode:
author Ian Rogers <irogers@google.com> 2013-05-02 21:10:01 -0700
committer Ian Rogers <irogers@google.com> 2013-06-21 11:10:42 -0700
commit1d54e73444e017d3a65234e0f193846f3e27472b (patch)
tree1de93661e95a0ce6fa78fdfc23d0cfd3dd2a06f7 /src/compiler/driver/compiler_driver.cc
parent4c22e7eabef3f815841dfc6e0d5bbead96150752 (diff)
GC clean up.
Greater use of directories and namespaces. Fix bugs that cause verify options to fail. Address numerous other issues: GC barrier wait occurring holding locks: GC barrier waits occur when we wait for threads to run the check point function on themselves. This is happening with the heap bitmap and mutator lock held meaning that a thread that tries to take either lock exclusively will block waiting on a thread that is waiting. If this thread is the thread we're waiting to run the check point then the VM will deadlock. This deadlock occurred unnoticed as the call to check for wait safety was removed in: https://googleplex-android-review.googlesource.com/#/c/249423/1. NewTimingLogger: Existing timing log states when a split ends but not when it begins. This isn't good for systrace, in the context of GC it means that races between mutators and the GC are hard to discover what phase the GC is in, we know what phase it just finished and derive but that's not ideal. Support for only 1 discontinuous space: Code special cases continuous and large object space, rather than assuming we can have a collection of both. Sorted atomic stacks: Used to improve verification performance. Simplify their use and add extra checks. Simplify mod-union table abstractions. Reduce use of std::strings and their associated overhead in hot code. Make time units of fields explicit. Reduce confusion that IsAllocSpace is really IsDlMallocSpace. Make GetTotalMemory (exposed via System) equal to the footprint (as in Dalvik) rather than the max memory footprint. Change-Id: Ie87067140fa4499b15edab691fe6565d79599812
Diffstat (limited to 'src/compiler/driver/compiler_driver.cc')
-rw-r--r--src/compiler/driver/compiler_driver.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/compiler/driver/compiler_driver.cc b/src/compiler/driver/compiler_driver.cc
index b04e5b1f3d..6050108d48 100644
--- a/src/compiler/driver/compiler_driver.cc
+++ b/src/compiler/driver/compiler_driver.cc
@@ -31,8 +31,9 @@
#include "oat_file.h"
#include "object_utils.h"
#include "runtime.h"
-#include "gc/card_table-inl.h"
-#include "gc/space.h"
+#include "gc/accounting/card_table-inl.h"
+#include "gc/accounting/heap_bitmap.h"
+#include "gc/space/space.h"
#include "mirror/class_loader.h"
#include "mirror/class-inl.h"
#include "mirror/dex_cache-inl.h"
@@ -761,7 +762,7 @@ void CompilerDriver::UpdateImageClasses(TimingLogger& timings) {
// Update image_classes_ with classes for objects created by <clinit> methods.
Thread* self = Thread::Current();
const char* old_cause = self->StartAssertNoThreadSuspension("ImageWriter");
- Heap* heap = Runtime::Current()->GetHeap();
+ gc::Heap* heap = Runtime::Current()->GetHeap();
// TODO: Image spaces only?
WriterMutexLock mu(self, *Locks::heap_bitmap_lock_);
heap->FlushAllocStack();
@@ -1092,7 +1093,7 @@ void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType type, InvokeType s
}
stats_->DirectMethodsToBoot(type);
}
- bool compiling_boot = Runtime::Current()->GetHeap()->GetSpaces().size() == 1;
+ bool compiling_boot = Runtime::Current()->GetHeap()->GetContinuousSpaces().size() == 1;
if (compiling_boot) {
if (support_boot_image_fixup_) {
MethodHelper mh(method);
@@ -1104,7 +1105,7 @@ void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType type, InvokeType s
}
}
} else {
- if (Runtime::Current()->GetHeap()->FindSpaceFromObject(method)->IsImageSpace()) {
+ if (Runtime::Current()->GetHeap()->FindSpaceFromObject(method, false)->IsImageSpace()) {
direct_method = reinterpret_cast<uintptr_t>(method);
}
direct_code = reinterpret_cast<uintptr_t>(method->GetEntryPointFromCompiledCode());
@@ -1382,7 +1383,7 @@ class ParallelCompilationManager {
CHECK_NE(self->GetState(), kRunnable);
// Wait for all the worker threads to finish.
- thread_pool_->Wait(self);
+ thread_pool_->Wait(self, true, false);
}
private:
@@ -1915,7 +1916,7 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl
mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(manager->GetClassLoader());
const char* descriptor = manager->GetDexFile()->GetClassDescriptor(class_def);
mirror::Class* klass = manager->GetClassLinker()->FindClass(descriptor, class_loader);
- bool compiling_boot = Runtime::Current()->GetHeap()->GetSpaces().size() == 1;
+ bool compiling_boot = Runtime::Current()->GetHeap()->GetContinuousSpaces().size() == 1;
bool can_init_static_fields = compiling_boot &&
manager->GetCompiler()->IsImageClass(descriptor);
if (klass != NULL) {
@@ -1925,8 +1926,9 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl
// on a second thread the sub-class is initialized (holding its lock) after first initializing
// its parents, whose locks are acquired. This leads to a parent-to-child and a child-to-parent
// lock ordering and consequent potential deadlock.
- static Mutex lock1("Initializer lock", kMonitorLock);
- MutexLock mu(soa.Self(), lock1);
+ // We need to use an ObjectLock due to potential suspension in the interpreting code. Rather
+ // than use a special Object for the purpose we use the Class of java.lang.Class.
+ ObjectLock lock1(soa.Self(), klass->GetClass());
// The lock required to initialize the class.
ObjectLock lock2(soa.Self(), klass);
// Only try to initialize classes that were successfully verified.