On Thu, 1 Sep 2022 21:12:08 GMT, Chris Plummer <[email protected]> wrote:
>> src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/DebuggerBase.java
>> line 242:
>>
>>> 240: private boolean canUsePageCacheFor64bitRead(long address) {
>>> 241: long pageMask = ~(pageSize - 1);
>>> 242: if ((address & pageMask) != ((address + 4) & pageMask)) {
>>
>> This looks a bit over-complicated.
>> Maybe something like
>> ` long pageMask = pageSize - 1;
>> if ((address & pageMask) > (pageSize - 8)) {
>> return false;
>> }`
>
> I tinkered with this code quite a bit before I had something that both worked
> and I liked. I don't know that your approach is actually any simpler, and at
> the moment I still prefer mine, but that might just be because I'm more
> familiar with it. However, it does seem that there should be a more elegant
> way of doing this.
Your code works only for the exact case - address of 64bit value points to the
last 32bit of the page.
My idea is to use more generic approach - check that the whole value is in the
page, i.e. this is special case of more common
boolean canUsePageCacheForRead(long address, int bits) {
long pageMask = pageSize - 1;
return ((address & pageMask) <= (pageSize - bits/8));
}
But I have no strong objections, feel free to keep your version
-------------
PR: https://git.openjdk.org/jdk/pull/10090