8211064: [AArch64] Interpreter and c1 don't correctly handle jboolean results in native calls
Reviewed-by: aph
Contributed-by: andrey.petushkov@gmail.com
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp Mon Sep 24 18:44:39 2018 +0200
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp Mon Sep 24 18:19:46 2018 +0100
@@ -822,6 +822,15 @@
return stub_start_addr;
}
+void MacroAssembler::c2bool(Register x) {
+ // implements x == 0 ? 0 : 1
+ // note: must only look at least-significant byte of x
+ // since C-style booleans are stored in one byte
+ // only! (was bug)
+ tst(x, 0xff);
+ cset(x, Assembler::NE);
+}
+
address MacroAssembler::ic_call(address entry, jint method_index) {
RelocationHolder rh = virtual_call_Relocation::spec(pc(), method_index);
// address const_ptr = long_constant((jlong)Universe::non_oop_word());
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp Mon Sep 24 18:44:39 2018 +0200
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp Mon Sep 24 18:19:46 2018 +0100
@@ -782,6 +782,9 @@
void resolve_jobject(Register value, Register thread, Register tmp);
+ // C 'boolean' to Java boolean: x == 0 ? 0 : 1
+ void c2bool(Register x);
+
// oop manipulations
void load_klass(Register dst, Register src);
void store_klass(Register dst, Register src);
--- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp Mon Sep 24 18:44:39 2018 +0200
+++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp Mon Sep 24 18:19:46 2018 +0100
@@ -1924,7 +1924,7 @@
// Unpack native results.
switch (ret_type) {
- case T_BOOLEAN: __ ubfx(r0, r0, 0, 8); break;
+ case T_BOOLEAN: __ c2bool(r0); break;
case T_CHAR : __ ubfx(r0, r0, 0, 16); break;
case T_BYTE : __ sbfx(r0, r0, 0, 8); break;
case T_SHORT : __ sbfx(r0, r0, 0, 16); break;
--- a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp Mon Sep 24 18:44:39 2018 +0200
+++ b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp Mon Sep 24 18:19:46 2018 +0100
@@ -557,7 +557,7 @@
BasicType type) {
address entry = __ pc();
switch (type) {
- case T_BOOLEAN: __ uxtb(r0, r0); break;
+ case T_BOOLEAN: __ c2bool(r0); break;
case T_CHAR : __ uxth(r0, r0); break;
case T_BYTE : __ sxtb(r0, r0); break;
case T_SHORT : __ sxth(r0, r0); break;