@@ -329,9 +329,20 @@ class NMethod : VMStructs {
329329
330330 short frameCompleteOffset () { return *(short *)at (_frame_complete_offset); }
331331
332- // TODO: offset is short on JDK 23+
333332 void setFrameCompleteOffset (int offset) {
334- *(int *)at (_frame_complete_offset) = offset;
333+ if (_nmethod_immutable_offset > 0 ) {
334+ // _frame_complete_offset is short on JDK 23+
335+ *(short *) at (_frame_complete_offset) = offset;
336+ } else {
337+ *(int *) at (_frame_complete_offset) = offset;
338+ }
339+ }
340+
341+ const char * immutableDataAt (int offset) {
342+ if (_nmethod_immutable_offset > 0 ) {
343+ return *(const char **) at (_nmethod_immutable_offset) + offset;
344+ }
345+ return at (offset);
335346 }
336347
337348 const char *code () {
@@ -344,7 +355,7 @@ class NMethod : VMStructs {
344355
345356 const char *scopes () {
346357 if (_scopes_data_offset > 0 ) {
347- return at (*(int *) at (_scopes_data_offset));
358+ return immutableDataAt (*(int *) at (_scopes_data_offset));
348359 } else {
349360 return *(const char **)at (-_scopes_data_offset);
350361 }
@@ -391,6 +402,9 @@ class NMethod : VMStructs {
391402 }
392403
393404 VMMethod **metadata () {
405+ if (_data_offset > 0 ) {
406+ return (VMMethod**) at (*(int *) at (_data_offset) + *(unsigned short *) at (_nmethod_metadata_offset));
407+ }
394408 return (VMMethod **)at (*(int *)at (_nmethod_metadata_offset));
395409 }
396410
@@ -663,26 +677,30 @@ class PcDesc {
663677
664678class ScopeDesc : VMStructs {
665679private:
666- NMethod *_nm;
680+ const unsigned char * _scopes;
681+ VMMethod** _metadata;
667682 const unsigned char *_stream;
668683 int _method_offset;
669684 int _bci;
670685
671686 int readInt ();
672687
673688public:
674- ScopeDesc (NMethod *nm) : _nm(nm) {}
689+ ScopeDesc (NMethod *nm) {
690+ _scopes = (const unsigned char *)nm->scopes ();
691+ _metadata = nm->metadata ();
692+ }
675693
676694 int decode (int offset) {
677- _stream = ( const unsigned char *)_nm-> scopes () + offset;
695+ _stream = _scopes + offset;
678696 int sender_offset = readInt ();
679697 _method_offset = readInt ();
680698 _bci = readInt () - 1 ;
681699 return sender_offset;
682700 }
683701
684702 VMMethod *method () {
685- return _method_offset > 0 ? _nm-> metadata () [_method_offset - 1 ] : NULL ;
703+ return _method_offset > 0 ? _metadata [_method_offset - 1 ] : NULL ;
686704 }
687705
688706 int bci () { return _bci; }
0 commit comments