Introduce the notion of an nterp frame.

See comments in nterp_helpers.cc. An nterp frame follows the
calling conventions and exception handling of the compiler. There are
no ManagedStack transitions, and the compiler and interpreter can
just call each other directly.

For the stack walker, an nterp frame looks like a compiled frame.

This CL introduces an nterp frame, another CL will contain an
implementation for x64.

Bug: 119800099
Test: test.py
Change-Id: Ie9b691f58908b7f283b4cd63b84b651526155d27
diff --git a/runtime/stack.cc b/runtime/stack.cc
index e69bc1e..410e0fd 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -38,6 +38,7 @@
 #include "mirror/class-inl.h"
 #include "mirror/object-inl.h"
 #include "mirror/object_array-inl.h"
+#include "nterp_helpers.h"
 #include "oat_quick_method_header.h"
 #include "obj_ptr-inl.h"
 #include "quick/quick_method_frame_info.h"
@@ -122,13 +123,16 @@
       return current_inline_frames_.back().GetDexPc();
     } else if (cur_oat_quick_method_header_ == nullptr) {
       return dex::kDexNoIndex;
-    } else if (!(*GetCurrentQuickFrame())->IsNative()) {
+    } else if ((*GetCurrentQuickFrame())->IsNative()) {
+      return cur_oat_quick_method_header_->ToDexPc(
+          GetCurrentQuickFrame(), cur_quick_frame_pc_, abort_on_failure);
+    } else if (cur_oat_quick_method_header_->IsOptimized()) {
       StackMap* stack_map = GetCurrentStackMap();
       DCHECK(stack_map->IsValid());
       return stack_map->GetDexPc();
     } else {
-      return cur_oat_quick_method_header_->ToDexPc(
-          GetCurrentQuickFrame(), cur_quick_frame_pc_, abort_on_failure);
+      DCHECK(cur_oat_quick_method_header_->IsNterpMethodHeader());
+      return NterpGetDexPC(cur_quick_frame_);
     }
   } else {
     return 0;
@@ -214,6 +218,10 @@
     if (GetVRegFromDebuggerShadowFrame(vreg, kind, val)) {
       return true;
     }
+    if (cur_oat_quick_method_header_->IsNterpMethodHeader()) {
+      *val = NterpGetVReg(cur_quick_frame_, vreg);
+      return true;
+    }
     DCHECK(cur_oat_quick_method_header_->IsOptimized());
     if (location.has_value() && kind != kReferenceVReg) {
       uint32_t val2 = *val;
@@ -772,7 +780,12 @@
 
 QuickMethodFrameInfo StackVisitor::GetCurrentQuickFrameInfo() const {
   if (cur_oat_quick_method_header_ != nullptr) {
-    return cur_oat_quick_method_header_->GetFrameInfo();
+    if (cur_oat_quick_method_header_->IsOptimized()) {
+      return cur_oat_quick_method_header_->GetFrameInfo();
+    } else {
+      DCHECK(cur_oat_quick_method_header_->IsNterpMethodHeader());
+      return NterpFrameInfo(cur_quick_frame_);
+    }
   }
 
   ArtMethod* method = GetMethod();