summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler/jni/quick/arm/calling_convention_arm.cc1
-rw-r--r--compiler/jni/quick/arm64/calling_convention_arm64.cc1
-rw-r--r--compiler/jni/quick/mips/calling_convention_mips.cc1
-rw-r--r--compiler/jni/quick/x86/calling_convention_x86.cc1
-rw-r--r--compiler/jni/quick/x86_64/calling_convention_x86_64.cc1
-rw-r--r--runtime/handle_scope-inl.h66
-rw-r--r--runtime/handle_scope.h62
-rw-r--r--runtime/mirror/array-inl.h1
8 files changed, 83 insertions, 51 deletions
diff --git a/compiler/jni/quick/arm/calling_convention_arm.cc b/compiler/jni/quick/arm/calling_convention_arm.cc
index 769cd4c83d..a3323e133a 100644
--- a/compiler/jni/quick/arm/calling_convention_arm.cc
+++ b/compiler/jni/quick/arm/calling_convention_arm.cc
@@ -16,6 +16,7 @@
#include "base/logging.h"
#include "calling_convention_arm.h"
+#include "handle_scope-inl.h"
#include "utils/arm/managed_register_arm.h"
namespace art {
diff --git a/compiler/jni/quick/arm64/calling_convention_arm64.cc b/compiler/jni/quick/arm64/calling_convention_arm64.cc
index 29763a2a10..b9c81787f0 100644
--- a/compiler/jni/quick/arm64/calling_convention_arm64.cc
+++ b/compiler/jni/quick/arm64/calling_convention_arm64.cc
@@ -16,6 +16,7 @@
#include "base/logging.h"
#include "calling_convention_arm64.h"
+#include "handle_scope-inl.h"
#include "utils/arm64/managed_register_arm64.h"
namespace art {
diff --git a/compiler/jni/quick/mips/calling_convention_mips.cc b/compiler/jni/quick/mips/calling_convention_mips.cc
index f7a7be7304..aefbf06fd7 100644
--- a/compiler/jni/quick/mips/calling_convention_mips.cc
+++ b/compiler/jni/quick/mips/calling_convention_mips.cc
@@ -17,6 +17,7 @@
#include "calling_convention_mips.h"
#include "base/logging.h"
+#include "handle_scope-inl.h"
#include "utils/mips/managed_register_mips.h"
namespace art {
diff --git a/compiler/jni/quick/x86/calling_convention_x86.cc b/compiler/jni/quick/x86/calling_convention_x86.cc
index 9bf7d0f071..a5686e1ac7 100644
--- a/compiler/jni/quick/x86/calling_convention_x86.cc
+++ b/compiler/jni/quick/x86/calling_convention_x86.cc
@@ -17,6 +17,7 @@
#include "calling_convention_x86.h"
#include "base/logging.h"
+#include "handle_scope-inl.h"
#include "utils/x86/managed_register_x86.h"
#include "utils.h"
diff --git a/compiler/jni/quick/x86_64/calling_convention_x86_64.cc b/compiler/jni/quick/x86_64/calling_convention_x86_64.cc
index a100552695..bbdf1fe7bb 100644
--- a/compiler/jni/quick/x86_64/calling_convention_x86_64.cc
+++ b/compiler/jni/quick/x86_64/calling_convention_x86_64.cc
@@ -17,6 +17,7 @@
#include "calling_convention_x86_64.h"
#include "base/logging.h"
+#include "handle_scope-inl.h"
#include "utils/x86_64/managed_register_x86_64.h"
#include "utils.h"
diff --git a/runtime/handle_scope-inl.h b/runtime/handle_scope-inl.h
index 9ddaf61c9f..421a413fb1 100644
--- a/runtime/handle_scope-inl.h
+++ b/runtime/handle_scope-inl.h
@@ -21,6 +21,7 @@
#include "handle.h"
#include "thread.h"
+#include "verify_object-inl.h"
namespace art {
@@ -42,6 +43,71 @@ inline StackHandleScope<kNumReferences>::~StackHandleScope() {
DCHECK_EQ(top_handle_scope, this);
}
+inline size_t HandleScope::SizeOf(uint32_t num_references) {
+ size_t header_size = sizeof(HandleScope);
+ size_t data_size = sizeof(StackReference<mirror::Object>) * num_references;
+ return header_size + data_size;
+}
+
+inline size_t HandleScope::SizeOf(size_t pointer_size, uint32_t num_references) {
+ // Assume that the layout is packed.
+ size_t header_size = pointer_size + sizeof(number_of_references_);
+ size_t data_size = sizeof(StackReference<mirror::Object>) * num_references;
+ return header_size + data_size;
+}
+
+inline mirror::Object* HandleScope::GetReference(size_t i) const {
+ DCHECK_LT(i, number_of_references_);
+ return GetReferences()[i].AsMirrorPtr();
+}
+
+inline Handle<mirror::Object> HandleScope::GetHandle(size_t i) {
+ DCHECK_LT(i, number_of_references_);
+ return Handle<mirror::Object>(&GetReferences()[i]);
+}
+
+inline MutableHandle<mirror::Object> HandleScope::GetMutableHandle(size_t i) {
+ DCHECK_LT(i, number_of_references_);
+ return MutableHandle<mirror::Object>(&GetReferences()[i]);
+}
+
+inline void HandleScope::SetReference(size_t i, mirror::Object* object) {
+ DCHECK_LT(i, number_of_references_);
+ GetReferences()[i].Assign(object);
+}
+
+inline bool HandleScope::Contains(StackReference<mirror::Object>* handle_scope_entry) const {
+ // A HandleScope should always contain something. One created by the
+ // jni_compiler should have a jobject/jclass as a native method is
+ // passed in a this pointer or a class
+ DCHECK_GT(number_of_references_, 0U);
+ return &GetReferences()[0] <= handle_scope_entry &&
+ handle_scope_entry <= &GetReferences()[number_of_references_ - 1];
+}
+
+template<size_t kNumReferences> template<class T>
+inline MutableHandle<T> StackHandleScope<kNumReferences>::NewHandle(T* object) {
+ SetReference(pos_, object);
+ MutableHandle<T> h(GetHandle<T>(pos_));
+ pos_++;
+ return h;
+}
+
+template<size_t kNumReferences> template<class T>
+inline HandleWrapper<T> StackHandleScope<kNumReferences>::NewHandleWrapper(T** object) {
+ SetReference(pos_, *object);
+ MutableHandle<T> h(GetHandle<T>(pos_));
+ pos_++;
+ return HandleWrapper<T>(object, h);
+}
+
+template<size_t kNumReferences>
+inline void StackHandleScope<kNumReferences>::SetReference(size_t i, mirror::Object* object) {
+ DCHECK_LT(i, kNumReferences);
+ VerifyObject(object);
+ GetReferences()[i].Assign(object);
+}
+
} // namespace art
#endif // ART_RUNTIME_HANDLE_SCOPE_INL_H_
diff --git a/runtime/handle_scope.h b/runtime/handle_scope.h
index 2c4f0f915d..782bbeaabc 100644
--- a/runtime/handle_scope.h
+++ b/runtime/handle_scope.h
@@ -22,6 +22,7 @@
#include "handle.h"
#include "stack.h"
#include "utils.h"
+#include "verify_object.h"
namespace art {
namespace mirror {
@@ -47,19 +48,10 @@ class PACKED(4) HandleScope {
// takes the pointer size explicitly so that at compile time we can cross-compile correctly.
// Returns the size of a HandleScope containing num_references handles.
- static size_t SizeOf(uint32_t num_references) {
- size_t header_size = sizeof(HandleScope);
- size_t data_size = sizeof(StackReference<mirror::Object>) * num_references;
- return header_size + data_size;
- }
+ static size_t SizeOf(uint32_t num_references);
// Returns the size of a HandleScope containing num_references handles.
- static size_t SizeOf(size_t pointer_size, uint32_t num_references) {
- // Assume that the layout is packed.
- size_t header_size = pointer_size + sizeof(number_of_references_);
- size_t data_size = sizeof(StackReference<mirror::Object>) * num_references;
- return header_size + data_size;
- }
+ static size_t SizeOf(size_t pointer_size, uint32_t num_references);
// Link to previous HandleScope or null.
HandleScope* GetLink() const {
@@ -67,37 +59,18 @@ class PACKED(4) HandleScope {
}
ALWAYS_INLINE mirror::Object* GetReference(size_t i) const
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- DCHECK_LT(i, number_of_references_);
- return GetReferences()[i].AsMirrorPtr();
- }
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
ALWAYS_INLINE Handle<mirror::Object> GetHandle(size_t i)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- DCHECK_LT(i, number_of_references_);
- return Handle<mirror::Object>(&GetReferences()[i]);
- }
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
ALWAYS_INLINE MutableHandle<mirror::Object> GetMutableHandle(size_t i)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- DCHECK_LT(i, number_of_references_);
- return MutableHandle<mirror::Object>(&GetReferences()[i]);
- }
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
ALWAYS_INLINE void SetReference(size_t i, mirror::Object* object)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- DCHECK_LT(i, number_of_references_);
- GetReferences()[i].Assign(object);
- }
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool Contains(StackReference<mirror::Object>* handle_scope_entry) const {
- // A HandleScope should always contain something. One created by the
- // jni_compiler should have a jobject/jclass as a native method is
- // passed in a this pointer or a class
- DCHECK_GT(number_of_references_, 0U);
- return &GetReferences()[0] <= handle_scope_entry &&
- handle_scope_entry <= &GetReferences()[number_of_references_ - 1];
- }
+ ALWAYS_INLINE bool Contains(StackReference<mirror::Object>* handle_scope_entry) const;
// Offset of link within HandleScope, used by generated code.
static size_t LinkOffset(size_t pointer_size ATTRIBUTE_UNUSED) {
@@ -174,27 +147,14 @@ class PACKED(4) StackHandleScope FINAL : public HandleScope {
ALWAYS_INLINE ~StackHandleScope();
template<class T>
- ALWAYS_INLINE MutableHandle<T> NewHandle(T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- SetReference(pos_, object);
- MutableHandle<T> h(GetHandle<T>(pos_));
- pos_++;
- return h;
- }
+ ALWAYS_INLINE MutableHandle<T> NewHandle(T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
template<class T>
ALWAYS_INLINE HandleWrapper<T> NewHandleWrapper(T** object)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- SetReference(pos_, *object);
- MutableHandle<T> h(GetHandle<T>(pos_));
- pos_++;
- return HandleWrapper<T>(object, h);
- }
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
ALWAYS_INLINE void SetReference(size_t i, mirror::Object* object)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- DCHECK_LT(i, kNumReferences);
- GetReferences()[i].Assign(object);
- }
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
private:
template<class T>
diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h
index 13f881d966..4dddd38b80 100644
--- a/runtime/mirror/array-inl.h
+++ b/runtime/mirror/array-inl.h
@@ -19,6 +19,7 @@
#include "array.h"
+#include "base/stringprintf.h"
#include "class.h"
#include "gc/heap-inl.h"
#include "thread.h"