On Tue, 27 Jun 2023 12:59:59 GMT, Stefan Karlsson <stef...@openjdk.org> wrote:

>> This is another version of PR https://github.com/openjdk/jdk/pull/14659 but 
>> I've added a pointer delta function in globalDefinitions.hpp to use for 
>> these pointer diff calculations that return int everywhere.  If the name is 
>> agreeable, I'll fix the other cases of this like this.  It's better than raw 
>> casts.
>> Tested with tier1-4.
>
> src/hotspot/share/code/codeBlob.inline.hpp line 36:
> 
>> 34: inline const ImmutableOopMap* CodeBlob::oop_map_for_slot(int slot, 
>> address return_address) const {
>> 35:   assert(_oop_maps != nullptr, "nope");
>> 36:   return _oop_maps->find_map_at_slot(slot, delta_as_int((intptr_t) 
>> return_address, (intptr_t) code_begin()));
> 
> Is this the only usage of `delta_as_int` that operates on `intptr_t`? If we 
> remove the casts then all usages would operate on pointers. Maybe this is an 
> indication that we only need a `pointer_delta_as_int` function, to go hand in 
> hand with the other `pointer_delta` functions?

Hm.  Maybe this would be ok. Our original idea was to make it T* not T until 
this cast.  I don't know how many other cases there are that I haven't gotten 
to yet.  But it would eliminate a cast, so that's good (unless these aren't the 
same).  Some instances have ptr - constant that gets promoted I think.
The reason we didn't pick pointer_delta_as_int because pointer_delta has 
different semantics.  pointer_delta insists on positive results.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14675#discussion_r1243892244

Reply via email to