src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp
changeset 48487 abf1d797e380
parent 48127 efc459cf351e
child 49845 c508fda31759
--- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp	Thu Dec 21 09:05:32 2017 +0100
+++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp	Wed Jan 03 17:29:20 2018 +0000
@@ -367,3 +367,24 @@
   set_ptr_at(data_offset, new_destination);
   OrderAccess::release();
 }
+
+// Generate a trampoline for a branch to dest.  If there's no need for a
+// trampoline, simply patch the call directly to dest.
+address NativeCall::trampoline_jump(CodeBuffer &cbuf, address dest) {
+  MacroAssembler a(&cbuf);
+  address stub = NULL;
+
+  if (a.far_branches()
+      && ! is_NativeCallTrampolineStub_at(instruction_address() + displacement())) {
+    stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest);
+  }
+
+  if (stub == NULL) {
+    // If we generated no stub, patch this call directly to dest.
+    // This will happen if we don't need far branches or if there
+    // already was a trampoline.
+    set_destination(dest);
+  }
+
+  return stub;
+}