summaryrefslogtreecommitdiffstats
path: root/runtime/reference_table.cc
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-09-03 16:16:56 -0700
committerIan Rogers <irogers@google.com>2014-09-03 17:15:54 -0700
commitc0542af3e2170143ba40d89136e284997e16bf64 (patch)
treea61e3b9cd297a4c52a0c0488a502cb77c47f0690 /runtime/reference_table.cc
parentd3c9358544bbab15093614c5c2b6a9de86e11f7b (diff)
downloadart-c0542af3e2170143ba40d89136e284997e16bf64.zip
art-c0542af3e2170143ba40d89136e284997e16bf64.tar.gz
art-c0542af3e2170143ba40d89136e284997e16bf64.tar.bz2
Remove abuse of mirror::Object* to reference special values.
Remove kInvalidIndirectRefObject, kClearedJniWeakGlobal and ObjectRegistry::kInvalidObject. Handle error conditions by passing in or returning an error value. GetObjectRefType is simplified to be faster and not return invalid references that are not expected according to the spec. Adjust check JNI and jni_internal_test appropriately. Fix cases in the debugger/JDWP of out arguments being passed by reference. Bug: 17376993 Change-Id: I3ce8a28c01827e163f4dc288449959464da788b1
Diffstat (limited to 'runtime/reference_table.cc')
-rw-r--r--runtime/reference_table.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/runtime/reference_table.cc b/runtime/reference_table.cc
index 70aba9b..01c5070 100644
--- a/runtime/reference_table.cc
+++ b/runtime/reference_table.cc
@@ -24,6 +24,7 @@
#include "mirror/class-inl.h"
#include "mirror/object-inl.h"
#include "mirror/string-inl.h"
+#include "runtime-inl.h"
#include "thread.h"
#include "utils.h"
@@ -62,7 +63,9 @@ void ReferenceTable::Remove(mirror::Object* obj) {
// If "obj" is an array, return the number of elements in the array.
// Otherwise, return zero.
static size_t GetElementCount(mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- if (obj == NULL || obj == kClearedJniWeakGlobal || !obj->IsArrayInstance()) {
+ // We assume the special cleared value isn't an array in the if statement below.
+ DCHECK(!Runtime::Current()->GetClearedJniWeakGlobal()->IsArrayInstance());
+ if (obj == nullptr || !obj->IsArrayInstance()) {
return 0;
}
return obj->AsArray()->GetLength();
@@ -81,9 +84,10 @@ struct ObjectComparator {
} else if (obj2 == NULL) {
return false;
}
- if (obj1 == kClearedJniWeakGlobal) {
+ Runtime* runtime = Runtime::Current();
+ if (runtime->IsClearedJniWeakGlobal(obj1)) {
return true;
- } else if (obj2 == kClearedJniWeakGlobal) {
+ } else if (runtime->IsClearedJniWeakGlobal(obj2)) {
return false;
}
@@ -116,7 +120,7 @@ static void DumpSummaryLine(std::ostream& os, mirror::Object* obj, size_t elemen
os << " NULL reference (count=" << equiv << ")\n";
return;
}
- if (obj == kClearedJniWeakGlobal) {
+ if (Runtime::Current()->IsClearedJniWeakGlobal(obj)) {
os << " cleared jweak (count=" << equiv << ")\n";
return;
}
@@ -167,7 +171,7 @@ void ReferenceTable::Dump(std::ostream& os, Table& entries) {
if (ref == NULL) {
continue;
}
- if (ref == kClearedJniWeakGlobal) {
+ if (Runtime::Current()->IsClearedJniWeakGlobal(ref)) {
os << StringPrintf(" %5d: cleared jweak\n", idx);
continue;
}
@@ -209,7 +213,8 @@ void ReferenceTable::Dump(std::ostream& os, Table& entries) {
sorted_entries.pop_back();
}
while (!sorted_entries.empty() &&
- sorted_entries.back().Read<kWithoutReadBarrier>() == kClearedJniWeakGlobal) {
+ Runtime::Current()->IsClearedJniWeakGlobal(
+ sorted_entries.back().Read<kWithoutReadBarrier>())) {
sorted_entries.pop_back();
}
if (sorted_entries.empty()) {