RFR(XS): 7902477: JMH perfasm fails with lastest JDK 13

Nick Gasson nick.gasson at arm.com
Wed Oct 30 09:37:02 UTC 2019


Hi,

Can anyone review this fix for assembly parsing?

Bug: https://bugs.openjdk.java.net/browse/CODETOOLS-7902477
Webrev: http://cr.openjdk.java.net/~ngasson/7902477/webrev.01/

The output of -XX:+PrintAssembly changed after JDK-8213084, which now
causes JMH profiling with -prof perfasm to fail with:

# Processing profiler results: LinuxPerfAsmProfiler Exception in thread "main" java.lang.NumberFormatException: For input string: "sp" under radix 16
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
        at java.base/java.lang.Long.parseLong(Long.java:699)
        at java.base/java.lang.Long.valueOf(Long.java:1124)
        at org.openjdk.jmh.profile.AbstractPerfAsmProfiler.parseAddress(AbstractPerfAsmProfiler.java:891)
        at org.openjdk.jmh.profile.AbstractPerfAsmProfiler.readAssembly(AbstractPerfAsmProfiler.java:829)
        at org.openjdk.jmh.profile.AbstractPerfAsmProfiler.processAssembly(AbstractPerfAsmProfiler.java:328)
        at org.openjdk.jmh.profile.AbstractPerfAsmProfiler.afterTrial(AbstractPerfAsmProfiler.java:273)
        at org.openjdk.jmh.runner.Runner.runSeparate(Runner.java:678)
        at org.openjdk.jmh.runner.Runner.runBenchmarks(Runner.java:561)
        at org.openjdk.jmh.runner.Runner.internalRun(Runner.java:320)
        at org.openjdk.jmh.runner.Runner.run(Runner.java:209)
        at org.openjdk.jmh.Main.main(Main.java:71)

Found on AArch64 but I think it affects all platforms. The problem seems
to be the extra "--------------" lines that are now printed which
incorrectly trigger the block in AbstractPerfAsmProfiler::readAssembly
that parses stub code headings.

    if (prevLine.contains("--------") || line.contains("StubRoutines::")) {
        // Try parsing the interpreter/runtime stub:
        // ----------------------------------------------------------------------
        // invokehandle 233 invokehandle [0x00007f631d023100, 0x00007f631d0233c0] 704 bytes
        // StubRoutines::catch_exception [0x00007feb43fa7b27, 0x00007feb43fa7b46[ (31 bytes)

        Pattern pattern = Pattern.compile("(.+)( +)\\[(.+), (.+)[\\]\\[](.*)");

That pattern will then be matched by lines like the following which are
preceded by ---------:

       0x0000ffff68819280:   stp  x29, x30, [sp, #-16]!

As a workaround I changed the regex to anchor to the start of the line
and require leading non-whitespace (the address on the line above has
leading spaces where the stubs do not):

  Pattern.compile("^(\\S.*)( +)\\[(.+), (.+)[\\]\\[](.*)");

Tested on JDK 13 and 11 with no obvious regressions.

Thanks,
Nick



More information about the jmh-dev mailing list