Make CodeItem fields private
Make code item fields private and use accessors. Added a hand full of
friend classes to reduce the size of the change.
Changed default to be nullable and removed CreateNullable.
CreateNullable was a bad API since it defaulted to the unsafe, may
add a CreateNonNullable if it's important for performance.
Motivation:
Have a different layout for code items in cdex.
Bug: 63756964
Test: test-art-host-gtest
Test: test/testrunner/testrunner.py --host
Test: art/tools/run-jdwp-tests.sh '--mode=host' '--variant=X32' --debug
Change-Id: I42bc7435e20358682075cb6de52713b595f95bf9
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index cfef9c7..542692f 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -1377,9 +1377,9 @@
}
// Is there any reason to believe there's any synchronization in this method?
- const DexFile::CodeItem* code_item = m->GetCodeItem();
- CHECK(code_item != nullptr) << m->PrettyMethod();
- if (code_item->tries_size_ == 0) {
+ CHECK(m->GetCodeItem() != nullptr) << m->PrettyMethod();
+ CodeItemDataAccessor accessor(m);
+ if (accessor.TriesSize() == 0) {
return; // No "tries" implies no synchronization, so no held locks to report.
}
@@ -1399,11 +1399,10 @@
for (verifier::MethodVerifier::DexLockInfo& dex_lock_info : monitor_enter_dex_pcs) {
// As a debug check, check that dex PC corresponds to a monitor-enter.
if (kIsDebugBuild) {
- const Instruction* monitor_enter_instruction =
- Instruction::At(&code_item->insns_[dex_lock_info.dex_pc]);
- CHECK_EQ(monitor_enter_instruction->Opcode(), Instruction::MONITOR_ENTER)
+ const Instruction& monitor_enter_instruction = accessor.InstructionAt(dex_lock_info.dex_pc);
+ CHECK_EQ(monitor_enter_instruction.Opcode(), Instruction::MONITOR_ENTER)
<< "expected monitor-enter @" << dex_lock_info.dex_pc << "; was "
- << reinterpret_cast<const void*>(monitor_enter_instruction);
+ << reinterpret_cast<const void*>(&monitor_enter_instruction);
}
// Iterate through the set of dex registers, as the compiler may not have held all of them