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
diff --git a/runtime/quick_exception_handler.h b/runtime/quick_exception_handler.h
index 1d600ed..b93769c 100644
--- a/runtime/quick_exception_handler.h
+++ b/runtime/quick_exception_handler.h
@@ -77,8 +77,8 @@
     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 @@
   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);
 };