From f9f94ca5422ae79bf4ed90f41b7698febc6bed24 Mon Sep 17 00:00:00 2001
Date: Fri, 12 Jul 2019 15:26:27 +0000
Subject: [PATCH] Backport of JDK-8203699: java/lang/invoke/SpecialInterfaceCall fails with SIGILL on aarch64

summary: Get super_klass value into r0 to make check in VerifyMethodHandles success
LLT: jdk/test/java/lang/invoke/lookup/TestDefenderMethodLookup.java
Bug url: https://bugs.openjdk.java.net/browse/JDK-8203699

---
 .../src/cpu/aarch64/vm/macroAssembler_aarch64.cpp  |   6 +-
 1 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
index 42b732f37a..4659d628db 100644
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
@@ -1208,7 +1208,6 @@ void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass,
   assert(sub_klass != r0, "killed reg"); // killed by mov(r0, super)
   assert(sub_klass != r2, "killed reg"); // killed by lea(r2, &pst_counter)
 
-  // Get super_klass value into r0 (even if it was in r5 or r2).
   RegSet pushed_registers;
   if (!IS_A_TEMP(r2))    pushed_registers += r2;
   if (!IS_A_TEMP(r5))    pushed_registers += r5;
@@ -1219,6 +1218,11 @@ void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass,
 
   push(pushed_registers, sp);
 
+  // Get super_klass value into r0 (even if it was in r5 or r2)
+  if (super_klass != r0) {
+    mov(r0, super_klass);
+  }
+
 #ifndef PRODUCT
   mov(rscratch2, (address)&SharedRuntime::_partial_subtype_ctr);
   Address pst_counter_addr(rscratch2);
diff --git a/jdk/test/java/lang/invoke/lookup/TestDefenderMethodLookup.java b/jdk/test/java/lang/invoke/lookup/TestDefenderMethodLookup.java
-- 
2.12.3

