dragonwell-project / dragonwell11

Alibaba Dragonwell11 JDK
https://www.aliyun.com/product/dragonwell
GNU General Public License v2.0
557 stars 112 forks source link

[Backport] CHA inline #773

Closed lusou-zhangquan closed 7 months ago

lusou-zhangquan commented 8 months ago

Introduction

With this backport, interface call could be inlined if there is only one implementation of the invoked method after class hierarchy analysis, as shown in the following case.

interface I1 {
    public int m();
}

abstract class C1 implements I1 {}

class C2 extends C1 {
    public int m() {
        return 0;
    }
}

class Test {
    public static void main(String[] args) {
        run(new C2());
    }

    public static void run(C1 c1) {
        c1.m(); // will inline C2.m because only class C2 implements method m after Class Hierarchy Analysis
    }
}

Test results

benchmark: renaissance platform: x86 config:4C8G image

benchmark: renaissance platform: aarch64 config:4C8G image

There isn't any change for SPECjbb on x86 and aarch64 platform.

Corresponding upstream commit

6986483CHA: optimize calls through interfaces 8223171Redundant nmethod dependencies for effectively final methods 8261954Dependencies: Improve iteration over class hierarchy under context class 8264548Dependencies: ClassHierarchyWalker::is_witness() cleanups 8266074 Vtable-based CHA implementation 8065760 CHA: Improve abstract method support 8036580 CHA: improve default method support

Others

  1. Because the absence of JDK-8264873 Dependencies: Split ClassHierarchyWalker in JDK11, the implementation of class LinkedConcreteMethodFinder in backported JDK-8266074 is little different with upstream, but keeps functionality consistent.
  2. Total number of new lines of this backport is about 2400, including 1500 lines for test cases and 900 lines for feature code.