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
diff --git a/src/common_test.h b/src/common_test.h
index 0c171a8..88da8a2 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -28,8 +28,8 @@
#include "class_linker.h"
#include "compiler/driver/compiler_driver.h"
#include "dex_file-inl.h"
+#include "gc/heap.h"
#include "gtest/gtest.h"
-#include "heap.h"
#include "instruction_set.h"
#include "mirror/class_loader.h"
#include "oat_file.h"
@@ -296,8 +296,8 @@
boot_class_path_.push_back(java_lang_dex_file_);
boot_class_path_.push_back(conscrypt_file_);
- std::string min_heap_string(StringPrintf("-Xms%zdm", Heap::kDefaultInitialSize / MB));
- std::string max_heap_string(StringPrintf("-Xmx%zdm", Heap::kDefaultMaximumSize / MB));
+ std::string min_heap_string(StringPrintf("-Xms%zdm", gc::Heap::kDefaultInitialSize / MB));
+ std::string max_heap_string(StringPrintf("-Xmx%zdm", gc::Heap::kDefaultMaximumSize / MB));
Runtime::Options options;
options.push_back(std::make_pair("compiler", reinterpret_cast<void*>(NULL)));
@@ -313,49 +313,50 @@
// Runtime::Create acquired the mutator_lock_ that is normally given away when we Runtime::Start,
// give it away now and then switch to a more managable ScopedObjectAccess.
Thread::Current()->TransitionFromRunnableToSuspended(kNative);
- // Whilst we're in native take the opportunity to initialize well known classes.
- WellKnownClasses::InitClasses(Thread::Current()->GetJniEnv());
- ScopedObjectAccess soa(Thread::Current());
- ASSERT_TRUE(runtime_.get() != NULL);
- class_linker_ = runtime_->GetClassLinker();
+ {
+ ScopedObjectAccess soa(Thread::Current());
+ ASSERT_TRUE(runtime_.get() != NULL);
+ class_linker_ = runtime_->GetClassLinker();
- InstructionSet instruction_set = kNone;
+ InstructionSet instruction_set = kNone;
#if defined(__arm__)
- instruction_set = kThumb2;
+ instruction_set = kThumb2;
#elif defined(__mips__)
- instruction_set = kMips;
+ instruction_set = kMips;
#elif defined(__i386__)
- instruction_set = kX86;
+ instruction_set = kX86;
#endif
- // TODO: make selectable
+ // TODO: make selectable
#if defined(ART_USE_PORTABLE_COMPILER)
- CompilerBackend compiler_backend = kPortable;
+ CompilerBackend compiler_backend = kPortable;
#else
- CompilerBackend compiler_backend = kQuick;
+ CompilerBackend compiler_backend = kQuick;
#endif
- if (!runtime_->HasResolutionMethod()) {
- runtime_->SetResolutionMethod(runtime_->CreateResolutionMethod());
- }
- for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) {
- Runtime::CalleeSaveType type = Runtime::CalleeSaveType(i);
- if (!runtime_->HasCalleeSaveMethod(type)) {
- runtime_->SetCalleeSaveMethod(
- runtime_->CreateCalleeSaveMethod(instruction_set, type), type);
+ if (!runtime_->HasResolutionMethod()) {
+ runtime_->SetResolutionMethod(runtime_->CreateResolutionMethod());
}
+ for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) {
+ Runtime::CalleeSaveType type = Runtime::CalleeSaveType(i);
+ if (!runtime_->HasCalleeSaveMethod(type)) {
+ runtime_->SetCalleeSaveMethod(
+ runtime_->CreateCalleeSaveMethod(instruction_set, type), type);
+ }
+ }
+ class_linker_->FixupDexCaches(runtime_->GetResolutionMethod());
+ compiler_driver_.reset(new CompilerDriver(compiler_backend, instruction_set,
+ true, new CompilerDriver::DescriptorSet,
+ 2, false, true, true));
}
- class_linker_->FixupDexCaches(runtime_->GetResolutionMethod());
- compiler_driver_.reset(new CompilerDriver(compiler_backend, instruction_set,
- true, new CompilerDriver::DescriptorSet,
- 2, false, true, true));
// We typically don't generate an image in unit tests, disable this optimization by default.
compiler_driver_->SetSupportBootImageFixup(false);
+ // We're back in native, take the opportunity to initialize well known classes.
+ WellKnownClasses::InitClasses(Thread::Current()->GetJniEnv());
// Create the heap thread pool so that the GC runs in parallel for tests. Normally, the thread
// pool is created by the runtime.
runtime_->GetHeap()->CreateThreadPool();
-
runtime_->GetHeap()->VerifyHeap(); // Check for heap corruption before the test
}