NativePcOffsetToReferenceMap
Rather than translate a native PC to a Dex PC and then to the reference
bitmap, just go straight from the native PC to the reference bitmap.
Encode the native PC offsets using a hash rather than linearly
searching.
Change-Id: Iee1073d93c941c0a31f639e5f23cea9e9f747bee
diff --git a/src/object.cc b/src/object.cc
index bac3ec1..f2043b1 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -450,8 +450,7 @@
return result;
}
-static const void* GetOatCode(const Method* m)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+static const void* GetOatCode(const Method* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Runtime* runtime = Runtime::Current();
const void* code = m->GetCode();
// Peel off any method tracing trampoline.
@@ -465,7 +464,11 @@
return code;
}
-uint32_t Method::ToDexPC(const uintptr_t pc) const {
+uintptr_t Method::NativePcOffset(const uintptr_t pc) const {
+ return pc - reinterpret_cast<uintptr_t>(GetOatCode(this));
+}
+
+uint32_t Method::ToDexPc(const uintptr_t pc) const {
#if !defined(ART_USE_LLVM_COMPILER)
const uint32_t* mapping_table = GetMappingTable();
if (mapping_table == NULL) {
@@ -488,7 +491,7 @@
#endif
}
-uintptr_t Method::ToNativePC(const uint32_t dex_pc) const {
+uintptr_t Method::ToNativePc(const uint32_t dex_pc) const {
const uint32_t* mapping_table = GetMappingTable();
if (mapping_table == NULL) {
DCHECK_EQ(dex_pc, 0U);
@@ -600,7 +603,7 @@
#else
UNIMPLEMENTED(FATAL);
#endif
- SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(Method, gc_map_),
+ SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(Method, native_gc_map_),
reinterpret_cast<const uint8_t*>(native_method), false);
}
#endif