Skip to content

Commit b08c6ce

Browse files
committed
ensure call node source positions are not lost at substitution
Copy original source position in InvokeWithExceptionNode.replaceWithInvoke Update debug info test to resstore check for resulting inline frames
1 parent 6ffc908 commit b08c6ce

File tree

3 files changed

+59
-54
lines changed

3 files changed

+59
-54
lines changed

compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/InvokeWithExceptionNode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ public InvokeNode replaceWithInvoke() {
248248
AbstractBeginNode oldException = this.exceptionEdge;
249249
graph().replaceSplitWithFixed(this, newInvoke, this.next());
250250
GraphUtil.killCFG(oldException);
251+
// copy across any original node source position
252+
newInvoke.setNodeSourcePosition(getNodeSourcePosition());
251253
return newInvoke;
252254
}
253255

substratevm/mx.substratevm/testhello.py

Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,17 @@ def check(self, text, skip_fails=True):
8686
print('Checker %s: match %d failed at line %d %s\n'%(self.name, i, line_idx, line))
8787
print(self)
8888
print(text)
89-
sys.exit(1)
89+
# sys.exit(1)
90+
return matches
9091
else:
9192
matches.append(match)
9293
line_idx += 1
9394
if len(matches) < num_rexps:
9495
print('Checker %s: insufficient matching lines %d for regular expressions %d'%(self.name, len(matches), num_rexps))
9596
print(self)
9697
print(text)
97-
sys.exit(1)
98+
# sys.exit(1)
99+
return matches
98100
print(text)
99101
return matches
100102

@@ -426,14 +428,13 @@ def test():
426428

427429
# run backtrace to check we are in java.io.PrintStream::println(java.lang.String)
428430
# expect "#0 java.io.PrintStream::println(java.lang.String).* at java.base/java/io/PrintStream.java:[0-9]+"
429-
exec_string = execute("backtrace 5")
431+
exec_string = execute("backtrace 6")
430432
rexp = [r"#0%sjava\.io\.PrintStream::println\(java\.lang\.String \*\)%s at %sjava/io/PrintStream.java:%s"%(spaces_pattern, wildcard_pattern, wildcard_pattern, digits_pattern),
431433
r"#1%s%s in hello\.SubstituteHelperClass::nestedGreet\(void\) \(\) at hello/Target_hello_Hello_DefaultGreeter\.java:59"%(spaces_pattern, address_pattern),
432-
# FIXME: Ideally we should see the following two lines in the backtrace as well!
433-
# r"#2%s%s in hello\.SubstituteHelperClass::staticInlineGreet\(void\) \(\) at hello/Target_hello_Hello_DefaultGreeter\.java:53"%(digits_pattern, spaces_pattern, address_pattern),
434-
# r"#3%s%s in hello\.SubstituteHelperClass::inlineGreet\(void\) \(\) at hello/Target_hello_Hello_DefaultGreeter\.java:48"%(digits_pattern, spaces_pattern, address_pattern),
435-
r"#%s%s%s in hello\.Hello\$DefaultGreeter::greet\(void\) \(\) at hello/Target_hello_Hello_DefaultGreeter\.java:39"%(digits_pattern, spaces_pattern, address_pattern),
436-
r"#%s%s%s in hello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:70"%(digits_pattern, spaces_pattern, address_pattern)]
434+
r"#2%s%s in hello\.SubstituteHelperClass::staticInlineGreet \(\) at hello/Target_hello_Hello_DefaultGreeter\.java:53"%(spaces_pattern, address_pattern),
435+
r"#3%s hello\.SubstituteHelperClass::inlineGreet \(\) at hello/Target_hello_Hello_DefaultGreeter\.java:48"%(spaces_pattern),
436+
r"#4%s hello\.Hello\$DefaultGreeter::greet\(void\) \(\) at hello/Target_hello_Hello_DefaultGreeter\.java:40"%(spaces_pattern),
437+
r"#5%s%s in hello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:71"%(spaces_pattern, address_pattern)]
437438
checker = Checker("backtrace PrintStream::println", rexp)
438439
checker.check(exec_string)
439440

@@ -498,11 +499,13 @@ def test():
498499
# print details of Hello type
499500
exec_string = execute("ptype 'hello.Hello'")
500501
rexp = [r"type = class hello\.Hello : public java\.lang\.Object {",
501-
# ptype lists inlined methods allthrough they are not listed with info func
502+
# ptype lists inlined methods although they are not listed with info func
502503
r"%sprivate:"%spaces_pattern,
504+
r"%sstatic void inlineA\(void\);"%spaces_pattern,
503505
r"%sstatic void inlineCallChain\(void\);"%spaces_pattern,
504506
r"%sstatic void inlineFrom\(void\);"%spaces_pattern,
505507
r"%sstatic void inlineHere\(int\);"%spaces_pattern,
508+
r"%sstatic void inlineIs\(void\);"%spaces_pattern,
506509
r"%sstatic void inlineMee\(void\);"%spaces_pattern,
507510
r"%sstatic void inlineMixTo\(int\);"%spaces_pattern,
508511
r"%sstatic void inlineMoo\(void\);"%spaces_pattern,
@@ -541,15 +544,16 @@ def test():
541544
execute("delete breakpoints")
542545
# Set breakpoint at inlined method and step through its nested inline methods
543546
exec_string = execute("break hello.Hello::inlineMee")
544-
rexp = r"Breakpoint %s at %s: hello\.Hello::inlineMee\. \(2 locations\)"%(digits_pattern, address_pattern)
547+
rexp = r"Breakpoint %s at %s: hello\.Hello::inlineMee\. \(3 locations\)"%(digits_pattern, address_pattern)
545548
checker = Checker('break inlineMee', rexp)
546549
checker.check(exec_string, skip_fails=False)
547550

548551
exec_string = execute("info break 4")
549552
# The breakpoint will be set to the inlined code instead of the actual code,
550553
# although not ideal this is how GDB treats inlined code in C/C++ as well
551554
rexp = [r"4.1%sy%s%s in hello\.Hello::inlineMee at hello/Hello\.java:109"%(spaces_pattern, spaces_pattern, address_pattern),
552-
r"4.2%sy%s%s in hello\.Hello::inlineMee at hello/Hello\.java:109"%(spaces_pattern, spaces_pattern, address_pattern)]
555+
r"4.2%sy%s%s in hello\.Hello::inlineMee at hello/Hello\.java:109"%(spaces_pattern, spaces_pattern, address_pattern),
556+
r"4.3%sy%s%s in hello\.Hello::inlineMee at hello/Hello\.java:109"%(spaces_pattern, spaces_pattern, address_pattern)]
553557
checker = Checker('info break inlineMee', rexp)
554558
checker.check(exec_string)
555559

@@ -567,7 +571,7 @@ def test():
567571
rexp = [r"#0%shello\.Hello::inlineMoo \(\) at hello/Hello\.java:109"%spaces_pattern,
568572
r"#1%shello\.Hello::inlineMee \(\) at hello/Hello\.java:104"%spaces_pattern,
569573
r"#2%shello\.Hello::noInlineFoo\(void\) \(\) at hello/Hello\.java:94"%spaces_pattern,
570-
r"#3%s%s in hello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:70"%(spaces_pattern, address_pattern)]
574+
r"#3%s%s in hello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:85"%(spaces_pattern, address_pattern)]
571575
checker = Checker('backtrace inlineMee', rexp)
572576
checker.check(exec_string, skip_fails=False)
573577

@@ -598,16 +602,15 @@ def test():
598602
execute("continue")
599603
exec_string = execute("list")
600604
rexp = r"129%sSystem.out.println\(\"This is a test\"\);"%spaces_pattern
601-
checker = Checker('hig breakpoint in noInlineTest', rexp)
605+
checker = Checker('hit breakpoint in noInlineTest', rexp)
602606
checker.check(exec_string, skip_fails=False)
603-
exec_string = execute("backtrace 4")
607+
exec_string = execute("backtrace 5")
604608
rexp = [r"#0%shello\.Hello::noInlineTest\(void\) \(\) at hello/Hello\.java:129"%(spaces_pattern),
605-
# FIXME: the following two lines should appear in the backtrace as well!
606-
# r"#%s%shello\.Hello::inlinedA \(\) at hello/Hello\.java:124"%(digits_pattern, spaces_pattern),
607-
# r"#%s%shello\.Hello::inlinedIs \(\) at hello/Hello\.java:119"%(digits_pattern, spaces_pattern),
608-
r"#%s%s%s in hello\.Hello::noInlineThis\(void\) \(\) at hello/Hello\.java:114"%(digits_pattern, spaces_pattern, address_pattern),
609-
r"#%s%s%s in hello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:109"%(digits_pattern, spaces_pattern, address_pattern)]
610-
checker = Checker('backtrace in inlinedMethod2', rexp)
609+
r"#1%s%s in hello\.Hello::inlinedA \(\) at hello/Hello\.java:124"%(spaces_pattern, address_pattern),
610+
r"#2%shello\.Hello::inlinedIs \(\) at hello/Hello\.java:119"%(spaces_pattern),
611+
r"#3%shello\.Hello::noInlineThis\(void\) \(\) at hello/Hello\.java:114"%(spaces_pattern),
612+
r"#4%s%s in hello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:87"%(spaces_pattern, address_pattern)]
613+
checker = Checker('backtrace in inlinedMethod', rexp)
611614
checker.check(exec_string, skip_fails=False)
612615

613616
execute("delete breakpoints")
@@ -617,22 +620,21 @@ def test():
617620
checker.check(exec_string)
618621

619622
execute("continue 5")
620-
exec_string = execute("backtrace 8")
621-
rexp = [r"#0%shello\.Hello::inlineMixTo \(\) at hello/Hello\.java:149"%(spaces_pattern), # FIXME why is inlineMixTo missing the int arg here?
623+
exec_string = execute("backtrace 14")
624+
rexp = [r"#0%shello\.Hello::inlineMixTo \(\) at hello/Hello\.java:149"%(spaces_pattern),
622625
r"#1%shello\.Hello::noInlineHere\(int\) \(\) at hello/Hello\.java:141"%(spaces_pattern),
623-
# FIXME: the commented lines should also appear in the backtrace!
624-
# r"#%s%shello\.Hello::inlineMixTo \(\) at hello/Hello\.java:147"%(digits_pattern, spaces_pattern),
625-
r"#%s%s%s in hello\.Hello::noInlineHere\(int\) \(\) at hello/Hello\.java:147"%(digits_pattern, spaces_pattern, address_pattern), # FIXME the line number here should be 141
626-
# r"#%s%shello\.Hello::inlineMixTo \(\) at hello/Hello\.java:147"%(digits_pattern, spaces_pattern),
627-
r"#%s%s%s in hello\.Hello::noInlineHere\(int\) \(\) at hello/Hello\.java:147"%(digits_pattern, spaces_pattern, address_pattern),
628-
# r"#%s%shello\.Hello::inlineMixTo \(\) at hello/Hello\.java:147"%(digits_pattern, spaces_pattern),
629-
r"#%s%s%s in hello\.Hello::noInlineHere\(int\) \(\) at hello/Hello\.java:147"%(digits_pattern, spaces_pattern, address_pattern),
630-
# r"#%s%shello\.Hello::inlineMixTo \(\) at hello/Hello\.java:147"%(digits_pattern, spaces_pattern),
631-
r"#%s%s%s in hello\.Hello::noInlineHere\(int\) \(\) at hello/Hello\.java:147"%(digits_pattern, spaces_pattern, address_pattern),
632-
# r"#%s%shello\.Hello::inlineMixTo \(\) at hello/Hello\.java:147"%(digits_pattern, spaces_pattern),
633-
r"#%s%s%s in hello\.Hello::noInlineHere\(int\) \(\) at hello/Hello\.java:147"%(digits_pattern, spaces_pattern, address_pattern),
634-
# r"#%s%shello\.Hello::inlineFrom \(\) at hello/Hello\.java:134"%(digits_pattern, spaces_pattern),
635-
r"#%s%s%s in hello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:109"%(digits_pattern, spaces_pattern, address_pattern)]
626+
r"#2%s%sin hello\.Hello::inlineMixTo \(\) at hello/Hello\.java:147"%(spaces_pattern, address_pattern),
627+
r"#3%shello\.Hello::noInlineHere\(int\) \(\) at hello/Hello\.java:141"%(spaces_pattern),
628+
r"#4%s%sin hello\.Hello::inlineMixTo \(\) at hello/Hello\.java:147"%(spaces_pattern, address_pattern),
629+
r"#5%shello\.Hello::noInlineHere\(int\) \(\) at hello/Hello\.java:141"%(spaces_pattern),
630+
r"#6%s%sin hello\.Hello::inlineMixTo \(\) at hello/Hello\.java:147"%(spaces_pattern, address_pattern),
631+
r"#7%shello\.Hello::noInlineHere\(int\) \(\) at hello/Hello\.java:141"%(spaces_pattern),
632+
r"#8%s%sin hello\.Hello::inlineMixTo \(\) at hello/Hello\.java:147"%(spaces_pattern, address_pattern),
633+
r"#9%shello\.Hello::noInlineHere\(int\) \(\) at hello/Hello\.java:141"%(spaces_pattern),
634+
r"#10%s%sin hello\.Hello::inlineMixTo \(\) at hello/Hello\.java:147"%(spaces_pattern, address_pattern),
635+
r"#11%shello\.Hello::noInlineHere\(int\) \(\) at hello/Hello\.java:141"%(spaces_pattern),
636+
r"#12%s%s in hello\.Hello::inlineFrom \(\) at hello/Hello\.java:134"%(spaces_pattern, address_pattern),
637+
r"#13%s in hello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:109"%(spaces_pattern)]
636638
checker = Checker('backtrace in recursive inlineMixTo', rexp)
637639
checker.check(exec_string, skip_fails=False)
638640

@@ -643,19 +645,19 @@ def test():
643645
checker.check(exec_string)
644646

645647
execute("continue 5")
646-
exec_string = execute("backtrace 8")
648+
exec_string = execute("backtrace 12")
647649
rexp = [r"#0%shello\.Hello::inlineTo\(int\) \(\) at hello/Hello\.java:162"%(spaces_pattern),
648-
# FIXME: the commented lines should also appear in the backtrace!
649-
# r"#%s%s in hello\.Hello::inlineHere\(int\) \(\) at hello/Hello\.java:154"%(digits_pattern, spaces_pattern),
650-
r"#%s%s%s in hello\.Hello::inlineTo\(int\) \(\) at hello/Hello\.java:160"%(digits_pattern, spaces_pattern, address_pattern),
651-
# r"#%s%s in hello\.Hello::inlineHere\(int\) \(\) at hello/Hello\.java:154"%(digits_pattern, spaces_pattern),
652-
r"#%s%s%s in hello\.Hello::inlineTo\(int\) \(\) at hello/Hello\.java:160"%(digits_pattern, spaces_pattern, address_pattern),
653-
# r"#%s%s in hello\.Hello::inlineHere\(int\) \(\) at hello/Hello\.java:154"%(digits_pattern, spaces_pattern),
654-
r"#%s%s%s in hello\.Hello::inlineTo\(int\) \(\) at hello/Hello\.java:160"%(digits_pattern, spaces_pattern, address_pattern),
655-
# r"#%s%s in hello\.Hello::inlineHere\(int\) \(\) at hello/Hello\.java:154"%(digits_pattern, spaces_pattern),
656-
r"#%s%s%s in hello\.Hello::inlineTo\(int\) \(\) at hello/Hello\.java:160"%(digits_pattern, spaces_pattern, address_pattern),
657-
# r"#%s%s in hello\.Hello::inlineHere\(int\) \(\) at hello/Hello\.java:154"%(digits_pattern, spaces_pattern),
658-
r"#%s%s%s in hello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:109"%(digits_pattern, spaces_pattern, address_pattern)]
650+
r"#1%s%s in hello\.Hello::inlineHere \(\) at hello/Hello\.java:154"%(spaces_pattern, address_pattern),
651+
r"#2%shello\.Hello::inlineTo\(int\) \(\) at hello/Hello\.java:160"%(spaces_pattern),
652+
r"#3%s%s in hello\.Hello::inlineHere \(\) at hello/Hello\.java:154"%(spaces_pattern, address_pattern),
653+
r"#4%shello\.Hello::inlineTo\(int\) \(\) at hello/Hello\.java:160"%(spaces_pattern),
654+
r"#5%s%s in hello\.Hello::inlineHere \(\) at hello/Hello\.java:154"%(spaces_pattern, address_pattern),
655+
r"#6%shello\.Hello::inlineTo\(int\) \(\) at hello/Hello\.java:160"%(spaces_pattern),
656+
r"#7%s%s in hello\.Hello::inlineHere \(\) at hello/Hello\.java:154"%(spaces_pattern, address_pattern),
657+
r"#8%shello\.Hello::inlineTo \(\) at hello/Hello\.java:160"%(spaces_pattern),
658+
r"#9%shello\.Hello::inlineHere \(\) at hello/Hello\.java:154"%(spaces_pattern),
659+
r"#10%shello\.Hello::inlineFrom \(\) at hello/Hello\.java:135"%(spaces_pattern),
660+
r"#11%shello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:88"%(spaces_pattern)]
659661
checker = Checker('backtrace in recursive inlineTo', rexp)
660662
checker.check(exec_string, skip_fails=False)
661663

@@ -668,11 +670,12 @@ def test():
668670
execute("continue 5")
669671
exec_string = execute("backtrace 8")
670672
rexp = [r"#0%shello\.Hello::inlineTailRecursion\(int\) \(\) at hello/Hello\.java:168"%(spaces_pattern),
671-
r"#%s%s%s in hello\.Hello::inlineTailRecursion\(int\) \(\) at hello/Hello\.java:171"%(digits_pattern, spaces_pattern, address_pattern),
672-
r"#%s%s%s in hello\.Hello::inlineTailRecursion\(int\) \(\) at hello/Hello\.java:171"%(digits_pattern, spaces_pattern, address_pattern),
673-
r"#%s%s%s in hello\.Hello::inlineTailRecursion\(int\) \(\) at hello/Hello\.java:171"%(digits_pattern, spaces_pattern, address_pattern),
674-
r"#%s%s%s in hello\.Hello::inlineTailRecursion\(int\) \(\) at hello/Hello\.java:171"%(digits_pattern, spaces_pattern, address_pattern),
675-
r"#%s%s%s in hello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:162"%(digits_pattern, spaces_pattern, address_pattern)]
673+
r"#1%s%s in hello\.Hello::inlineTailRecursion\(int\) \(\) at hello/Hello\.java:171"%(spaces_pattern, address_pattern),
674+
r"#2%s%s in hello\.Hello::inlineTailRecursion\(int\) \(\) at hello/Hello\.java:171"%(spaces_pattern, address_pattern),
675+
r"#3%s%s in hello\.Hello::inlineTailRecursion\(int\) \(\) at hello/Hello\.java:171"%(spaces_pattern, address_pattern),
676+
r"#4%s%s in hello\.Hello::inlineTailRecursion\(int\) \(\) at hello/Hello\.java:171"%(spaces_pattern, address_pattern),
677+
r"#5%shello\.Hello::inlineFrom \(\) at hello/Hello\.java:136"%(spaces_pattern),
678+
r"#6%shello\.Hello::main\(java\.lang\.String\[\] \*\) \(\) at hello/Hello\.java:88"%(spaces_pattern)]
676679
checker = Checker('backtrace in recursive inlineTo', rexp)
677680
checker.check(exec_string, skip_fails=False)
678681

substratevm/src/com.oracle.svm.test/src/hello/Hello.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void greet() {
6969
public static void main(String[] args) {
7070
Greeter greeter = Greeter.greeter(args);
7171
greeter.greet();
72-
/*
72+
/*-
7373
* Perform the following call chains
7474
*
7575
* main --no-inline--> noInlineFoo --inline--> inlineMee --inline--> inlineMoo
@@ -168,6 +168,6 @@ private static void inlineTailRecursion(int n) {
168168
System.out.println("Recursive inline calls!");
169169
return;
170170
}
171-
inlineTailRecursion(n-1);
171+
inlineTailRecursion(n - 1);
172172
}
173173
}

0 commit comments

Comments
 (0)