Skip to content

Commit 67a6429

Browse files
committed
Type all frames as MaterializedFrame in FindThreadAndFrameLocalStorageNode
* They can never be VirtualFrame.
1 parent b7a173d commit 67a6429

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/main/java/org/truffleruby/language/threadlocal/FindThreadAndFrameLocalStorageNode.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
1818
import com.oracle.truffle.api.dsl.Cached;
1919
import com.oracle.truffle.api.dsl.Specialization;
20-
import com.oracle.truffle.api.frame.Frame;
2120
import com.oracle.truffle.api.frame.FrameDescriptor;
2221
import com.oracle.truffle.api.frame.FrameSlot;
2322
import com.oracle.truffle.api.frame.FrameSlotKind;
@@ -64,7 +63,7 @@ protected StorageInFrameFinder(FrameDescriptor fd, FrameSlot fs, Object defaultV
6463
this.depth = depth;
6564
}
6665

67-
public boolean matches(Frame callerFrame) {
66+
public boolean matches(MaterializedFrame callerFrame) {
6867
return callerFrame != null && callerFrame.getFrameDescriptor() == descriptor;
6968
}
7069

@@ -73,8 +72,7 @@ public ThreadAndFrameLocalStorage getStorage(RubyContext context, MaterializedFr
7372
return getStorageFromFrame(context, frame, slot, defaultValue, true);
7473
}
7574

76-
public static StorageInFrameFinder of(RubyContext context, Frame aFrame, String variableName) {
77-
MaterializedFrame callerFrame = aFrame.materialize();
75+
public static StorageInFrameFinder of(RubyContext context, MaterializedFrame callerFrame, String variableName) {
7876
FrameDescriptor descriptor = callerFrame.getFrameDescriptor();
7977

8078
int depth = getVariableDeclarationFrameDepth(callerFrame, variableName);
@@ -86,7 +84,7 @@ public static StorageInFrameFinder of(RubyContext context, Frame aFrame, String
8684
}
8785

8886
private static int getVariableDeclarationFrameDepth(MaterializedFrame topFrame, String variableName) {
89-
Frame frame = topFrame;
87+
MaterializedFrame frame = topFrame;
9088
int count = 0;
9189

9290
while (true) {
@@ -95,7 +93,7 @@ private static int getVariableDeclarationFrameDepth(MaterializedFrame topFrame,
9593
return count;
9694
}
9795

98-
final Frame nextFrame = RubyArguments.getDeclarationFrame(frame);
96+
final MaterializedFrame nextFrame = RubyArguments.getDeclarationFrame(frame);
9997
if (nextFrame != null) {
10098
frame = nextFrame;
10199
count++;
@@ -105,16 +103,16 @@ private static int getVariableDeclarationFrameDepth(MaterializedFrame topFrame,
105103
}
106104
}
107105

108-
private static Frame getVariableDeclarationFrame(Frame topFrame, String variableName) {
109-
Frame frame = topFrame;
106+
private static MaterializedFrame getVariableDeclarationFrame(MaterializedFrame topFrame, String variableName) {
107+
MaterializedFrame frame = topFrame;
110108

111109
while (true) {
112110
final FrameSlot slot = getVariableSlot(frame, variableName);
113111
if (slot != null) {
114112
return frame;
115113
}
116114

117-
final Frame nextFrame = RubyArguments.getDeclarationFrame(frame);
115+
final MaterializedFrame nextFrame = RubyArguments.getDeclarationFrame(frame);
118116
if (nextFrame != null) {
119117
frame = nextFrame;
120118
} else {
@@ -123,7 +121,7 @@ private static Frame getVariableDeclarationFrame(Frame topFrame, String variable
123121
}
124122
}
125123

126-
private static FrameSlot getVariableSlot(Frame frame, String variableName) {
124+
private static FrameSlot getVariableSlot(MaterializedFrame frame, String variableName) {
127125
final FrameDescriptor descriptor = frame.getFrameDescriptor();
128126
synchronized (descriptor) {
129127
return descriptor.findFrameSlot(variableName);
@@ -139,16 +137,16 @@ private static FrameSlot getVariableFrameSlotWrite(MaterializedFrame frame, Stri
139137
}
140138

141139
@TruffleBoundary
142-
private static ThreadAndFrameLocalStorage getStorageSearchingDeclarations(RubyContext context, Frame topFrame, String variableName) {
143-
final Frame frame = getVariableDeclarationFrame(topFrame, variableName);
140+
private static ThreadAndFrameLocalStorage getStorageSearchingDeclarations(RubyContext context, MaterializedFrame topFrame, String variableName) {
141+
final MaterializedFrame frame = getVariableDeclarationFrame(topFrame, variableName);
144142
if (frame == null) {
145143
return null;
146144
}
147145
FrameSlot slot = getVariableFrameSlotWrite(frame.materialize(), variableName);
148146
return getStorageFromFrame(context, frame, slot, frame.getFrameDescriptor().getDefaultValue(), true);
149147
}
150148

151-
private static ThreadAndFrameLocalStorage getStorageFromFrame(RubyContext context, Frame frame, FrameSlot slot, Object defaultValue, boolean add) {
149+
private static ThreadAndFrameLocalStorage getStorageFromFrame(RubyContext context, MaterializedFrame frame, FrameSlot slot, Object defaultValue, boolean add) {
152150
final Object previousMatchData = frame.getValue(slot);
153151

154152
if (previousMatchData == defaultValue) { // Never written to

0 commit comments

Comments
 (0)