@@ -396,9 +396,20 @@ class NMethod : VMStructs {
396396 return *(short *) at (_frame_complete_offset);
397397 }
398398
399- // TODO: offset is short on JDK 23+
400399 void setFrameCompleteOffset (int offset) {
401- *(int *) at (_frame_complete_offset) = offset;
400+ if (_nmethod_immutable_offset > 0 ) {
401+ // _frame_complete_offset is short on JDK 23+
402+ *(short *) at (_frame_complete_offset) = offset;
403+ } else {
404+ *(int *) at (_frame_complete_offset) = offset;
405+ }
406+ }
407+
408+ const char * immutableDataAt (int offset) {
409+ if (_nmethod_immutable_offset > 0 ) {
410+ return *(const char **) at (_nmethod_immutable_offset) + offset;
411+ }
412+ return at (offset);
402413 }
403414
404415 const char * code () {
@@ -411,7 +422,7 @@ class NMethod : VMStructs {
411422
412423 const char * scopes () {
413424 if (_scopes_data_offset > 0 ) {
414- return at (*(int *) at (_scopes_data_offset));
425+ return immutableDataAt (*(int *) at (_scopes_data_offset));
415426 } else {
416427 return *(const char **) at (-_scopes_data_offset);
417428 }
@@ -464,6 +475,9 @@ class NMethod : VMStructs {
464475 }
465476
466477 VMMethod** metadata () {
478+ if (_data_offset > 0 ) {
479+ return (VMMethod**) at (*(int *) at (_data_offset) + *(unsigned short *) at (_nmethod_metadata_offset));
480+ }
467481 return (VMMethod**) at (*(int *) at (_nmethod_metadata_offset));
468482 }
469483
@@ -556,27 +570,30 @@ class PcDesc {
556570
557571class ScopeDesc : VMStructs {
558572 private:
559- NMethod* _nm;
573+ const unsigned char * _scopes;
574+ VMMethod** _metadata;
560575 const unsigned char * _stream;
561576 int _method_offset;
562577 int _bci;
563578
564579 int readInt ();
565580
566581 public:
567- ScopeDesc (NMethod* nm) : _nm(nm) {
582+ ScopeDesc (NMethod* nm) {
583+ _scopes = (const unsigned char *)nm->scopes ();
584+ _metadata = nm->metadata ();
568585 }
569586
570587 int decode (int offset) {
571- _stream = ( const unsigned char *)_nm-> scopes () + offset;
588+ _stream = _scopes + offset;
572589 int sender_offset = readInt ();
573590 _method_offset = readInt ();
574591 _bci = readInt () - 1 ;
575592 return sender_offset;
576593 }
577594
578595 VMMethod* method () {
579- return _method_offset > 0 ? _nm-> metadata () [_method_offset - 1 ] : NULL ;
596+ return _method_offset > 0 ? _metadata [_method_offset - 1 ] : NULL ;
580597 }
581598
582599 int bci () {
0 commit comments