RFR: 8345580: Remove const from Node::_idx which is modified

Yagmur Eren duke at openjdk.org
Wed Dec 18 14:36:11 UTC 2024


On Tue, 17 Dec 2024 17:33:23 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

> @nelanbu You should probably then remove the hack with casting away the const-ness:
> 
> ```
>   void set_idx(uint new_idx) {
>     const node_idx_t* ref = &_idx;
>     *(node_idx_t*)ref = new_idx;
>   }
> ```
> 
> Could simply become
> 
> ```
>   void set_idx(uint new_idx) {
>     _idx = new_idx;
>   }
> ```
> 
> Please check if there is any similar trick anywhere else.

Thanks for highlighting this @eme64! It seems that this trick is used only here if I am not missing something.

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

PR Comment: https://git.openjdk.org/jdk/pull/22646#issuecomment-2551473598


More information about the hotspot-compiler-dev mailing list