summaryrefslogtreecommitdiff
path: root/runtime/stack_map.h
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2016-02-05 17:25:17 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-02-05 17:25:17 +0000
commit9fba3f67a0792ad5eeb495e489d11a87211c318f (patch)
tree7204ab0951b14fa2536fe33d974e413a3cbe87a5 /runtime/stack_map.h
parent0f638c64686c03256c949051331b0838c9888a2a (diff)
parentb331febbab8e916680faba722cc84b66b84218a3 (diff)
Merge "Revert "Revert "Implement on-stack replacement for arm/arm64/x86/x86_64."""
Diffstat (limited to 'runtime/stack_map.h')
-rw-r--r--runtime/stack_map.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index 84185ce49f..97eb805501 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -1195,6 +1195,35 @@ class CodeInfo {
return StackMap();
}
+ StackMap GetOsrStackMapForDexPc(uint32_t dex_pc, const StackMapEncoding& encoding) const {
+ size_t e = GetNumberOfStackMaps();
+ if (e == 0) {
+ // There cannot be OSR stack map if there is no stack map.
+ return StackMap();
+ }
+ // Walk over all stack maps. If two consecutive stack maps are identical, then we
+ // have found a stack map suitable for OSR.
+ for (size_t i = 0; i < e - 1; ++i) {
+ StackMap stack_map = GetStackMapAt(i, encoding);
+ if (stack_map.GetDexPc(encoding) == dex_pc) {
+ StackMap other = GetStackMapAt(i + 1, encoding);
+ if (other.GetDexPc(encoding) == dex_pc &&
+ other.GetNativePcOffset(encoding) == stack_map.GetNativePcOffset(encoding)) {
+ DCHECK_EQ(other.GetDexRegisterMapOffset(encoding),
+ stack_map.GetDexRegisterMapOffset(encoding));
+ DCHECK(!stack_map.HasInlineInfo(encoding));
+ if (i < e - 2) {
+ // Make sure there are not three identical stack maps following each other.
+ DCHECK_NE(stack_map.GetNativePcOffset(encoding),
+ GetStackMapAt(i + 2, encoding).GetNativePcOffset(encoding));
+ }
+ return stack_map;
+ }
+ }
+ }
+ return StackMap();
+ }
+
StackMap GetStackMapForNativePcOffset(uint32_t native_pc_offset,
const StackMapEncoding& encoding) const {
// TODO: Safepoint stack maps are sorted by native_pc_offset but catch stack