diff options
Diffstat (limited to 'runtime/verifier/reg_type_cache.cc')
-rw-r--r-- | runtime/verifier/reg_type_cache.cc | 76 |
1 files changed, 37 insertions, 39 deletions
diff --git a/runtime/verifier/reg_type_cache.cc b/runtime/verifier/reg_type_cache.cc index d51374bf2d..255b506d1d 100644 --- a/runtime/verifier/reg_type_cache.cc +++ b/runtime/verifier/reg_type_cache.cc @@ -65,8 +65,8 @@ void RegTypeCache::FillPrimitiveAndSmallConstantTypes() { DCHECK_EQ(entries_.size(), primitive_count_); } -const RegType& RegTypeCache::FromDescriptor(mirror::ClassLoader* loader, const char* descriptor, - bool precise) { +RegType& RegTypeCache::FromDescriptor(mirror::ClassLoader* loader, const char* descriptor, + bool precise) { DCHECK(RegTypeCache::primitive_initialized_); if (descriptor[1] == '\0') { switch (descriptor[0]) { @@ -97,7 +97,7 @@ const RegType& RegTypeCache::FromDescriptor(mirror::ClassLoader* loader, const c } }; -const RegType& RegTypeCache::RegTypeFromPrimitiveType(Primitive::Type prim_type) const { +RegType& RegTypeCache::RegTypeFromPrimitiveType(Primitive::Type prim_type) const { CHECK(RegTypeCache::primitive_initialized_); switch (prim_type) { case Primitive::kPrimBoolean: @@ -156,8 +156,8 @@ mirror::Class* RegTypeCache::ResolveClass(const char* descriptor, mirror::ClassL return klass; } -const RegType& RegTypeCache::From(mirror::ClassLoader* loader, const char* descriptor, - bool precise) { +RegType& RegTypeCache::From(mirror::ClassLoader* loader, const char* descriptor, + bool precise) { // Try looking up the class in the cache first. for (size_t i = primitive_count_; i < entries_.size(); i++) { if (MatchDescriptor(i, descriptor, precise)) { @@ -208,7 +208,7 @@ const RegType& RegTypeCache::From(mirror::ClassLoader* loader, const char* descr } } -const RegType& RegTypeCache::FromClass(const char* descriptor, mirror::Class* klass, bool precise) { +RegType& RegTypeCache::FromClass(const char* descriptor, mirror::Class* klass, bool precise) { DCHECK(klass != nullptr && !klass->IsErroneous()); if (klass->IsPrimitive()) { // Note: precise isn't used for primitive classes. A char is assignable to an int. All @@ -218,7 +218,7 @@ const RegType& RegTypeCache::FromClass(const char* descriptor, mirror::Class* kl // Look for the reference in the list of entries to have. for (size_t i = primitive_count_; i < entries_.size(); i++) { RegType* cur_entry = entries_[i]; - if (cur_entry->klass_ == klass && MatchingPrecisionForClass(cur_entry, precise)) { + if (cur_entry->klass_.Read() == klass && MatchingPrecisionForClass(cur_entry, precise)) { return *cur_entry; } } @@ -311,17 +311,15 @@ void RegTypeCache::CreatePrimitiveAndSmallConstantTypes() { } } -const RegType& RegTypeCache::FromUnresolvedMerge(const RegType& left, const RegType& right) { +RegType& RegTypeCache::FromUnresolvedMerge(RegType& left, RegType& right) { std::set<uint16_t> types; if (left.IsUnresolvedMergedReference()) { - RegType& non_const(const_cast<RegType&>(left)); - types = (down_cast<UnresolvedMergedType*>(&non_const))->GetMergedTypes(); + types = (down_cast<UnresolvedMergedType*>(&left))->GetMergedTypes(); } else { types.insert(left.GetId()); } if (right.IsUnresolvedMergedReference()) { - RegType& non_const(const_cast<RegType&>(right)); - std::set<uint16_t> right_types = (down_cast<UnresolvedMergedType*>(&non_const))->GetMergedTypes(); + std::set<uint16_t> right_types = (down_cast<UnresolvedMergedType*>(&right))->GetMergedTypes(); types.insert(right_types.begin(), right_types.end()); } else { types.insert(right.GetId()); @@ -348,7 +346,7 @@ const RegType& RegTypeCache::FromUnresolvedMerge(const RegType& left, const RegT return *entry; } -const RegType& RegTypeCache::FromUnresolvedSuperClass(const RegType& child) { +RegType& RegTypeCache::FromUnresolvedSuperClass(RegType& child) { // Check if entry already exists. for (size_t i = primitive_count_; i < entries_.size(); i++) { RegType* cur_entry = entries_[i]; @@ -367,7 +365,7 @@ const RegType& RegTypeCache::FromUnresolvedSuperClass(const RegType& child) { return *entry; } -const UninitializedType& RegTypeCache::Uninitialized(const RegType& type, uint32_t allocation_pc) { +UninitializedType& RegTypeCache::Uninitialized(RegType& type, uint32_t allocation_pc) { UninitializedType* entry = NULL; const std::string& descriptor(type.GetDescriptor()); if (type.IsUnresolvedTypes()) { @@ -397,7 +395,7 @@ const UninitializedType& RegTypeCache::Uninitialized(const RegType& type, uint32 return *entry; } -const RegType& RegTypeCache::FromUninitialized(const RegType& uninit_type) { +RegType& RegTypeCache::FromUninitialized(RegType& uninit_type) { RegType* entry; if (uninit_type.IsUnresolvedTypes()) { @@ -439,44 +437,44 @@ const RegType& RegTypeCache::FromUninitialized(const RegType& uninit_type) { return *entry; } -const ImpreciseConstType& RegTypeCache::ByteConstant() { - const ConstantType& result = FromCat1Const(std::numeric_limits<jbyte>::min(), false); +ImpreciseConstType& RegTypeCache::ByteConstant() { + ConstantType& result = FromCat1Const(std::numeric_limits<jbyte>::min(), false); DCHECK(result.IsImpreciseConstant()); - return *down_cast<const ImpreciseConstType*>(&result); + return *down_cast<ImpreciseConstType*>(&result); } -const ImpreciseConstType& RegTypeCache::CharConstant() { +ImpreciseConstType& RegTypeCache::CharConstant() { int32_t jchar_max = static_cast<int32_t>(std::numeric_limits<jchar>::max()); - const ConstantType& result = FromCat1Const(jchar_max, false); + ConstantType& result = FromCat1Const(jchar_max, false); DCHECK(result.IsImpreciseConstant()); - return *down_cast<const ImpreciseConstType*>(&result); + return *down_cast<ImpreciseConstType*>(&result); } -const ImpreciseConstType& RegTypeCache::ShortConstant() { - const ConstantType& result = FromCat1Const(std::numeric_limits<jshort>::min(), false); +ImpreciseConstType& RegTypeCache::ShortConstant() { + ConstantType& result = FromCat1Const(std::numeric_limits<jshort>::min(), false); DCHECK(result.IsImpreciseConstant()); - return *down_cast<const ImpreciseConstType*>(&result); + return *down_cast<ImpreciseConstType*>(&result); } -const ImpreciseConstType& RegTypeCache::IntConstant() { - const ConstantType& result = FromCat1Const(std::numeric_limits<jint>::max(), false); +ImpreciseConstType& RegTypeCache::IntConstant() { + ConstantType& result = FromCat1Const(std::numeric_limits<jint>::max(), false); DCHECK(result.IsImpreciseConstant()); - return *down_cast<const ImpreciseConstType*>(&result); + return *down_cast<ImpreciseConstType*>(&result); } -const ImpreciseConstType& RegTypeCache::PosByteConstant() { - const ConstantType& result = FromCat1Const(std::numeric_limits<jbyte>::max(), false); +ImpreciseConstType& RegTypeCache::PosByteConstant() { + ConstantType& result = FromCat1Const(std::numeric_limits<jbyte>::max(), false); DCHECK(result.IsImpreciseConstant()); - return *down_cast<const ImpreciseConstType*>(&result); + return *down_cast<ImpreciseConstType*>(&result); } -const ImpreciseConstType& RegTypeCache::PosShortConstant() { - const ConstantType& result = FromCat1Const(std::numeric_limits<jshort>::max(), false); +ImpreciseConstType& RegTypeCache::PosShortConstant() { + ConstantType& result = FromCat1Const(std::numeric_limits<jshort>::max(), false); DCHECK(result.IsImpreciseConstant()); - return *down_cast<const ImpreciseConstType*>(&result); + return *down_cast<ImpreciseConstType*>(&result); } -const UninitializedType& RegTypeCache::UninitializedThisArgument(const RegType& type) { +UninitializedType& RegTypeCache::UninitializedThisArgument(RegType& type) { UninitializedType* entry; const std::string& descriptor(type.GetDescriptor()); if (type.IsUnresolvedTypes()) { @@ -502,10 +500,10 @@ const UninitializedType& RegTypeCache::UninitializedThisArgument(const RegType& return *entry; } -const ConstantType& RegTypeCache::FromCat1NonSmallConstant(int32_t value, bool precise) { +ConstantType& RegTypeCache::FromCat1NonSmallConstant(int32_t value, bool precise) { for (size_t i = primitive_count_; i < entries_.size(); i++) { RegType* cur_entry = entries_[i]; - if (cur_entry->klass_ == NULL && cur_entry->IsConstant() && + if (cur_entry->klass_.IsNull() && cur_entry->IsConstant() && cur_entry->IsPreciseConstant() == precise && (down_cast<ConstantType*>(cur_entry))->ConstantValue() == value) { return *down_cast<ConstantType*>(cur_entry); @@ -521,7 +519,7 @@ const ConstantType& RegTypeCache::FromCat1NonSmallConstant(int32_t value, bool p return *entry; } -const ConstantType& RegTypeCache::FromCat2ConstLo(int32_t value, bool precise) { +ConstantType& RegTypeCache::FromCat2ConstLo(int32_t value, bool precise) { for (size_t i = primitive_count_; i < entries_.size(); i++) { RegType* cur_entry = entries_[i]; if (cur_entry->IsConstantLo() && (cur_entry->IsPrecise() == precise) && @@ -539,7 +537,7 @@ const ConstantType& RegTypeCache::FromCat2ConstLo(int32_t value, bool precise) { return *entry; } -const ConstantType& RegTypeCache::FromCat2ConstHi(int32_t value, bool precise) { +ConstantType& RegTypeCache::FromCat2ConstHi(int32_t value, bool precise) { for (size_t i = primitive_count_; i < entries_.size(); i++) { RegType* cur_entry = entries_[i]; if (cur_entry->IsConstantHi() && (cur_entry->IsPrecise() == precise) && @@ -557,7 +555,7 @@ const ConstantType& RegTypeCache::FromCat2ConstHi(int32_t value, bool precise) { return *entry; } -const RegType& RegTypeCache::GetComponentType(const RegType& array, mirror::ClassLoader* loader) { +RegType& RegTypeCache::GetComponentType(RegType& array, mirror::ClassLoader* loader) { if (!array.IsArrayTypes()) { return Conflict(); } else if (array.IsUnresolvedTypes()) { |