summaryrefslogtreecommitdiffstats
path: root/runtime/mirror/class.cc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2014-05-07 15:43:14 -0700
committerMathieu Chartier <mathieuc@google.com>2014-05-13 14:45:54 -0700
commiteb8167a4f4d27fce0530f6724ab8032610cd146b (patch)
treebcfeaf13ad78f2dd68466bbd0e20c71944f7e854 /runtime/mirror/class.cc
parent6fb66a2bc4e1c0b7931101153e58714991237af7 (diff)
downloadart-eb8167a4f4d27fce0530f6724ab8032610cd146b.zip
art-eb8167a4f4d27fce0530f6724ab8032610cd146b.tar.gz
art-eb8167a4f4d27fce0530f6724ab8032610cd146b.tar.bz2
Add Handle/HandleScope and delete SirtRef.
Delete SirtRef and replaced it with Handle. Handles are value types which wrap around StackReference*. Renamed StackIndirectReferenceTable to HandleScope. Added a scoped handle wrapper which wraps around an Object** and restores it in its destructor. Renamed Handle::get -> Get. Bug: 8473721 Change-Id: Idbfebd4f35af629f0f43931b7c5184b334822c7a
Diffstat (limited to 'runtime/mirror/class.cc')
-rw-r--r--runtime/mirror/class.cc32
1 files changed, 13 insertions, 19 deletions
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index ff63782..15b69f3 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -28,7 +28,7 @@
#include "object_array-inl.h"
#include "object_utils.h"
#include "runtime.h"
-#include "sirt_ref.h"
+#include "handle_scope-inl.h"
#include "thread.h"
#include "throwable.h"
#include "utils.h"
@@ -77,20 +77,13 @@ void Class::SetStatus(Status new_status, Thread* self) {
<< "Attempt to set as erroneous an already erroneous class " << PrettyClass(this);
// Stash current exception.
- SirtRef<mirror::Object> old_throw_this_object(self, NULL);
- SirtRef<mirror::ArtMethod> old_throw_method(self, NULL);
- SirtRef<mirror::Throwable> old_exception(self, NULL);
- uint32_t old_throw_dex_pc;
- {
- ThrowLocation old_throw_location;
- mirror::Throwable* old_exception_obj = self->GetException(&old_throw_location);
- old_throw_this_object.reset(old_throw_location.GetThis());
- old_throw_method.reset(old_throw_location.GetMethod());
- old_exception.reset(old_exception_obj);
- old_throw_dex_pc = old_throw_location.GetDexPc();
- self->ClearException();
- }
- CHECK(old_exception.get() != NULL);
+ StackHandleScope<3> hs(self);
+ ThrowLocation old_throw_location;
+ Handle<mirror::Throwable> old_exception(hs.NewHandle(self->GetException(&old_throw_location)));
+ CHECK(old_exception.Get() != nullptr);
+ Handle<mirror::Object> old_throw_this_object(hs.NewHandle(old_throw_location.GetThis()));
+ Handle<mirror::ArtMethod> old_throw_method(hs.NewHandle(old_throw_location.GetMethod()));
+ uint32_t old_throw_dex_pc = old_throw_location.GetDexPc();
// clear exception to call FindSystemClass
self->ClearException();
@@ -107,10 +100,10 @@ void Class::SetStatus(Status new_status, Thread* self) {
}
// Restore exception.
- ThrowLocation gc_safe_throw_location(old_throw_this_object.get(), old_throw_method.get(),
+ ThrowLocation gc_safe_throw_location(old_throw_this_object.Get(), old_throw_method.Get(),
old_throw_dex_pc);
- self->SetException(gc_safe_throw_location, old_exception.get());
+ self->SetException(gc_safe_throw_location, old_exception.Get());
}
CHECK(sizeof(Status) == sizeof(uint32_t)) << PrettyClass(this);
if (Runtime::Current()->IsActiveTransaction()) {
@@ -149,7 +142,8 @@ String* Class::ComputeName() {
return name;
}
Thread* self = Thread::Current();
- SirtRef<mirror::Class> sirt_c(self, this);
+ StackHandleScope<1> hs(self);
+ Handle<mirror::Class> handle_c(hs.NewHandle(this));
std::string descriptor(ClassHelper(this).GetDescriptor());
if ((descriptor[0] != 'L') && (descriptor[0] != '[')) {
// The descriptor indicates that this is the class for
@@ -179,7 +173,7 @@ String* Class::ComputeName() {
std::replace(descriptor.begin(), descriptor.end(), '/', '.');
name = String::AllocFromModifiedUtf8(self, descriptor.c_str());
}
- sirt_c->SetName(name);
+ handle_c->SetName(name);
return name;
}