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

Backport-of: f94f957734355fe112e861d1f2f0b49df20f6b66
  • Loading branch information
adinn committed May 10, 2023
1 parent b9eca2d commit d4467a7
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 @@ -413,11 +413,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 @@ -426,6 +439,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

1 comment on commit d4467a7

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.