8209637: [s390x] Interpreter doesn't call result handler after native calls

Reviewed-by: goetz, lucy
This commit is contained in:
Volker Simonis 2018-08-21 09:25:06 +02:00
parent 789b608995
commit ea4f2f60d5
3 changed files with 122 additions and 11 deletions

View File

@ -1681,7 +1681,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
__ z_lg(Z_R1/*active_handles*/, thread_(active_handles));
__ clear_mem(Address(Z_R1, JNIHandleBlock::top_offset_in_bytes()), 4);
// Bandle exceptions (exception handling will handle unlocking!).
// Handle exceptions (exception handling will handle unlocking!).
{
Label L;
__ load_and_test_long(Z_R0/*pending_exception*/, thread_(pending_exception));
@ -1710,17 +1710,9 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
__ notify_method_exit(true/*native_method*/, ilgl, InterpreterMacroAssembler::NotifyJVMTI);
// Move native method result back into proper registers and return.
// C++ interpreter does not use result handler. So do we need to here? TODO(ZASM): check if correct.
{ NearLabel no_oop_or_null;
__ mem2freg_opt(Z_FRET, Address(Z_fp, _z_ijava_state_neg(fresult)));
__ load_and_test_long(Z_RET, Address(Z_fp, _z_ijava_state_neg(lresult)));
__ z_bre(no_oop_or_null); // No unboxing if the result is NULL.
__ load_absolute_address(Z_R1, AbstractInterpreter::result_handler(T_OBJECT));
__ compareU64_and_branch(Z_R1, Rresult_handler, Assembler::bcondNotEqual, no_oop_or_null);
__ z_lg(Z_RET, oop_tmp_offset, Z_fp);
__ verify_oop(Z_RET);
__ bind(no_oop_or_null);
}
__ mem2reg_opt(Z_RET, Address(Z_fp, _z_ijava_state_neg(lresult)));
__ call_stub(Rresult_handler);
// Pop the native method's interpreter frame.
__ pop_interpreter_frame(Z_R14 /*return_pc*/, Z_ARG2/*tmp1*/, Z_ARG3/*tmp2*/);

View File

@ -0,0 +1,89 @@
/*
* Copyright (c) 2018 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8209637
* @summary [s390x] Interpreter doesn't call result handler after native calls
* @author Volker Simonis
*
* @run main/othervm/native -XX:-UseOnStackReplacement -Xbatch JNIBooleanTest 50000
* @run main/othervm/native -Xint JNIBooleanTest 256
*/
import java.lang.reflect.Method;
public class JNIBooleanTest {
static native boolean foo(byte b);
static boolean bar(byte b) {
return foo(b);
}
public static void main(String args[]) throws Exception {
int count = args.length > 0 ? Integer.parseInt(args[0]) : 50_000;
byte b = 0;
for (int i = 0; i < count; i++) {
boolean bool = foo(b);
if ((b == 0 && bool) || (b != 0 && !bool)) {
throw new RuntimeException("Error: foo(" + b + ") = " + bool + " in iteration " + i);
}
b++;
}
b = 0;
for (int i = 0; i < count; i++) {
boolean bool = bar(b);
if ((b == 0 && bool) || (b != 0 && !bool)) {
throw new RuntimeException("Error: bar(" + b + ") = " + bool + " in iteration " + i);
}
b++;
}
Method foo = JNIBooleanTest.class.getDeclaredMethod("foo", byte.class);
b = 0;
for (int i = 0; i < count; i++) {
boolean bool = ((Boolean)foo.invoke(null, b)).booleanValue();
if ((b == 0 && bool) || (b != 0 && !bool)) {
throw new RuntimeException("Error: foo(" + b + ") = " + bool + " in iteration " + i + " (reflective)");
}
b++;
}
Method bar = JNIBooleanTest.class.getDeclaredMethod("bar", byte.class);
b = 0;
for (int i = 0; i < count; i++) {
boolean bool = ((Boolean)bar.invoke(null, b)).booleanValue();
if ((b == 0 && bool) || (b != 0 && !bool)) {
throw new RuntimeException("Error: bar(" + b + ") = " + bool + " in iteration " + i + " (reflective)");
}
b++;
}
}
static {
System.loadLibrary("JNIBooleanTest");
}
}

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2018 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "jni.h"
JNIEXPORT jboolean JNICALL
Java_JNIBooleanTest_foo(JNIEnv *env, jclass cls, jbyte b) {
jboolean old = b;
return old;
}