summaryrefslogtreecommitdiffstats
path: root/runtime/indirect_reference_table-inl.h
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/indirect_reference_table-inl.h
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/indirect_reference_table-inl.h')
-rw-r--r--runtime/indirect_reference_table-inl.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/runtime/indirect_reference_table-inl.h b/runtime/indirect_reference_table-inl.h
index 00f7b06..9bf3ea2 100644
--- a/runtime/indirect_reference_table-inl.h
+++ b/runtime/indirect_reference_table-inl.h
@@ -19,6 +19,7 @@
#include "indirect_reference_table.h"
+#include "runtime-inl.h"
#include "verify_object-inl.h"
namespace art {
@@ -26,6 +27,15 @@ namespace mirror {
class Object;
} // namespace mirror
+inline void IrtIterator::SkipNullsAndTombstones() {
+ // We skip NULLs and tombstones. Clients don't want to see implementation details.
+ while (i_ < capacity_ &&
+ (table_[i_].IsNull() ||
+ Runtime::Current()->IsClearedJniWeakGlobal(table_[i_].Read<kWithoutReadBarrier>()))) {
+ ++i_;
+ }
+}
+
// Verifies that the indirect table lookup is valid.
// Returns "false" if something looks bad.
inline bool IndirectReferenceTable::GetChecked(IndirectRef iref) const {
@@ -73,15 +83,11 @@ inline bool IndirectReferenceTable::CheckEntry(const char* what, IndirectRef ire
template<ReadBarrierOption kReadBarrierOption>
inline mirror::Object* IndirectReferenceTable::Get(IndirectRef iref) const {
if (!GetChecked(iref)) {
- return kInvalidIndirectRefObject;
+ return nullptr;
}
uint32_t idx = ExtractIndex(iref);
- mirror::Object* obj = table_[idx].Read<kWithoutReadBarrier>();
- if (LIKELY(obj != kClearedJniWeakGlobal)) {
- // The read barrier or VerifyObject won't handle kClearedJniWeakGlobal.
- obj = table_[idx].Read<kReadBarrierOption>();
- VerifyObject(obj);
- }
+ mirror::Object* obj = table_[idx].Read<kReadBarrierOption>();
+ VerifyObject(obj);
return obj;
}