RFR: 8334060: Implementation of Late Barrier Expansion for G1 [v15]

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Fri Sep 6 09:43:57 UTC 2024


On Thu, 5 Sep 2024 20:36:01 GMT, halkosajtarevic <duke at openjdk.org> wrote:

> Sorry, one maybe dumb question, hopefully matching the context here: Is this whole handling also required if those references point to instances of enums? Or could we do some further optimizations in such cases? Or is that exactly what C2 is doing afterwards?

Hi, do you mean whether G1 requires barriers when writing enum instances into object fields, as in `storeEnum` in this example?


  (...)

  public enum Day {MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY};

  static class MyObject {
    Day day;
  }

  public static void storeEnum(MyObject o, Day d) {
    o.day = d;
  }

  (...)

    MyObject o = new MyObject();
    Day d = Day.TUESDAY;
    storeEnum(o, d);

  (...)


If so, the answer is yes: C2 treats this case as any other object write and generates GC barriers accordingly. Do you have any specific optimization in mind?

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

PR Comment: https://git.openjdk.org/jdk/pull/19746#issuecomment-2333674779


More information about the hotspot-gc-dev mailing list