[8u] RFR: 8151284: aarch32: on-stack replacement does not work properly when invoked from compiled

Andrey Petushkov andrey.petushkov at gmail.com
Fri Mar 4 15:30:33 UTC 2016


Hi All!

Below is a fix for the On Stack Replacement functionality. The bug is caused by borrowing code from aarch64 but using sp for both sp and esp purposes. As a result the correct value of sp gets lost after removing of the frame. The trivial fix is to save the value across the frame pop routine.

It’s easy to verify the bug by means of stack traversal, e.g. by creating an throwable. In this case the VM crashes with segmentation fault in frame::sender

The problem could be reproduced with the following test code:
=== test begins ===
public class OSRTest {
    private static Object lock1 = new Object();
    private static Object lock2 = new Object();
    private static int x;

    private static void test() {
        x++;
        if (x % 10000 == 0)
            test2();
    }

    public static void main(String[] args) {
        long k = 1;
        synchronized (lock1) {
            for (int i=0;i<1000000;++i) {
                synchronized (OSRTest.class) {
                    for (int j=0;j<100000;++j) {
                        ++i;
                        k += i;
                        test();
                    }
                }
                // System.out.print(", " + i);
            }
        }
        System.out.println(", ."+k+"x"+x);
    }

    private static void test2() {
        long k = 1;
        synchronized (lock1) {
            for (int i=0;i<1000000;++i) {
                synchronized (OSRTest.class) {
                    for (int j=0;j<100000;++j) {
                        ++i;
                        k += i;
        x++;
        if (x % 10000 == 0)
            (new Exception("test3 exception, please ignore")).printStackTrace();
                    }
                }
            }
        }
        System.out.println(", ."+k+"x"+x);
    }
}
=== test ends ===

Webrev: http://cr.openjdk.java.net/~snazarki/8151284/ <http://cr.openjdk.java.net/~snazarki/8151284/>

Thanks,
Andrey


More information about the aarch32-port-dev mailing list