summaryrefslogtreecommitdiffstats
path: root/runtime/quick_exception_handler.h
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2014-08-13 11:12:22 -0700
committerHiroshi Yamauchi <yamauchi@google.com>2014-08-13 20:46:10 -0700
commit649278cec7119cdd1bea3d0b710dbb2aa7c650b6 (patch)
tree6b5e08abee97e8af1ee5635488e6476d3fb3dc15 /runtime/quick_exception_handler.h
parent99c251bbd225dd97d0deece29559a430b12a0b66 (diff)
downloadart-649278cec7119cdd1bea3d0b710dbb2aa7c650b6.tar.gz
art-649278cec7119cdd1bea3d0b710dbb2aa7c650b6.tar.bz2
art-649278cec7119cdd1bea3d0b710dbb2aa7c650b6.zip
More efficient stack walk in exception throwing.
In the exception handling code, we currently walk down the stack twice, once to get the stack height which we use to compute frame IDs (the bottom frame is zero), and once more to find the catch block to jump to. For a deep stack, this could result in very slow exception handling. That is, if have a lot of finally or catch blocks that we end up jumping to in a deep stack, we need to do a lot of catch/rethrow chains. Since we'd need to walk down to the bottom each time to compute frames IDs in each catch/rethrow, we'd need to walk down O(N^2) frames at the worst case. Instead of frames IDs ((the bottom frame is zero), we will use the frame depth (the top frame is zero) and no longer need to walk down the stack just to get the stack height. We walk down O(N) frames. This was what was happening with code.google.gson.functional.CircularReferenceTest. With this change, the test run time went from ~120s down to ~3s on N5 and it no longer crashes due to the thread suspension timeout. Bug: 16800209 Change-Id: Ie815df1e3e8fb9d82e40685d4cc2b8838fd8aa07
Diffstat (limited to 'runtime/quick_exception_handler.h')
-rw-r--r--runtime/quick_exception_handler.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/runtime/quick_exception_handler.h b/runtime/quick_exception_handler.h
index 1d600ed697..b93769cb97 100644
--- a/runtime/quick_exception_handler.h
+++ b/runtime/quick_exception_handler.h
@@ -77,8 +77,8 @@ class QuickExceptionHandler {
clear_exception_ = clear_exception;
}
- void SetHandlerFrameId(size_t frame_id) {
- handler_frame_id_ = frame_id;
+ void SetHandlerFrameDepth(size_t frame_depth) {
+ handler_frame_depth_ = frame_depth;
}
private:
@@ -97,8 +97,8 @@ class QuickExceptionHandler {
uint32_t handler_dex_pc_;
// Should the exception be cleared as the catch block has no move-exception?
bool clear_exception_;
- // Frame id of the catch handler or the upcall.
- size_t handler_frame_id_;
+ // Frame depth of the catch handler or the upcall.
+ size_t handler_frame_depth_;
DISALLOW_COPY_AND_ASSIGN(QuickExceptionHandler);
};