From 0ebcf5c59d6203d8e0c1a76cd45e867b4f7aefd7 Mon Sep 17 00:00:00 2001
From: Nick Gasson <ngasson@openjdk.org>
Date: Tue, 28 Jul 2020 16:50:32 +0800
Subject: [PATCH] 8237483: AArch64 C1 OopMap inserted twice fatal error

Reviewed-by: aph
---
 src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
index a8b8c10f44a..2f712c5cc71 100644
--- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
@@ -2108,6 +2108,13 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit
 
   // get current pc information
   // pc is only needed if the method has an exception handler, the unwind code does not need it.
+  if (compilation()->debug_info_recorder()->last_pc_offset() == __ offset()) {
+    // As no instructions have been generated yet for this LIR node it's
+    // possible that an oop map already exists for the current offset.
+    // In that case insert an dummy NOP here to ensure all oop map PCs
+    // are unique. See JDK-8237483.
+    __ nop();
+  }
   int pc_for_athrow_offset = __ offset();
   InternalAddress pc_for_athrow(__ pc());
   __ adr(exceptionPC->as_register(), pc_for_athrow);