RFR: 8349814: [leyden] Reduce uncommon traps in preload code [v3]

Aleksey Shipilev shade at openjdk.org
Tue Apr 1 16:58:22 UTC 2025


On Mon, 24 Feb 2025 08:03:58 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:

>> Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:
>> 
>>  - Shuffle things around to capture more cases
>>  - Comment
>>  - Fix
>
> Looks good.

So, @iwanowww (or maybe @iklam), here is the trouble that shows up as ciTypeFlow trap. Build the JDK from this branch, and then run `reproduce-traps.sh`. Then it would show something like:


$ reproduce-traps.sh

-------------------------------
[1.103s][debug][deoptimization] ciTypeFlow uncommon_trap method=com.sun.tools.javac.util.StringNameTable::fromString(Ljava/lang/String;)Lcom/sun/tools/javac/util/Name; bci=28 reason='unloaded' action='reinterpret' index='40' debug_id='0' do_new: unresolved klass
...

-------------------------------
     50    W0.0   Q12.9    C0.0    A0.0    412      AP 4       com.sun.tools.javac.util.StringNameTable::fromString (50 bytes)
     51 [0.052s][debug][deoptimization] cid= 412     level=4 com.sun.tools.javac.util.StringNameTable::fromString(Ljava/lang/String;)Lcom/sun/tools/javac/util/Name; trap_bci=28 unloaded preloaded reinterpret pc=0x00007f4483eb9bac relative_pc=0x000000000000072c
     51                                    412      AP  4       com.sun.tools.javac.util.StringNameTable::fromString (50 bytes)   made not entrant: uncommon trap
...


So it fails when `ciTypeFlow` traps at `do_new: unresolved klass`. I think that _maybe_ `ciTypeFlow` is actually not the culprit here, but we are failing to resolve the relevant class during assembly? Here is the Java source and relevant bytecode:

Java code:


    @Override
    public Name fromString(String string) {
        Name name = nameMap.get(string);
        if (name == null) {
            if (intern) {
                string = string.intern();
            }
            name = new NameImpl(this, string);  // <--- TRAPS HERE
            nameMap.put(string, name);
        }
        return name;
    }



Relevant bytecode:


  public com.sun.tools.javac.util.Name fromString(java.lang.String);
    descriptor: (Ljava/lang/String;)Lcom/sun/tools/javac/util/Name;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=4, locals=3, args_size=2
         0: aload_0
         1: getfield      #21                 // Field nameMap:Ljava/util/HashMap;
         4: aload_1
         5: invokevirtual #29                 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
         8: checkcast     #33                 // class com/sun/tools/javac/util/Name
        11: astore_2
        12: aload_2
        13: ifnonnull     48
        16: aload_0
        17: getfield      #25                 // Field intern:Z
        20: ifeq          28
        23: aload_1
        24: invokevirtual #35                 // Method java/lang/String.intern:()Ljava/lang/String;
        27: astore_1
        28: new           #40                 // class com/sun/tools/javac/util/StringNameTable$NameImpl <---- TRAPS HERE
        31: dup
        32: aload_0
        33: aload_1
        34: invokespecial #42                 // Method com/sun/tools/javac/util/StringNameTable$NameImpl."<init>":(Lcom/sun/tools/javac/util/StringNameTable;Ljava/lang/String;)V

-------------

PR Comment: https://git.openjdk.org/leyden/pull/38#issuecomment-2769987972


More information about the leyden-dev mailing list