Skip to content

Commit

Permalink
8307331: Correctly update line maps when class redefine rewrites byte…
Browse files Browse the repository at this point in the history
…codes

Reviewed-by: sspitsyn
  • Loading branch information
adinn committed May 5, 2023
1 parent 302bc2f commit f94f957
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/hotspot/share/runtime/relocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,24 @@ void Relocator::adjust_exception_table(int bci, int delta) {
}
}

static void print_linenumber_table(unsigned char* table) {
CompressedLineNumberReadStream stream(table);
tty->print_cr("-------------------------------------------------");
while (stream.read_pair()) {
tty->print_cr(" - line %d: %d", stream.line(), stream.bci());
}
tty->print_cr("-------------------------------------------------");
}

// The width of instruction at "bci" is changing by "delta". Adjust the line number table.
void Relocator::adjust_line_no_table(int bci, int delta) {
if (method()->has_linenumber_table()) {
CompressedLineNumberReadStream reader(method()->compressed_linenumber_table());
// if we already made adjustments then use the updated table
unsigned char *table = compressed_line_number_table();
if (table == nullptr) {
table = method()->compressed_linenumber_table();
}
CompressedLineNumberReadStream reader(table);
CompressedLineNumberWriteStream writer(64); // plenty big for most line number tables
while (reader.read_pair()) {
int adjustment = (reader.bci() > bci) ? delta : 0;
Expand All @@ -420,6 +433,10 @@ void Relocator::adjust_line_no_table(int bci, int delta) {
writer.write_terminator();
set_compressed_line_number_table(writer.buffer());
set_compressed_line_number_table_size(writer.position());
if (TraceRelocator) {
tty->print_cr("Adjusted line number table");
print_linenumber_table(compressed_line_number_table());
}
}
}

Expand Down

3 comments on commit f94f957

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adinn
Copy link
Contributor Author

@adinn adinn commented on f94f957 May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on f94f957 May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adinn the backport was successfully created on the branch adinn-backport-f94f9577 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit f94f9577 from the openjdk/jdk repository.

The commit being backported was authored by Andrew Dinn on 5 May 2023 and was reviewed by Serguei Spitsyn.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git adinn-backport-f94f9577:adinn-backport-f94f9577
$ git checkout adinn-backport-f94f9577
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git adinn-backport-f94f9577

Please sign in to comment.