ObjPtr<mirror::Object> obj = soa.Decode<mirror::Object>(jobj);
CHECK(obj != nullptr);
for (jint i = 0; i < reps; ++i) {
- jobject ref = soa.Env()->AddLocalReference<jobject>(obj.Decode());
+ jobject ref = soa.Env()->AddLocalReference<jobject>(obj.Ptr());
soa.Env()->DeleteLocalRef(ref);
}
}
ScopedObjectAccess soa(env);
ObjPtr<mirror::Object> obj = soa.Decode<mirror::Object>(jobj);
CHECK(obj != nullptr);
- jobject ref = soa.Env()->AddLocalReference<jobject>(obj.Decode());
+ jobject ref = soa.Env()->AddLocalReference<jobject>(obj.Ptr());
for (jint i = 0; i < reps; ++i) {
CHECK_EQ(soa.Decode<mirror::Object>(ref), obj);
}
inline mirror::ClassLoader* CompilerDriver::GetClassLoader(const ScopedObjectAccess& soa,
const DexCompilationUnit* mUnit) {
- return soa.Decode<mirror::ClassLoader>(mUnit->GetClassLoader()).Decode();
+ return soa.Decode<mirror::ClassLoader>(mUnit->GetClassLoader()).Ptr();
}
inline mirror::Class* CompilerDriver::ResolveClass(
DCHECK(!resolved_field->IsStatic());
ObjPtr<mirror::Class> fields_class = resolved_field->GetDeclaringClass();
bool fast_get = referrer_class != nullptr &&
- referrer_class->CanAccessResolvedField(fields_class.Decode(),
+ referrer_class->CanAccessResolvedField(fields_class.Ptr(),
resolved_field,
dex_cache,
field_idx);
return std::make_pair(true, true);
}
if (CanAccessResolvedMember<ArtMember>(
- referrer_class, members_class.Decode(), resolved_member, dex_cache, member_idx)) {
+ referrer_class, members_class.Ptr(), resolved_member, dex_cache, member_idx)) {
// We have the resolved member, we must make it into a index for the referrer
// in its static storage (which may fail if it doesn't have a slot for it)
// TODO: for images we can elide the static storage base null check
ArtField** resolved_fields = dex_cache->GetResolvedFields();
for (size_t i = 0; i < dex_cache->NumResolvedFields(); i++) {
ArtField* field = mirror::DexCache::GetElementPtrSize(resolved_fields, i, target_ptr_size_);
- if (field != nullptr && !KeepClass(field->GetDeclaringClass().Decode())) {
+ if (field != nullptr && !KeepClass(field->GetDeclaringClass().Ptr())) {
dex_cache->SetResolvedField(i, nullptr, target_ptr_size_);
}
}
case kNativeObjectRelocationTypeArtField: {
memcpy(dest, pair.first, sizeof(ArtField));
reinterpret_cast<ArtField*>(dest)->SetDeclaringClass(
- GetImageAddress(reinterpret_cast<ArtField*>(pair.first)->GetDeclaringClass().Decode()));
+ GetImageAddress(reinterpret_cast<ArtField*>(pair.first)->GetDeclaringClass().Ptr()));
break;
}
case kNativeObjectRelocationTypeRuntimeMethod:
Thread* self = Thread::Current();
ScopedObjectAccess soa(self);
- EXPECT_TRUE(self->HoldsLock(soa.Decode<mirror::Object>(thisObj).Decode()));
+ EXPECT_TRUE(self->HoldsLock(soa.Decode<mirror::Object>(thisObj).Ptr()));
return nullptr;
}
for (const DexFile* dex_file : dex_files) {
ScopedObjectAccess soa(Thread::Current());
class_linker->RegisterDexFile(*dex_file,
- soa.Decode<mirror::ClassLoader>(class_loader).Decode());
+ soa.Decode<mirror::ClassLoader>(class_loader).Ptr());
}
compiler_driver_->SetDexFilesForOatFile(dex_files);
compiler_driver_->CompileAll(class_loader, dex_files, &timings);
}
instr->SetReferenceTypeInfo(
ReferenceTypeInfo::Create(handle_cache_->GetStringClassHandle(), /* is_exact */ true));
- } else if (IsAdmissible(klass.Decode())) {
+ } else if (IsAdmissible(klass.Ptr())) {
ReferenceTypeInfo::TypeHandle handle = handle_cache_->NewHandle(klass);
is_exact = is_exact || handle->CannotBeAssignedFromOtherTypes();
instr->SetReferenceTypeInfo(ReferenceTypeInfo::Create(handle, is_exact));
ScopedObjectAccess soa(self);
dex_caches_.push_back(soa.AddLocalReference<jobject>(
class_linker->RegisterDexFile(*dex_file,
- soa.Decode<mirror::ClassLoader>(class_loader_).Decode())));
+ soa.Decode<mirror::ClassLoader>(class_loader_).Ptr())));
}
return true;
mirror::Class* klass = value->AsClass();
os << StringPrintf("%p Class: %s\n", klass, PrettyDescriptor(klass).c_str());
} else {
- os << StringPrintf("%p %s\n", value.Decode(), PrettyDescriptor(type).c_str());
+ os << StringPrintf("%p %s\n", value.Ptr(), PrettyDescriptor(type).c_str());
}
}
PrettyObjectValue(os, field_type, value);
} else {
os << StringPrintf("%p %s\n",
- value.Decode(),
+ value.Ptr(),
PrettyDescriptor(field->GetTypeDescriptor()).c_str());
}
}
void Visit(ArtField* field) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_) {
ArtField* const dest = patch_oat_->RelocatedCopyOf(field);
dest->SetDeclaringClass(
- patch_oat_->RelocatedAddressOfPointer(field->GetDeclaringClass().Decode()));
+ patch_oat_->RelocatedAddressOfPointer(field->GetDeclaringClass().Ptr()));
}
private:
DCHECK(object != nullptr) << PrettyField(this);
DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted());
if (UNLIKELY(IsVolatile())) {
- object->SetFieldObjectVolatile<kTransactionActive>(GetOffset(), new_value.Decode());
+ object->SetFieldObjectVolatile<kTransactionActive>(GetOffset(), new_value.Ptr());
} else {
- object->SetFieldObject<kTransactionActive>(GetOffset(), new_value.Decode());
+ object->SetFieldObject<kTransactionActive>(GetOffset(), new_value.Ptr());
}
}
template <typename Visitor>
inline void ArtField::UpdateObjects(const Visitor& visitor) {
ObjPtr<mirror::Class> old_class = DeclaringClassRoot().Read<kWithoutReadBarrier>();
- ObjPtr<mirror::Class> new_class = visitor(old_class.Decode());
+ ObjPtr<mirror::Class> new_class = visitor(old_class.Ptr());
if (old_class != new_class) {
SetDeclaringClass(new_class);
}
ObjPtr<mirror::Object> obj = soa.Decode<mirror::Object>(jobj);
if (!obj->GetClass()->IsThrowableClass()) {
AbortF("expected java.lang.Throwable but got object of type "
- "%s: %p", PrettyTypeOf(obj).c_str(), obj.Decode());
+ "%s: %p", PrettyTypeOf(obj).c_str(), obj.Ptr());
return false;
}
return true;
ObjPtr<mirror::Class> c = soa.Decode<mirror::Class>(jc);
if (!c->IsThrowableClass()) {
AbortF("expected java.lang.Throwable class but got object of "
- "type %s: %p", PrettyDescriptor(c).c_str(), c.Decode());
+ "type %s: %p", PrettyDescriptor(c).c_str(), c.Ptr());
return false;
}
return true;
REQUIRES_SHARED(Locks::mutator_lock_) {
ObjPtr<mirror::Class> c = soa.Decode<mirror::Class>(jc);
if (!c->IsInstantiableNonArray()) {
- AbortF("can't make objects of type %s: %p", PrettyDescriptor(c).c_str(), c.Decode());
+ AbortF("can't make objects of type %s: %p", PrettyDescriptor(c).c_str(), c.Ptr());
return false;
}
return true;
okay = false;
} else {
obj = soa.Vm()->DecodeWeakGlobal(soa.Self(), ref);
- okay = Runtime::Current()->IsClearedJniWeakGlobal(obj.Decode());
+ okay = Runtime::Current()->IsClearedJniWeakGlobal(obj.Ptr());
}
if (!okay) {
AbortF("%s is an invalid %s: %p (%p)",
what, ToStr<IndirectRefKind>(GetIndirectRefKind(java_object)).c_str(),
- java_object, obj.Decode());
+ java_object, obj.Ptr());
return false;
}
}
Runtime::Current()->GetHeap()->DumpSpaces(LOG_STREAM(ERROR));
AbortF("%s is an invalid %s: %p (%p)",
what, ToStr<IndirectRefKind>(GetIndirectRefKind(java_object)).c_str(),
- java_object, obj.Decode());
+ java_object, obj.Ptr());
return false;
}
Runtime::Current()->GetHeap()->DumpSpaces(LOG_STREAM(ERROR));
AbortF("jarray is an invalid %s: %p (%p)",
ToStr<IndirectRefKind>(GetIndirectRefKind(java_array)).c_str(),
- java_array, a.Decode());
+ java_array, a.Ptr());
return false;
} else if (!a->IsArrayInstance()) {
AbortF("jarray argument has non-array type: %s", PrettyTypeOf(a).c_str());
*error_msg = StringPrintf("Null name for dex element at index %d", i);
return false;
}
- out_dex_file_names->push_front(name.Decode());
+ out_dex_file_names->push_front(name.Ptr());
}
}
}
return nullptr;
} else {
// success, return mirror::Class*
- return soa.Decode<mirror::Class>(result.get()).Decode();
+ return soa.Decode<mirror::Class>(result.get()).Ptr();
}
}
UNREACHABLE();
// Set the class access flags incl. VerificationAttempted, so we do not try to set the flag on
// the methods.
klass->SetAccessFlags(kAccClassIsProxy | kAccPublic | kAccFinal | kAccVerificationAttempted);
- klass->SetClassLoader(soa.Decode<mirror::ClassLoader>(loader).Decode());
+ klass->SetClassLoader(soa.Decode<mirror::ClassLoader>(loader).Ptr());
DCHECK_EQ(klass->GetPrimitiveType(), Primitive::kPrimNot);
- klass->SetName(soa.Decode<mirror::String>(name).Decode());
+ klass->SetName(soa.Decode<mirror::String>(name).Ptr());
klass->SetDexCache(GetClassRoot(kJavaLangReflectProxy)->GetDexCache());
mirror::Class::SetStatus(klass, mirror::Class::kStatusIdx, self);
std::string descriptor(GetDescriptorForProxy(klass.Get()));
CHECK_EQ(interfaces_sfield.GetDeclaringClass(), klass.Get());
interfaces_sfield.SetObject<false>(
klass.Get(),
- soa.Decode<mirror::ObjectArray<mirror::Class>>(interfaces).Decode());
+ soa.Decode<mirror::ObjectArray<mirror::Class>>(interfaces).Ptr());
CHECK_EQ(throws_sfield.GetDeclaringClass(), klass.Get());
throws_sfield.SetObject<false>(
klass.Get(),
- soa.Decode<mirror::ObjectArray<mirror::ObjectArray<mirror::Class>>>(throws).Decode());
+ soa.Decode<mirror::ObjectArray<mirror::ObjectArray<mirror::Class>>>(throws).Ptr());
{
// Lock on klass is released. Lock new class object.
CHECK_EQ(PrettyField(klass->GetStaticField(1)), throws_field_name);
CHECK_EQ(klass.Get()->GetInterfaces(),
- soa.Decode<mirror::ObjectArray<mirror::Class>>(interfaces).Decode());
+ soa.Decode<mirror::ObjectArray<mirror::Class>>(interfaces).Ptr());
CHECK_EQ(klass.Get()->GetThrows(),
- soa.Decode<mirror::ObjectArray<mirror::ObjectArray<mirror::Class>>>(throws).Decode());
+ soa.Decode<mirror::ObjectArray<mirror::ObjectArray<mirror::Class>>>(throws).Ptr());
}
return klass.Get();
}
DCHECK(self != nullptr);
const size_t hash = ComputeModifiedUtf8Hash(descriptor);
// Find the class in the loaded classes table.
- type = LookupClass(self, descriptor, hash, class_loader.Decode());
+ type = LookupClass(self, descriptor, hash, class_loader.Ptr());
}
}
if (type != nullptr || type->IsResolved()) {
uint32_t type_idx = klass->GetClassDef()->class_idx_;
ObjPtr<mirror::DexCache> dex_cache = klass->GetDexCache();
const DexFile& dex_file = klass->GetDexFile();
- EXPECT_EQ(dex_cache->GetResolvedType(type_idx), klass.Decode());
+ EXPECT_EQ(dex_cache->GetResolvedType(type_idx), klass.Ptr());
EXPECT_OBJ_PTR_EQ(
class_linker_->LookupResolvedType(dex_file, type_idx, dex_cache, class_loader.Get()),
klass);
soa.Decode<mirror::ClassLoader>(jclass_loader));
DCHECK_EQ(class_loader->GetClass(),
- soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_PathClassLoader).Decode());
+ soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_PathClassLoader).Ptr());
DCHECK_EQ(class_loader->GetParent()->GetClass(),
- soa.Decode<mirror::Class>(WellKnownClasses::java_lang_BootClassLoader).Decode());
+ soa.Decode<mirror::Class>(WellKnownClasses::java_lang_BootClassLoader).Ptr());
// The class loader is a PathClassLoader which inherits from BaseDexClassLoader.
// We need to get the DexPathList and loop through it.
namespace art {
// OBJ pointer helpers to avoid needing .Decode everywhere.
-#define EXPECT_OBJ_PTR_EQ(a, b) EXPECT_EQ(MakeObjPtr(a).Decode(), MakeObjPtr(b).Decode());
-#define ASSERT_OBJ_PTR_EQ(a, b) ASSERT_EQ(MakeObjPtr(a).Decode(), MakeObjPtr(b).Decode());
-#define EXPECT_OBJ_PTR_NE(a, b) EXPECT_NE(MakeObjPtr(a).Decode(), MakeObjPtr(b).Decode());
-#define ASSERT_OBJ_PTR_NE(a, b) ASSERT_NE(MakeObjPtr(a).Decode(), MakeObjPtr(b).Decode());
+#define EXPECT_OBJ_PTR_EQ(a, b) EXPECT_EQ(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr());
+#define ASSERT_OBJ_PTR_EQ(a, b) ASSERT_EQ(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr());
+#define EXPECT_OBJ_PTR_NE(a, b) EXPECT_NE(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr());
+#define ASSERT_OBJ_PTR_NE(a, b) ASSERT_NE(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr());
class ClassLinker;
class CompilerCallbacks;
return field_value;
case Primitive::kPrimNot:
- field_value.SetL(f->GetObject(o).Decode());
+ field_value.SetL(f->GetObject(o).Ptr());
return field_value;
case Primitive::kPrimVoid:
}
mirror::Class* annotation_member_class =
- soa.Decode<mirror::Class>(WellKnownClasses::libcore_reflect_AnnotationMember).Decode();
+ soa.Decode<mirror::Class>(WellKnownClasses::libcore_reflect_AnnotationMember).Ptr();
mirror::Class* annotation_member_array_class =
class_linker->FindArrayClass(self, &annotation_member_class);
if (annotation_member_array_class == nullptr) {
*annotation_ptr = annotation;
if (result_style == DexFile::kAllObjects && primitive_type != Primitive::kPrimVoid) {
- element_object = BoxPrimitive(primitive_type, annotation_value->value_).Decode();
+ element_object = BoxPrimitive(primitive_type, annotation_value->value_).Ptr();
set_object = true;
}
if (set_object) {
- annotation_value->value_.SetL(element_object.Decode());
+ annotation_value->value_.SetL(element_object.Ptr());
}
return true;
ScopedObjectAccessUnchecked soa(self);
StackHandleScope<1> hs(self);
mirror::Class* annotation_array_class =
- soa.Decode<mirror::Class>(WellKnownClasses::java_lang_annotation_Annotation__array).Decode();
+ soa.Decode<mirror::Class>(WellKnownClasses::java_lang_annotation_Annotation__array).Ptr();
mirror::Class* annotation_array_array_class =
Runtime::Current()->GetClassLinker()->FindArrayClass(self, &annotation_array_class);
if (annotation_array_array_class == nullptr) {
} else {
JValue jv;
jv.SetJ(args.at(i).j);
- mirror::Object* val = BoxPrimitive(Primitive::GetType(shorty[i + 1]), jv).Decode();
+ mirror::Object* val = BoxPrimitive(Primitive::GetType(shorty[i + 1]), jv).Ptr();
if (val == nullptr) {
CHECK(soa.Self()->IsExceptionPending());
return zero;
mirror::Class* result_type = interface_method->GetReturnType(true /* resolve */, pointer_size);
ObjPtr<mirror::Object> result_ref = soa.Decode<mirror::Object>(result);
JValue result_unboxed;
- if (!UnboxPrimitiveForResult(result_ref.Decode(), result_type, &result_unboxed)) {
+ if (!UnboxPrimitiveForResult(result_ref.Ptr(), result_type, &result_unboxed)) {
DCHECK(soa.Self()->IsExceptionPending());
return zero;
}
StaticObjectRead,
sizeof(mirror::HeapReference<mirror::Object>));
if (LIKELY(field != nullptr)) {
- return field->GetObj(field->GetDeclaringClass()).Decode();
+ return field->GetObj(field->GetDeclaringClass()).Ptr();
}
field = FindFieldFromCode<StaticObjectRead, true>(field_idx,
referrer,
self,
sizeof(mirror::HeapReference<mirror::Object>));
if (LIKELY(field != nullptr)) {
- return field->GetObj(field->GetDeclaringClass()).Decode();
+ return field->GetObj(field->GetDeclaringClass()).Ptr();
}
return nullptr; // Will throw exception by checking with Thread::Current.
}
InstanceObjectRead,
sizeof(mirror::HeapReference<mirror::Object>));
if (LIKELY(field != nullptr && obj != nullptr)) {
- return field->GetObj(obj).Decode();
+ return field->GetObj(obj).Ptr();
}
field = FindInstanceField<InstanceObjectRead, true>(field_idx,
referrer,
sizeof(mirror::HeapReference<mirror::Object>),
&obj);
if (LIKELY(field != nullptr)) {
- return field->GetObj(obj).Decode();
+ return field->GetObj(obj).Ptr();
}
return nullptr; // Will throw exception by checking with Thread::Current.
}
void BuildQuickArgumentVisitor::FixupReferences() {
// Fixup any references which may have changed.
for (const auto& pair : references_) {
- pair.second->Assign(soa_->Decode<mirror::Object>(pair.first).Decode());
+ pair.second->Assign(soa_->Decode<mirror::Object>(pair.first).Ptr());
soa_->Env()->DeleteLocalRef(pair.first);
}
}
void RememberForGcArgumentVisitor::FixupReferences() {
// Fixup any references which may have changed.
for (const auto& pair : references_) {
- pair.second->Assign(soa_->Decode<mirror::Object>(pair.first).Decode());
+ pair.second->Assign(soa_->Decode<mirror::Object>(pair.first).Ptr());
soa_->Env()->DeleteLocalRef(pair.first);
}
}
if (obj == nullptr) {
return true;
}
- return IsAligned<kObjectAlignment>(obj.Decode()) &&
- FindSpaceFromObject(obj.Decode(), true) != nullptr;
+ return IsAligned<kObjectAlignment>(obj.Ptr()) &&
+ FindSpaceFromObject(obj.Ptr(), true) != nullptr;
}
bool Heap::IsNonDiscontinuousSpaceHeapAddress(const mirror::Object* obj) const {
bool Heap::IsMovableObject(ObjPtr<mirror::Object> obj) const {
if (kMovingCollector) {
- space::Space* space = FindContinuousSpaceFromObject(obj.Decode(), true);
+ space::Space* space = FindContinuousSpaceFromObject(obj.Ptr(), true);
if (space != nullptr) {
// TODO: Check large object?
return space->CanMoveObjects();
args[0].l = arg.get();
InvokeWithJValues(soa, nullptr, WellKnownClasses::java_lang_ref_FinalizerReference_add, args);
// Restore object in case it gets moved.
- *object = soa.Decode<mirror::Object>(arg.get()).Decode();
+ *object = soa.Decode<mirror::Object>(arg.get()).Ptr();
}
void Heap::RequestConcurrentGCAndSaveObject(Thread* self, bool force_full, mirror::Object** obj) {
template<class MirrorType>
inline GcRoot<MirrorType>::GcRoot(ObjPtr<MirrorType, kIsDebugBuild> ref)
- : GcRoot(ref.Decode()) { }
+ : GcRoot(ref.Ptr()) { }
inline std::string RootInfo::ToString() const {
std::ostringstream oss;
ALWAYS_INLINE T* Assign(ObjPtr<T> reference) REQUIRES_SHARED(Locks::mutator_lock_) {
StackReference<mirror::Object>* ref = Handle<T>::GetReference();
T* old = down_cast<T*>(ref->AsMirrorPtr());
- ref->Assign(reference.Decode());
+ ref->Assign(reference.Ptr());
return old;
}
template<size_t kNumReferences> template<class MirrorType, bool kPoison>
inline MutableHandle<MirrorType> StackHandleScope<kNumReferences>::NewHandle(
ObjPtr<MirrorType, kPoison> object) {
- return NewHandle(object.Decode());
+ return NewHandle(object.Ptr());
}
template<size_t kNumReferences> template<class T>
template<class MirrorType, bool kPoison>
inline MutableHandle<MirrorType> StackHandleScopeCollection::NewHandle(
ObjPtr<MirrorType, kPoison> ptr) {
- return NewHandle(ptr.Decode());
+ return NewHandle(ptr.Ptr());
}
} // namespace art
ScopedThreadStateChange tsc(self, kNative);
jresult = fn(soa.Env(), klass.get());
}
- result->SetL(soa.Decode<Object>(jresult).Decode());
+ result->SetL(soa.Decode<Object>(jresult).Ptr());
} else if (shorty == "V") {
typedef void (fntype)(JNIEnv*, jclass);
fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni());
ScopedThreadStateChange tsc(self, kNative);
jresult = fn(soa.Env(), klass.get(), arg0.get());
}
- result->SetL(soa.Decode<Object>(jresult).Decode());
+ result->SetL(soa.Decode<Object>(jresult).Ptr());
} else if (shorty == "IIZ") {
typedef jint (fntype)(JNIEnv*, jclass, jint, jboolean);
fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni());
ScopedThreadStateChange tsc(self, kNative);
jresult = fn(soa.Env(), rcvr.get());
}
- result->SetL(soa.Decode<Object>(jresult).Decode());
+ result->SetL(soa.Decode<Object>(jresult).Ptr());
} else if (shorty == "V") {
typedef void (fntype)(JNIEnv*, jobject);
fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni());
ScopedThreadStateChange tsc(self, kNative);
jresult = fn(soa.Env(), rcvr.get(), arg0.get());
}
- result->SetL(soa.Decode<Object>(jresult).Decode());
+ result->SetL(soa.Decode<Object>(jresult).Ptr());
ScopedThreadStateChange tsc(self, kNative);
} else if (shorty == "III") {
typedef jint (fntype)(JNIEnv*, jobject, jint, jint);
this_object = obj;
}
instrumentation->FieldReadEvent(self,
- this_object.Decode(),
+ this_object.Ptr(),
shadow_frame.GetMethod(),
shadow_frame.GetDexPC(),
f);
shadow_frame.SetVRegLong(vregA, f->GetLong(obj));
break;
case Primitive::kPrimNot:
- shadow_frame.SetVRegReference(vregA, f->GetObject(obj).Decode());
+ shadow_frame.SetVRegReference(vregA, f->GetObject(obj).Ptr());
break;
default:
LOG(FATAL) << "Unreachable: " << field_type;
HandleWrapperObjPtr<mirror::Object> h(hs.NewHandleWrapper(&obj));
JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA);
ObjPtr<Object> this_object = f->IsStatic() ? nullptr : obj;
- instrumentation->FieldWriteEvent(self, this_object.Decode(),
+ instrumentation->FieldWriteEvent(self, this_object.Ptr(),
shadow_frame.GetMethod(),
shadow_frame.GetDexPC(),
f,
HandleWrapperObjPtr<mirror::Object> h_obj(hs.NewHandleWrapper(&obj));
field_class = f->GetType<true>();
}
- if (!reg->VerifierInstanceOf(field_class.Decode())) {
+ if (!reg->VerifierInstanceOf(field_class.Ptr())) {
// This should never happen.
std::string temp1, temp2, temp3;
self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;",
uint32_t* args ATTRIBUTE_UNUSED, JValue* result) {
ScopedObjectAccessUnchecked soa(self);
if (Runtime::Current()->IsActiveTransaction()) {
- result->SetL(soa.Decode<mirror::Object>(self->CreateInternalStackTrace<true>(soa)).Decode());
+ result->SetL(soa.Decode<mirror::Object>(self->CreateInternalStackTrace<true>(soa)).Ptr());
} else {
- result->SetL(soa.Decode<mirror::Object>(self->CreateInternalStackTrace<false>(soa)).Decode());
+ result->SetL(soa.Decode<mirror::Object>(self->CreateInternalStackTrace<false>(soa)).Ptr());
}
}
return nullptr;
}
WriterMutexLock mu(self, globals_lock_);
- IndirectRef ref = globals_.Add(IRT_FIRST_SEGMENT, obj.Decode());
+ IndirectRef ref = globals_.Add(IRT_FIRST_SEGMENT, obj.Ptr());
return reinterpret_cast<jobject>(ref);
}
while (UNLIKELY(!MayAccessWeakGlobals(self))) {
weak_globals_add_condition_.WaitHoldingLocks(self);
}
- IndirectRef ref = weak_globals_.Add(IRT_FIRST_SEGMENT, obj.Decode());
+ IndirectRef ref = weak_globals_.Add(IRT_FIRST_SEGMENT, obj.Ptr());
return reinterpret_cast<jweak>(ref);
}
ObjPtr<mirror::ClassLoader> loader = soa.Decode<mirror::ClassLoader>(class_loader);
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
- if (class_linker->IsBootClassLoader(soa, loader.Decode())) {
+ if (class_linker->IsBootClassLoader(soa, loader.Ptr())) {
loader = nullptr;
class_loader = nullptr;
}
- class_loader_allocator = class_linker->GetAllocatorForClassLoader(loader.Decode());
+ class_loader_allocator = class_linker->GetAllocatorForClassLoader(loader.Ptr());
CHECK(class_loader_allocator != nullptr);
}
if (library != nullptr) {
}
}
if (method == nullptr || method->IsStatic() != is_static) {
- ThrowNoSuchMethodError(soa, c.Decode(), name, sig, is_static ? "static" : "non-static");
+ ThrowNoSuchMethodError(soa, c.Ptr(), name, sig, is_static ? "static" : "non-static");
return nullptr;
}
return soa.EncodeMethod(method);
// Not even a java.lang.reflect.Field, return null. TODO, is this check necessary?
return nullptr;
}
- ObjPtr<mirror::Field> field = down_cast<mirror::Field*>(obj_field.Decode());
+ ObjPtr<mirror::Field> field = down_cast<mirror::Field*>(obj_field.Ptr());
return soa.EncodeField(field->GetArtField());
}
static jobject NewGlobalRef(JNIEnv* env, jobject obj) {
ScopedObjectAccess soa(env);
ObjPtr<mirror::Object> decoded_obj = soa.Decode<mirror::Object>(obj);
- return soa.Vm()->AddGlobalRef(soa.Self(), decoded_obj.Decode());
+ return soa.Vm()->AddGlobalRef(soa.Self(), decoded_obj.Ptr());
}
static void DeleteGlobalRef(JNIEnv* env, jobject obj) {
static jweak NewWeakGlobalRef(JNIEnv* env, jobject obj) {
ScopedObjectAccess soa(env);
ObjPtr<mirror::Object> decoded_obj = soa.Decode<mirror::Object>(obj);
- return soa.Vm()->AddWeakGlobalRef(soa.Self(), decoded_obj.Decode());
+ return soa.Vm()->AddWeakGlobalRef(soa.Self(), decoded_obj.Ptr());
}
static void DeleteWeakGlobalRef(JNIEnv* env, jweak obj) {
ObjPtr<mirror::ObjectArray<mirror::Object>> array =
soa.Decode<mirror::ObjectArray<mirror::Object>>(java_array);
ObjPtr<mirror::Object> value = soa.Decode<mirror::Object>(java_value);
- array->Set<false>(index, value.Decode());
+ array->Set<false>(index, value.Ptr());
}
static jbooleanArray NewBooleanArray(JNIEnv* env, jsize length) {
ScopedObjectAccess soa(env);
mirror::Class* array_class;
{
- mirror::Class* element_class = soa.Decode<mirror::Class>(element_jclass).Decode();
+ mirror::Class* element_class = soa.Decode<mirror::Class>(element_jclass).Ptr();
if (UNLIKELY(element_class->IsPrimitive())) {
soa.Vm()->JniAbortF("NewObjectArray", "not an object type: %s",
PrettyDescriptor(element_class).c_str());
return nullptr;
} else {
for (jsize i = 0; i < length; ++i) {
- result->SetWithoutChecks<false>(i, initial_object.Decode());
+ result->SetWithoutChecks<false>(i, initial_object.Ptr());
}
}
}
return;
}
const size_t component_size = array->GetClass()->GetComponentSize();
- ReleasePrimitiveArray(soa, array.Decode(), component_size, elements, mode);
+ ReleasePrimitiveArray(soa, array.Ptr(), component_size, elements, mode);
}
static jboolean* GetBooleanArrayElements(JNIEnv* env, jbooleanArray array, jboolean* is_copy) {
current_class != nullptr;
current_class = current_class->GetSuperClass()) {
// Search first only comparing methods which are native.
- m = FindMethod<true>(current_class.Decode(), name, sig);
+ m = FindMethod<true>(current_class.Ptr(), name, sig);
if (m != nullptr) {
break;
}
// Search again comparing to all methods, to find non-native methods that match.
- m = FindMethod<false>(current_class.Decode(), name, sig);
+ m = FindMethod<false>(current_class.Ptr(), name, sig);
if (m != nullptr) {
break;
}
<< "Failed to register native method "
<< PrettyDescriptor(c) << "." << name << sig << " in "
<< c->GetDexCache()->GetLocation()->ToModifiedUtf8();
- ThrowNoSuchMethodError(soa, c.Decode(), name, sig, "static or non-static");
+ ThrowNoSuchMethodError(soa, c.Ptr(), name, sig, "static or non-static");
return JNI_ERR;
} else if (!m->IsNative()) {
LOG(return_errors ? ::android::base::ERROR : ::android::base::FATAL)
<< "Failed to register non-native method "
<< PrettyDescriptor(c) << "." << name << sig
<< " as native";
- ThrowNoSuchMethodError(soa, c.Decode(), name, sig, "native");
+ ThrowNoSuchMethodError(soa, c.Ptr(), name, sig, "native");
return JNI_ERR;
}
if (soa.Self()->IsExceptionPending()) {
return JNI_ERR;
}
- soa.Env()->monitors.Add(o.Decode());
+ soa.Env()->monitors.Add(o.Ptr());
return JNI_OK;
}
if (soa.Self()->IsExceptionPending()) {
return JNI_ERR;
}
- soa.Env()->monitors.Remove(o.Decode());
+ soa.Env()->monitors.Remove(o.Ptr());
return JNI_OK;
}
return nullptr;
}
DCHECK_EQ(sizeof(ElementT), array->GetClass()->GetComponentSize());
- return array.Decode();
+ return array.Ptr();
}
template <typename ArrayT, typename ElementT, typename ArtArrayT>
DCHECK(dex_access_to != nullptr);
if (UNLIKELY(!this->CanAccess(dex_access_to))) {
if (throw_on_failure) {
- ThrowIllegalAccessErrorClass(this, dex_access_to.Decode());
+ ThrowIllegalAccessErrorClass(this, dex_access_to.Ptr());
}
return false;
}
if (UNLIKELY(!this->CanAccess(dex_access_to))) {
if (throw_on_failure) {
ThrowIllegalAccessErrorClassForMethodDispatch(this,
- dex_access_to.Decode(),
+ dex_access_to.Ptr(),
method,
throw_invoke_type);
}
inline bool Class::CheckResolvedFieldAccess(ObjPtr<Class> access_to,
ArtField* field,
uint32_t field_idx) {
- return ResolvedFieldAccessTest<true, true>(access_to.Decode(), field, field_idx, nullptr);
+ return ResolvedFieldAccessTest<true, true>(access_to.Ptr(), field, field_idx, nullptr);
}
inline bool Class::CanAccessResolvedMethod(Class* access_to, ArtMethod* method,
template<bool kTransactionActive>
void Field::SetDeclaringClass(ObjPtr<mirror::Class> c) {
- SetFieldObject<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_), c.Decode());
+ SetFieldObject<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_), c.Ptr());
}
} // namespace mirror
ObjPtr<mirror::Object, /*kPoison*/ true> null_ptr;
EXPECT_TRUE(null_ptr.IsNull());
EXPECT_TRUE(null_ptr.IsValid());
- EXPECT_TRUE(null_ptr.Decode() == nullptr);
+ EXPECT_TRUE(null_ptr.Ptr() == nullptr);
EXPECT_TRUE(null_ptr == nullptr);
EXPECT_TRUE(null_ptr == null_ptr);
EXPECT_FALSE(null_ptr != null_ptr);
ObjPtr<Class, /*kPoison*/ true> X(h_X.Get());
EXPECT_TRUE(!X.IsNull());
EXPECT_TRUE(X.IsValid());
- EXPECT_TRUE(X.Decode() != nullptr);
+ EXPECT_TRUE(X.Ptr() != nullptr);
EXPECT_OBJ_PTR_EQ(h_X.Get(), X);
// FindClass may cause thread suspension, it should invalidate X.
ObjPtr<Class, /*kPoison*/ true> Y(class_linker_->FindClass(soa.Self(), "LY;", class_loader));
EXPECT_TRUE(!Y.IsNull());
EXPECT_TRUE(Y.IsValid());
- EXPECT_TRUE(Y.Decode() != nullptr);
+ EXPECT_TRUE(Y.Ptr() != nullptr);
// Should IsNull be safe to call on null ObjPtr? I'll allow it for now.
EXPECT_TRUE(!X.IsNull());
ObjPtr<mirror::Object, /*kPoison*/ false> unpoisoned;
EXPECT_TRUE(unpoisoned.IsNull());
EXPECT_TRUE(unpoisoned.IsValid());
- EXPECT_TRUE(unpoisoned.Decode() == nullptr);
+ EXPECT_TRUE(unpoisoned.Ptr() == nullptr);
EXPECT_TRUE(unpoisoned == nullptr);
EXPECT_TRUE(unpoisoned == unpoisoned);
EXPECT_FALSE(unpoisoned != unpoisoned);
*dex_class_def);
// Add the used dex file. This only required for the DexFile.loadClass API since normal
// class loaders already keep their dex files live.
- class_linker->InsertDexFileInToClassLoader(soa.Decode<mirror::Object>(dexFile).Decode(),
+ class_linker->InsertDexFileInToClassLoader(soa.Decode<mirror::Object>(dexFile).Ptr(),
class_loader.Get());
if (result != nullptr) {
VLOG(class_linker) << "DexFile_defineClassNative returning " << result
// InMemoryClassLoader/DexData instance now that a class has
// been loaded.
class_linker->InsertDexFileInToClassLoader(
- soa.Decode<mirror::Object>(dexData).Decode(), class_loader.Get());
+ soa.Decode<mirror::Object>(dexData).Ptr(), class_loader.Get());
return soa.AddLocalReference<jclass>(result);
}
}
if (c == nullptr) {
return 0;
}
- std::vector<mirror::Class*> classes {c.Decode()};
+ std::vector<mirror::Class*> classes {c.Ptr()};
uint64_t count = 0;
heap->CountInstances(classes, countAssignable, &count);
return count;
ThrowNegativeArraySizeException(length);
return nullptr;
}
- mirror::Class* element_class = soa.Decode<mirror::Class>(javaElementClass).Decode();
+ mirror::Class* element_class = soa.Decode<mirror::Class>(javaElementClass).Ptr();
if (UNLIKELY(element_class == nullptr)) {
ThrowNullPointerException("element class == null");
return nullptr;
ThrowNegativeArraySizeException(length);
return nullptr;
}
- mirror::Class* element_class = soa.Decode<mirror::Class>(javaElementClass).Decode();
+ mirror::Class* element_class = soa.Decode<mirror::Class>(javaElementClass).Ptr();
if (UNLIKELY(element_class == nullptr)) {
ThrowNullPointerException("element class == null");
return nullptr;
ThrowIllegalArgumentException("not an array");
return 0;
}
- if (Runtime::Current()->GetHeap()->IsMovableObject(array.Decode())) {
+ if (Runtime::Current()->GetHeap()->IsMovableObject(array.Ptr())) {
ThrowRuntimeException("Trying to get address of movable array object");
return 0;
}
ObjPtr<mirror::Constructor> result =
mirror::Class::GetDeclaredConstructorInternal<kRuntimePointerSize, false>(
soa.Self(),
- DecodeClass(soa, javaThis).Decode(),
- soa.Decode<mirror::ObjectArray<mirror::Class>>(args).Decode());
+ DecodeClass(soa, javaThis).Ptr(),
+ soa.Decode<mirror::ObjectArray<mirror::Class>>(args).Ptr());
return soa.AddLocalReference<jobject>(result);
}
DCHECK(!Runtime::Current()->IsActiveTransaction());
mirror::Method* result = mirror::Class::GetDeclaredMethodInternal<kRuntimePointerSize, false>(
soa.Self(),
- DecodeClass(soa, javaThis).Decode(),
- soa.Decode<mirror::String>(name).Decode(),
- soa.Decode<mirror::ObjectArray<mirror::Class>>(args).Decode());
+ DecodeClass(soa, javaThis).Ptr(),
+ soa.Decode<mirror::String>(name).Ptr(),
+ soa.Decode<mirror::ObjectArray<mirror::Class>>(args).Ptr());
return soa.AddLocalReference<jobject>(result);
}
soa.Decode<mirror::Class>(WellKnownClasses::java_lang_annotation_Annotation__array);
mirror::ObjectArray<mirror::Object>* empty_array =
mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(),
- annotation_array_class.Decode(),
+ annotation_array_class.Ptr(),
0);
return soa.AddLocalReference<jobjectArray>(empty_array);
}
ScopedFastNativeObjectAccess soa(env);
ObjPtr<mirror::DexCache> dex_cache = soa.Decode<mirror::DexCache>(javaDexCache);
CHECK_LT(static_cast<size_t>(type_index), dex_cache->NumResolvedTypes());
- dex_cache->SetResolvedType(type_index, soa.Decode<mirror::Class>(type).Decode());
+ dex_cache->SetResolvedType(type_index, soa.Decode<mirror::Class>(type).Ptr());
}
static void DexCache_setResolvedString(JNIEnv* env, jobject javaDexCache, jint string_index,
ScopedFastNativeObjectAccess soa(env);
ObjPtr<mirror::DexCache> dex_cache = soa.Decode<mirror::DexCache>(javaDexCache);
CHECK_LT(static_cast<size_t>(string_index), dex_cache->GetDexFile()->NumStringIds());
- dex_cache->SetResolvedString(string_index, soa.Decode<mirror::String>(string).Decode());
+ dex_cache->SetResolvedString(string_index, soa.Decode<mirror::String>(string).Ptr());
}
static JNINativeMethod gMethods[] = {
return -1;
} else {
return soa.Decode<mirror::String>(java_this)->CompareTo(
- soa.Decode<mirror::String>(java_rhs).Decode());
+ soa.Decode<mirror::String>(java_rhs).Ptr());
}
}
// Make sure source and destination are both arrays.
ObjPtr<mirror::Object> srcObject = soa.Decode<mirror::Object>(javaSrc);
if (UNLIKELY(!srcObject->IsArrayInstance())) {
- ThrowArrayStoreException_NotAnArray("source", srcObject.Decode());
+ ThrowArrayStoreException_NotAnArray("source", srcObject.Ptr());
return;
}
ObjPtr<mirror::Object> dstObject = soa.Decode<mirror::Object>(javaDst);
if (UNLIKELY(!dstObject->IsArrayInstance())) {
- ThrowArrayStoreException_NotAnArray("destination", dstObject.Decode());
+ ThrowArrayStoreException_NotAnArray("destination", dstObject.Ptr());
return;
}
mirror::Array* srcArray = srcObject->AsArray();
}
MutexLock mu(soa.Self(), *Locks::thread_list_lock_);
Thread* thread = Thread::FromManagedThread(soa, java_thread);
- return thread->HoldsLock(object.Decode());
+ return thread->HoldsLock(object.Ptr());
}
static void Thread_nativeInterrupt(JNIEnv* env, jobject java_thread) {
static void Thread_sleep(JNIEnv* env, jclass, jobject java_lock, jlong ms, jint ns) {
ScopedFastNativeObjectAccess soa(env);
ObjPtr<mirror::Object> lock = soa.Decode<mirror::Object>(java_lock);
- Monitor::Wait(Thread::Current(), lock.Decode(), ms, ns, true, kSleeping);
+ Monitor::Wait(Thread::Current(), lock.Ptr(), ms, ns, true, kSleeping);
}
/*
mirror::Class* c = cl->LookupClass(soa.Self(),
descriptor.c_str(),
descriptor_hash,
- loader.Decode());
+ loader.Ptr());
if (c != nullptr && c->IsResolved()) {
return soa.AddLocalReference<jclass>(c);
}
ScopedFastNativeObjectAccess soa(env);
ObjPtr<mirror::FinalizerReference> ref = soa.Decode<mirror::FinalizerReference>(javaThis);
return Runtime::Current()->GetHeap()->GetReferenceProcessor()->MakeCircularListIfUnenqueued(
- ref.Decode());
+ ref.Ptr());
}
static JNINativeMethod gMethods[] = {
ScopedFastNativeObjectAccess soa(env);
ObjPtr<mirror::Reference> ref = soa.Decode<mirror::Reference>(javaThis);
mirror::Object* const referent =
- Runtime::Current()->GetHeap()->GetReferenceProcessor()->GetReferent(soa.Self(), ref.Decode());
+ Runtime::Current()->GetHeap()->GetReferenceProcessor()->GetReferent(soa.Self(), ref.Ptr());
return soa.AddLocalReference<jobject>(referent);
}
DCHECK_EQ(dimensions_obj->GetClass()->GetComponentType()->GetPrimitiveType(),
Primitive::kPrimInt);
Handle<mirror::IntArray> dimensions_array(
- hs.NewHandle(down_cast<mirror::IntArray*>(dimensions_obj.Decode())));
+ hs.NewHandle(down_cast<mirror::IntArray*>(dimensions_obj.Ptr())));
mirror::Array* new_array = mirror::Array::CreateMultiArray(soa.Self(), element_class,
dimensions_array);
return soa.AddLocalReference<jobject>(new_array);
ThrowNegativeArraySizeException(length);
return nullptr;
}
- mirror::Class* element_class = soa.Decode<mirror::Class>(javaElementClass).Decode();
+ mirror::Class* element_class = soa.Decode<mirror::Class>(javaElementClass).Ptr();
Runtime* runtime = Runtime::Current();
ClassLinker* class_linker = runtime->GetClassLinker();
mirror::Class* array_class = class_linker->FindArrayClass(soa.Self(), &element_class);
ObjPtr<mirror::Class> annotation_array_class =
soa.Decode<mirror::Class>(WellKnownClasses::java_lang_annotation_Annotation__array);
ObjPtr<mirror::ObjectArray<mirror::Object>> empty_array =
- mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(), annotation_array_class.Decode(), 0);
+ mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(), annotation_array_class.Ptr(), 0);
return soa.AddLocalReference<jobjectArray>(empty_array);
}
return soa.AddLocalReference<jobjectArray>(annotations::GetAnnotationsForMethod(method));
*class_or_rcvr = declaringClass;
return true;
}
- *class_or_rcvr = soa.Decode<mirror::Object>(j_rcvr).Decode();
+ *class_or_rcvr = soa.Decode<mirror::Object>(j_rcvr).Ptr();
if (!VerifyObjectIsClass(MakeObjPtr(*class_or_rcvr), MakeObjPtr(declaringClass))) {
DCHECK(soa.Self()->IsExceptionPending());
return false;
static jobject Field_get(JNIEnv* env, jobject javaField, jobject javaObj) {
ScopedFastNativeObjectAccess soa(env);
- mirror::Field* f = soa.Decode<mirror::Field>(javaField).Decode();
+ mirror::Field* f = soa.Decode<mirror::Field>(javaField).Ptr();
mirror::Object* o = nullptr;
if (!CheckReceiver(soa, javaObj, &f, &o)) {
DCHECK(soa.Self()->IsExceptionPending());
DCHECK(soa.Self()->IsExceptionPending());
return nullptr;
}
- return soa.AddLocalReference<jobject>(BoxPrimitive(field_type, value).Decode());
+ return soa.AddLocalReference<jobject>(BoxPrimitive(field_type, value).Ptr());
}
template<Primitive::Type kPrimitiveType>
ALWAYS_INLINE inline static JValue GetPrimitiveField(JNIEnv* env, jobject javaField,
jobject javaObj) {
ScopedFastNativeObjectAccess soa(env);
- mirror::Field* f = soa.Decode<mirror::Field>(javaField).Decode();
+ mirror::Field* f = soa.Decode<mirror::Field>(javaField).Ptr();
mirror::Object* o = nullptr;
if (!CheckReceiver(soa, javaObj, &f, &o)) {
DCHECK(soa.Self()->IsExceptionPending());
static void Field_set(JNIEnv* env, jobject javaField, jobject javaObj, jobject javaValue) {
ScopedFastNativeObjectAccess soa(env);
- mirror::Field* f = soa.Decode<mirror::Field>(javaField).Decode();
+ mirror::Field* f = soa.Decode<mirror::Field>(javaField).Ptr();
// Check that the receiver is non-null and an instance of the field's declaring class.
mirror::Object* o = nullptr;
if (!CheckReceiver(soa, javaObj, &f, &o)) {
static void SetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj,
const JValue& new_value) {
ScopedFastNativeObjectAccess soa(env);
- mirror::Field* f = soa.Decode<mirror::Field>(javaField).Decode();
+ mirror::Field* f = soa.Decode<mirror::Field>(javaField).Ptr();
mirror::Object* o = nullptr;
if (!CheckReceiver(soa, javaObj, &f, &o)) {
return;
// Return an empty array instead of a null pointer.
mirror::Class* annotation_array_class =
soa.Decode<mirror::Class>(
- WellKnownClasses::java_lang_annotation_Annotation__array).Decode();
+ WellKnownClasses::java_lang_annotation_Annotation__array).Ptr();
mirror::ObjectArray<mirror::Object>* empty_array =
mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(), annotation_array_class, 0);
return soa.AddLocalReference<jobjectArray>(empty_array);
// CAS or the CAS could fail incorrectly.
mirror::HeapReference<mirror::Object>* field_addr =
reinterpret_cast<mirror::HeapReference<mirror::Object>*>(
- reinterpret_cast<uint8_t*>(obj.Decode()) + static_cast<size_t>(offset));
+ reinterpret_cast<uint8_t*>(obj.Ptr()) + static_cast<size_t>(offset));
ReadBarrier::Barrier<mirror::Object, kWithReadBarrier, /*kAlwaysUpdateField*/true>(
- obj.Decode(),
+ obj.Ptr(),
MemberOffset(offset),
field_addr);
}
bool success = obj->CasFieldStrongSequentiallyConsistentObject<false>(MemberOffset(offset),
- expectedValue.Decode(),
- newValue.Decode());
+ expectedValue.Ptr(),
+ newValue.Ptr());
return success ? JNI_TRUE : JNI_FALSE;
}
ObjPtr<mirror::Object> obj = soa.Decode<mirror::Object>(javaObj);
ObjPtr<mirror::Object> newValue = soa.Decode<mirror::Object>(javaNewValue);
// JNI must use non transactional mode.
- obj->SetFieldObject<false>(MemberOffset(offset), newValue.Decode());
+ obj->SetFieldObject<false>(MemberOffset(offset), newValue.Ptr());
}
static void Unsafe_putObjectVolatile(JNIEnv* env, jobject, jobject javaObj, jlong offset,
ObjPtr<mirror::Object> obj = soa.Decode<mirror::Object>(javaObj);
ObjPtr<mirror::Object> newValue = soa.Decode<mirror::Object>(javaNewValue);
// JNI must use non transactional mode.
- obj->SetFieldObjectVolatile<false>(MemberOffset(offset), newValue.Decode());
+ obj->SetFieldObjectVolatile<false>(MemberOffset(offset), newValue.Ptr());
}
static void Unsafe_putOrderedObject(JNIEnv* env, jobject, jobject javaObj, jlong offset,
ObjPtr<mirror::Object> newValue = soa.Decode<mirror::Object>(javaNewValue);
QuasiAtomic::ThreadFenceRelease();
// JNI must use non transactional mode.
- obj->SetFieldObject<false>(MemberOffset(offset), newValue.Decode());
+ obj->SetFieldObject<false>(MemberOffset(offset), newValue.Ptr());
}
static jint Unsafe_getArrayBaseOffsetForComponentType(JNIEnv* env, jclass, jobject component_class) {
template<class MirrorType, bool kPoison>
inline void ObjPtr<MirrorType, kPoison>::AssertValid() const {
if (kPoison) {
- CHECK(IsValid()) << "Stale object pointer " << DecodeUnchecked() << " , expected cookie "
+ CHECK(IsValid()) << "Stale object pointer " << Ptr() << " , expected cookie "
<< TrimCookie(Thread::Current()->GetPoisonObjectCookie()) << " but got " << GetCookie();
}
}
template<class MirrorType, bool kPoison>
inline std::ostream& operator<<(std::ostream& os, ObjPtr<MirrorType, kPoison> ptr) {
// May be used for dumping bad pointers, do not use the checked version.
- return os << ptr.DecodeUnchecked();
+ return os << ptr.PtrUnchecked();
}
} // namespace art
template <typename Type>
ALWAYS_INLINE ObjPtr(const ObjPtr<Type>& other) REQUIRES_SHARED(Locks::mutator_lock_)
- : reference_(Encode(static_cast<MirrorType*>(other.Decode()))) {}
+ : reference_(Encode(static_cast<MirrorType*>(other.Ptr()))) {}
template <typename Type>
ALWAYS_INLINE ObjPtr& operator=(const ObjPtr& other) {
- reference_ = Encode(static_cast<MirrorType*>(other.Decode()));
+ reference_ = Encode(static_cast<MirrorType*>(other.Ptr()));
return *this;
}
}
ALWAYS_INLINE MirrorType* operator->() const REQUIRES_SHARED(Locks::mutator_lock_) {
- return Decode();
+ return Ptr();
}
ALWAYS_INLINE bool IsNull() const {
return reference_ == 0;
}
- // Decode makes sure that the object pointer is valid.
- ALWAYS_INLINE MirrorType* Decode() const REQUIRES_SHARED(Locks::mutator_lock_) {
+ // Ptr makes sure that the object pointer is valid.
+ ALWAYS_INLINE MirrorType* Ptr() const REQUIRES_SHARED(Locks::mutator_lock_) {
AssertValid();
- return DecodeUnchecked();
+ return PtrUnchecked();
}
ALWAYS_INLINE bool IsValid() const REQUIRES_SHARED(Locks::mutator_lock_);
ALWAYS_INLINE void AssertValid() const REQUIRES_SHARED(Locks::mutator_lock_);
ALWAYS_INLINE bool operator==(const ObjPtr& ptr) const REQUIRES_SHARED(Locks::mutator_lock_) {
- return Decode() == ptr.Decode();
+ return Ptr() == ptr.Ptr();
}
template <typename PointerType>
ALWAYS_INLINE bool operator==(const PointerType* ptr) const
REQUIRES_SHARED(Locks::mutator_lock_) {
- return Decode() == ptr;
+ return Ptr() == ptr;
}
ALWAYS_INLINE bool operator==(std::nullptr_t) const {
}
ALWAYS_INLINE bool operator!=(const ObjPtr& ptr) const REQUIRES_SHARED(Locks::mutator_lock_) {
- return Decode() != ptr.Decode();
+ return Ptr() != ptr.Ptr();
}
template <typename PointerType>
ALWAYS_INLINE bool operator!=(const PointerType* ptr) const
REQUIRES_SHARED(Locks::mutator_lock_) {
- return Decode() != ptr;
+ return Ptr() != ptr;
}
ALWAYS_INLINE bool operator!=(std::nullptr_t) const {
return !IsNull();
}
- // Decode unchecked does not check that object pointer is valid. Do not use if you can avoid it.
- ALWAYS_INLINE MirrorType* DecodeUnchecked() const {
+ // Ptr unchecked does not check that object pointer is valid. Do not use if you can avoid it.
+ ALWAYS_INLINE MirrorType* PtrUnchecked() const {
if (kPoison) {
return reinterpret_cast<MirrorType*>(
static_cast<uintptr_t>(static_cast<uint32_t>(reference_ << kObjectAlignmentShift)));
jobject java_lock, jlong millis) {
art::ScopedFastNativeObjectAccess soa(env);
art::ObjPtr<art::mirror::Object> lock = soa.Decode<art::mirror::Object>(java_lock);
- art::Monitor::Wait(art::Thread::Current(), lock.Decode(), millis, 0, true, art::kSleeping);
+ art::Monitor::Wait(art::Thread::Current(), lock.Ptr(), millis, 0, true, art::kSleeping);
}
JNIEXPORT jobject JVM_CurrentThread(JNIEnv* env, jclass unused ATTRIBUTE_UNUSED) {
art::ThrowNullPointerException("object == null");
return JNI_FALSE;
}
- return soa.Self()->HoldsLock(object.Decode());
+ return soa.Self()->HoldsLock(object.Ptr());
}
JNIEXPORT void JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring java_name) {
if (UNLIKELY(o == nullptr)) {
ThrowNullPointerException("null receiver");
return false;
- } else if (UNLIKELY(!o->InstanceOf(c.Decode()))) {
+ } else if (UNLIKELY(!o->InstanceOf(c.Ptr()))) {
InvalidReceiverError(o, c);
return false;
}
}
void Append(ObjPtr<mirror::Object> obj) REQUIRES_SHARED(Locks::mutator_lock_) {
- Append(StackReference<mirror::Object>::FromMirrorPtr(obj.Decode()).AsVRegValue());
+ Append(StackReference<mirror::Object>::FromMirrorPtr(obj.Ptr()).AsVRegValue());
}
void AppendWide(uint64_t value) {
// Box if necessary and return.
return soa.AddLocalReference<jobject>(
- BoxPrimitive(Primitive::GetType(shorty[0]), result).Decode());
+ BoxPrimitive(Primitive::GetType(shorty[0]), result).Ptr());
}
ObjPtr<mirror::Object> BoxPrimitive(Primitive::Type src_class, const JValue& value) {
}
return false;
}
- unboxed_value->SetL(o.Decode());
+ unboxed_value->SetL(o.Ptr());
return true;
}
if (UNLIKELY(dst_class->GetPrimitiveType() == Primitive::kPrimVoid)) {
IndirectRef ref = reinterpret_cast<IndirectRef>(obj);
IndirectRefKind kind = GetIndirectRefKind(ref);
if (kind == kLocal) {
- self->GetJniEnv()->locals.Update(obj, result.Decode());
+ self->GetJniEnv()->locals.Update(obj, result.Ptr());
} else if (kind == kHandleScopeOrInvalid) {
LOG(FATAL) << "Unsupported UpdateReference for kind kHandleScopeOrInvalid";
} else if (kind == kGlobal) {
- self->GetJniEnv()->vm->UpdateGlobal(self, ref, result.Decode());
+ self->GetJniEnv()->vm->UpdateGlobal(self, ref, result.Ptr());
} else {
DCHECK_EQ(kind, kWeakGlobal);
- self->GetJniEnv()->vm->UpdateWeakGlobal(self, ref, result.Decode());
+ self->GetJniEnv()->vm->UpdateWeakGlobal(self, ref, result.Ptr());
}
}
// We can't run in a transaction yet.
contextClassLoader->SetObject<false>(
soa.Self()->GetPeer(),
- soa.Decode<mirror::ClassLoader>(system_class_loader.get()).Decode());
+ soa.Decode<mirror::ClassLoader>(system_class_loader.get()).Ptr());
return env->NewGlobalRef(system_class_loader.get());
}
template<typename T, typename MirrorType, bool kPoison>
inline T ScopedObjectAccessAlreadyRunnable::AddLocalReference(
ObjPtr<MirrorType, kPoison> obj) const {
- return AddLocalReference<T>(obj.Decode());
+ return AddLocalReference<T>(obj.Ptr());
}
template<typename T, bool kPoison>
// Copy peer into self, deleting global reference when done.
CHECK(self->tlsPtr_.jpeer != nullptr);
- self->tlsPtr_.opeer = soa.Decode<mirror::Object>(self->tlsPtr_.jpeer).Decode();
+ self->tlsPtr_.opeer = soa.Decode<mirror::Object>(self->tlsPtr_.jpeer).Ptr();
self->GetJniEnv()->DeleteGlobalRef(self->tlsPtr_.jpeer);
self->tlsPtr_.jpeer = nullptr;
self->SetThreadName(self->GetThreadName(soa)->ToModifiedUtf8().c_str());
Thread* Thread::FromManagedThread(const ScopedObjectAccessAlreadyRunnable& soa,
jobject java_thread) {
- return FromManagedThread(soa, soa.Decode<mirror::Object>(java_thread).Decode());
+ return FromManagedThread(soa, soa.Decode<mirror::Object>(java_thread).Ptr());
}
static size_t FixStackSize(size_t stack_size) {
}
{
ScopedObjectAccess soa(this);
- tlsPtr_.opeer = soa.Decode<mirror::Object>(peer.get()).Decode();
+ tlsPtr_.opeer = soa.Decode<mirror::Object>(peer.get()).Ptr();
}
env->CallNonvirtualVoidMethod(peer.get(),
WellKnownClasses::java_lang_Thread,
void Thread::SetException(ObjPtr<mirror::Throwable> new_exception) {
CHECK(new_exception != nullptr);
// TODO: DCHECK(!IsExceptionPending());
- tlsPtr_.exception = new_exception.Decode();
+ tlsPtr_.exception = new_exception.Ptr();
}
} // namespace art
ObjPtr<mirror::Class> klass = field->GetDeclaringClass();
const RegType& field_klass =
FromClass(klass->GetDescriptor(&temp),
- klass.Decode(),
+ klass.Ptr(),
klass->CannotBeAssignedFromOtherTypes());
if (obj_type.IsUninitializedTypes()) {
// Field accesses through uninitialized references are only allowable for constructors where
can_load_classes_ ? field->GetType<true>() : field->GetType<false>();
if (field_type_class != nullptr) {
field_type = &FromClass(field->GetTypeDescriptor(),
- field_type_class.Decode(),
+ field_type_class.Ptr(),
field_type_class->CannotBeAssignedFromOtherTypes());
} else {
DCHECK(!can_load_classes_ || self_->IsExceptionPending());
if (field_type_class != nullptr) {
field_type = &FromClass(field->GetTypeDescriptor(),
- field_type_class.Decode(),
+ field_type_class.Ptr(),
field_type_class->CannotBeAssignedFromOtherTypes());
} else {
Thread* self = Thread::Current();
SetVerifierDeps(dex_files);
ObjPtr<mirror::ClassLoader> loader = soa->Decode<mirror::ClassLoader>(class_loader_);
- class_linker_->RegisterDexFile(*dex_file_, loader.Decode());
+ class_linker_->RegisterDexFile(*dex_file_, loader.Ptr());
klass_Main_ = FindClassByName("LMain;", soa);
CHECK(klass_Main_ != nullptr);
extern "C" JNIEXPORT jlong JNICALL Java_Main_objectAddress(JNIEnv* env, jclass, jobject object) {
ScopedObjectAccess soa(env);
- return reinterpret_cast<jlong>(soa.Decode<mirror::Object>(object).Decode());
+ return reinterpret_cast<jlong>(soa.Decode<mirror::Object>(object).Ptr());
}
extern "C" JNIEXPORT jboolean JNICALL Java_Main_supportCollectorTransition(JNIEnv*, jclass) {
extern "C" JNIEXPORT jlong JNICALL Java_MovingGCThread_objectAddress(JNIEnv* env, jclass, jobject object) {
ScopedObjectAccess soa(env);
- return reinterpret_cast<jlong>(soa.Decode<mirror::Object>(object).Decode());
+ return reinterpret_cast<jlong>(soa.Decode<mirror::Object>(object).Ptr());
}
} // namespace
extern "C" JNIEXPORT jint JNICALL Java_Main_doNativeCall(JNIEnv*, jobject value) {
ScopedObjectAccess soa(Thread::Current());
std::unique_ptr<Context> context(Context::Create());
- TestVisitor visitor(soa.Self(), context.get(), soa.Decode<mirror::Object>(value).Decode());
+ TestVisitor visitor(soa.Self(), context.get(), soa.Decode<mirror::Object>(value).Ptr());
visitor.WalkStack();
return visitor.found_method_index_;
}
extern "C" JNIEXPORT jint JNICALL Java_Main_doNativeCallRef(JNIEnv*, jobject value) {
ScopedObjectAccess soa(Thread::Current());
std::unique_ptr<Context> context(Context::Create());
- TestVisitor visitor(soa.Self(), context.get(), soa.Decode<mirror::Object>(value).Decode());
+ TestVisitor visitor(soa.Self(), context.get(), soa.Decode<mirror::Object>(value).Ptr());
visitor.WalkStack();
return visitor.found_method_index_;
}
array = env->NewLongArray(num_methods);
}
CHECK(array != nullptr);
- mirror::PointerArray* pointer_array = soa.Decode<mirror::PointerArray>(array).Decode();
+ mirror::PointerArray* pointer_array = soa.Decode<mirror::PointerArray>(array).Ptr();
for (size_t i = 0; i != num_methods; ++i) {
ArtMethod* method = mirror::DexCache::GetElementPtrSize(methods, i, kRuntimePointerSize);
pointer_array->SetElementPtrSize(i, method, kRuntimePointerSize);
uint32_t value = 0;
CHECK(GetVReg(m, 1, kReferenceVReg, &value));
CHECK_EQ(reinterpret_cast<mirror::Object*>(value),
- soa_.Decode<mirror::Object>(expected_value_).Decode());
+ soa_.Decode<mirror::Object>(expected_value_).Ptr());
}
return true;
}
auto* image_space = space->AsImageSpace();
const auto& image_header = image_space->GetImageHeader();
if (image_header.IsAppImage()) {
- if (image_space->HasAddress(klass_ptr.Decode())) {
+ if (image_space->HasAddress(klass_ptr.Ptr())) {
return JNI_TRUE;
}
}