1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "reference_type_info.h" 18 19 #include "scoped_thread_state_change-inl.h" 20 #include "thread-current-inl.h" 21 22 namespace art HIDDEN { 23 DCheckValidTypeInfo(TypeHandle type_handle,bool is_exact)24void ReferenceTypeInfo::DCheckValidTypeInfo(TypeHandle type_handle, bool is_exact) { 25 if (kIsDebugBuild) { 26 ScopedObjectAccess soa(Thread::Current()); 27 CHECK(IsValidHandle(type_handle)); 28 if (!is_exact) { 29 CHECK(!type_handle->CannotBeAssignedFromOtherTypes()) 30 << "Callers of ReferenceTypeInfo::Create should ensure is_exact is properly computed"; 31 } 32 } 33 } 34 operator <<(std::ostream & os,const ReferenceTypeInfo & rhs)35std::ostream& operator<<(std::ostream& os, const ReferenceTypeInfo& rhs) { 36 ScopedObjectAccess soa(Thread::Current()); 37 os << "[" 38 << " is_valid=" << rhs.IsValid() 39 << " type=" << (!rhs.IsValid() ? "?" : mirror::Class::PrettyClass(rhs.GetTypeHandle().Get())) 40 << " is_exact=" << rhs.IsExact() 41 << " ]"; 42 return os; 43 } 44 45 } // namespace art 46