Skip to content

Commit

Permalink
8331404: IGV: Show line numbers for callees in properties
Browse files Browse the repository at this point in the history
  • Loading branch information
chhagedorn committed Apr 30, 2024
1 parent b128bd7 commit 4c9dda0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
47 changes: 30 additions & 17 deletions src/hotspot/share/opto/idealGraphPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions src/hotspot/share/opto/idealGraphPrinter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Matcher;
class Node;
class InlineTree;
class ciMethod;
class JVMState;

class IdealGraphPrinter : public CHeapObj<mtCompiler> {
private:
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4c9dda0

Please sign in to comment.