summaryrefslogtreecommitdiffstats
path: root/runtime/method_helper.h
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-09-11 08:30:08 -0700
committerAndreas Gampe <agampe@google.com>2014-09-15 19:50:12 -0700
commit5a4b8a236030460651a3136397d23ca6744e7eb7 (patch)
tree0e43891398e416d3fa77c7de391bf4db4408e8ee /runtime/method_helper.h
parent19f7c95491a053b818f914137fa73df0517b8792 (diff)
downloadart-5a4b8a236030460651a3136397d23ca6744e7eb7.zip
art-5a4b8a236030460651a3136397d23ca6744e7eb7.tar.gz
art-5a4b8a236030460651a3136397d23ca6744e7eb7.tar.bz2
ART: Rename Handle hierarchy
Bring the names in line with normal OO principles: ConstHandle becomes Handle, and Handle becomes MutableHandle. Change-Id: I0f018eb7ba28bc422e3a23dd73a6cbe6fc2d2044
Diffstat (limited to 'runtime/method_helper.h')
-rw-r--r--runtime/method_helper.h53
1 files changed, 36 insertions, 17 deletions
diff --git a/runtime/method_helper.h b/runtime/method_helper.h
index 8150456..fe364d3 100644
--- a/runtime/method_helper.h
+++ b/runtime/method_helper.h
@@ -24,17 +24,11 @@
namespace art {
-class MethodHelper {
+template <template <class T> class HandleKind>
+class MethodHelperT {
public:
- explicit MethodHelper(Handle<mirror::ArtMethod> m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : method_(m), shorty_(nullptr), shorty_len_(0) {
- SetMethod(m.Get());
- }
-
- void ChangeMethod(mirror::ArtMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- DCHECK(new_m != nullptr);
- SetMethod(new_m);
- shorty_ = nullptr;
+ explicit MethodHelperT(HandleKind<mirror::ArtMethod> m)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : method_(m), shorty_(nullptr), shorty_len_(0) {
}
mirror::ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -110,10 +104,12 @@ class MethodHelper {
return GetParamPrimitiveType(param) == Primitive::kPrimNot;
}
- ALWAYS_INLINE bool HasSameNameAndSignature(MethodHelper* other)
+ template <template <class T> class HandleKind2>
+ ALWAYS_INLINE bool HasSameNameAndSignature(MethodHelperT<HandleKind2>* other)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool HasSameSignatureWithDifferentClassLoaders(MethodHelper* other)
+ template <template <class T> class HandleKind2>
+ bool HasSameSignatureWithDifferentClassLoaders(MethodHelperT<HandleKind2>* other)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
mirror::Class* GetClassFromTypeIdx(uint16_t type_idx, bool resolve = true)
@@ -130,6 +126,33 @@ class MethodHelper {
uint32_t name_and_signature_idx)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ protected:
+ HandleKind<mirror::ArtMethod> method_;
+
+ const char* shorty_;
+ uint32_t shorty_len_;
+
+ private:
+ template <template <class T2> class HandleKind2> friend class MethodHelperT;
+
+ DISALLOW_COPY_AND_ASSIGN(MethodHelperT);
+};
+
+class MethodHelper : public MethodHelperT<Handle> {
+ using MethodHelperT<Handle>::MethodHelperT;
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MethodHelper);
+};
+
+class MutableMethodHelper : public MethodHelperT<MutableHandle> {
+ using MethodHelperT<MutableHandle>::MethodHelperT;
+ public:
+ void ChangeMethod(mirror::ArtMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+ DCHECK(new_m != nullptr);
+ SetMethod(new_m);
+ shorty_ = nullptr;
+ }
+
private:
// Set the method_ field, for proxy methods looking up the interface method via the resolved
// methods table.
@@ -137,11 +160,7 @@ class MethodHelper {
method_.Assign(method);
}
- Handle<mirror::ArtMethod> method_;
- const char* shorty_;
- uint32_t shorty_len_;
-
- DISALLOW_COPY_AND_ASSIGN(MethodHelper);
+ DISALLOW_COPY_AND_ASSIGN(MutableMethodHelper);
};
} // namespace art