reg_type_cache.cc revision b58474e08f6014663d1d3e215f3377d3ae616ad1
1776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers/* 2776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * Copyright (C) 2012 The Android Open Source Project 3776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * 4776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * Licensed under the Apache License, Version 2.0 (the "License"); 5776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * you may not use this file except in compliance with the License. 6776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * You may obtain a copy of the License at 7776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * 8776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * http://www.apache.org/licenses/LICENSE-2.0 9776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * 10776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * Unless required by applicable law or agreed to in writing, software 11776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * distributed under the License is distributed on an "AS IS" BASIS, 12776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * See the License for the specific language governing permissions and 14776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers * limitations under the License. 15776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers */ 16776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers 1751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal#include "reg_type_cache-inl.h" 18776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers 1951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal#include "base/casts.h" 209837939678bb5dcba178e5fb00ed59b5d14c8d9bIan Rogers#include "class_linker-inl.h" 214f6ad8ab428038129b2d0d6c40b7fd625cca15e1Ian Rogers#include "dex_file-inl.h" 222dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers#include "mirror/class-inl.h" 232dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers#include "mirror/object-inl.h" 247b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers#include "reg_type-inl.h" 25776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers 26776ac1fa61237db645adb4370a4aab888530caf4Ian Rogersnamespace art { 27776ac1fa61237db645adb4370a4aab888530caf4Ian Rogersnamespace verifier { 281bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers 2951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asalbool RegTypeCache::primitive_initialized_ = false; 3051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asaluint16_t RegTypeCache::primitive_count_ = 0; 317b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogersconst PreciseConstType* RegTypeCache::small_precise_constants_[kMaxSmallConstant - kMinSmallConstant + 1]; 32776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers 337b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogersstatic bool MatchingPrecisionForClass(const RegType* entry, bool precise) 3490443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) { 3504f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers if (entry->IsPreciseReference() == precise) { 3604f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers // We were or weren't looking for a precise reference and we found what we need. 3704f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers return true; 3804f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers } else { 3904f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers if (!precise && entry->GetClass()->CannotBeAssignedFromOtherTypes()) { 4004f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers // We weren't looking for a precise reference, as we're looking up based on a descriptor, but 4104f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers // we found a matching entry based on the descriptor. Return the precise entry in that case. 4204f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers return true; 4304f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers } 4404f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers return false; 4504f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers } 46776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers} 47776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers 4841c65c19c15ffac41089fa9f37502f94c046960dIan Rogersvoid RegTypeCache::FillPrimitiveAndSmallConstantTypes() { 4951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(UndefinedType::GetInstance()); 5051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(ConflictType::GetInstance()); 5151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(BooleanType::GetInstance()); 5251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(ByteType::GetInstance()); 5351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(ShortType::GetInstance()); 5451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(CharType::GetInstance()); 5551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(IntegerType::GetInstance()); 5651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(LongLoType::GetInstance()); 5751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(LongHiType::GetInstance()); 5851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(FloatType::GetInstance()); 5951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(DoubleLoType::GetInstance()); 6051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entries_.push_back(DoubleHiType::GetInstance()); 6141c65c19c15ffac41089fa9f37502f94c046960dIan Rogers for (int32_t value = kMinSmallConstant; value <= kMaxSmallConstant; ++value) { 6241c65c19c15ffac41089fa9f37502f94c046960dIan Rogers int32_t i = value - kMinSmallConstant; 6341c65c19c15ffac41089fa9f37502f94c046960dIan Rogers DCHECK_EQ(entries_.size(), small_precise_constants_[i]->GetId()); 6441c65c19c15ffac41089fa9f37502f94c046960dIan Rogers entries_.push_back(small_precise_constants_[i]); 6541c65c19c15ffac41089fa9f37502f94c046960dIan Rogers } 6651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal DCHECK_EQ(entries_.size(), primitive_count_); 6751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal} 6851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal 69d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst RegType& RegTypeCache::FromDescriptor(mirror::ClassLoader* loader, const char* descriptor, 70d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogers bool precise) { 711bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers DCHECK(RegTypeCache::primitive_initialized_); 721bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers if (descriptor[1] == '\0') { 73776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers switch (descriptor[0]) { 7451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case 'Z': 7551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return Boolean(); 7651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case 'B': 7751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return Byte(); 7851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case 'S': 7951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return Short(); 8051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case 'C': 8151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return Char(); 8251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case 'I': 8351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return Integer(); 8451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case 'J': 8551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return LongLo(); 8651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case 'F': 8751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return Float(); 8851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case 'D': 8951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return DoubleLo(); 9051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case 'V': // For void types, conflict types. 9151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal default: 9251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return Conflict(); 93776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 94776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } else if (descriptor[0] == 'L' || descriptor[0] == '[') { 9551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return From(loader, descriptor, precise); 96776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } else { 9751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return Conflict(); 98776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 99c8ccf68b805c92674545f63e0341ba47e8d9701cAndreas Gampe} 100776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers 101d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst RegType& RegTypeCache::RegTypeFromPrimitiveType(Primitive::Type prim_type) const { 1027b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers DCHECK(RegTypeCache::primitive_initialized_); 10351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal switch (prim_type) { 10451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case Primitive::kPrimBoolean: 10551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *BooleanType::GetInstance(); 10651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case Primitive::kPrimByte: 10751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *ByteType::GetInstance(); 10851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case Primitive::kPrimShort: 10951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *ShortType::GetInstance(); 11051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case Primitive::kPrimChar: 11151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *CharType::GetInstance(); 11251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case Primitive::kPrimInt: 11351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *IntegerType::GetInstance(); 11451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case Primitive::kPrimLong: 11551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *LongLoType::GetInstance(); 11651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case Primitive::kPrimFloat: 11751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *FloatType::GetInstance(); 11851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case Primitive::kPrimDouble: 11951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *DoubleLoType::GetInstance(); 12051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal case Primitive::kPrimVoid: 12151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal default: 12251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *ConflictType::GetInstance(); 12351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 124b49035706fceb2b13e8154668f175af624cf88f4Ian Rogers} 125b49035706fceb2b13e8154668f175af624cf88f4Ian Rogers 1261ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogersbool RegTypeCache::MatchDescriptor(size_t idx, const StringPiece& descriptor, bool precise) { 1277b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* entry = entries_[idx]; 1281ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers if (descriptor != entry->descriptor_) { 129637c65b1e431fd90195b71c141b3590bd81cc91aIan Rogers return false; 130637c65b1e431fd90195b71c141b3590bd81cc91aIan Rogers } 13104f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers if (entry->HasClass()) { 13204f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers return MatchingPrecisionForClass(entry, precise); 13351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 13404f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers // There is no notion of precise unresolved references, the precise information is just dropped 13504f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers // on the floor. 13604f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers DCHECK(entry->IsUnresolvedReference()); 13704f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers return true; 13851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal} 13951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal 1401bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogersmirror::Class* RegTypeCache::ResolveClass(const char* descriptor, mirror::ClassLoader* loader) { 14151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // Class was not found, must create new type. 14251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // Try resolving class 14351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); 1449837939678bb5dcba178e5fb00ed59b5d14c8d9bIan Rogers Thread* self = Thread::Current(); 145eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier StackHandleScope<1> hs(self); 146eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier Handle<mirror::ClassLoader> class_loader(hs.NewHandle(loader)); 1477b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers mirror::Class* klass = nullptr; 14851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal if (can_load_classes_) { 1499837939678bb5dcba178e5fb00ed59b5d14c8d9bIan Rogers klass = class_linker->FindClass(self, descriptor, class_loader); 150776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } else { 151e7c9a8c2b8481aafbc6af4ce6229bd361ba24742Mathieu Chartier klass = class_linker->LookupClass(self, descriptor, ComputeModifiedUtf8Hash(descriptor), 152e7c9a8c2b8481aafbc6af4ce6229bd361ba24742Mathieu Chartier loader); 153eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier if (klass != nullptr && !klass->IsLoaded()) { 15462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // We found the class but without it being loaded its not safe for use. 155eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier klass = nullptr; 15662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 15751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 15851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return klass; 15951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal} 1601bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers 161d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst RegType& RegTypeCache::From(mirror::ClassLoader* loader, const char* descriptor, 162d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogers bool precise) { 1631ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers // Try looking up the class in the cache first. We use a StringPiece to avoid continual strlen 1641ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers // operations on the descriptor. 1651ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers StringPiece descriptor_sp(descriptor); 1662c6de22d6dcdc6fe1a065480582989e15a47fcb5Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 1671ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers if (MatchDescriptor(i, descriptor_sp, precise)) { 1682c6de22d6dcdc6fe1a065480582989e15a47fcb5Sameer Abu Asal return *(entries_[i]); 1692c6de22d6dcdc6fe1a065480582989e15a47fcb5Sameer Abu Asal } 1702c6de22d6dcdc6fe1a065480582989e15a47fcb5Sameer Abu Asal } 1712c6de22d6dcdc6fe1a065480582989e15a47fcb5Sameer Abu Asal // Class not found in the cache, will create a new type for that. 17251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // Try resolving class. 17351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal mirror::Class* klass = ResolveClass(descriptor, loader); 1747b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers if (klass != nullptr) { 17551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // Class resolved, first look for the class in the list of entries 17651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // Class was not found, must create new type. 1777934ac288acfb2552bb0b06ec1f61e5820d924a4Brian Carlstrom // To pass the verification, the type should be imprecise, 1789f57a86148827b36906eef65857c8be40401fbf4Sameer Abu Asal // instantiable or an interface with the precise type set to false. 17902c42237741b5573f9d790a5a0f17f408dceb543Sameer Abu Asal DCHECK(!precise || klass->IsInstantiable()); 1809f57a86148827b36906eef65857c8be40401fbf4Sameer Abu Asal // Create a precise type if: 1812c6de22d6dcdc6fe1a065480582989e15a47fcb5Sameer Abu Asal // 1- Class is final and NOT an interface. a precise interface is meaningless !! 1829f57a86148827b36906eef65857c8be40401fbf4Sameer Abu Asal // 2- Precise Flag passed as true. 18351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal RegType* entry; 1849f57a86148827b36906eef65857c8be40401fbf4Sameer Abu Asal // Create an imprecise type if we can't tell for a fact that it is precise. 18504f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers if (klass->CannotBeAssignedFromOtherTypes() || precise) { 18602c42237741b5573f9d790a5a0f17f408dceb543Sameer Abu Asal DCHECK(!(klass->IsAbstract()) || klass->IsArrayClass()); 18702c42237741b5573f9d790a5a0f17f408dceb543Sameer Abu Asal DCHECK(!klass->IsInterface()); 1881ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers entry = new PreciseReferenceType(klass, descriptor_sp.as_string(), entries_.size()); 18980537bb742dff4ccdf6d04b1c0bb7d2179acc8cbElliott Hughes } else { 1901ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers entry = new ReferenceType(klass, descriptor_sp.as_string(), entries_.size()); 19180537bb742dff4ccdf6d04b1c0bb7d2179acc8cbElliott Hughes } 192aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe AddEntry(entry); 19351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *entry; 19451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } else { // Class not resolved. 19551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // We tried loading the class and failed, this might get an exception raised 19651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // so we want to clear it before we go on. 197639815628cf52a4a944a4322cb09da37cded2de9Andreas Gampe if (can_load_classes_) { 198639815628cf52a4a944a4322cb09da37cded2de9Andreas Gampe DCHECK(Thread::Current()->IsExceptionPending()); 199639815628cf52a4a944a4322cb09da37cded2de9Andreas Gampe Thread::Current()->ClearException(); 200639815628cf52a4a944a4322cb09da37cded2de9Andreas Gampe } else { 201639815628cf52a4a944a4322cb09da37cded2de9Andreas Gampe DCHECK(!Thread::Current()->IsExceptionPending()); 202639815628cf52a4a944a4322cb09da37cded2de9Andreas Gampe } 2031bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers if (IsValidDescriptor(descriptor)) { 2041ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers RegType* entry = new UnresolvedReferenceType(descriptor_sp.as_string(), entries_.size()); 205aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe AddEntry(entry); 206776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers return *entry; 207776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } else { 20851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // The descriptor is broken return the unknown type as there's nothing sensible that 20951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // could be done at runtime 21051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return Conflict(); 211776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 212776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 213776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers} 2141bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers 215d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst RegType& RegTypeCache::FromClass(const char* descriptor, mirror::Class* klass, bool precise) { 21658a5af8568d224ca7eccf2483396ff9862f8d1eeAndreas Gampe DCHECK(klass != nullptr); 217776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers if (klass->IsPrimitive()) { 21804f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers // Note: precise isn't used for primitive classes. A char is assignable to an int. All 21904f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers // primitive classes are final. 22051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return RegTypeFromPrimitiveType(klass->GetPrimitiveType()); 221776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } else { 22251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // Look for the reference in the list of entries to have. 22351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 2247b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 2255441091dc78c64a683cb336ff27e80c364bc2cd3Ian Rogers if (cur_entry->klass_.Read() == klass && MatchingPrecisionForClass(cur_entry, precise)) { 226776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers return *cur_entry; 227776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 228776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 22951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // No reference to the class was found, create new reference. 23051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal RegType* entry; 23151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal if (precise) { 232637c65b1e431fd90195b71c141b3590bd81cc91aIan Rogers entry = new PreciseReferenceType(klass, descriptor, entries_.size()); 23351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } else { 234637c65b1e431fd90195b71c141b3590bd81cc91aIan Rogers entry = new ReferenceType(klass, descriptor, entries_.size()); 23551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 236aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe AddEntry(entry); 237776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers return *entry; 238776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 239776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers} 240776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers 24112d625f87bcd6c4059a205bb39007a255f57f382Mathieu ChartierRegTypeCache::RegTypeCache(bool can_load_classes) : can_load_classes_(can_load_classes) { 2427b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers if (kIsDebugBuild) { 2437b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers Thread::Current()->AssertThreadSuspensionIsAllowable(gAborting == 0); 244639815628cf52a4a944a4322cb09da37cded2de9Andreas Gampe } 245639815628cf52a4a944a4322cb09da37cded2de9Andreas Gampe entries_.reserve(64); 246639815628cf52a4a944a4322cb09da37cded2de9Andreas Gampe FillPrimitiveAndSmallConstantTypes(); 247639815628cf52a4a944a4322cb09da37cded2de9Andreas Gampe} 248639815628cf52a4a944a4322cb09da37cded2de9Andreas Gampe 24951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu AsalRegTypeCache::~RegTypeCache() { 25051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal CHECK_LE(primitive_count_, entries_.size()); 25151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal // Delete only the non primitive types. 25241c65c19c15ffac41089fa9f37502f94c046960dIan Rogers if (entries_.size() == kNumPrimitivesAndSmallConstants) { 25341c65c19c15ffac41089fa9f37502f94c046960dIan Rogers // All entries are from the global pool, nothing to delete. 25451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return; 25551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 2567b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers std::vector<const RegType*>::iterator non_primitive_begin = entries_.begin(); 25741c65c19c15ffac41089fa9f37502f94c046960dIan Rogers std::advance(non_primitive_begin, kNumPrimitivesAndSmallConstants); 25851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal STLDeleteContainerPointers(non_primitive_begin, entries_.end()); 25951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal} 26051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal 26151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asalvoid RegTypeCache::ShutDown() { 26251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal if (RegTypeCache::primitive_initialized_) { 26351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal UndefinedType::Destroy(); 26451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal ConflictType::Destroy(); 26551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal BooleanType::Destroy(); 26651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal ByteType::Destroy(); 26751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal ShortType::Destroy(); 26851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal CharType::Destroy(); 26951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal IntegerType::Destroy(); 27051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal LongLoType::Destroy(); 27151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal LongHiType::Destroy(); 27225ae7ebfd227869dd12f807047c56177d0bf645bIan Rogers FloatType::Destroy(); 27351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal DoubleLoType::Destroy(); 27451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal DoubleHiType::Destroy(); 275dfe78a6e6b526d482298100a1f6392a8c7105522Ian Rogers for (int32_t value = kMinSmallConstant; value <= kMaxSmallConstant; ++value) { 2767b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const PreciseConstType* type = small_precise_constants_[value - kMinSmallConstant]; 27741c65c19c15ffac41089fa9f37502f94c046960dIan Rogers delete type; 278dfe78a6e6b526d482298100a1f6392a8c7105522Ian Rogers small_precise_constants_[value - kMinSmallConstant] = nullptr; 27941c65c19c15ffac41089fa9f37502f94c046960dIan Rogers } 28062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers RegTypeCache::primitive_initialized_ = false; 28162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers RegTypeCache::primitive_count_ = 0; 28251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 28351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal} 28451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal 28541c65c19c15ffac41089fa9f37502f94c046960dIan Rogerstemplate <class Type> 2867b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogersconst Type* RegTypeCache::CreatePrimitiveTypeInstance(const std::string& descriptor) { 2877b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers mirror::Class* klass = nullptr; 28841c65c19c15ffac41089fa9f37502f94c046960dIan Rogers // Try loading the class from linker. 28941c65c19c15ffac41089fa9f37502f94c046960dIan Rogers if (!descriptor.empty()) { 2909837939678bb5dcba178e5fb00ed59b5d14c8d9bIan Rogers klass = art::Runtime::Current()->GetClassLinker()->FindSystemClass(Thread::Current(), 2919837939678bb5dcba178e5fb00ed59b5d14c8d9bIan Rogers descriptor.c_str()); 29210f0ca2844e82a3319a12246af913e14f93194efLogan Chien DCHECK(klass != nullptr); 29341c65c19c15ffac41089fa9f37502f94c046960dIan Rogers } 2947b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const Type* entry = Type::CreateInstance(klass, descriptor, RegTypeCache::primitive_count_); 29541c65c19c15ffac41089fa9f37502f94c046960dIan Rogers RegTypeCache::primitive_count_++; 29641c65c19c15ffac41089fa9f37502f94c046960dIan Rogers return entry; 29741c65c19c15ffac41089fa9f37502f94c046960dIan Rogers} 29841c65c19c15ffac41089fa9f37502f94c046960dIan Rogers 29941c65c19c15ffac41089fa9f37502f94c046960dIan Rogersvoid RegTypeCache::CreatePrimitiveAndSmallConstantTypes() { 30033e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<UndefinedType>(""); 30133e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<ConflictType>(""); 30233e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<BooleanType>("Z"); 30333e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<ByteType>("B"); 30433e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<ShortType>("S"); 30533e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<CharType>("C"); 30633e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<IntegerType>("I"); 30733e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<LongLoType>("J"); 30833e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<LongHiType>("J"); 30933e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<FloatType>("F"); 31033e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<DoubleLoType>("D"); 31133e9566255c426e7a2c8fca5b8a1b6a94a5d352cIan Rogers CreatePrimitiveTypeInstance<DoubleHiType>("D"); 31241c65c19c15ffac41089fa9f37502f94c046960dIan Rogers for (int32_t value = kMinSmallConstant; value <= kMaxSmallConstant; ++value) { 31341c65c19c15ffac41089fa9f37502f94c046960dIan Rogers PreciseConstType* type = new PreciseConstType(value, primitive_count_); 31441c65c19c15ffac41089fa9f37502f94c046960dIan Rogers small_precise_constants_[value - kMinSmallConstant] = type; 31541c65c19c15ffac41089fa9f37502f94c046960dIan Rogers primitive_count_++; 31641c65c19c15ffac41089fa9f37502f94c046960dIan Rogers } 31751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal} 31851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal 319d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst RegType& RegTypeCache::FromUnresolvedMerge(const RegType& left, const RegType& right) { 320750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe BitVector types(1, // Allocate at least a word. 321750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe true, // Is expandable. 322750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe Allocator::GetMallocAllocator()); // TODO: Arenas in the verifier. 323750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe const RegType* left_resolved; 324529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers if (left.IsUnresolvedMergedReference()) { 325750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe const UnresolvedMergedType* left_merge = down_cast<const UnresolvedMergedType*>(&left); 326750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe types.Copy(&left_merge->GetUnresolvedTypes()); 327750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe left_resolved = &left_merge->GetResolvedPart(); 328b58474e08f6014663d1d3e215f3377d3ae616ad1Andreas Gampe } else if (left.IsUnresolvedTypes()) { 329750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe types.SetBit(left.GetId()); 330750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe left_resolved = &Zero(); 331529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers } else { 332750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe left_resolved = &left; 333529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers } 334750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe 335750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe const RegType* right_resolved; 336529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers if (right.IsUnresolvedMergedReference()) { 337750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe const UnresolvedMergedType* right_merge = down_cast<const UnresolvedMergedType*>(&right); 338750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe types.Union(&right_merge->GetUnresolvedTypes()); 339750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe right_resolved = &right_merge->GetResolvedPart(); 340b58474e08f6014663d1d3e215f3377d3ae616ad1Andreas Gampe } else if (right.IsUnresolvedTypes()) { 341750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe types.SetBit(right.GetId()); 342750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe right_resolved = &Zero(); 343529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers } else { 344750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe right_resolved = &right; 345750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe } 346750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe 347750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe // Merge the resolved parts. Left and right might be equal, so use SafeMerge. 348750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe const RegType& resolved_parts_merged = left_resolved->SafeMerge(*right_resolved, this); 349750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe // If we get a conflict here, the merge result is a conflict, not an unresolved merge type. 350750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe if (resolved_parts_merged.IsConflict()) { 351750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe return Conflict(); 352529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers } 353750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe 354529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers // Check if entry already exists. 35551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 3567b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 357529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers if (cur_entry->IsUnresolvedMergedReference()) { 358750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe const UnresolvedMergedType* cmp_type = down_cast<const UnresolvedMergedType*>(cur_entry); 359750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe const RegType& resolved_part = cmp_type->GetResolvedPart(); 360750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe const BitVector& unresolved_part = cmp_type->GetUnresolvedTypes(); 361750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe // Use SameBitsSet. "types" is expandable to allow merging in the components, but the 362750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe // BitVector in the final RegType will be made non-expandable. 363750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe if (&resolved_part == &resolved_parts_merged && 364750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe types.SameBitsSet(&unresolved_part)) { 365529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers return *cur_entry; 366529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers } 367529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers } 368529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers } 369750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe 370529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers // Create entry. 371750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe RegType* entry = new UnresolvedMergedType(resolved_parts_merged, 372750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe types, 373750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe this, 374750f7c2827318f6d07620f2ef0321218ea4d8670Andreas Gampe entries_.size()); 375aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe AddEntry(entry); 376529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers return *entry; 377529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers} 3781bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers 379d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst RegType& RegTypeCache::FromUnresolvedSuperClass(const RegType& child) { 380529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers // Check if entry already exists. 38151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 3827b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 38351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal if (cur_entry->IsUnresolvedSuperClass()) { 3847b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const UnresolvedSuperClass* tmp_entry = 3857b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers down_cast<const UnresolvedSuperClass*>(cur_entry); 38651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal uint16_t unresolved_super_child_id = 38751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal tmp_entry->GetUnresolvedSuperClassChildId(); 38851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal if (unresolved_super_child_id == child.GetId()) { 38951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *cur_entry; 39051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 39151a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 39251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 39351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal RegType* entry = new UnresolvedSuperClass(child.GetId(), this, entries_.size()); 394aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe AddEntry(entry); 39551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal return *entry; 396529781dad1d4bc5685fd9ebbf04c1369246c2403Ian Rogers} 3971bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers 398d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst UninitializedType& RegTypeCache::Uninitialized(const RegType& type, uint32_t allocation_pc) { 3997b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers UninitializedType* entry = nullptr; 400637c65b1e431fd90195b71c141b3590bd81cc91aIan Rogers const std::string& descriptor(type.GetDescriptor()); 401776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers if (type.IsUnresolvedTypes()) { 40251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 4037b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 404776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers if (cur_entry->IsUnresolvedAndUninitializedReference() && 4057b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers down_cast<const UnresolvedUninitializedRefType*>(cur_entry)->GetAllocationPc() 4067b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers == allocation_pc && 40751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal (cur_entry->GetDescriptor() == descriptor)) { 4087b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers return *down_cast<const UnresolvedUninitializedRefType*>(cur_entry); 409776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 410776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 411637c65b1e431fd90195b71c141b3590bd81cc91aIan Rogers entry = new UnresolvedUninitializedRefType(descriptor, allocation_pc, entries_.size()); 412776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } else { 4132dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers mirror::Class* klass = type.GetClass(); 41451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 4157b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 416776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers if (cur_entry->IsUninitializedReference() && 4177b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers down_cast<const UninitializedReferenceType*>(cur_entry) 41851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal ->GetAllocationPc() == allocation_pc && 419776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers cur_entry->GetClass() == klass) { 4207b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers return *down_cast<const UninitializedReferenceType*>(cur_entry); 421776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 422776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 423637c65b1e431fd90195b71c141b3590bd81cc91aIan Rogers entry = new UninitializedReferenceType(klass, descriptor, allocation_pc, entries_.size()); 424776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 425aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe AddEntry(entry); 426776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers return *entry; 427776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers} 4281bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers 429d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst RegType& RegTypeCache::FromUninitialized(const RegType& uninit_type) { 430776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers RegType* entry; 4319f57a86148827b36906eef65857c8be40401fbf4Sameer Abu Asal 432776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers if (uninit_type.IsUnresolvedTypes()) { 4331bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers const std::string& descriptor(uninit_type.GetDescriptor()); 43451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 4357b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 43651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal if (cur_entry->IsUnresolvedReference() && 43751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal cur_entry->GetDescriptor() == descriptor) { 438776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers return *cur_entry; 439776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 440776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 4411ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers entry = new UnresolvedReferenceType(descriptor, entries_.size()); 442776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } else { 4432dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers mirror::Class* klass = uninit_type.GetClass(); 444df62950e7a32031b82360c407d46a37b94188fbbBrian Carlstrom if (uninit_type.IsUninitializedThisReference() && !klass->IsFinal()) { 44504f94f4f02093fa0fc58007fd5f4ef4c58f8270aIan Rogers // For uninitialized "this reference" look for reference types that are not precise. 4469f57a86148827b36906eef65857c8be40401fbf4Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 4477b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 4489f57a86148827b36906eef65857c8be40401fbf4Sameer Abu Asal if (cur_entry->IsReference() && cur_entry->GetClass() == klass) { 4499f57a86148827b36906eef65857c8be40401fbf4Sameer Abu Asal return *cur_entry; 4509f57a86148827b36906eef65857c8be40401fbf4Sameer Abu Asal } 4519f57a86148827b36906eef65857c8be40401fbf4Sameer Abu Asal } 4521bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers entry = new ReferenceType(klass, "", entries_.size()); 453be2aa44277e5be04d6e3a9b80af9df01e26b73c0Andreas Gampe } else if (!klass->IsPrimitive()) { 45462342ec720069cebe55f45aea2ff8512a17e7d62Ian Rogers // We're uninitialized because of allocation, look or create a precise type as allocations 45562342ec720069cebe55f45aea2ff8512a17e7d62Ian Rogers // may only create objects of that type. 456be2aa44277e5be04d6e3a9b80af9df01e26b73c0Andreas Gampe // Note: we do not check whether the given klass is actually instantiable (besides being 457be2aa44277e5be04d6e3a9b80af9df01e26b73c0Andreas Gampe // primitive), that is, we allow interfaces and abstract classes here. The reasoning is 458be2aa44277e5be04d6e3a9b80af9df01e26b73c0Andreas Gampe // twofold: 459be2aa44277e5be04d6e3a9b80af9df01e26b73c0Andreas Gampe // 1) The "new-instance" instruction to generate the uninitialized type will already 460be2aa44277e5be04d6e3a9b80af9df01e26b73c0Andreas Gampe // queue an instantiation error. This is a soft error that must be thrown at runtime, 461be2aa44277e5be04d6e3a9b80af9df01e26b73c0Andreas Gampe // and could potentially change if the class is resolved differently at runtime. 462be2aa44277e5be04d6e3a9b80af9df01e26b73c0Andreas Gampe // 2) Checking whether the klass is instantiable and using conflict may produce a hard 463be2aa44277e5be04d6e3a9b80af9df01e26b73c0Andreas Gampe // error when the value is used, which leads to a VerifyError, which is not the 464be2aa44277e5be04d6e3a9b80af9df01e26b73c0Andreas Gampe // correct semantics. 46562342ec720069cebe55f45aea2ff8512a17e7d62Ian Rogers for (size_t i = primitive_count_; i < entries_.size(); i++) { 4667b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 46762342ec720069cebe55f45aea2ff8512a17e7d62Ian Rogers if (cur_entry->IsPreciseReference() && cur_entry->GetClass() == klass) { 46862342ec720069cebe55f45aea2ff8512a17e7d62Ian Rogers return *cur_entry; 4699f57a86148827b36906eef65857c8be40401fbf4Sameer Abu Asal } 470776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 47162342ec720069cebe55f45aea2ff8512a17e7d62Ian Rogers entry = new PreciseReferenceType(klass, uninit_type.GetDescriptor(), entries_.size()); 47262342ec720069cebe55f45aea2ff8512a17e7d62Ian Rogers } else { 47362342ec720069cebe55f45aea2ff8512a17e7d62Ian Rogers return Conflict(); 474776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 4756f485c62b9cfce3ab71020c646ab9f48d9d29d6dBrian Carlstrom } 476aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe AddEntry(entry); 477776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers return *entry; 478776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers} 4791bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers 480d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst UninitializedType& RegTypeCache::UninitializedThisArgument(const RegType& type) { 48141c65c19c15ffac41089fa9f37502f94c046960dIan Rogers UninitializedType* entry; 482637c65b1e431fd90195b71c141b3590bd81cc91aIan Rogers const std::string& descriptor(type.GetDescriptor()); 483ad0b3a35857d2cd2db720028ebc51176191e2219Ian Rogers if (type.IsUnresolvedTypes()) { 48451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 4857b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 486ad0b3a35857d2cd2db720028ebc51176191e2219Ian Rogers if (cur_entry->IsUnresolvedAndUninitializedThisReference() && 487ad0b3a35857d2cd2db720028ebc51176191e2219Ian Rogers cur_entry->GetDescriptor() == descriptor) { 4887b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers return *down_cast<const UninitializedType*>(cur_entry); 489ad0b3a35857d2cd2db720028ebc51176191e2219Ian Rogers } 490ad0b3a35857d2cd2db720028ebc51176191e2219Ian Rogers } 4911bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers entry = new UnresolvedUninitializedThisRefType(descriptor, entries_.size()); 492ad0b3a35857d2cd2db720028ebc51176191e2219Ian Rogers } else { 4932dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers mirror::Class* klass = type.GetClass(); 49451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 4957b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 49662342ec720069cebe55f45aea2ff8512a17e7d62Ian Rogers if (cur_entry->IsUninitializedThisReference() && cur_entry->GetClass() == klass) { 4977b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers return *down_cast<const UninitializedType*>(cur_entry); 498ad0b3a35857d2cd2db720028ebc51176191e2219Ian Rogers } 499776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 500637c65b1e431fd90195b71c141b3590bd81cc91aIan Rogers entry = new UninitializedThisReferenceType(klass, descriptor, entries_.size()); 501776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 502aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe AddEntry(entry); 503776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers return *entry; 504776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers} 5051bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers 506d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst ConstantType& RegTypeCache::FromCat1NonSmallConstant(int32_t value, bool precise) { 50751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 5087b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 5095441091dc78c64a683cb336ff27e80c364bc2cd3Ian Rogers if (cur_entry->klass_.IsNull() && cur_entry->IsConstant() && 510637c65b1e431fd90195b71c141b3590bd81cc91aIan Rogers cur_entry->IsPreciseConstant() == precise && 5117b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers (down_cast<const ConstantType*>(cur_entry))->ConstantValue() == value) { 5127b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers return *down_cast<const ConstantType*>(cur_entry); 513776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 514776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 51541c65c19c15ffac41089fa9f37502f94c046960dIan Rogers ConstantType* entry; 51651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal if (precise) { 51751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entry = new PreciseConstType(value, entries_.size()); 51851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } else { 51951a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entry = new ImpreciseConstType(value, entries_.size()); 52051a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 521aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe AddEntry(entry); 5222bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers return *entry; 5232bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers} 5242bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers 525d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst ConstantType& RegTypeCache::FromCat2ConstLo(int32_t value, bool precise) { 52651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 5277b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 52851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal if (cur_entry->IsConstantLo() && (cur_entry->IsPrecise() == precise) && 5297b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers (down_cast<const ConstantType*>(cur_entry))->ConstantValueLo() == value) { 5307b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers return *down_cast<const ConstantType*>(cur_entry); 5312bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers } 5322bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers } 53341c65c19c15ffac41089fa9f37502f94c046960dIan Rogers ConstantType* entry; 53451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal if (precise) { 53551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entry = new PreciseConstLoType(value, entries_.size()); 53651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } else { 53751a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entry = new ImpreciseConstLoType(value, entries_.size()); 53851a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 539aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe AddEntry(entry); 5402bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers return *entry; 5412bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers} 5422bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers 543d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst ConstantType& RegTypeCache::FromCat2ConstHi(int32_t value, bool precise) { 54451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal for (size_t i = primitive_count_; i < entries_.size(); i++) { 5457b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 54651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal if (cur_entry->IsConstantHi() && (cur_entry->IsPrecise() == precise) && 5477b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers (down_cast<const ConstantType*>(cur_entry))->ConstantValueHi() == value) { 5487b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers return *down_cast<const ConstantType*>(cur_entry); 5492bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers } 5502bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers } 55141c65c19c15ffac41089fa9f37502f94c046960dIan Rogers ConstantType* entry; 55251a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal if (precise) { 55351a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entry = new PreciseConstHiType(value, entries_.size()); 55451a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } else { 55551a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal entry = new ImpreciseConstHiType(value, entries_.size()); 55651a5fb78d1b03b5235c2ae45414235282182bb86Sameer Abu Asal } 557aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe AddEntry(entry); 558776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers return *entry; 559776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers} 560776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers 561d8f69b086baf6717ce949d1c4de90d73b91083b0Ian Rogersconst RegType& RegTypeCache::GetComponentType(const RegType& array, mirror::ClassLoader* loader) { 562a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers if (!array.IsArrayTypes()) { 563a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers return Conflict(); 564a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers } else if (array.IsUnresolvedTypes()) { 5651bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers const std::string& descriptor(array.GetDescriptor()); 5661bf8d4dbe5cb9891e8a1125ff1928b544efc243aIan Rogers const std::string component(descriptor.substr(1, descriptor.size() - 1)); 567b49035706fceb2b13e8154668f175af624cf88f4Ian Rogers return FromDescriptor(loader, component.c_str(), false); 568776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } else { 5692dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers mirror::Class* klass = array.GetClass()->GetComponentType(); 5701ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers std::string temp; 571aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe if (klass->IsErroneous()) { 572aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe // Arrays may have erroneous component types, use unresolved in that case. 573aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe // We assume that the primitive classes are not erroneous, so we know it is a 574aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe // reference type. 5751ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers return FromDescriptor(loader, klass->GetDescriptor(&temp), false); 576aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe } else { 5771ff3c98775a4577cf053dba9a0c2d5c21c07b298Ian Rogers return FromClass(klass->GetDescriptor(&temp), klass, 578aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe klass->CannotBeAssignedFromOtherTypes()); 579aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe } 580b49035706fceb2b13e8154668f175af624cf88f4Ian Rogers } 581b49035706fceb2b13e8154668f175af624cf88f4Ian Rogers} 582b49035706fceb2b13e8154668f175af624cf88f4Ian Rogers 583b49035706fceb2b13e8154668f175af624cf88f4Ian Rogersvoid RegTypeCache::Dump(std::ostream& os) { 584b49035706fceb2b13e8154668f175af624cf88f4Ian Rogers for (size_t i = 0; i < entries_.size(); i++) { 5857b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers const RegType* cur_entry = entries_[i]; 5867b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers if (cur_entry != nullptr) { 5872bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers os << i << ": " << cur_entry->Dump() << "\n"; 588b49035706fceb2b13e8154668f175af624cf88f4Ian Rogers } 589776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers } 590776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers} 591776ac1fa61237db645adb4370a4aab888530caf4Ian Rogers 592bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartiervoid RegTypeCache::VisitStaticRoots(RootVisitor* visitor) { 5937c438b19b71932ac8a44eff44f20744a01559c8dMathieu Chartier // Visit the primitive types, this is required since if there are no active verifiers they wont 5947c438b19b71932ac8a44eff44f20744a01559c8dMathieu Chartier // be in the entries array, and therefore not visited as roots. 5957c438b19b71932ac8a44eff44f20744a01559c8dMathieu Chartier if (primitive_initialized_) { 59612d625f87bcd6c4059a205bb39007a255f57f382Mathieu Chartier RootInfo ri(kRootUnknown); 597bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier UndefinedType::GetInstance()->VisitRoots(visitor, ri); 598bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier ConflictType::GetInstance()->VisitRoots(visitor, ri); 599bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier BooleanType::GetInstance()->VisitRoots(visitor, ri); 600bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier ByteType::GetInstance()->VisitRoots(visitor, ri); 601bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier ShortType::GetInstance()->VisitRoots(visitor, ri); 602bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier CharType::GetInstance()->VisitRoots(visitor, ri); 603bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier IntegerType::GetInstance()->VisitRoots(visitor, ri); 604bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier LongLoType::GetInstance()->VisitRoots(visitor, ri); 605bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier LongHiType::GetInstance()->VisitRoots(visitor, ri); 606bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier FloatType::GetInstance()->VisitRoots(visitor, ri); 607bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier DoubleLoType::GetInstance()->VisitRoots(visitor, ri); 608bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier DoubleHiType::GetInstance()->VisitRoots(visitor, ri); 6097c438b19b71932ac8a44eff44f20744a01559c8dMathieu Chartier for (int32_t value = kMinSmallConstant; value <= kMaxSmallConstant; ++value) { 610bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier small_precise_constants_[value - kMinSmallConstant]->VisitRoots(visitor, ri); 6117c438b19b71932ac8a44eff44f20744a01559c8dMathieu Chartier } 6127c438b19b71932ac8a44eff44f20744a01559c8dMathieu Chartier } 6137c438b19b71932ac8a44eff44f20744a01559c8dMathieu Chartier} 6147c438b19b71932ac8a44eff44f20744a01559c8dMathieu Chartier 615bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartiervoid RegTypeCache::VisitRoots(RootVisitor* visitor, const RootInfo& root_info) { 6163e781622a67e6d83e76e1bf765e9d84b3c718dc9Hiroshi Yamauchi // Exclude the static roots that are visited by VisitStaticRoots(). 6173e781622a67e6d83e76e1bf765e9d84b3c718dc9Hiroshi Yamauchi for (size_t i = primitive_count_; i < entries_.size(); ++i) { 618bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier entries_[i]->VisitRoots(visitor, root_info); 619c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier } 620c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier} 621c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier 622aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampevoid RegTypeCache::AddEntry(RegType* new_entry) { 623aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe entries_.push_back(new_entry); 624aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe} 625aa910d5ef43256102809e397de305c23f1c315e6Andreas Gampe 626a21039c3ae2b20e44ceb2735251c04d0aac89afdElliott Hughes} // namespace verifier 627a21039c3ae2b20e44ceb2735251c04d0aac89afdElliott Hughes} // namespace art 628