<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div><p style="margin:0px 0px 1.2em">Hence my suggestion
        to go back a little, and see what we can do to speed up access
        for a segment created with:</p>
      <pre style="font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em;color:rgb(51,51,51);background:repeat rgb(248,248,248);display:block">MemorySegment.NULL.reinterpret(Long.MAX_VALUE)
</code></pre>
      <p style="margin:0px 0px 1.2em">(which, as Ron
        correctly points out, might not mean <em>exactly as fast as
          Unsafe</em>)</p></div></div></blockquote><div>If a sign check is genuinely causing a meaningful slow down you could potentially re-spec such a NULL->MAX memory segment to not do it. In that case a negative number would be treated as unsigned. Alternatively, the sign bit could be masked out of the address which should be faster than a compare and branch. Given that such a memory segment is already requesting that safety checks be disabled, maybe the check for negative addresses isn't that important as there are already so many ways to segfault the VM with such a segment.</div><div><br></div></div></div>