ART: Profile all branches for on-stack replacement
Change the switch, goto and mterp interpreters to profile
not-taken as well as taken branches. This allows for on-stack
replacement when the cfg has been rearranged such that the loop
header was originally the fallthrough of a Dalvik byte-code branch.
Note that this increases the already-heavy cost of branch profiling.
Measuring on a Nexus 6 using a very branchy benchmark (logic subtest
from Caffeinemark), we see:
No profiling Taken only Taken & not-taken
mterp 9728 3434 2384
C++ goto 3914 2422 2037
C++ switch 2986 2411 2112
As measured, the cost of branch profiling is dominating execution
time. This will be addressed in follow-up CLs.
Change-Id: Ibc858f317398dd991ed8e4f3c3d72bd4c9a60594
diff --git a/runtime/interpreter/interpreter_goto_table_impl.cc b/runtime/interpreter/interpreter_goto_table_impl.cc
index ca8598e..12d6fdc 100644
--- a/runtime/interpreter/interpreter_goto_table_impl.cc
+++ b/runtime/interpreter/interpreter_goto_table_impl.cc
@@ -792,6 +792,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}
@@ -810,6 +811,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}
@@ -828,6 +830,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}
@@ -846,6 +849,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}
@@ -864,6 +868,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}
@@ -882,6 +887,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}
@@ -899,6 +905,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}
@@ -916,6 +923,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}
@@ -933,6 +941,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}
@@ -950,6 +959,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}
@@ -967,6 +977,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}
@@ -984,6 +995,7 @@
}
ADVANCE(offset);
} else {
+ BRANCH_INSTRUMENTATION(2);
ADVANCE(2);
}
}