Skip to content

Commit e335348

Browse files
committed
avoid calling getSourceSection on foreign root nodes on the fast path
1 parent c70a226 commit e335348

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,17 @@ public RootCallTarget getRootCallTarget() {
448448
@Override
449449
@ExportMessage
450450
public SourceSection getSourceLocation() {
451-
return getRootNode().getSourceSection();
451+
RootNode rootNode = getRootNode();
452+
if (rootNode instanceof PRootNode) {
453+
return ((PRootNode) rootNode).getSourceSection();
454+
} else {
455+
return getForeignSourceSection(rootNode);
456+
}
457+
}
458+
459+
@TruffleBoundary
460+
private static SourceSection getForeignSourceSection(RootNode rootNode) {
461+
return rootNode.getSourceSection();
452462
}
453463

454464
@Override

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PFunction.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.oracle.graal.python.builtins.objects.object.PythonObject;
3434
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
3535
import com.oracle.graal.python.builtins.objects.type.LazyPythonClass;
36+
import com.oracle.graal.python.nodes.PRootNode;
3637
import com.oracle.graal.python.nodes.SpecialMethodNames;
3738
import com.oracle.graal.python.nodes.attributes.WriteAttributeToDynamicObjectNode;
3839
import com.oracle.graal.python.nodes.generator.GeneratorFunctionRootNode;
@@ -207,7 +208,17 @@ public boolean isCallable() {
207208
@Override
208209
@ExportMessage
209210
public SourceSection getSourceLocation() {
210-
return getCallTarget().getRootNode().getSourceSection();
211+
RootNode rootNode = getCallTarget().getRootNode();
212+
if (rootNode instanceof PRootNode) {
213+
return ((PRootNode) rootNode).getSourceSection();
214+
} else {
215+
return getForeignSourceSection(rootNode);
216+
}
217+
}
218+
219+
@TruffleBoundary
220+
private static SourceSection getForeignSourceSection(RootNode rootNode) {
221+
return rootNode.getSourceSection();
211222
}
212223

213224
@Override

0 commit comments

Comments
 (0)