Add code item accessor helper classes
Add classes to abstract accesses to code item data. These classes
handle both standard dex and compact dex.
Added:
- CodeItemInstructionsAccessor to handle code item instructions.
- CodeItemDataAccessor to handle code item data excluding debug info.
Moved inline_method_analyzer to use the new classes to test the new
APIs.
Bug: 63756964
Test: test-art-host
Change-Id: I9926acb77b81fa64ed4a3b49b7bed1aab30a0f33
diff --git a/runtime/art_method.h b/runtime/art_method.h
index 8927481..df9b3aa 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -22,8 +22,10 @@
#include "base/bit_utils.h"
#include "base/casts.h"
#include "base/enums.h"
+#include "base/iteration_range.h"
#include "base/logging.h"
#include "dex_file.h"
+#include "dex_instruction_iterator.h"
#include "gc_root.h"
#include "modifiers.h"
#include "obj_ptr.h"
@@ -700,6 +702,15 @@
"ptr_sized_fields_.entry_point_from_quick_compiled_code_");
}
+ // Returns the dex instructions of the code item for the art method. Must not be called on null
+ // code items.
+ ALWAYS_INLINE IterationRange<DexInstructionIterator> DexInstructions()
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
+ // Handles a null code item by returning iterators that have a null address.
+ ALWAYS_INLINE IterationRange<DexInstructionIterator> NullableDexInstructions()
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
protected:
// Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
// The class we are a part of.