RFR: 8241613: Suspicious calls to MacroAssembler::null_check(Register, offset)

Matias Saavedra Silva matsaave at openjdk.org
Wed Mar 15 18:10:21 UTC 2023


On Wed, 15 Mar 2023 07:00:38 GMT, David Holmes <dholmes at openjdk.org> wrote:

> I can't attest to the correctness of this by visual inspection. Have you tested exercising this code with suitable null arrays?
> 
> Thanks.

With the way the `null_check` method currently works, a null check will not be emitted unless one is needed as defined by `needs_explicit_null_check(offset)`. This method returns true only if the offset is less than 0 or greater than the page size, which is not possible, or at least unlikely, for values like `klass_offset_in_bytes()` and `length_offset_in_bytes()`. These fields are located near the top of the structure so the offset should be much smaller than the page size. 

Using null arrays will not trigger the removed null checks and will fail by NullPointerException or ArrayIndexOutofBoundsException later. The removed calls were not doing anything. I verified this with some simple tests locally and also updated the description with the tiered tests used.

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

PR: https://git.openjdk.org/jdk/pull/13026


More information about the hotspot-runtime-dev mailing list