Skip to content

Commit c437b50

Browse files
committed
Avoid unconditional transferToInterpreterAndDeopt in AbstractImportNode
1 parent cf89041 commit c437b50

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/AbstractImportNode.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ protected static byte[] singleByte() {
457457
@Specialization
458458
TruffleString resolveName(VirtualFrame frame, TruffleString name, Object globals, int level,
459459
@Bind Node inliningTarget,
460+
@Cached PConstructAndRaiseNode constructAndRaiseNode,
460461
@Cached GetDictFromGlobalsNode getDictNode,
461462
@Cached PyDictGetItem getPackageOrNameNode,
462463
@Cached PyDictGetItem getSpecNode,
@@ -549,15 +550,15 @@ TruffleString resolveName(VirtualFrame frame, TruffleString name, Object globals
549550
if (path == null) {
550551
int dotIdx = indexOfCodePointNode.execute(pkgString, '.', 0, codePointLengthNode.execute(pkgString, TS_ENCODING), TS_ENCODING);
551552
if (dotIdx < 0) {
552-
throw noParentError(frame);
553+
throw noParentError(frame, constructAndRaiseNode);
553554
}
554555
pkgString = substringNode.execute(pkgString, 0, dotIdx, TS_ENCODING, true);
555556
}
556557
}
557558

558559
int lastDotIdx = codePointLengthNode.execute(pkgString, TS_ENCODING);
559560
if (lastDotIdx == 0) {
560-
throw noParentError(frame);
561+
throw noParentError(frame, constructAndRaiseNode);
561562
}
562563

563564
for (int levelUp = 1; levelUp < level; levelUp += 1) {
@@ -579,8 +580,8 @@ TruffleString resolveName(VirtualFrame frame, TruffleString name, Object globals
579580
return toStringNode.execute(sb);
580581
}
581582

582-
private static RuntimeException noParentError(VirtualFrame frame) {
583-
throw PConstructAndRaiseNode.getUncached().raiseImportError(frame, ATTEMPTED_RELATIVE_IMPORT_BEYOND_TOPLEVEL);
583+
private static RuntimeException noParentError(VirtualFrame frame, PConstructAndRaiseNode raiseNode) {
584+
throw raiseNode.raiseImportError(frame, ATTEMPTED_RELATIVE_IMPORT_BEYOND_TOPLEVEL);
584585
}
585586
}
586587

0 commit comments

Comments
 (0)