diff options
author | 2019-05-28 16:39:29 +0100 | |
---|---|---|
committer | 2019-05-31 14:15:59 +0000 | |
commit | 3068d582eff4552ff260d7966fcbdc93e17d0207 (patch) | |
tree | bc894a414070a06ea2a231fb98607b57b8c3b0cb /runtime/mirror/class.cc | |
parent | 991cd5cc16267b74e390f640eb441102062babb6 (diff) |
Clean up creating handles from `this`.
Make these member functions static and take an additional
parameter `Handle<.> h_this`. Callers mostly already have
a Handle<> to pass, so we avoid an extra StackHandleScope.
This pattern was already used for some functions.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing --interpreter
Change-Id: I4f4478b0526bcb2f3c23305d3b3cc4a65fff9ff5
Diffstat (limited to 'runtime/mirror/class.cc')
-rw-r--r-- | runtime/mirror/class.cc | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc index d6c10decff..a36fe1253c 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -94,14 +94,12 @@ ObjPtr<mirror::Class> Class::GetPrimitiveClass(ObjPtr<mirror::String> name) { } } -ObjPtr<ClassExt> Class::EnsureExtDataPresent(Thread* self) { - ObjPtr<ClassExt> existing(GetExtData()); +ObjPtr<ClassExt> Class::EnsureExtDataPresent(Handle<Class> h_this, Thread* self) { + ObjPtr<ClassExt> existing(h_this->GetExtData()); if (!existing.IsNull()) { return existing; } - StackHandleScope<3> hs(self); - // Handlerize 'this' since we are allocating here. - Handle<Class> h_this(hs.NewHandle(this)); + StackHandleScope<2> hs(self); // Clear exception so we can allocate. Handle<Throwable> throwable(hs.NewHandle(self->GetException())); self->ClearException(); @@ -172,7 +170,7 @@ void Class::SetStatus(Handle<Class> h_this, ClassStatus new_status, Thread* self } } - ObjPtr<ClassExt> ext(h_this->EnsureExtDataPresent(self)); + ObjPtr<ClassExt> ext(EnsureExtDataPresent(h_this, self)); if (!ext.IsNull()) { self->AssertPendingException(); ext->SetVerifyError(self->GetException()); @@ -1205,12 +1203,13 @@ class CopyClassVisitor { DISALLOW_COPY_AND_ASSIGN(CopyClassVisitor); }; -ObjPtr<Class> Class::CopyOf( - Thread* self, int32_t new_length, ImTable* imt, PointerSize pointer_size) { +ObjPtr<Class> Class::CopyOf(Handle<Class> h_this, + Thread* self, + int32_t new_length, + ImTable* imt, + PointerSize pointer_size) { DCHECK_GE(new_length, static_cast<int32_t>(sizeof(Class))); // We may get copied by a compacting GC. - StackHandleScope<1> hs(self); - Handle<Class> h_this(hs.NewHandle(this)); Runtime* runtime = Runtime::Current(); gc::Heap* heap = runtime->GetHeap(); // The num_bytes (3rd param) is sizeof(Class) as opposed to SizeOf() |