diff options
Diffstat (limited to 'runtime/stack_map.h')
-rw-r--r-- | runtime/stack_map.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/runtime/stack_map.h b/runtime/stack_map.h index 07b79b5530..a15a08180e 100644 --- a/runtime/stack_map.h +++ b/runtime/stack_map.h @@ -1115,7 +1115,7 @@ class CodeInfo { region_.StoreUnaligned<NumberOfStackMapsType>(kNumberOfStackMapsOffset, number_of_stack_maps); } - // Get the size all the stack maps of this CodeInfo object, in bytes. + // Get the size of all the stack maps of this CodeInfo object, in bytes. size_t GetStackMapsSize(const StackMapEncoding& encoding) const { return encoding.ComputeStackMapSize() * GetNumberOfStackMaps(); } @@ -1174,9 +1174,23 @@ class CodeInfo { return StackMap(); } + // Searches the stack map list backwards because catch stack maps are stored + // at the end. + StackMap GetCatchStackMapForDexPc(uint32_t dex_pc, const StackMapEncoding& encoding) const { + for (size_t i = GetNumberOfStackMaps(); i > 0; --i) { + StackMap stack_map = GetStackMapAt(i - 1, encoding); + if (stack_map.GetDexPc(encoding) == dex_pc) { + return stack_map; + } + } + return StackMap(); + } + StackMap GetStackMapForNativePcOffset(uint32_t native_pc_offset, const StackMapEncoding& encoding) const { - // TODO: stack maps are sorted by native pc, we can do a binary search. + // TODO: Safepoint stack maps are sorted by native_pc_offset but catch stack + // maps are not. If we knew that the method does not have try/catch, + // we could do binary search. for (size_t i = 0, e = GetNumberOfStackMaps(); i < e; ++i) { StackMap stack_map = GetStackMapAt(i, encoding); if (stack_map.GetNativePcOffset(encoding) == native_pc_offset) { |