8331404: IGV: Show line numbers for callees in properties

Reviewed-by: tholenstein, thartmann
This commit is contained in:
Christian Hagedorn 2024-05-03 05:49:39 +00:00
parent 7c1fad4fb6
commit 8bc641ebe7
2 changed files with 35 additions and 20 deletions

@ -609,23 +609,7 @@ void IdealGraphPrinter::visit_node(Node *n, bool edges, VectorSet* temp_set) {
}
}
if (caller != nullptr) {
stringStream bciStream;
ciMethod* last = nullptr;
int last_bci;
while(caller) {
if (caller->has_method()) {
last = caller->method();
last_bci = caller->bci();
}
bciStream.print("%d ", caller->bci());
caller = caller->caller();
}
print_prop("bci", bciStream.freeze());
if (last != nullptr && last->has_linenumber_table() && last_bci >= 0) {
print_prop("line", last->line_number_from_bci(last_bci));
}
}
print_bci_and_line_number(caller);
#ifdef ASSERT
if (node->debug_orig() != nullptr) {
@ -654,6 +638,35 @@ void IdealGraphPrinter::visit_node(Node *n, bool edges, VectorSet* temp_set) {
}
}
void IdealGraphPrinter::print_bci_and_line_number(JVMState* caller) {
if (caller != nullptr) {
ResourceMark rm;
stringStream bciStream;
stringStream lineStream;
// Print line and bci numbers for the callee and all entries in the call stack until we reach the root method.
while (caller) {
const int bci = caller->bci();
bool appended_line = false;
if (caller->has_method()) {
ciMethod* method = caller->method();
if (method->has_linenumber_table() && bci >= 0) {
lineStream.print("%d ", method->line_number_from_bci(bci));
appended_line = true;
}
}
if (!appended_line) {
lineStream.print("%s ", "_");
}
bciStream.print("%d ", bci);
caller = caller->caller();
}
print_prop("bci", bciStream.freeze());
print_prop("line", lineStream.freeze());
}
}
void IdealGraphPrinter::print_field(const Node* node) {
buffer[0] = 0;
stringStream ss(buffer, sizeof(buffer) - 1);

@ -40,6 +40,7 @@ class Matcher;
class Node;
class InlineTree;
class ciMethod;
class JVMState;
class IdealGraphPrinter : public CHeapObj<mtCompiler> {
private:
@ -96,9 +97,10 @@ class IdealGraphPrinter : public CHeapObj<mtCompiler> {
Compile *C;
double _max_freq;
void print_method(ciMethod *method, int bci, InlineTree *tree);
void print_inline_tree(InlineTree *tree);
void visit_node(Node *n, bool edges, VectorSet* temp_set);
void print_method(ciMethod* method, int bci, InlineTree* tree);
void print_inline_tree(InlineTree* tree);
void visit_node(Node* n, bool edges, VectorSet* temp_set);
void print_bci_and_line_number(JVMState* caller);
void print_field(const Node* node);
ciField* get_field(const Node* node);
ciField* find_source_field_of_array_access(const Node* node, uint& depth);