Happy path

Roland Westrelin rwestrel at redhat.com
Thu Mar 15 09:16:15 UTC 2018


Here is a follow up patch:

http://cr.openjdk.java.net/~roland/shenandoah/happypath/webrev.01/

With this one, adjacent heap stable tests are merged, control flow
between heap stable tests is cloned in each branch of the dominating
heap state test (only simple control flow is supported, membars are not
for instance), read barriers are removed in the heap stable branch.

So for instance:

    private static class A {
        float field;
        A field2;
        float field3;
    }

    private static void test15(A a, A b) {
        a.field2 = b.field2;
    }

compiles down to:

  0x00007fdefd194740: mov    %eax,-0x16000(%rsp)
  0x00007fdefd194747: push   %rbp
  0x00007fdefd194748: sub    $0x10,%rsp         ;*synchronization entry
                                                ; - TestHappyPath::test15 at -1 (line 182)

  0x00007fdefd19474c: mov    0x14(%rdx),%ebp    ; implicit exception: dispatches to 0x00007fdefd19481d
 ;; B2: #       B5 B3 <- B1  Freq: 0.999999

  0x00007fdefd19474f: cmpb   $0x0,0x668(%r15)
  0x00007fdefd194757: jne    0x00007fdefd194768
 ;; B3: #       B20 B4 <- B2  Freq: 0.998999

  0x00007fdefd194759: mov    %ebp,0x14(%rsi)    ; implicit exception: dispatches to 0x00007fdefd19482a
 ;; B4: #       N1 <- B10 B3  Freq: 0.999998

  0x00007fdefd19475c: add    $0x10,%rsp
  0x00007fdefd194760: pop    %rbp
  0x00007fdefd194761: test   %eax,0x1564f899(%rip)        # 0x00007fdf127e4000
                                                ;   {poll_return}
  0x00007fdefd194767: retq

or for:
    private static void test18(A a, A b, A c, A d, boolean flag1, boolean flag2, boolean flag3) {
        if (flag1) {
            if (flag2) {
                b.field = 0x42;
            } else {
                if (flag3) {
                    c.field = 0x42;
                }
            }
        }
        d.field = 0x42;
    }

the heap stable test for d.field is hoisted above the if (flag1), the
entire control flow is cloned in the heap stable branch and the entire
method body can run without barriers if the heap stable test succeeds.

Anyway, that all seems to optimize well on simple test cases and be
stable enough that someone else can play with it. I'm not looking for
comments on the code itself because it needs some polishing. I'd like
feedback on whether this works/performas as expected, if there are code
patterns that are not well supported etc.

Roland.



More information about the shenandoah-dev mailing list