RFR (S) 8217879: hs_err should print more instructions in hex dump
Stefan Karlsson
stefan.karlsson at oracle.com
Tue Jan 29 13:40:35 UTC 2019
While looking at this I also considered if this:
delta = max_delta;
address low = pc - delta;
while (delta > 0 && pc > low && !is_readable_pointer(low)) {
delta >>= 1;
low = pc - delta;
}
delta = max_delta;
address high = pc + delta;
while (delta > 0 && pc < high && !is_readable_pointer(high)) {
delta >>= 1;
high = pc + delta;
}
could be changed to:
delta = max_delta;
while (delta > 0 && !is_readable_pointer(pc - delta)) {
delta >>= 1;
}
address low = pc - delta;
delta = max_delta;
while (delta > 0 && !is_readable_pointer(pc + delta)) {
delta >>= 1;
}
address high = pc + delta;
to simplify the loops.
I realize that this removes the underflow/overflow checks, but I think
the compiler might actually reduce them to true, because of the
undefined behavior of underflowing/overflowing:
address low = pc - delta;
while (delta > 0 && pc > low ...) {
Since the compiler can assume that 'pc - delta' doesn't underflow it can
transform 'pc > low' to 'pc > pc - delta' and then to '0 > 0 - delta',
which is always true when delta is positive.
StefanK
On 2019-01-29 12:36, Aleksey Shipilev wrote:
> On 1/29/19 12:21 PM, Stefan Karlsson wrote:
>> For this to work as you intend it, max_delta must not be set to page size. If max_delta is set to
>> page size, the following would end up with low in Page 0 and high in Page 2:
>>
>> +--------+
>> | Page 0 | readable
>> +--------+ < 'pc' beginning of Page 1
>> | Page 1| unreadable
>> +--------+
>> | Page 2 | readable
>> +--------+
>>
>> Therefore it seems a bit off to cap with the page size in:
>> MIN2(256, min_page_size());
>>
>> Given that you use 256 today, this isn't really a problem, but maybe future proof this a bit and use
>> min_page_size / 2 to guarantee that either low or high ends up in Page 1?
> Right, thanks. To handle that corner case, let's do /2 indeed, updated webrev in-place.
>
> -Aleksey
>
More information about the hotspot-dev
mailing list