changeset 5104:f56ae2c42b1c

make C2 runtime calls to generated code branch using bl rather than blrt
author adinn
date Tue, 24 Sep 2013 18:06:44 +0100
parents 731e43d74e37
children 9719d9a2649a
files src/cpu/aarch64/vm/aarch64.ad
diffstat 1 files changed, 27 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/aarch64/vm/aarch64.ad	Fri Sep 20 15:59:37 2013 +0100
+++ b/src/cpu/aarch64/vm/aarch64.ad	Tue Sep 24 18:06:44 2013 +0100
@@ -772,14 +772,17 @@
 }
 
 int MachCallRuntimeNode::ret_addr_offset() {
-  // call should be
-  //   mov(rscratch1, RuntimeAddress(addr) // ifdef BUILTIN_SIM
+  // for generated stubs the call will be
+  //   bl(addr)
+  // for real runtime callouts it iwll be
+  //   mov(rscratch1, RuntimeAddress(addr)
   //   blrt rscratch1
-  // or
-  //   br RuntimeAddress(addr) // ifndef BUILTIN_SIM
-  // TODO
-  // allow for AArch64 version
-  return 20;
+  CodeBlob *cb = CodeCache::find_blob(_entry_point);
+  if (cb) {
+    return 4;
+  } else {
+    return 20;
+  }
 }
 
 // Indicate if the safepoint node needs the polling page as an input
@@ -2878,12 +2881,23 @@
 
   enc_class aarch64_enc_java_to_runtime(method meth) %{
     MacroAssembler _masm(&cbuf);
-    int gpcnt;
-    int fpcnt;
-    int rtype;
-    getCallInfo(tf(), gpcnt, fpcnt, rtype);
-    __ mov(rscratch1, RuntimeAddress((address)$meth$$method));
-    __ blrt(rscratch1, gpcnt, fpcnt, rtype);
+
+    // some calls to generated routines (arraycopy code) are scheduled
+    // by C2 as runtime calls. if so we can call them using a br (they
+    // will be in a reachable segment) otherwise we have to use a blrt
+    // which loads the absolute address into a register.
+    address entry = (address)$meth$$method;
+    CodeBlob *cb = CodeCache::find_blob(entry);
+    if (cb) {
+      __ bl(Address(entry));
+    } else {
+      int gpcnt;
+      int fpcnt;
+      int rtype;
+      getCallInfo(tf(), gpcnt, fpcnt, rtype);
+      __ mov(rscratch1, RuntimeAddress(entry));
+      __ blrt(rscratch1, gpcnt, fpcnt, rtype);
+    }
   %}
 
   enc_class aarch64_enc_rethrow() %{