Skip to content

Commit 8bc641e

Browse files
committed
8331404: IGV: Show line numbers for callees in properties
Reviewed-by: tholenstein, thartmann
1 parent 7c1fad4 commit 8bc641e

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

src/hotspot/share/opto/idealGraphPrinter.cpp

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -609,23 +609,7 @@ void IdealGraphPrinter::visit_node(Node *n, bool edges, VectorSet* temp_set) {
609609
}
610610
}
611611

612-
if (caller != nullptr) {
613-
stringStream bciStream;
614-
ciMethod* last = nullptr;
615-
int last_bci;
616-
while(caller) {
617-
if (caller->has_method()) {
618-
last = caller->method();
619-
last_bci = caller->bci();
620-
}
621-
bciStream.print("%d ", caller->bci());
622-
caller = caller->caller();
623-
}
624-
print_prop("bci", bciStream.freeze());
625-
if (last != nullptr && last->has_linenumber_table() && last_bci >= 0) {
626-
print_prop("line", last->line_number_from_bci(last_bci));
627-
}
628-
}
612+
print_bci_and_line_number(caller);
629613

630614
#ifdef ASSERT
631615
if (node->debug_orig() != nullptr) {
@@ -654,6 +638,35 @@ void IdealGraphPrinter::visit_node(Node *n, bool edges, VectorSet* temp_set) {
654638
}
655639
}
656640

641+
void IdealGraphPrinter::print_bci_and_line_number(JVMState* caller) {
642+
if (caller != nullptr) {
643+
ResourceMark rm;
644+
stringStream bciStream;
645+
stringStream lineStream;
646+
647+
// Print line and bci numbers for the callee and all entries in the call stack until we reach the root method.
648+
while (caller) {
649+
const int bci = caller->bci();
650+
bool appended_line = false;
651+
if (caller->has_method()) {
652+
ciMethod* method = caller->method();
653+
if (method->has_linenumber_table() && bci >= 0) {
654+
lineStream.print("%d ", method->line_number_from_bci(bci));
655+
appended_line = true;
656+
}
657+
}
658+
if (!appended_line) {
659+
lineStream.print("%s ", "_");
660+
}
661+
bciStream.print("%d ", bci);
662+
caller = caller->caller();
663+
}
664+
665+
print_prop("bci", bciStream.freeze());
666+
print_prop("line", lineStream.freeze());
667+
}
668+
}
669+
657670
void IdealGraphPrinter::print_field(const Node* node) {
658671
buffer[0] = 0;
659672
stringStream ss(buffer, sizeof(buffer) - 1);

src/hotspot/share/opto/idealGraphPrinter.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Matcher;
4040
class Node;
4141
class InlineTree;
4242
class ciMethod;
43+
class JVMState;
4344

4445
class IdealGraphPrinter : public CHeapObj<mtCompiler> {
4546
private:
@@ -96,9 +97,10 @@ class IdealGraphPrinter : public CHeapObj<mtCompiler> {
9697
Compile *C;
9798
double _max_freq;
9899

99-
void print_method(ciMethod *method, int bci, InlineTree *tree);
100-
void print_inline_tree(InlineTree *tree);
101-
void visit_node(Node *n, bool edges, VectorSet* temp_set);
100+
void print_method(ciMethod* method, int bci, InlineTree* tree);
101+
void print_inline_tree(InlineTree* tree);
102+
void visit_node(Node* n, bool edges, VectorSet* temp_set);
103+
void print_bci_and_line_number(JVMState* caller);
102104
void print_field(const Node* node);
103105
ciField* get_field(const Node* node);
104106
ciField* find_source_field_of_array_access(const Node* node, uint& depth);

0 commit comments

Comments
 (0)