summaryrefslogtreecommitdiffstats
path: root/runtime/mirror/class.cc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2013-09-13 13:46:47 -0700
committerMathieu Chartier <mathieuc@google.com>2013-11-11 15:34:27 -0800
commit590fee9e8972f872301c2d16a575d579ee564bee (patch)
treeb02db45c72f1911ec896b93379ada0276aea3199 /runtime/mirror/class.cc
parent5b70680b8df6d8fa95bb8e1070d0107f3d388940 (diff)
downloadart-590fee9e8972f872301c2d16a575d579ee564bee.zip
art-590fee9e8972f872301c2d16a575d579ee564bee.tar.gz
art-590fee9e8972f872301c2d16a575d579ee564bee.tar.bz2
Compacting collector.
The compacting collector is currently similar to semispace. It works by copying objects back and forth between two bump pointer spaces. There are types of objects which are "non-movable" due to current runtime limitations. These are Classes, Methods, and Fields. Bump pointer spaces are a new type of continuous alloc space which have no lock in the allocation code path. When you allocate from these it uses atomic operations to increase an index. Traversing the objects in the bump pointer space relies on Object::SizeOf matching the allocated size exactly. Runtime changes: JNI::GetArrayElements returns copies objects if you attempt to get the backing data of a movable array. For GetArrayElementsCritical, we return direct backing storage for any types of arrays, but temporarily disable the GC until the critical region is completed. Added a new runtime call called VisitObjects, this is used in place of the old pattern which was flushing the allocation stack and walking the bitmaps. Changed image writer to be compaction safe and use object monitor word for forwarding addresses. Added a bunch of added SIRTs to ClassLinker, MethodLinker, etc.. TODO: Enable switching allocators, compacting on background, etc.. Bug: 8981901 Change-Id: I3c886fd322a6eef2b99388d19a765042ec26ab99
Diffstat (limited to 'runtime/mirror/class.cc')
-rw-r--r--runtime/mirror/class.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index f3cb54a..cdc5ab2 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -52,7 +52,8 @@ void Class::ResetClass() {
void Class::SetStatus(Status new_status, Thread* self) {
Status old_status = GetStatus();
- bool class_linker_initialized = Runtime::Current()->GetClassLinker() != nullptr;
+ ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
+ bool class_linker_initialized = class_linker != nullptr && class_linker->IsInitialized();
if (LIKELY(class_linker_initialized)) {
if (UNLIKELY(new_status <= old_status && new_status != kStatusError)) {
LOG(FATAL) << "Unexpected change back of class status for " << PrettyClass(this) << " "
@@ -588,7 +589,6 @@ ArtField* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex
ArtField* Class::FindStaticField(const StringPiece& name, const StringPiece& type) {
// Is the field in this class (or its interfaces), or any of its
// superclasses (or their interfaces)?
- ClassHelper kh;
for (Class* k = this; k != NULL; k = k->GetSuperClass()) {
// Is the field in this class?
ArtField* f = k->FindDeclaredStaticField(name, type);
@@ -596,7 +596,7 @@ ArtField* Class::FindStaticField(const StringPiece& name, const StringPiece& typ
return f;
}
// Is this field in any of this class' interfaces?
- kh.ChangeClass(k);
+ ClassHelper kh(k);
for (uint32_t i = 0; i < kh.NumDirectInterfaces(); ++i) {
Class* interface = kh.GetDirectInterface(i);
f = interface->FindStaticField(name, type);
@@ -609,7 +609,6 @@ ArtField* Class::FindStaticField(const StringPiece& name, const StringPiece& typ
}
ArtField* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) {
- ClassHelper kh;
for (Class* k = this; k != NULL; k = k->GetSuperClass()) {
// Is the field in this class?
ArtField* f = k->FindDeclaredStaticField(dex_cache, dex_field_idx);
@@ -617,7 +616,7 @@ ArtField* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_i
return f;
}
// Is this field in any of this class' interfaces?
- kh.ChangeClass(k);
+ ClassHelper kh(k);
for (uint32_t i = 0; i < kh.NumDirectInterfaces(); ++i) {
Class* interface = kh.GetDirectInterface(i);
f = interface->FindStaticField(dex_cache, dex_field_idx);
@@ -631,7 +630,6 @@ ArtField* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_i
ArtField* Class::FindField(const StringPiece& name, const StringPiece& type) {
// Find a field using the JLS field resolution order
- ClassHelper kh;
for (Class* k = this; k != NULL; k = k->GetSuperClass()) {
// Is the field in this class?
ArtField* f = k->FindDeclaredInstanceField(name, type);
@@ -643,7 +641,7 @@ ArtField* Class::FindField(const StringPiece& name, const StringPiece& type) {
return f;
}
// Is this field in any of this class' interfaces?
- kh.ChangeClass(k);
+ ClassHelper kh(k);
for (uint32_t i = 0; i < kh.NumDirectInterfaces(); ++i) {
Class* interface = kh.GetDirectInterface(i);
f = interface->FindStaticField(name, type);