changeset 51806:8a07817a6c57

8207345: AArch64: Trampoline generation code reads from unitialized memory Reviewed-by: shade
author aph
date Tue, 17 Jul 2018 15:28:17 +0100
parents 9502e3b9d415
children e15cd424736d
files src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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
+      }
     }
   }