Move monitor related object routines to object-inl.h
Also pass through readily available self Thread. Remove unused wait method.
Rename ObjectLock.Wait to document it doesn't honor interrupts.
Change-Id: I991e5036997b3f60ee4fdf1a420beabab9a70c85
diff --git a/src/mirror/object-inl.h b/src/mirror/object-inl.h
index 723192d..b6c8008 100644
--- a/src/mirror/object-inl.h
+++ b/src/mirror/object-inl.h
@@ -24,7 +24,9 @@
#include "array.h"
#include "field.h"
#include "class.h"
+#include "monitor.h"
#include "runtime.h"
+#include "throwable.h"
namespace art {
namespace mirror {
@@ -41,6 +43,34 @@
SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(Object, klass_), new_klass, false, false);
}
+inline uint32_t Object::GetThinLockId() {
+ return Monitor::GetThinLockId(monitor_);
+}
+
+inline void Object::MonitorEnter(Thread* self) {
+ Monitor::MonitorEnter(self, this);
+}
+
+inline bool Object::MonitorExit(Thread* self) {
+ return Monitor::MonitorExit(self, this);
+}
+
+inline void Object::Notify(Thread* self) {
+ Monitor::Notify(self, this);
+}
+
+inline void Object::NotifyAll(Thread* self) {
+ Monitor::NotifyAll(self, this);
+}
+
+inline void Object::Wait(Thread* self) {
+ Monitor::Wait(self, this, 0, 0, true, kWaiting);
+}
+
+inline void Object::Wait(Thread* self, int64_t ms, int32_t ns) {
+ Monitor::Wait(self, this, ms, ns, true, kTimedWaiting);
+}
+
inline bool Object::InstanceOf(const Class* klass) const {
DCHECK(klass != NULL);
DCHECK(GetClass() != NULL);
@@ -114,6 +144,64 @@
return GetClass()->IsReferenceClass();
}
+inline Array* Object::AsArray() {
+ DCHECK(IsArrayInstance());
+ return down_cast<Array*>(this);
+}
+
+inline const Array* Object::AsArray() const {
+ DCHECK(IsArrayInstance());
+ return down_cast<const Array*>(this);
+}
+
+inline BooleanArray* Object::AsBooleanArray() {
+ DCHECK(GetClass()->IsArrayClass());
+ DCHECK(GetClass()->GetComponentType()->IsPrimitiveBoolean());
+ return down_cast<BooleanArray*>(this);
+}
+
+inline ByteArray* Object::AsByteArray() {
+ DCHECK(GetClass()->IsArrayClass());
+ DCHECK(GetClass()->GetComponentType()->IsPrimitiveByte());
+ return down_cast<ByteArray*>(this);
+}
+
+inline CharArray* Object::AsCharArray() {
+ DCHECK(GetClass()->IsArrayClass());
+ DCHECK(GetClass()->GetComponentType()->IsPrimitiveChar());
+ return down_cast<CharArray*>(this);
+}
+
+inline ShortArray* Object::AsShortArray() {
+ DCHECK(GetClass()->IsArrayClass());
+ DCHECK(GetClass()->GetComponentType()->IsPrimitiveShort());
+ return down_cast<ShortArray*>(this);
+}
+
+inline IntArray* Object::AsIntArray() {
+ DCHECK(GetClass()->IsArrayClass());
+ DCHECK(GetClass()->GetComponentType()->IsPrimitiveInt() ||
+ GetClass()->GetComponentType()->IsPrimitiveFloat());
+ return down_cast<IntArray*>(this);
+}
+
+inline LongArray* Object::AsLongArray() {
+ DCHECK(GetClass()->IsArrayClass());
+ DCHECK(GetClass()->GetComponentType()->IsPrimitiveLong() ||
+ GetClass()->GetComponentType()->IsPrimitiveDouble());
+ return down_cast<LongArray*>(this);
+}
+
+inline String* Object::AsString() {
+ DCHECK(GetClass()->IsStringClass());
+ return down_cast<String*>(this);
+}
+
+inline Throwable* Object::AsThrowable() {
+ DCHECK(GetClass()->IsThrowableClass());
+ return down_cast<Throwable*>(this);
+}
+
inline bool Object::IsWeakReferenceInstance() const {
return GetClass()->IsWeakReferenceClass();
}