ART: Avoid some tidy nullptr warnings
Sprinkle some (D)CHECKs to tell tidy our expectations.
Bug: 32619234
Test: m test-art-host
Change-Id: I315b1602b20475402dd8383e1accc49e5a63eb5c
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc
index d8e442c..c2e83cd 100644
--- a/compiler/optimizing/code_generator.cc
+++ b/compiler/optimizing/code_generator.cc
@@ -1126,6 +1126,7 @@
if (osr) {
DCHECK_EQ(info->GetSuspendCheck(), instruction);
DCHECK(info->IsIrreducible());
+ DCHECK(environment != nullptr);
if (kIsDebugBuild) {
for (size_t i = 0, environment_size = environment->Size(); i < environment_size; ++i) {
HInstruction* in_environment = environment->GetInstructionAt(i);
diff --git a/runtime/gc/collector/semi_space.cc b/runtime/gc/collector/semi_space.cc
index 19b1fc7..15e0711 100644
--- a/runtime/gc/collector/semi_space.cc
+++ b/runtime/gc/collector/semi_space.cc
@@ -736,7 +736,8 @@
void SemiSpace::ProcessMarkStack() {
TimingLogger::ScopedTiming t(__FUNCTION__, GetTimings());
accounting::ContinuousSpaceBitmap* live_bitmap = nullptr;
- if (collect_from_space_only_) {
+ const bool collect_from_space_only = collect_from_space_only_;
+ if (collect_from_space_only) {
// If a bump pointer space only collection (and the promotion is
// enabled,) we delay the live-bitmap marking of promoted objects
// from MarkObject() until this function.
@@ -748,7 +749,7 @@
}
while (!mark_stack_->IsEmpty()) {
Object* obj = mark_stack_->PopBack();
- if (collect_from_space_only_ && promo_dest_space_->HasAddress(obj)) {
+ if (collect_from_space_only && promo_dest_space_->HasAddress(obj)) {
// obj has just been promoted. Mark the live bitmap for it,
// which is delayed from MarkObject().
DCHECK(!live_bitmap->Test(obj));
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index af87637..c1ccd33 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -33,6 +33,7 @@
#include "android/dlext.h"
#endif
+#include <android-base/logging.h>
#include "android-base/stringprintf.h"
#include "art_method.h"
@@ -467,6 +468,7 @@
}
prev_entry = &entry;
}
+ CHECK(prev_entry != nullptr);
CHECK_LT(prev_entry->GetIndex(index_bits), number_of_indexes);
}
}
@@ -1755,11 +1757,15 @@
}
}
-OatDexFile::OatDexFile(TypeLookupTable&& lookup_table) : lookup_table_(std::move(lookup_table)) {}
+OatDexFile::OatDexFile(TypeLookupTable&& lookup_table) : lookup_table_(std::move(lookup_table)) {
+ // Stripped-down OatDexFile only allowed in the compiler.
+ CHECK(Runtime::Current() == nullptr || Runtime::Current()->IsAotCompiler());
+}
OatDexFile::~OatDexFile() {}
size_t OatDexFile::FileSize() const {
+ DCHECK(dex_file_pointer_ != nullptr);
return reinterpret_cast<const DexFile::Header*>(dex_file_pointer_)->file_size_;
}
@@ -1779,6 +1785,7 @@
}
uint32_t OatDexFile::GetOatClassOffset(uint16_t class_def_index) const {
+ DCHECK(oat_class_offsets_pointer_ != nullptr);
return oat_class_offsets_pointer_[class_def_index];
}