summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2016-07-21 10:33:13 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-07-21 10:33:13 +0000
commit65ad9b3516c4f4bc4e7abf5c6e065a675cf024d8 (patch)
tree7650ae342ce201d498526609d506df7f52783d3a
parenta92938a17b75eed3213030faaff9cfb321d47f37 (diff)
parentbb268b14da040c5df27a413426aa2baab602ed15 (diff)
Merge "Clean up Class::FindStaticField()."
-rw-r--r--runtime/class_linker.cc2
-rw-r--r--runtime/mirror/class.cc15
-rw-r--r--runtime/mirror/class.h4
-rw-r--r--runtime/native/dalvik_system_VMRuntime.cc2
4 files changed, 14 insertions, 9 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index e5a2f36938..d0dad6494e 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -7695,7 +7695,7 @@ ArtField* ClassLinker::ResolveField(const DexFile& dex_file,
}
if (is_static) {
- resolved = mirror::Class::FindStaticField(self, klass, dex_cache.Get(), field_idx);
+ resolved = mirror::Class::FindStaticField(self, klass.Get(), dex_cache.Get(), field_idx);
} else {
resolved = klass->FindInstanceField(dex_cache.Get(), field_idx);
}
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index 9c77d3814c..1c31c5764b 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -748,21 +748,24 @@ ArtField* Class::FindStaticField(Thread* self, Handle<Class> klass, const String
return nullptr;
}
-ArtField* Class::FindStaticField(Thread* self, Handle<Class> klass, const DexCache* dex_cache,
+ArtField* Class::FindStaticField(Thread* self,
+ Class* klass,
+ const DexCache* dex_cache,
uint32_t dex_field_idx) {
- for (Class* k = klass.Get(); k != nullptr; k = k->GetSuperClass()) {
+ for (Class* k = klass; k != nullptr; k = k->GetSuperClass()) {
// Is the field in this class?
ArtField* f = k->FindDeclaredStaticField(dex_cache, dex_field_idx);
if (f != nullptr) {
return f;
}
- // Wrap k incase it moves during GetDirectInterface.
+ // Though GetDirectInterface() should not cause thread suspension when called
+ // from here, it takes a Handle as an argument, so we need to wrap `k`.
+ ScopedAssertNoThreadSuspension ants(self, __FUNCTION__);
StackHandleScope<1> hs(self);
- HandleWrapper<mirror::Class> h_k(hs.NewHandleWrapper(&k));
+ Handle<mirror::Class> h_k(hs.NewHandle(k));
// Is this field in any of this class' interfaces?
for (uint32_t i = 0; i < h_k->NumDirectInterfaces(); ++i) {
- StackHandleScope<1> hs2(self);
- Handle<mirror::Class> interface(hs2.NewHandle(GetDirectInterface(self, h_k, i)));
+ mirror::Class* interface = GetDirectInterface(self, h_k, i);
f = FindStaticField(self, interface, dex_cache, dex_field_idx);
if (f != nullptr) {
return f;
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index f044b5968b..9be9f0107b 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -1091,7 +1091,9 @@ class MANAGED Class FINAL : public Object {
// Finds the given static field in this class or superclass, only searches classes that
// have the same dex cache.
- static ArtField* FindStaticField(Thread* self, Handle<Class> klass, const DexCache* dex_cache,
+ static ArtField* FindStaticField(Thread* self,
+ Class* klass,
+ const DexCache* dex_cache,
uint32_t dex_field_idx)
SHARED_REQUIRES(Locks::mutator_lock_);
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index 79b18aa84e..d987f65a08 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -342,7 +342,7 @@ static void PreloadDexCachesResolveField(Handle<mirror::DexCache> dex_cache, uin
return;
}
if (is_static) {
- field = mirror::Class::FindStaticField(self, klass, dex_cache.Get(), field_idx);
+ field = mirror::Class::FindStaticField(self, klass.Get(), dex_cache.Get(), field_idx);
} else {
field = klass->FindInstanceField(dex_cache.Get(), field_idx);
}