summaryrefslogtreecommitdiffstats
path: root/runtime/entrypoints/quick
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/entrypoints/quick
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/entrypoints/quick')
-rw-r--r--runtime/entrypoints/quick/quick_lock_entrypoints.cc12
-rw-r--r--runtime/entrypoints/quick/quick_trampoline_entrypoints.cc10
2 files changed, 14 insertions, 8 deletions
diff --git a/runtime/entrypoints/quick/quick_lock_entrypoints.cc b/runtime/entrypoints/quick/quick_lock_entrypoints.cc
index 2102ab1..540abb3 100644
--- a/runtime/entrypoints/quick/quick_lock_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_lock_entrypoints.cc
@@ -29,9 +29,15 @@ extern "C" int artLockObjectFromCode(mirror::Object* obj, Thread* self, mirror::
"Null reference used for synchronization (monitor-enter)");
return -1; // Failure.
} else {
- obj->MonitorEnter(self); // May block
- DCHECK(self->HoldsLock(obj));
- DCHECK(!self->IsExceptionPending());
+ if (kIsDebugBuild) {
+ // GC may move the obj, need Sirt for the following DCHECKs.
+ SirtRef<mirror::Object> sirt_obj(self, obj);
+ obj->MonitorEnter(self); // May block
+ CHECK(self->HoldsLock(sirt_obj.get()));
+ CHECK(!self->IsExceptionPending());
+ } else {
+ obj->MonitorEnter(self); // May block
+ }
return 0; // Success.
// Only possible exception is NPE and is handled before entry
}
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 01d3549..8ba08ee 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -416,10 +416,10 @@ extern "C" uint64_t artQuickProxyInvokeHandler(mirror::ArtMethod* proxy_method,
// Read object references held in arguments from quick frames and place in a JNI local references,
// so they don't get garbage collected.
-class RememberFoGcArgumentVisitor : public QuickArgumentVisitor {
+class RememberForGcArgumentVisitor : public QuickArgumentVisitor {
public:
- RememberFoGcArgumentVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty,
- uint32_t shorty_len, ScopedObjectAccessUnchecked* soa) :
+ RememberForGcArgumentVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty,
+ uint32_t shorty_len, ScopedObjectAccessUnchecked* soa) :
QuickArgumentVisitor(sp, is_static, shorty, shorty_len), soa_(soa) {}
virtual void Visit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -441,7 +441,7 @@ class RememberFoGcArgumentVisitor : public QuickArgumentVisitor {
private:
ScopedObjectAccessUnchecked* soa_;
std::vector<std::pair<jobject, mirror::Object**> > references_;
- DISALLOW_COPY_AND_ASSIGN(RememberFoGcArgumentVisitor);
+ DISALLOW_COPY_AND_ASSIGN(RememberForGcArgumentVisitor);
};
// Lazily resolve a method for quick. Called by stub code.
@@ -531,7 +531,7 @@ extern "C" const void* artQuickResolutionTrampoline(mirror::ArtMethod* called,
uint32_t shorty_len;
const char* shorty =
dex_file->GetMethodShorty(dex_file->GetMethodId(dex_method_idx), &shorty_len);
- RememberFoGcArgumentVisitor visitor(sp, invoke_type == kStatic, shorty, shorty_len, &soa);
+ RememberForGcArgumentVisitor visitor(sp, invoke_type == kStatic, shorty, shorty_len, &soa);
visitor.VisitArguments();
thread->EndAssertNoThreadSuspension(old_cause);
// Resolve method filling in dex cache.