summaryrefslogtreecommitdiff
path: root/runtime/obj_ptr-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/obj_ptr-inl.h')
-rw-r--r--runtime/obj_ptr-inl.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/runtime/obj_ptr-inl.h b/runtime/obj_ptr-inl.h
index 3dfcf9e2cf..1c698b5c4d 100644
--- a/runtime/obj_ptr-inl.h
+++ b/runtime/obj_ptr-inl.h
@@ -41,6 +41,7 @@ inline void ObjPtr<MirrorType, kPoison>::AssertValid() const {
template<class MirrorType, bool kPoison>
inline uintptr_t ObjPtr<MirrorType, kPoison>::Encode(MirrorType* ptr) {
uintptr_t ref = reinterpret_cast<uintptr_t>(ptr);
+ DCHECK_ALIGNED(ref, kObjectAlignment);
if (kPoison && ref != 0) {
DCHECK_LE(ref, 0xFFFFFFFFU);
ref >>= kObjectAlignmentShift;
@@ -52,6 +53,12 @@ inline uintptr_t ObjPtr<MirrorType, kPoison>::Encode(MirrorType* ptr) {
return ref;
}
+template<class MirrorType, bool kPoison>
+inline std::ostream& operator<<(std::ostream& os, ObjPtr<MirrorType, kPoison> ptr) {
+ // May be used for dumping bad pointers, do not use the checked version.
+ return os << ptr.DecodeUnchecked();
+}
+
} // namespace art
#endif // ART_RUNTIME_OBJ_PTR_INL_H_