diff options
-rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 3 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 3 | ||||
-rw-r--r-- | runtime/arch/x86/thread_x86.cc | 3 | ||||
-rw-r--r-- | runtime/debugger.cc | 2 | ||||
-rw-r--r-- | runtime/mirror/class-inl.h | 6 | ||||
-rw-r--r-- | runtime/mirror/object_array-inl.h | 6 | ||||
-rw-r--r-- | runtime/thread.cc | 3 |
7 files changed, 17 insertions, 9 deletions
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index f6ae45238c..bb5debba29 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -3370,7 +3370,8 @@ void InstructionCodeGeneratorARM::VisitArrayGet(HArrayGet* instruction) { case Primitive::kPrimInt: case Primitive::kPrimNot: { - DCHECK_EQ(sizeof(mirror::HeapReference<mirror::Object>), sizeof(int32_t)); + static_assert(sizeof(mirror::HeapReference<mirror::Object>) == sizeof(int32_t), + "art::mirror::HeapReference<mirror::Object> and int32_t have different sizes."); uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value(); Register out = locations->Out().AsRegister<Register>(); if (index.IsConstant()) { diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index bfc827de1c..4da5bc4e51 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -3503,7 +3503,8 @@ void InstructionCodeGeneratorX86_64::VisitArrayGet(HArrayGet* instruction) { case Primitive::kPrimInt: case Primitive::kPrimNot: { - DCHECK_EQ(sizeof(mirror::HeapReference<mirror::Object>), sizeof(int32_t)); + static_assert(sizeof(mirror::HeapReference<mirror::Object>) == sizeof(int32_t), + "art::mirror::HeapReference<mirror::Object> and int32_t have different sizes."); uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value(); CpuRegister out = locations->Out().AsRegister<CpuRegister>(); if (index.IsConstant()) { diff --git a/runtime/arch/x86/thread_x86.cc b/runtime/arch/x86/thread_x86.cc index b97c143914..3d19f06092 100644 --- a/runtime/arch/x86/thread_x86.cc +++ b/runtime/arch/x86/thread_x86.cc @@ -79,7 +79,8 @@ void Thread::InitCpu() { } #else // Read current LDT entries. - CHECK_EQ((size_t)LDT_ENTRY_SIZE, sizeof(uint64_t)); + static_assert(static_cast<size_t>(LDT_ENTRY_SIZE) == sizeof(uint64_t), + "LDT_ENTRY_SIZE is different from sizeof(uint64_t)."); std::vector<uint64_t> ldt(LDT_ENTRIES); size_t ldt_size(sizeof(uint64_t) * ldt.size()); memset(&ldt[0], 0, ldt_size); diff --git a/runtime/debugger.cc b/runtime/debugger.cc index 5918c10515..f84e10c628 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -3942,7 +3942,7 @@ void Dbg::ExecuteMethodWithoutPendingException(ScopedObjectAccess& soa, DebugInv << " arg_count=" << pReq->arg_count; CHECK(m != nullptr); - CHECK_EQ(sizeof(jvalue), sizeof(uint64_t)); + static_assert(sizeof(jvalue) == sizeof(uint64_t), "jvalue and uint64_t have different sizes."); // Invoke the method. ScopedLocalRef<jobject> ref(soa.Env(), soa.AddLocalReference<jobject>(pReq->receiver.Read())); diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 8c9222f6a4..122cc6b738 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -552,7 +552,8 @@ inline void Class::SetName(String* name) { template<VerifyObjectFlags kVerifyFlags> inline Primitive::Type Class::GetPrimitiveType() { - DCHECK_EQ(sizeof(Primitive::Type), sizeof(int32_t)); + static_assert(sizeof(Primitive::Type) == sizeof(int32_t), + "art::Primitive::Type and int32_t have different sizes."); int32_t v32 = GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, primitive_type_)); Primitive::Type type = static_cast<Primitive::Type>(v32 & 0xFFFF); DCHECK_EQ(static_cast<size_t>(v32 >> 16), Primitive::ComponentSizeShift(type)); @@ -561,7 +562,8 @@ inline Primitive::Type Class::GetPrimitiveType() { template<VerifyObjectFlags kVerifyFlags> inline size_t Class::GetPrimitiveTypeSizeShift() { - DCHECK_EQ(sizeof(Primitive::Type), sizeof(int32_t)); + static_assert(sizeof(Primitive::Type) == sizeof(int32_t), + "art::Primitive::Type and int32_t have different sizes."); int32_t v32 = GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, primitive_type_)); size_t size_shift = static_cast<Primitive::Type>(v32 >> 16); DCHECK_EQ(size_shift, Primitive::ComponentSizeShift(static_cast<Primitive::Type>(v32 & 0xFFFF))); diff --git a/runtime/mirror/object_array-inl.h b/runtime/mirror/object_array-inl.h index bef4af617a..4a7e7b35da 100644 --- a/runtime/mirror/object_array-inl.h +++ b/runtime/mirror/object_array-inl.h @@ -129,7 +129,8 @@ inline void ObjectArray<T>::AssignableMemmove(int32_t dst_pos, ObjectArray<T>* s } } // Perform the memmove using int memmove then perform the write barrier. - CHECK_EQ(sizeof(HeapReference<T>), sizeof(uint32_t)); + static_assert(sizeof(HeapReference<T>) == sizeof(uint32_t), + "art::mirror::HeapReference<T> and uint32_t have different sizes."); IntArray* dstAsIntArray = reinterpret_cast<IntArray*>(this); IntArray* srcAsIntArray = reinterpret_cast<IntArray*>(src); if (kUseReadBarrier) { @@ -172,7 +173,8 @@ inline void ObjectArray<T>::AssignableMemcpy(int32_t dst_pos, ObjectArray<T>* sr } } // Perform the memmove using int memcpy then perform the write barrier. - CHECK_EQ(sizeof(HeapReference<T>), sizeof(uint32_t)); + static_assert(sizeof(HeapReference<T>) == sizeof(uint32_t), + "art::mirror::HeapReference<T> and uint32_t have different sizes."); IntArray* dstAsIntArray = reinterpret_cast<IntArray*>(this); IntArray* srcAsIntArray = reinterpret_cast<IntArray*>(src); if (kUseReadBarrier) { diff --git a/runtime/thread.cc b/runtime/thread.cc index fe8b0d8c60..348d68586a 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -1277,7 +1277,8 @@ Thread::Thread(bool daemon) : tls32_(daemon), wait_monitor_(nullptr), interrupte tlsPtr_.name = new std::string(kThreadNameDuringStartup); tlsPtr_.nested_signal_state = static_cast<jmp_buf*>(malloc(sizeof(jmp_buf))); - CHECK_EQ((sizeof(Thread) % 4), 0U) << sizeof(Thread); + static_assert((sizeof(Thread) % 4) == 0U, + "art::Thread has a size which is not a multiple of 4."); tls32_.state_and_flags.as_struct.flags = 0; tls32_.state_and_flags.as_struct.state = kNative; memset(&tlsPtr_.held_mutexes[0], 0, sizeof(tlsPtr_.held_mutexes)); |