summaryrefslogtreecommitdiffstats
path: root/runtime/mirror
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2018-05-24 15:19:52 +0100
committerVladimir Marko <vmarko@google.com>2018-05-25 11:37:45 +0100
commitc7aa87e1666ac48ddf9149cfdfd64b026b3969e5 (patch)
tree32d5d74718cc558e13642873e55724782ac9df22 /runtime/mirror
parent0278be74269fcfe4f2517d449f2bd53472f9b2f9 (diff)
downloadart-c7aa87e1666ac48ddf9149cfdfd64b026b3969e5.tar.gz
art-c7aa87e1666ac48ddf9149cfdfd64b026b3969e5.tar.bz2
art-c7aa87e1666ac48ddf9149cfdfd64b026b3969e5.zip
Remove static_class_ from Method/VarHandle and CallSite.
And add MethodHandle to the class roots to avoid extra indirection through MethodHandleImpl. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: Iaf172f3732677f2b4509e8297e6e9af5fb81a89f
Diffstat (limited to 'runtime/mirror')
-rw-r--r--runtime/mirror/call_site.cc20
-rw-r--r--runtime/mirror/call_site.h10
-rw-r--r--runtime/mirror/method_handle_impl.cc32
-rw-r--r--runtime/mirror/method_handle_impl.h9
-rw-r--r--runtime/mirror/method_handles_lookup.cc25
-rw-r--r--runtime/mirror/method_handles_lookup.h10
-rw-r--r--runtime/mirror/method_type.cc20
-rw-r--r--runtime/mirror/method_type.h10
-rw-r--r--runtime/mirror/var_handle.cc117
-rw-r--r--runtime/mirror/var_handle.h35
-rw-r--r--runtime/mirror/var_handle_test.cc9
11 files changed, 23 insertions, 274 deletions
diff --git a/runtime/mirror/call_site.cc b/runtime/mirror/call_site.cc
index eb613df4c6..808f77cde1 100644
--- a/runtime/mirror/call_site.cc
+++ b/runtime/mirror/call_site.cc
@@ -17,36 +17,20 @@
#include "call_site.h"
#include "class-inl.h"
+#include "class_root.h"
#include "gc_root-inl.h"
namespace art {
namespace mirror {
-GcRoot<mirror::Class> CallSite::static_class_;
-
mirror::CallSite* CallSite::Create(Thread* const self, Handle<MethodHandle> target) {
StackHandleScope<1> hs(self);
Handle<mirror::CallSite> cs(
- hs.NewHandle(ObjPtr<CallSite>::DownCast(StaticClass()->AllocObject(self))));
+ hs.NewHandle(ObjPtr<CallSite>::DownCast(GetClassRoot<CallSite>()->AllocObject(self))));
CHECK(!Runtime::Current()->IsActiveTransaction());
cs->SetFieldObject<false>(TargetOffset(), target.Get());
return cs.Get();
}
-void CallSite::SetClass(Class* klass) {
- CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
- CHECK(klass != nullptr);
- static_class_ = GcRoot<Class>(klass);
-}
-
-void CallSite::ResetClass() {
- CHECK(!static_class_.IsNull());
- static_class_ = GcRoot<Class>(nullptr);
-}
-
-void CallSite::VisitRoots(RootVisitor* visitor) {
- static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
-}
-
} // namespace mirror
} // namespace art
diff --git a/runtime/mirror/call_site.h b/runtime/mirror/call_site.h
index 93f274808c..9b6afca3aa 100644
--- a/runtime/mirror/call_site.h
+++ b/runtime/mirror/call_site.h
@@ -33,18 +33,10 @@ class MANAGED CallSite : public Object {
Handle<MethodHandle> method_handle)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
- static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
- return static_class_.Read();
- }
-
MethodHandle* GetTarget() REQUIRES_SHARED(Locks::mutator_lock_) {
return GetFieldObject<MethodHandle>(TargetOffset());
}
- static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
- static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
-
private:
static inline MemberOffset TargetOffset() {
return MemberOffset(OFFSETOF_MEMBER(CallSite, target_));
@@ -52,8 +44,6 @@ class MANAGED CallSite : public Object {
HeapReference<mirror::MethodHandle> target_;
- static GcRoot<mirror::Class> static_class_; // java.lang.invoke.CallSite.class
-
friend struct art::CallSiteOffsets; // for verifying offset information
DISALLOW_IMPLICIT_CONSTRUCTORS(CallSite);
};
diff --git a/runtime/mirror/method_handle_impl.cc b/runtime/mirror/method_handle_impl.cc
index 0b4dde1aa8..a6c1609d01 100644
--- a/runtime/mirror/method_handle_impl.cc
+++ b/runtime/mirror/method_handle_impl.cc
@@ -17,6 +17,7 @@
#include "method_handle_impl-inl.h"
#include "class-inl.h"
+#include "class_root.h"
#include "gc_root-inl.h"
namespace art {
@@ -30,12 +31,6 @@ const char* MethodHandle::GetReturnTypeDescriptor(const char* invoke_method_name
}
}
-mirror::Class* MethodHandle::StaticClass() {
- mirror::Class* klass = MethodHandleImpl::StaticClass()->GetSuperClass();
- DCHECK(klass->DescriptorEquals("Ljava/lang/invoke/MethodHandle;"));
- return klass;
-}
-
void MethodHandle::Initialize(uintptr_t art_field_or_method,
Kind kind,
Handle<MethodType> method_type)
@@ -48,35 +43,14 @@ void MethodHandle::Initialize(uintptr_t art_field_or_method,
SetField64<false>(ArtFieldOrMethodOffset(), art_field_or_method);
}
-GcRoot<mirror::Class> MethodHandleImpl::static_class_;
-
-mirror::Class* MethodHandleImpl::StaticClass() {
- return static_class_.Read();
-}
-
-void MethodHandleImpl::SetClass(Class* klass) {
- CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
- CHECK(klass != nullptr);
- static_class_ = GcRoot<Class>(klass);
-}
-
-void MethodHandleImpl::ResetClass() {
- CHECK(!static_class_.IsNull());
- static_class_ = GcRoot<Class>(nullptr);
-}
-
-void MethodHandleImpl::VisitRoots(RootVisitor* visitor) {
- static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
-}
-
mirror::MethodHandleImpl* MethodHandleImpl::Create(Thread* const self,
uintptr_t art_field_or_method,
MethodHandle::Kind kind,
Handle<MethodType> method_type)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_) {
StackHandleScope<1> hs(self);
- Handle<mirror::MethodHandleImpl> mh(
- hs.NewHandle(ObjPtr<MethodHandleImpl>::DownCast(StaticClass()->AllocObject(self))));
+ Handle<mirror::MethodHandleImpl> mh(hs.NewHandle(ObjPtr<MethodHandleImpl>::DownCast(
+ GetClassRoot<MethodHandleImpl>()->AllocObject(self))));
mh->Initialize(art_field_or_method, kind, method_type);
return mh.Get();
}
diff --git a/runtime/mirror/method_handle_impl.h b/runtime/mirror/method_handle_impl.h
index 3b0002c2af..4813b3c3f7 100644
--- a/runtime/mirror/method_handle_impl.h
+++ b/runtime/mirror/method_handle_impl.h
@@ -87,8 +87,6 @@ class MANAGED MethodHandle : public Object {
// supported.
static const char* GetReturnTypeDescriptor(const char* invoke_method_name);
- static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_);
-
protected:
void Initialize(uintptr_t art_field_or_method, Kind kind, Handle<MethodType> method_type)
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -130,19 +128,12 @@ class MANAGED MethodHandleImpl : public MethodHandle {
Handle<MethodType> method_type)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
- static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_);
-
- static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
- static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
-
private:
static MemberOffset InfoOffset() {
return MemberOffset(OFFSETOF_MEMBER(MethodHandleImpl, info_));
}
HeapReference<mirror::Object> info_; // Unused by the runtime.
- static GcRoot<mirror::Class> static_class_; // java.lang.invoke.MethodHandleImpl.class
friend struct art::MethodHandleImplOffsets; // for verifying offset information
DISALLOW_IMPLICIT_CONSTRUCTORS(MethodHandleImpl);
diff --git a/runtime/mirror/method_handles_lookup.cc b/runtime/mirror/method_handles_lookup.cc
index aeecf75c1f..1ac38dad24 100644
--- a/runtime/mirror/method_handles_lookup.cc
+++ b/runtime/mirror/method_handles_lookup.cc
@@ -17,6 +17,7 @@
#include "method_handles_lookup.h"
#include "class-inl.h"
+#include "class_root.h"
#include "dex/modifiers.h"
#include "gc_root-inl.h"
#include "handle_scope.h"
@@ -28,33 +29,15 @@
namespace art {
namespace mirror {
-GcRoot<mirror::Class> MethodHandlesLookup::static_class_;
-
-void MethodHandlesLookup::SetClass(Class* klass) {
- CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
- CHECK(klass != nullptr);
- static_class_ = GcRoot<Class>(klass);
-}
-
-void MethodHandlesLookup::ResetClass() {
- CHECK(!static_class_.IsNull());
- static_class_ = GcRoot<Class>(nullptr);
-}
-
-void MethodHandlesLookup::VisitRoots(RootVisitor* visitor) {
- static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
-}
-
MethodHandlesLookup* MethodHandlesLookup::Create(Thread* const self, Handle<Class> lookup_class)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_) {
static constexpr uint32_t kAllModes = kAccPublic | kAccPrivate | kAccProtected | kAccStatic;
- StackHandleScope<1> hs(self);
- Handle<MethodHandlesLookup> mhl(
- hs.NewHandle(ObjPtr<MethodHandlesLookup>::DownCast(StaticClass()->AllocObject(self))));
+ ObjPtr<MethodHandlesLookup> mhl = ObjPtr<MethodHandlesLookup>::DownCast(
+ GetClassRoot<MethodHandlesLookup>()->AllocObject(self));
mhl->SetFieldObject<false>(LookupClassOffset(), lookup_class.Get());
mhl->SetField32<false>(AllowedModesOffset(), kAllModes);
- return mhl.Get();
+ return mhl.Ptr();
}
MethodHandlesLookup* MethodHandlesLookup::GetDefault(Thread* const self) {
diff --git a/runtime/mirror/method_handles_lookup.h b/runtime/mirror/method_handles_lookup.h
index fefcb2ed29..aa94f95ae0 100644
--- a/runtime/mirror/method_handles_lookup.h
+++ b/runtime/mirror/method_handles_lookup.h
@@ -40,14 +40,6 @@ class MANAGED MethodHandlesLookup : public Object {
Handle<Class> lookup_class)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
- static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
- return static_class_.Read();
- }
-
- static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
- static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
-
// Returns the result of java.lang.invoke.MethodHandles.lookup().
static mirror::MethodHandlesLookup* GetDefault(Thread* const self)
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -71,8 +63,6 @@ class MANAGED MethodHandlesLookup : public Object {
int32_t allowed_modes_;
- static GcRoot<mirror::Class> static_class_; // java.lang.invoke.MethodHandles.Lookup.class
-
friend struct art::MethodHandlesLookupOffsets; // for verifying offset information
DISALLOW_IMPLICIT_CONSTRUCTORS(MethodHandlesLookup);
};
diff --git a/runtime/mirror/method_type.cc b/runtime/mirror/method_type.cc
index 45f7a87951..a8be8b7019 100644
--- a/runtime/mirror/method_type.cc
+++ b/runtime/mirror/method_type.cc
@@ -17,6 +17,7 @@
#include "method_type.h"
#include "class-inl.h"
+#include "class_root.h"
#include "gc_root-inl.h"
#include "method_handles.h"
@@ -35,14 +36,12 @@ ObjPtr<ObjectArray<Class>> AllocatePTypesArray(Thread* self, int count)
} // namespace
-GcRoot<Class> MethodType::static_class_;
-
MethodType* MethodType::Create(Thread* const self,
Handle<Class> return_type,
Handle<ObjectArray<Class>> parameter_types) {
StackHandleScope<1> hs(self);
Handle<MethodType> mt(
- hs.NewHandle(ObjPtr<MethodType>::DownCast(StaticClass()->AllocObject(self))));
+ hs.NewHandle(ObjPtr<MethodType>::DownCast(GetClassRoot<MethodType>()->AllocObject(self))));
// TODO: Do we ever create a MethodType during a transaction ? There doesn't
// seem like a good reason to do a polymorphic invoke that results in the
@@ -172,20 +171,5 @@ std::string MethodType::PrettyDescriptor() REQUIRES_SHARED(Locks::mutator_lock_)
return ss.str();
}
-void MethodType::SetClass(Class* klass) {
- CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
- CHECK(klass != nullptr);
- static_class_ = GcRoot<Class>(klass);
-}
-
-void MethodType::ResetClass() {
- CHECK(!static_class_.IsNull());
- static_class_ = GcRoot<Class>(nullptr);
-}
-
-void MethodType::VisitRoots(RootVisitor* visitor) {
- static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
-}
-
} // namespace mirror
} // namespace art
diff --git a/runtime/mirror/method_type.h b/runtime/mirror/method_type.h
index 771162a2de..014b211d66 100644
--- a/runtime/mirror/method_type.h
+++ b/runtime/mirror/method_type.h
@@ -48,10 +48,6 @@ class MANAGED MethodType : public Object {
int32_t start_index)
REQUIRES_SHARED(Locks::mutator_lock_);
- static Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
- return static_class_.Read();
- }
-
ObjectArray<Class>* GetPTypes() REQUIRES_SHARED(Locks::mutator_lock_) {
return GetFieldObject<ObjectArray<Class>>(OFFSET_OF_OBJECT_MEMBER(MethodType, p_types_));
}
@@ -68,10 +64,6 @@ class MANAGED MethodType : public Object {
return GetFieldObject<Class>(OFFSET_OF_OBJECT_MEMBER(MethodType, r_type_));
}
- static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
- static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
-
// Returns true iff. |this| is an exact match for method type |target|, i.e
// iff. they have the same return types and parameter types.
bool IsExactMatch(MethodType* target) REQUIRES_SHARED(Locks::mutator_lock_);
@@ -111,8 +103,6 @@ class MANAGED MethodType : public Object {
HeapReference<Class> r_type_;
HeapReference<Object> wrap_alt_; // Unused in the runtime
- static GcRoot<Class> static_class_; // java.lang.invoke.MethodType.class
-
friend struct art::MethodTypeOffsets; // for verifying offset information
DISALLOW_IMPLICIT_CONSTRUCTORS(MethodType);
};
diff --git a/runtime/mirror/var_handle.cc b/runtime/mirror/var_handle.cc
index c755299a79..8311d911cc 100644
--- a/runtime/mirror/var_handle.cc
+++ b/runtime/mirror/var_handle.cc
@@ -20,6 +20,7 @@
#include "art_field-inl.h"
#include "class-inl.h"
#include "class_linker.h"
+#include "class_root.h"
#include "gc_root-inl.h"
#include "intrinsics_enum.h"
#include "jni/jni_internal.h"
@@ -1580,17 +1581,18 @@ bool VarHandle::Access(AccessMode access_mode,
ShadowFrame* shadow_frame,
const InstructionOperands* const operands,
JValue* result) {
- Class* klass = GetClass();
- if (klass == FieldVarHandle::StaticClass()) {
+ ObjPtr<ObjectArray<Class>> class_roots = Runtime::Current()->GetClassLinker()->GetClassRoots();
+ ObjPtr<Class> klass = GetClass();
+ if (klass == GetClassRoot<FieldVarHandle>(class_roots)) {
auto vh = reinterpret_cast<FieldVarHandle*>(this);
return vh->Access(access_mode, shadow_frame, operands, result);
- } else if (klass == ArrayElementVarHandle::StaticClass()) {
+ } else if (klass == GetClassRoot<ArrayElementVarHandle>(class_roots)) {
auto vh = reinterpret_cast<ArrayElementVarHandle*>(this);
return vh->Access(access_mode, shadow_frame, operands, result);
- } else if (klass == ByteArrayViewVarHandle::StaticClass()) {
+ } else if (klass == GetClassRoot<ByteArrayViewVarHandle>(class_roots)) {
auto vh = reinterpret_cast<ByteArrayViewVarHandle*>(this);
return vh->Access(access_mode, shadow_frame, operands, result);
- } else if (klass == ByteBufferViewVarHandle::StaticClass()) {
+ } else if (klass == GetClassRoot<ByteBufferViewVarHandle>(class_roots)) {
auto vh = reinterpret_cast<ByteBufferViewVarHandle*>(this);
return vh->Access(access_mode, shadow_frame, operands, result);
} else {
@@ -1681,27 +1683,6 @@ bool VarHandle::GetAccessModeByMethodName(const char* method_name, AccessMode* a
return true;
}
-Class* VarHandle::StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
- return static_class_.Read();
-}
-
-void VarHandle::SetClass(Class* klass) {
- CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
- CHECK(klass != nullptr);
- static_class_ = GcRoot<Class>(klass);
-}
-
-void VarHandle::ResetClass() {
- CHECK(!static_class_.IsNull());
- static_class_ = GcRoot<Class>(nullptr);
-}
-
-void VarHandle::VisitRoots(RootVisitor* visitor) {
- static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
-}
-
-GcRoot<Class> VarHandle::static_class_;
-
ArtField* FieldVarHandle::GetField() {
uintptr_t opaque_field = static_cast<uintptr_t>(GetField64(ArtFieldOffset()));
return reinterpret_cast<ArtField*>(opaque_field);
@@ -1758,27 +1739,6 @@ bool FieldVarHandle::Access(AccessMode access_mode,
UNREACHABLE();
}
-Class* FieldVarHandle::StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
- return static_class_.Read();
-}
-
-void FieldVarHandle::SetClass(Class* klass) {
- CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
- CHECK(klass != nullptr);
- static_class_ = GcRoot<Class>(klass);
-}
-
-void FieldVarHandle::ResetClass() {
- CHECK(!static_class_.IsNull());
- static_class_ = GcRoot<Class>(nullptr);
-}
-
-void FieldVarHandle::VisitRoots(RootVisitor* visitor) {
- static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
-}
-
-GcRoot<Class> FieldVarHandle::static_class_;
-
bool ArrayElementVarHandle::Access(AccessMode access_mode,
ShadowFrame* shadow_frame,
const InstructionOperands* const operands,
@@ -1867,27 +1827,6 @@ bool ArrayElementVarHandle::Access(AccessMode access_mode,
UNREACHABLE();
}
-Class* ArrayElementVarHandle::StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
- return static_class_.Read();
-}
-
-void ArrayElementVarHandle::SetClass(Class* klass) {
- CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
- CHECK(klass != nullptr);
- static_class_ = GcRoot<Class>(klass);
-}
-
-void ArrayElementVarHandle::ResetClass() {
- CHECK(!static_class_.IsNull());
- static_class_ = GcRoot<Class>(nullptr);
-}
-
-void ArrayElementVarHandle::VisitRoots(RootVisitor* visitor) {
- static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
-}
-
-GcRoot<Class> ArrayElementVarHandle::static_class_;
-
bool ByteArrayViewVarHandle::GetNativeByteOrder() {
return GetFieldBoolean(NativeByteOrderOffset());
}
@@ -1976,27 +1915,6 @@ bool ByteArrayViewVarHandle::Access(AccessMode access_mode,
UNREACHABLE();
}
-Class* ByteArrayViewVarHandle::StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
- return static_class_.Read();
-}
-
-void ByteArrayViewVarHandle::SetClass(Class* klass) {
- CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
- CHECK(klass != nullptr);
- static_class_ = GcRoot<Class>(klass);
-}
-
-void ByteArrayViewVarHandle::ResetClass() {
- CHECK(!static_class_.IsNull());
- static_class_ = GcRoot<Class>(nullptr);
-}
-
-void ByteArrayViewVarHandle::VisitRoots(RootVisitor* visitor) {
- static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
-}
-
-GcRoot<Class> ByteArrayViewVarHandle::static_class_;
-
bool ByteBufferViewVarHandle::GetNativeByteOrder() {
return GetFieldBoolean(NativeByteOrderOffset());
}
@@ -2117,26 +2035,5 @@ bool ByteBufferViewVarHandle::Access(AccessMode access_mode,
UNREACHABLE();
}
-Class* ByteBufferViewVarHandle::StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
- return static_class_.Read();
-}
-
-void ByteBufferViewVarHandle::SetClass(Class* klass) {
- CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
- CHECK(klass != nullptr);
- static_class_ = GcRoot<Class>(klass);
-}
-
-void ByteBufferViewVarHandle::ResetClass() {
- CHECK(!static_class_.IsNull());
- static_class_ = GcRoot<Class>(nullptr);
-}
-
-void ByteBufferViewVarHandle::VisitRoots(RootVisitor* visitor) {
- static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
-}
-
-GcRoot<Class> ByteBufferViewVarHandle::static_class_;
-
} // namespace mirror
} // namespace art
diff --git a/runtime/mirror/var_handle.h b/runtime/mirror/var_handle.h
index 5186d43830..4fd18c14e2 100644
--- a/runtime/mirror/var_handle.h
+++ b/runtime/mirror/var_handle.h
@@ -149,11 +149,6 @@ class MANAGED VarHandle : public Object {
// VarHandle access method, such as "setOpaque". Returns false otherwise.
static bool GetAccessModeByMethodName(const char* method_name, AccessMode* access_mode);
- static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
- static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
-
private:
Class* GetCoordinateType0() REQUIRES_SHARED(Locks::mutator_lock_);
Class* GetCoordinateType1() REQUIRES_SHARED(Locks::mutator_lock_);
@@ -185,9 +180,6 @@ class MANAGED VarHandle : public Object {
HeapReference<mirror::Class> var_type_;
int32_t access_modes_bit_mask_;
- // Root representing java.lang.invoke.VarHandle.class.
- static GcRoot<mirror::Class> static_class_;
-
friend class VarHandleTest; // for testing purposes
friend struct art::VarHandleOffsets; // for verifying offset information
DISALLOW_IMPLICIT_CONSTRUCTORS(VarHandle);
@@ -218,9 +210,6 @@ class MANAGED FieldVarHandle : public VarHandle {
// ArtField instance corresponding to variable for accessors.
int64_t art_field_;
- // Root representing java.lang.invoke.FieldVarHandle.class.
- static GcRoot<mirror::Class> static_class_;
-
friend class VarHandleTest; // for var_handle_test.
friend struct art::FieldVarHandleOffsets; // for verifying offset information
DISALLOW_IMPLICIT_CONSTRUCTORS(FieldVarHandle);
@@ -236,15 +225,7 @@ class MANAGED ArrayElementVarHandle : public VarHandle {
JValue* result)
REQUIRES_SHARED(Locks::mutator_lock_);
- static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
- static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
-
private:
- // Root representing java.lang.invoke.ArrayElementVarHandle.class.
- static GcRoot<mirror::Class> static_class_;
-
friend class VarHandleTest;
DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayElementVarHandle);
};
@@ -261,11 +242,6 @@ class MANAGED ByteArrayViewVarHandle : public VarHandle {
bool GetNativeByteOrder() REQUIRES_SHARED(Locks::mutator_lock_);
- static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
- static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
-
private:
static MemberOffset NativeByteOrderOffset() {
return MemberOffset(OFFSETOF_MEMBER(ByteArrayViewVarHandle, native_byte_order_));
@@ -274,9 +250,6 @@ class MANAGED ByteArrayViewVarHandle : public VarHandle {
// Flag indicating that accessors should use native byte-ordering.
uint8_t native_byte_order_;
- // Root representing java.lang.invoke.ByteArrayViewVarHandle.class.
- static GcRoot<mirror::Class> static_class_;
-
friend class VarHandleTest; // for var_handle_test.
friend struct art::ByteArrayViewVarHandleOffsets; // for verifying offset information
DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArrayViewVarHandle);
@@ -294,11 +267,6 @@ class MANAGED ByteBufferViewVarHandle : public VarHandle {
bool GetNativeByteOrder() REQUIRES_SHARED(Locks::mutator_lock_);
- static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
- static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
- static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
-
private:
bool AccessHeapBuffer(AccessMode access_mode,
ObjPtr<Object> byte_buffer,
@@ -322,9 +290,6 @@ class MANAGED ByteBufferViewVarHandle : public VarHandle {
// Flag indicating that accessors should use native byte-ordering.
uint8_t native_byte_order_;
- // Root representing java.lang.invoke.ByteBufferViewVarHandle.class.
- static GcRoot<mirror::Class> static_class_;
-
friend class VarHandleTest; // for var_handle_test.
friend struct art::ByteBufferViewVarHandleOffsets; // for verifying offset information
DISALLOW_IMPLICIT_CONSTRUCTORS(ByteBufferViewVarHandle);
diff --git a/runtime/mirror/var_handle_test.cc b/runtime/mirror/var_handle_test.cc
index 005aba3edd..2c1283225d 100644
--- a/runtime/mirror/var_handle_test.cc
+++ b/runtime/mirror/var_handle_test.cc
@@ -23,6 +23,7 @@
#include "class-inl.h"
#include "class_linker-inl.h"
#include "class_loader.h"
+#include "class_root.h"
#include "common_runtime_test.h"
#include "handle_scope-inl.h"
#include "jvalue-inl.h"
@@ -43,7 +44,7 @@ class VarHandleTest : public CommonRuntimeTest {
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_) {
StackHandleScope<4> hs(self);
Handle<FieldVarHandle> fvh = hs.NewHandle(
- ObjPtr<FieldVarHandle>::DownCast(FieldVarHandle::StaticClass()->AllocObject(self)));
+ ObjPtr<FieldVarHandle>::DownCast(GetClassRoot<FieldVarHandle>()->AllocObject(self)));
Handle<Class> var_type = hs.NewHandle(art_field->ResolveType());
if (art_field->IsStatic()) {
@@ -67,7 +68,7 @@ class VarHandleTest : public CommonRuntimeTest {
StackHandleScope<3> hs(self);
Handle<ArrayElementVarHandle> vh = hs.NewHandle(
ObjPtr<ArrayElementVarHandle>::DownCast(
- ArrayElementVarHandle::StaticClass()->AllocObject(self)));
+ GetClassRoot<ArrayElementVarHandle>()->AllocObject(self)));
// Initialize super class fields
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
@@ -85,7 +86,7 @@ class VarHandleTest : public CommonRuntimeTest {
StackHandleScope<4> hs(self);
Handle<ByteArrayViewVarHandle> bvh = hs.NewHandle(
ObjPtr<ByteArrayViewVarHandle>::DownCast(
- ByteArrayViewVarHandle::StaticClass()->AllocObject(self)));
+ GetClassRoot<ByteArrayViewVarHandle>()->AllocObject(self)));
// Initialize super class fields
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
@@ -106,7 +107,7 @@ class VarHandleTest : public CommonRuntimeTest {
StackHandleScope<5> hs(self);
Handle<ByteBufferViewVarHandle> bvh = hs.NewHandle(
ObjPtr<ByteBufferViewVarHandle>::DownCast(
- ByteArrayViewVarHandle::StaticClass()->AllocObject(self)));
+ GetClassRoot<ByteArrayViewVarHandle>()->AllocObject(self)));
// Initialize super class fields
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Handle<Class> var_type = hs.NewHandle(view_array_class->GetComponentType());