This change fixes an infinite loop in the clhsdb dumpcodecache command.

[JDK-8166317](https://bugs.openjdk.org/browse/JDK-8166317) introduced trimming 
of the unused tail of the interpreter’s stub buffer, allowing `_queue_end` to 
`equal _buffer_limit`. The native `StubQueue::next()` was updated to handle 
this case, but the corresponding change was not made to SA’s 
`StubQueue.getNext()`.

The native `StubQueue::next()` already handles this case:
https://github.com/openjdk/jdk/blob/a5d5806cb48100eff225898129bb357778d7cfa0/src/hotspot/share/code/stubs.hpp#L211-L213
This change adds the missing wrap-around condition to SA’s 
`StubQueue.getNext()`.

### Testing
- jtreg:hotspot/jtreg/serviceability/sa/


TEST                                              TOTAL  PASS  FAIL ERROR  SKIP
jtreg:test/hotspot/jtreg/serviceability/sa           80    75     0     0     5


- Manual verification: dumpcodecache returns to the clhsdb prompt, and a 
subsequent command can be executed.

$ jhsdb clhsdb --pid 13353
Attaching to process 133539, please wait...
hsdb> dumpcodecache
Disassembly for compiled method [public static int toUnsignedInt(byte) 
@0x0000ffff50175988 ] @0x0000ffff74ac8008

Method
public static int toUnsignedInt(byte) @0x0000ffff50175988 of public final class 
java.lang.Byte [signature 
Ljava/lang/Number;Ljava/lang/Comparable<Ljava/lang/Byte;>;Ljava/lang/constant/Constable;]
 @0x0000001c0005f000
<snip>
0x0000ffff746a495c:    br       x8

java.lang.NullPointerException
java.lang.NullPointerException
hsdb>


During verification, I also observed NullPointerExceptions during CodeHeap 
iteration. Source history indicates that these are caused by a separate 
null-handling regression introduced by 
[JDK-8349088](https://bugs.openjdk.org/browse/JDK-8349088). I will file a 
separate JBS issue and address that problem independently.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - Update copyright year
 - Fix SA StubQueue iteration when queue end equals buffer limit

Changes: https://git.openjdk.org/jdk/pull/33463/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33463&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8373933
  Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/33463.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33463/head:pull/33463

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

Reply via email to