Cleanup instrumentation_levels and instrumentation_stubs_installed

We had instrumentation_levels and instrumentation_stubs_installed which
were kind of similar but slightly different in what they actually
represent. Their meaning also changed with the recent changes to avoid
instrumentation stubs. They were used sometimes incorrectly in the code.
This CL:
1. Renames instrumentation_stubs_installed to run_exit_hooks
2. Renames the instrumentation level to not refer instrumentation stubs
3. Fixes a few places that should have checked for the instrumentation
   level but checked for instrumention_stubs_installed.

Bug: 206029744
Test: art/test.py
Change-Id: I20a6e9442661a6465c92321904c846d35ebb1e53
diff --git a/compiler/jni/quick/jni_compiler.cc b/compiler/jni/quick/jni_compiler.cc
index c485a00..58d11ae 100644
--- a/compiler/jni/quick/jni_compiler.cc
+++ b/compiler/jni/quick/jni_compiler.cc
@@ -570,7 +570,7 @@
   std::unique_ptr<JNIMacroLabel> method_exit_hook_return;
   if (UNLIKELY(needs_entry_exit_hooks)) {
     uint64_t address = reinterpret_cast64<uint64_t>(Runtime::Current()->GetInstrumentation());
-    int offset = instrumentation::Instrumentation::NeedsExitHooksOffset().Int32Value();
+    int offset = instrumentation::Instrumentation::RunExitHooksOffset().Int32Value();
     method_exit_hook_slow_path = __ CreateLabel();
     method_exit_hook_return = __ CreateLabel();
     __ TestByteAndJumpIfNotZero(address + offset, method_exit_hook_slow_path.get());
diff --git a/runtime/arch/arm/quick_entrypoints_arm.S b/runtime/arch/arm/quick_entrypoints_arm.S
index 1709c95..8f5d88a 100644
--- a/runtime/arch/arm/quick_entrypoints_arm.S
+++ b/runtime/arch/arm/quick_entrypoints_arm.S
@@ -1530,7 +1530,7 @@
     vmov d0, r0, r1
 
     LOAD_RUNTIME_INSTANCE r2
-    ldr r2, [r2,  #INSTRUMENTATION_STUBS_INSTALLED_OFFSET_FROM_RUNTIME_INSTANCE]
+    ldr r2, [r2,  #RUN_EXIT_HOOKS_OFFSET_FROM_RUNTIME_INSTANCE]
     cbnz r2, .Lcall_method_exit_hook
 .Lcall_method_exit_hook_done:
 
diff --git a/runtime/arch/arm64/quick_entrypoints_arm64.S b/runtime/arch/arm64/quick_entrypoints_arm64.S
index 9f86a76..af79868 100644
--- a/runtime/arch/arm64/quick_entrypoints_arm64.S
+++ b/runtime/arch/arm64/quick_entrypoints_arm64.S
@@ -1901,7 +1901,7 @@
     .cfi_def_cfa_register sp
 
     LOAD_RUNTIME_INSTANCE x1
-    ldrb w1, [x1, #INSTRUMENTATION_STUBS_INSTALLED_OFFSET_FROM_RUNTIME_INSTANCE]
+    ldrb w1, [x1, #RUN_EXIT_HOOKS_OFFSET_FROM_RUNTIME_INSTANCE]
     cbnz w1, .Lcall_method_exit_hook
 .Lcall_method_exit_hook_done:
 
diff --git a/runtime/arch/x86/quick_entrypoints_x86.S b/runtime/arch/x86/quick_entrypoints_x86.S
index 479f46d..dcf81d5 100644
--- a/runtime/arch/x86/quick_entrypoints_x86.S
+++ b/runtime/arch/x86/quick_entrypoints_x86.S
@@ -1719,7 +1719,7 @@
     punpckldq %xmm1, %xmm0
 
     LOAD_RUNTIME_INSTANCE ebx
-    cmpb MACRO_LITERAL(0), INSTRUMENTATION_STUBS_INSTALLED_OFFSET_FROM_RUNTIME_INSTANCE(%ebx)
+    cmpb MACRO_LITERAL(0), RUN_EXIT_HOOKS_OFFSET_FROM_RUNTIME_INSTANCE(%ebx)
     jne .Lcall_method_exit_hook
 .Lcall_method_exit_hook_done:
 
diff --git a/runtime/arch/x86_64/quick_entrypoints_x86_64.S b/runtime/arch/x86_64/quick_entrypoints_x86_64.S
index 5a568d3..3703cad 100644
--- a/runtime/arch/x86_64/quick_entrypoints_x86_64.S
+++ b/runtime/arch/x86_64/quick_entrypoints_x86_64.S
@@ -1578,7 +1578,7 @@
     movq %rax, %xmm0
 
     LOAD_RUNTIME_INSTANCE rcx
-    cmpb MACRO_LITERAL(0), INSTRUMENTATION_STUBS_INSTALLED_OFFSET_FROM_RUNTIME_INSTANCE(%rcx)
+    cmpb MACRO_LITERAL(0), RUN_EXIT_HOOKS_OFFSET_FROM_RUNTIME_INSTANCE(%rcx)
     jne .Lcall_method_exit_hook
 .Lcall_method_exit_hook_done:
 
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index eaad1f0..a2f4513 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -3387,7 +3387,7 @@
   // classes. However it could not update methods of this class while we
   // were loading it. Now the class is resolved, we can update entrypoints
   // as required by instrumentation.
-  if (Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled()) {
+  if (Runtime::Current()->GetInstrumentation()->EntryExitStubsInstalled()) {
     // We must be in the kRunnable state to prevent instrumentation from
     // suspending all threads to update entrypoints while we are doing it
     // for this class.
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 4960f38..8bb4a7c 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -1997,7 +1997,7 @@
   }
 
   instrumentation::Instrumentation* instr = Runtime::Current()->GetInstrumentation();
-  if (UNLIKELY(instr->AreExitStubsInstalled() && Runtime::Current()->IsJavaDebuggable())) {
+  if (UNLIKELY(instr->HasMethodEntryListeners())) {
     instr->MethodEnterEvent(self, called);
     if (self->IsExceptionPending()) {
       return nullptr;
@@ -2543,7 +2543,8 @@
       << "Enter instrumentation exit stub with pending exception " << self->GetException()->Dump();
 
   instrumentation::Instrumentation* instr = Runtime::Current()->GetInstrumentation();
-  JValue return_value;
+  DCHECK(instr->RunExitHooks());
+
   bool is_ref = false;
   ArtMethod* method = *sp;
   if (instr->HasMethodExitListeners()) {
@@ -2551,9 +2552,8 @@
 
     CHECK(gpr_result != nullptr);
     CHECK(fpr_result != nullptr);
-    DCHECK(instr->AreExitStubsInstalled());
 
-    return_value = instr->GetReturnValue(method, &is_ref, gpr_result, fpr_result);
+    JValue return_value = instr->GetReturnValue(method, &is_ref, gpr_result, fpr_result);
     MutableHandle<mirror::Object> res(hs.NewHandle<mirror::Object>(nullptr));
     if (is_ref) {
       // Take a handle to the return value so we won't lose it if we suspend.
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index 62a2d8f..0112681 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -108,7 +108,7 @@
 };
 
 Instrumentation::Instrumentation()
-    : instrumentation_stubs_installed_(false),
+    : run_exit_hooks_(false),
       instrumentation_level_(InstrumentationLevel::kInstrumentNothing),
       forced_interpret_only_(false),
       have_method_entry_listeners_(false),
@@ -122,8 +122,7 @@
       have_branch_listeners_(false),
       have_exception_handled_listeners_(false),
       quick_alloc_entry_points_instrumentation_counter_(0),
-      alloc_entrypoints_instrumented_(false) {
-}
+      alloc_entrypoints_instrumented_(false) {}
 
 bool Instrumentation::ProcessMethodUnwindCallbacks(Thread* self,
                                                    std::queue<ArtMethod*>& methods,
@@ -617,10 +616,18 @@
 }
 
 void Instrumentation::InstrumentThreadStack(Thread* thread, bool force_deopt) {
-  instrumentation_stubs_installed_ = true;
+  run_exit_hooks_ = true;
   InstrumentationInstallStack(thread, this, force_deopt);
 }
 
+void Instrumentation::InstrumentAllThreadStacks(bool force_deopt) {
+  run_exit_hooks_ = true;
+  MutexLock mu(Thread::Current(), *Locks::thread_list_lock_);
+  for (Thread* thread : Runtime::Current()->GetThreadList()->GetList()) {
+    InstrumentThreadStack(thread, force_deopt);
+  }
+}
+
 // Removes the instrumentation exit pc as the return PC for every quick frame.
 static void InstrumentationRestoreStack(Thread* thread, void* arg)
     REQUIRES(Locks::mutator_lock_) {
@@ -677,13 +684,7 @@
 }
 
 void Instrumentation::DeoptimizeAllThreadFrames() {
-  Thread* self = Thread::Current();
-  MutexLock mu(self, *Locks::thread_list_lock_);
-  ThreadList* tl = Runtime::Current()->GetThreadList();
-  tl->ForEach([&](Thread* t) {
-    Locks::mutator_lock_->AssertExclusiveHeld(self);
-    InstrumentThreadStack(t, /* deopt_all_frames= */ true);
-  });
+  InstrumentAllThreadStacks(/* force_deopt= */ true);
 }
 
 static bool HasEvent(Instrumentation::InstrumentationEvent expected, uint32_t events) {
@@ -886,7 +887,7 @@
 
 void Instrumentation::EnableEntryExitHooks(const char* key) {
   DCHECK(Runtime::Current()->IsJavaDebuggable());
-  ConfigureStubs(key, InstrumentationLevel::kInstrumentWithInstrumentationStubs);
+  ConfigureStubs(key, InstrumentationLevel::kInstrumentWithEntryExitHooks);
 }
 
 void Instrumentation::MaybeRestoreInstrumentationStack() {
@@ -912,9 +913,7 @@
   });
   if (no_remaining_deopts) {
     Runtime::Current()->GetThreadList()->ForEach(InstrumentationRestoreStack, this);
-    // Only do this after restoring, as walking the stack when restoring will see
-    // the instrumentation exit pc.
-    instrumentation_stubs_installed_ = false;
+    run_exit_hooks_ = false;
   }
 }
 
@@ -937,11 +936,7 @@
   InstallStubsClassVisitor visitor(this);
   runtime->GetClassLinker()->VisitClasses(&visitor);
   if (requested_level > InstrumentationLevel::kInstrumentNothing) {
-    instrumentation_stubs_installed_ = true;
-    MutexLock mu(self, *Locks::thread_list_lock_);
-    for (Thread* thread : Runtime::Current()->GetThreadList()->GetList()) {
-      InstrumentThreadStack(thread, /* deopt_all_frames= */ false);
-    }
+    InstrumentAllThreadStacks(/* force_deopt= */ false);
   } else {
     MaybeRestoreInstrumentationStack();
   }
@@ -1037,7 +1032,7 @@
 }
 
 void Instrumentation::UpdateMethodsCodeImpl(ArtMethod* method, const void* new_code) {
-  if (!AreExitStubsInstalled()) {
+  if (!EntryExitStubsInstalled()) {
     // Fast path: no instrumentation.
     DCHECK(!IsDeoptimized(method));
     UpdateEntryPoints(method, new_code);
@@ -1115,7 +1110,6 @@
   CHECK(!method->IsProxyMethod());
   CHECK(method->IsInvokable());
 
-  Thread* self = Thread::Current();
   {
     Locks::mutator_lock_->AssertExclusiveHeld(Thread::Current());
     bool has_not_been_deoptimized = AddDeoptimizedMethod(method);
@@ -1125,16 +1119,10 @@
   if (!InterpreterStubsInstalled()) {
     UpdateEntryPoints(method, GetQuickToInterpreterBridge());
 
-    // Install instrumentation exit stub and instrumentation frames. We may already have installed
-    // these previously so it will only cover the newly created frames.
-    instrumentation_stubs_installed_ = true;
-    MutexLock mu(self, *Locks::thread_list_lock_);
-    for (Thread* thread : Runtime::Current()->GetThreadList()->GetList()) {
-      // This isn't a strong deopt. We deopt this method if it is still in the
-      // deopt methods list. If by the time we hit this frame we no longer need
-      // a deopt it is safe to continue. So we don't mark the frame.
-      InstrumentThreadStack(thread, /* deopt_all_frames= */ false);
-    }
+    // Instrument thread stacks to request a check if the caller needs a deoptimization.
+    // This isn't a strong deopt. We deopt this method if it is still in the deopt methods list.
+    // If by the time we hit this frame we no longer need a deopt it is safe to continue.
+    InstrumentAllThreadStacks(/* force_deopt= */ false);
   }
 }
 
@@ -1228,7 +1216,7 @@
   if (needs_interpreter) {
     level = InstrumentationLevel::kInstrumentWithInterpreter;
   } else {
-    level = InstrumentationLevel::kInstrumentWithInstrumentationStubs;
+    level = InstrumentationLevel::kInstrumentWithEntryExitHooks;
   }
   ConfigureStubs(key, level);
 }
@@ -1533,12 +1521,9 @@
 }
 
 bool Instrumentation::ShouldDeoptimizeCaller(Thread* self, ArtMethod** sp) {
-  // When exit stubs aren't installed we don't need to check for any instrumentation related
+  // When exit stubs aren't called we don't need to check for any instrumentation related
   // deoptimizations.
-  // TODO(mythria): Once we remove instrumentation stubs rename AreExitStubsInstalled. This is
-  // used to check if any instrumentation related work needs to be done. For ex: calling method
-  // entry / exit hooks, checking for instrumentation related deopts in suspend points
-  if (!AreExitStubsInstalled()) {
+  if (!RunExitHooks()) {
     return false;
   }
 
diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h
index 626ff8e..f46dcf1 100644
--- a/runtime/instrumentation.h
+++ b/runtime/instrumentation.h
@@ -194,20 +194,19 @@
   };
 
   enum class InstrumentationLevel {
-    kInstrumentNothing,                   // execute without instrumentation
-    kInstrumentWithInstrumentationStubs,  // execute with instrumentation entry/exit stubs
-    kInstrumentWithInterpreter            // execute with interpreter
+    kInstrumentNothing,             // execute without instrumentation
+    kInstrumentWithEntryExitHooks,  // execute with entry/exit hooks
+    kInstrumentWithInterpreter      // execute with interpreter
   };
 
   Instrumentation();
 
-  static constexpr MemberOffset NeedsExitHooksOffset() {
-    // Assert that instrumentation_stubs_installed_ is 8bits wide. If the size changes
+  static constexpr MemberOffset RunExitHooksOffset() {
+    // Assert that run_entry_exit_hooks_ is 8bits wide. If the size changes
     // update the compare instructions in the code generator when generating checks for
     // MethodEntryExitHooks.
-    static_assert(sizeof(instrumentation_stubs_installed_) == 1,
-                  "instrumentation_stubs_installed_ isn't expected size");
-    return MemberOffset(OFFSETOF_MEMBER(Instrumentation, instrumentation_stubs_installed_));
+    static_assert(sizeof(run_exit_hooks_) == 1, "run_exit_hooks_ isn't expected size");
+    return MemberOffset(OFFSETOF_MEMBER(Instrumentation, run_exit_hooks_));
   }
 
   static constexpr MemberOffset HaveMethodEntryListenersOffset() {
@@ -337,7 +336,7 @@
   }
 
   bool EntryExitStubsInstalled() const {
-    return instrumentation_level_ == InstrumentationLevel::kInstrumentWithInstrumentationStubs ||
+    return instrumentation_level_ == InstrumentationLevel::kInstrumentWithEntryExitHooks ||
            instrumentation_level_ == InstrumentationLevel::kInstrumentWithInterpreter;
   }
 
@@ -355,8 +354,8 @@
     return forced_interpret_only_;
   }
 
-  bool AreExitStubsInstalled() const {
-    return instrumentation_stubs_installed_;
+  bool RunExitHooks() const {
+    return run_exit_hooks_;
   }
 
   bool HasMethodEntryListeners() const REQUIRES_SHARED(Locks::mutator_lock_) {
@@ -559,6 +558,8 @@
   //    the stack frame to run entry / exit hooks but we don't need to deoptimize.
   // deopt_all_frames indicates whether the frames need to deoptimize or not.
   void InstrumentThreadStack(Thread* thread, bool deopt_all_frames) REQUIRES(Locks::mutator_lock_);
+  void InstrumentAllThreadStacks(bool deopt_all_frames) REQUIRES(Locks::mutator_lock_)
+      REQUIRES(!Locks::thread_list_lock_);
 
   // Force all currently running frames to be deoptimized back to interpreter. This should only be
   // used in cases where basically all compiled code has been invalidated.
@@ -653,12 +654,30 @@
   void UpdateMethodsCodeImpl(ArtMethod* method, const void* new_code)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  // Have we hijacked ArtMethod::code_ so that it calls instrumentation/interpreter code?
-  bool instrumentation_stubs_installed_;
+  // We need to run method exit hooks for two reasons:
+  // 1. When method exit listeners are installed
+  // 2. When we need to check if the caller of this method needs a deoptimization. This is needed
+  // only for deoptimizing the currently active invocations on stack when we deoptimize a method or
+  // invalidate the JITed code when redefining the classes. So future invocations don't need to do
+  // this check.
+  //
+  // For JITed code of non-native methods we already have a stack slot reserved for deoptimizing
+  // on demand and we use that stack slot to check if the caller needs a deoptimization. JITed code
+  // checks if there are any method exit listeners or if the stack slot is set to determine if
+  // method exit hooks need to be executed.
+  //
+  // For JITed JNI stubs there is no reserved stack slot for this and we just use this variable to
+  // check if we need to run method entry / exit hooks. This variable would be set when either of
+  // the above conditions are true. If we need method exit hooks only for case 2, we would call exit
+  // hooks for any future invocations which aren't necessary.
+  // QuickToInterpreterBridge and GenericJniStub also use this for same reasons.
+  // If calling entry / exit hooks becomes expensive we could do the same optimization we did for
+  // JITed code by having a reserved stack slot.
+  bool run_exit_hooks_;
 
   // The required level of instrumentation. This could be one of the following values:
   // kInstrumentNothing: no instrumentation support is needed
-  // kInstrumentWithInstrumentationStubs: needs support to call method entry/exit stubs.
+  // kInstrumentWithEntryExitHooks: needs support to call method entry/exit stubs.
   // kInstrumentWithInterpreter: only execute with interpreter
   Instrumentation::InstrumentationLevel instrumentation_level_;
 
diff --git a/runtime/instrumentation_test.cc b/runtime/instrumentation_test.cc
index 260ccb6..85073ae 100644
--- a/runtime/instrumentation_test.cc
+++ b/runtime/instrumentation_test.cc
@@ -467,7 +467,8 @@
   instrumentation::Instrumentation* instr = Runtime::Current()->GetInstrumentation();
   ASSERT_NE(instr, nullptr);
 
-  EXPECT_FALSE(instr->AreExitStubsInstalled());
+  EXPECT_FALSE(instr->RunExitHooks());
+  EXPECT_FALSE(instr->EntryExitStubsInstalled());
   EXPECT_FALSE(instr->AreAllMethodsDeoptimized());
   EXPECT_FALSE(instr->NeedsSlowInterpreterForListeners());
   EXPECT_FALSE(instr->ShouldNotifyMethodEnterExitEvents());
@@ -630,7 +631,7 @@
   DeoptimizeMethod(soa.Self(), method_to_deoptimize);
 
   EXPECT_FALSE(instr->AreAllMethodsDeoptimized());
-  EXPECT_TRUE(instr->AreExitStubsInstalled());
+  EXPECT_TRUE(instr->RunExitHooks());
   EXPECT_TRUE(instr->IsDeoptimized(method_to_deoptimize));
 
   constexpr const char* instrumentation_key = "DeoptimizeDirectMethod";
@@ -650,7 +651,8 @@
   DeoptimizeEverything(soa.Self(), instrumentation_key);
 
   EXPECT_TRUE(instr->AreAllMethodsDeoptimized());
-  EXPECT_TRUE(instr->AreExitStubsInstalled());
+  EXPECT_TRUE(instr->RunExitHooks());
+  EXPECT_TRUE(instr->InterpreterStubsInstalled());
 
   UndeoptimizeEverything(soa.Self(), instrumentation_key, true);
 
@@ -681,7 +683,7 @@
   EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentNothing,
             GetCurrentInstrumentationLevel());
   EXPECT_FALSE(instr->AreAllMethodsDeoptimized());
-  EXPECT_TRUE(instr->AreExitStubsInstalled());
+  EXPECT_TRUE(instr->RunExitHooks());
   EXPECT_TRUE(instr->IsDeoptimized(method_to_deoptimize));
 
   constexpr const char* instrumentation_key = "MixedDeoptimization";
@@ -689,14 +691,14 @@
   EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter,
             GetCurrentInstrumentationLevel());
   EXPECT_TRUE(instr->AreAllMethodsDeoptimized());
-  EXPECT_TRUE(instr->AreExitStubsInstalled());
+  EXPECT_TRUE(instr->RunExitHooks());
   EXPECT_TRUE(instr->IsDeoptimized(method_to_deoptimize));
 
   UndeoptimizeEverything(soa.Self(), instrumentation_key, false);
   EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentNothing,
             GetCurrentInstrumentationLevel());
   EXPECT_FALSE(instr->AreAllMethodsDeoptimized());
-  EXPECT_TRUE(instr->AreExitStubsInstalled());
+  EXPECT_TRUE(instr->RunExitHooks());
   EXPECT_TRUE(instr->IsDeoptimized(method_to_deoptimize));
 
   UndeoptimizeMethod(soa.Self(), method_to_deoptimize, instrumentation_key, true);
@@ -717,7 +719,7 @@
   EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter,
             GetCurrentInstrumentationLevel());
   EXPECT_TRUE(instr->AreAllMethodsDeoptimized());
-  EXPECT_TRUE(instr->AreExitStubsInstalled());
+  EXPECT_TRUE(instr->RunExitHooks());
 
   DisableMethodTracing(soa.Self(), instrumentation_key);
   EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentNothing,
@@ -733,10 +735,10 @@
 
   constexpr const char* instrumentation_key = "MethodTracing";
   EnableMethodTracing(soa.Self(), instrumentation_key, false);
-  EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
+  EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks,
             GetCurrentInstrumentationLevel());
   EXPECT_FALSE(instr->AreAllMethodsDeoptimized());
-  EXPECT_TRUE(instr->AreExitStubsInstalled());
+  EXPECT_TRUE(instr->RunExitHooks());
 
   DisableMethodTracing(soa.Self(), instrumentation_key);
   EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentNothing,
@@ -779,9 +781,8 @@
 
   // Check we can switch to instrumentation stubs
   CheckConfigureStubs(kClientOneKey,
-                      Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
-  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
-                        1U);
+                      Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks);
+  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks, 1U);
 
   // Check we can disable instrumentation.
   CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
@@ -806,9 +807,8 @@
 
   // Configure stubs with instrumentation stubs.
   CheckConfigureStubs(kClientOneKey,
-                      Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
-  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
-                        1U);
+                      Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks);
+  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks, 1U);
 
   // Configure stubs with interpreter.
   CheckConfigureStubs(kClientOneKey,
@@ -830,9 +830,8 @@
 
   // Configure stubs with instrumentation stubs.
   CheckConfigureStubs(kClientOneKey,
-                      Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
-  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
-                        1U);
+                      Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks);
+  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks, 1U);
 
   // Check we can disable instrumentation.
   CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
@@ -845,9 +844,8 @@
 
   // Configure stubs with instrumentation stubs.
   CheckConfigureStubs(kClientOneKey,
-                      Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
-  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
-                        1U);
+                      Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks);
+  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks, 1U);
 
   // Configure stubs with interpreter.
   CheckConfigureStubs(kClientOneKey,
@@ -856,9 +854,8 @@
 
   // Configure stubs with instrumentation stubs again.
   CheckConfigureStubs(kClientOneKey,
-                      Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
-  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
-                        1U);
+                      Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks);
+  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks, 1U);
 
   // Check we can disable instrumentation.
   CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
@@ -881,21 +878,18 @@
 
   // Configure stubs with instrumentation stubs for 1st client.
   CheckConfigureStubs(kClientOneKey,
-                      Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
-  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
-                        1U);
+                      Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks);
+  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks, 1U);
 
   // Configure stubs with instrumentation stubs for 2nd client.
   CheckConfigureStubs(kClientTwoKey,
-                      Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
-  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
-                        2U);
+                      Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks);
+  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks, 2U);
 
   // 1st client requests instrumentation deactivation but 2nd client still needs
   // instrumentation stubs.
   CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
-  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
-                        1U);
+  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks, 1U);
 
   // 2nd client requests instrumentation deactivation
   CheckConfigureStubs(kClientTwoKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
@@ -929,9 +923,8 @@
 
   // Configure stubs with instrumentation stubs for 1st client.
   CheckConfigureStubs(kClientOneKey,
-                      Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
-  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
-                        1U);
+                      Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks);
+  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks, 1U);
 
   // Configure stubs with interpreter for 2nd client.
   CheckConfigureStubs(kClientTwoKey,
@@ -957,14 +950,13 @@
 
   // Configure stubs with instrumentation stubs for 2nd client.
   CheckConfigureStubs(kClientTwoKey,
-                      Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
+                      Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks);
   CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 2U);
 
   // 1st client requests instrumentation deactivation but 2nd client still needs
   // instrumentation stubs.
   CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
-  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
-                        1U);
+  CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithEntryExitHooks, 1U);
 
   // 2nd client requests instrumentation deactivation
   CheckConfigureStubs(kClientTwoKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
diff --git a/runtime/interpreter/mterp/nterp.cc b/runtime/interpreter/mterp/nterp.cc
index 6d14f6d..a4e64e3 100644
--- a/runtime/interpreter/mterp/nterp.cc
+++ b/runtime/interpreter/mterp/nterp.cc
@@ -45,7 +45,7 @@
   // interpreter-only runtime to always be in a switch-like interpreter.
   return IsNterpSupported() &&
       !runtime->IsJavaDebuggable() &&
-      !instr->AreExitStubsInstalled() &&
+      !instr->EntryExitStubsInstalled() &&
       !instr->InterpretOnly() &&
       !runtime->IsAotCompiler() &&
       !instr->NeedsSlowInterpreterForListeners() &&
diff --git a/tools/cpp-define-generator/runtime.def b/tools/cpp-define-generator/runtime.def
index 89a3578..fd6567d 100644
--- a/tools/cpp-define-generator/runtime.def
+++ b/tools/cpp-define-generator/runtime.def
@@ -31,6 +31,6 @@
 ASM_DEFINE(RUNTIME_SAVE_REFS_ONLY_METHOD_OFFSET,
            art::Runtime::GetCalleeSaveMethodOffset(art::CalleeSaveType::kSaveRefsOnly))
 ASM_DEFINE(RUNTIME_INSTRUMENTATION_OFFSET, art::Runtime::GetInstrumentationOffset().Int32Value())
-ASM_DEFINE(INSTRUMENTATION_STUBS_INSTALLED_OFFSET_FROM_RUNTIME_INSTANCE,
+ASM_DEFINE(RUN_EXIT_HOOKS_OFFSET_FROM_RUNTIME_INSTANCE,
            art::Runtime::GetInstrumentationOffset().Int32Value() +
-           art::instrumentation::Instrumentation::NeedsExitHooksOffset().Int32Value())
+           art::instrumentation::Instrumentation::RunExitHooksOffset().Int32Value())