8207345: AArch64: Trampoline generation code reads from unitialized memory
authoraph
Tue, 17 Jul 2018 15:28:17 +0100
changeset 51132 8a07817a6c57
parent 51131 9502e3b9d415
child 51133 e15cd424736d
8207345: AArch64: Trampoline generation code reads from unitialized memory Reviewed-by: shade
src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Tue Jul 17 22:22:00 2018 +0800
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Tue Jul 17 15:28:17 2018 +0100
@@ -739,11 +739,19 @@
          || entry.rspec().type() == relocInfo::static_call_type
          || entry.rspec().type() == relocInfo::virtual_call_type, "wrong reloc type");
 
-  unsigned int start_offset = offset();
-  if (far_branches() && !Compile::current()->in_scratch_emit_size()) {
-    address stub = emit_trampoline_stub(start_offset, entry.target());
-    if (stub == NULL) {
-      return NULL; // CodeCache is full
+  // We need a trampoline if branches are far.
+  if (far_branches()) {
+    // We don't want to emit a trampoline if C2 is generating dummy
+    // code during its branch shortening phase.
+    CompileTask* task = ciEnv::current()->task();
+    bool in_scratch_emit_size =
+      (task != NULL && is_c2_compile(task->comp_level()) &&
+       Compile::current()->in_scratch_emit_size());
+    if (!in_scratch_emit_size) {
+      address stub = emit_trampoline_stub(offset(), entry.target());
+      if (stub == NULL) {
+        return NULL; // CodeCache is full
+      }
     }
   }