On 2/5/19 5:57 PM, Andrew Haley wrote:
> On 2/5/19 5:55 PM, Nick Gasson (Arm Technology China) wrote:
>> The stack trace you sent below is incomplete, it's missing the frame for
>> Spinner.run (i.e. the AARCH64Frame object corresponding to the native
>> wrapper frame). Did you try on x86 or with the patch I posted? I'm not able
>> to test at the moment but I think you will get one exra frame in the output.
>> I don't know why you don't get the NPE, I guess it depends on what's in that
>> stack slot.
>
> Never mind, found it. A more complex test is needed.
Here's the test that reveals the problem: it seems that you need an entry frame
which calls compiled Java code.
[aph@merino ~]$ cat Spinner.c
#include <jni.h>
#include <stdio.h>
/*
* Class: Spinner
* Method: run
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_Spinner_run(JNIEnv *env, jclass cls) {
jmethodID mid = (*env)->GetStaticMethodID(env, cls, "test", "()V");
(*env)->CallStaticVoidMethod(env, cls, mid);
// printf("Spinning...\n");
// for(;;);
}
[aph@merino ~]$ cat Spinner.java
public class Spinner {
static native void run();
static {
System.loadLibrary("Spinner");
}
static volatile int nn;
public static void test() {
System.out.println("Spinning");
for(int i = 1; i !=0; i = (i + 1) | 1)
nn = (int)Math.log(i);
}
public static void main(String[] args) {
run();
}
}
--
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671