Skip to content

Commit 968ace2

Browse files
committed
Skip over any extra built-in function frames when looking for the eval caller.
1 parent b374116 commit 968ace2

File tree

1 file changed

+16
-4
lines changed
  • graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/nodes/function

1 file changed

+16
-4
lines changed

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/nodes/function/EvalNode.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,23 @@ public static String formatEvalOrigin(Node callNode, JSContext context, String d
153153

154154
@TruffleBoundary
155155
public static Node findCallNode(JSRealm realm) {
156-
JavaScriptBaseNode callNode = realm.getCallNode();
157-
if (callNode != null) {
158-
return callNode;
156+
JavaScriptBaseNode caller = realm.getCallNode();
157+
if (isValidCallNode(caller)) {
158+
return caller;
159159
}
160-
return Truffle.getRuntime().iterateFrames(frameInstance -> frameInstance.getCallNode());
160+
return Truffle.getRuntime().iterateFrames(frameInstance -> {
161+
Node callNode = frameInstance.getCallNode();
162+
// Skip built-in function frames to find the true caller.
163+
if (isValidCallNode(callNode)) {
164+
return callNode;
165+
} else {
166+
return null;
167+
}
168+
});
169+
}
170+
171+
private static boolean isValidCallNode(Node callNode) {
172+
return callNode != null && callNode.getRootNode() instanceof AbstractFunctionRootNode functionRoot && functionRoot.getActiveScriptOrModule() != null;
161173
}
162174

163175
@TruffleBoundary

0 commit comments

Comments
 (0)