Unsafe vs MemorySegments / Bounds checking...

Brian S O'Neill bronee at gmail.com
Wed Oct 30 14:56:30 UTC 2024


Would it be possible to remove the explicit call to Objects.requireNonNull?

In X-VarHandleSegmentView.java.template:

     @ForceInline
     static AbstractMemorySegmentImpl checkSegment(Object obb, Object 
encl, long base, boolean ro) {
         AbstractMemorySegmentImpl oo = 
(AbstractMemorySegmentImpl)Objects.requireNonNull(obb);
         oo.checkEnclosingLayout(base, (MemoryLayout)encl, ro);
         return oo;
     }

A NPE will be thrown on the next line if oo is null.



On 2024-10-30 07:42 AM, Brian S O'Neill wrote:
> Well, there's these inlining failures in FFM:
> 
> @ 6   jdk.internal.foreign.AbstractMemorySegmentImpl::<init> (21 bytes) 
>   force inline by annotation
>    @ 1   java.lang.Object::<init> (1 bytes)   failed to inline: inlining 
> too deep
> 
> 
> @ 7   jdk.internal.foreign.AbstractMemorySegmentImpl::reinterpret (14 
> bytes)   failed to inline: callee uses too much stack
> 
> 
> @ 10   java.lang.invoke.VarHandleSegmentAsChars::checkSegment (24 bytes) 
>    force inline by annotation
>    @ 1   java.util.Objects::requireNonNull (14 bytes)   force inline by 
> annotation
>      @ 8   java.lang.NullPointerException::<init> (5 bytes)   failed to 
> inline: don't inline Throwable constructors
> 
> 
>


More information about the panama-dev mailing list