jni: Add read barrier fast path to jni compiler

Static method dispatch via JNI requires a read barrier
for the ArtMethod::GetDeclaringClass() load before adding it to the
JNI StackHandleScope.

We used to call ReadBarrierJni unconditionally but add a branch
to skip calling it if the GC is not currently in the marking phase.

Test: ART_USE_READ_BARRIER=true make test-art-host test-art-target
Bug: 30437917
Change-Id: I4f505ebde17c0a67209c7bb51b3f39e37a06373a
diff --git a/compiler/utils/mips64/assembler_mips64.h b/compiler/utils/mips64/assembler_mips64.h
index 6277b5d..238cb9d 100644
--- a/compiler/utils/mips64/assembler_mips64.h
+++ b/compiler/utils/mips64/assembler_mips64.h
@@ -335,6 +335,8 @@
 
 class Mips64Assembler FINAL : public Assembler, public JNIMacroAssembler<PointerSize::k64> {
  public:
+  using JNIBase = JNIMacroAssembler<PointerSize::k64>;
+
   explicit Mips64Assembler(ArenaAllocator* arena)
       : Assembler(arena),
         overwriting_(false),
@@ -574,6 +576,35 @@
   }
 
   void Bind(Mips64Label* label);
+
+  // Don't warn about a different virtual Bind/Jump in the base class.
+  using JNIBase::Bind;
+  using JNIBase::Jump;
+
+  // Create a new label that can be used with Jump/Bind calls.
+  std::unique_ptr<JNIMacroLabel> CreateLabel() OVERRIDE {
+    LOG(FATAL) << "Not implemented on MIPS64";
+    UNREACHABLE();
+  }
+  // Emit an unconditional jump to the label.
+  void Jump(JNIMacroLabel* label ATTRIBUTE_UNUSED) OVERRIDE {
+    LOG(FATAL) << "Not implemented on MIPS64";
+    UNREACHABLE();
+  }
+  // Emit a conditional jump to the label by applying a unary condition test to the register.
+  void Jump(JNIMacroLabel* label ATTRIBUTE_UNUSED,
+            JNIMacroUnaryCondition cond ATTRIBUTE_UNUSED,
+            ManagedRegister test ATTRIBUTE_UNUSED) OVERRIDE {
+    LOG(FATAL) << "Not implemented on MIPS64";
+    UNREACHABLE();
+  }
+
+  // Code at this offset will serve as the target for the Jump call.
+  void Bind(JNIMacroLabel* label ATTRIBUTE_UNUSED) OVERRIDE {
+    LOG(FATAL) << "Not implemented on MIPS64";
+    UNREACHABLE();
+  }
+
   void Bc(Mips64Label* label);
   void Jialc(Mips64Label* label, GpuRegister indirect_reg);
   void Bltc(GpuRegister rs, GpuRegister rt, Mips64Label* label);