RFR: 8374789: C2: refactor GraphKit code that create AddP nodes for raw memory to use helper method

Christian Hagedorn chagedorn at openjdk.org
Thu Feb 12 09:31:04 UTC 2026


On Wed, 11 Feb 2026 06:13:23 GMT, Guanqiang Han <ghan at openjdk.org> wrote:

> This PR refactors GraphKit code that creates AddP nodes for raw memory to use a dedicated helper method. This avoids passing top() explicitly at call sites and improves readability.
> 
> Please review this change. Thanks!
> 
> **Test:** GHA

Thanks for cleaning this up! Now that we have the static creation methods, I think we could even go a step further and not only replace the `GraphKit` uses but actually also all the other remaining uses. Then we can make the `AddPNode` constructur private. What do you think?

src/hotspot/share/opto/addnode.hpp line 250:

> 248:   static AddPNode* make_off_heap(Node* ptr, Node* offset) {
> 249:     return make_with_base(Compile::current()->top(), ptr, offset);
> 250:   }

We should add some new lines for better readability:

Suggestion:


  static AddPNode* make_with_base(Node* base, Node* ptr, Node* offset) {
    return new AddPNode(base, ptr, offset);
  }

  static AddPNode* make_off_heap(Node* ptr, Node* offset) {
    return make_with_base(Compile::current()->top(), ptr, offset);
  }

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

PR Review: https://git.openjdk.org/jdk/pull/29666#pullrequestreview-3789708810
PR Review Comment: https://git.openjdk.org/jdk/pull/29666#discussion_r2797688793


More information about the shenandoah-dev mailing list