10
10
package org .truffleruby .language .arguments ;
11
11
12
12
import org .truffleruby .language .FrameSendingNode ;
13
+ import org .truffleruby .language .NotOptimizedWarningNode ;
13
14
import org .truffleruby .language .RubyBaseNode ;
14
15
15
16
import com .oracle .truffle .api .CompilerDirectives ;
16
17
import com .oracle .truffle .api .CompilerDirectives .CompilationFinal ;
17
18
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
18
19
import com .oracle .truffle .api .frame .FrameInstance .FrameAccess ;
19
- import com .oracle .truffle .api .frame .Frame ;
20
20
import com .oracle .truffle .api .frame .MaterializedFrame ;
21
+ import com .oracle .truffle .api .frame .VirtualFrame ;
21
22
import com .oracle .truffle .api .nodes .DirectCallNode ;
22
23
import com .oracle .truffle .api .nodes .IndirectCallNode ;
23
24
import com .oracle .truffle .api .nodes .Node ;
@@ -27,12 +28,13 @@ public class ReadCallerFrameNode extends RubyBaseNode {
27
28
28
29
private final ConditionProfile callerFrameProfile = ConditionProfile .createBinaryProfile ();
29
30
@ CompilationFinal private volatile boolean deoptWhenNotPassedCallerFrame = true ;
31
+ @ Child private NotOptimizedWarningNode notOptimizedNode = null ;
30
32
31
33
public static ReadCallerFrameNode create () {
32
34
return new ReadCallerFrameNode ();
33
35
}
34
36
35
- public MaterializedFrame execute (Frame frame ) {
37
+ public MaterializedFrame execute (VirtualFrame frame ) {
36
38
final MaterializedFrame callerFrame = RubyArguments .getCallerFrame (frame );
37
39
38
40
if (callerFrameProfile .profile (callerFrame != null )) {
@@ -53,6 +55,7 @@ private MaterializedFrame getCallerFrame() {
53
55
if (!notifyCallerToSendFrame ()) {
54
56
// If we fail to notify the call node (e.g., because it is a UncachedDispatchNode which is not handled yet),
55
57
// we don't want to deoptimize this CallTarget on every call.
58
+ getNotOptimizedNode ().warn ("Unoptimized reading of caller frame." );
56
59
deoptWhenNotPassedCallerFrame = false ;
57
60
}
58
61
return getContext ().getCallStack ().getCallerFrameIgnoringSend (FrameAccess .MATERIALIZE ).materialize ();
@@ -68,7 +71,6 @@ private boolean notifyCallerToSendFrame() {
68
71
return true ;
69
72
}
70
73
if (parent instanceof RubyBaseNode ) {
71
- new Error ().printStackTrace ();
72
74
return false ;
73
75
}
74
76
parent = parent .getParent ();
@@ -78,4 +80,11 @@ private boolean notifyCallerToSendFrame() {
78
80
return false ;
79
81
}
80
82
83
+ public NotOptimizedWarningNode getNotOptimizedNode () {
84
+ if (notOptimizedNode == null ) {
85
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
86
+ notOptimizedNode = insert (NotOptimizedWarningNode .create ());
87
+ }
88
+ return notOptimizedNode ;
89
+ }
81
90
}
0 commit comments