Skip to content

Commit 7501b55

Browse files
eregonaardvark179
authored andcommitted
Cleanups
1 parent 6e14eec commit 7501b55

File tree

13 files changed

+77
-172
lines changed

13 files changed

+77
-172
lines changed

src/main/java/org/truffleruby/Layouts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ public abstract class Layouts {
2727

2828
// Frame slot name for special variable storage.
2929

30-
public static final String SPECIAL_VARIABLLE_STORAGE = TranslatorEnvironment.TEMP_PREFIX + "$~_";
30+
public static final String SPECIAL_VARIABLES_STORAGE = TranslatorEnvironment.TEMP_PREFIX + "$~_";
3131

3232
}

src/main/java/org/truffleruby/core/CoreLibrary.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ public class CoreLibrary {
227227

228228
public final FrameDescriptor emptyDescriptor;
229229
/* Some things (such as procs created from symbols) require a declaration frame, and this should include a slot for
230-
* special variable storage. This frame descriptor should be used for those frames to provide a constant frame shape
231-
* in those cases. */
230+
* special variable storage. This frame descriptor should be used for those frames to provide a constant frame
231+
* descriptor in those cases. */
232232
public final FrameDescriptor emptyDeclarationDescriptor;
233233
public final FrameSlot emptyDeclarationSpecialVariableSlot;
234234

@@ -594,7 +594,7 @@ public CoreLibrary(RubyContext context) {
594594
emptyDescriptor = new FrameDescriptor(Nil.INSTANCE);
595595
emptyDeclarationDescriptor = new FrameDescriptor(Nil.INSTANCE);
596596
emptyDeclarationSpecialVariableSlot = emptyDeclarationDescriptor
597-
.addFrameSlot(Layouts.SPECIAL_VARIABLLE_STORAGE);
597+
.addFrameSlot(Layouts.SPECIAL_VARIABLES_STORAGE);
598598
argv = new RubyArray(arrayClass, RubyLanguage.arrayShape, ArrayStoreLibrary.INITIAL_STORE, 0);
599599

600600
globalVariables = new GlobalVariables();

src/main/java/org/truffleruby/core/kernel/TruffleKernelNodes.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ public abstract static class GetSpecialVariableStorage extends RubyContextNode {
187187
public abstract SpecialVariableStorage execute(VirtualFrame frame);
188188

189189
@Specialization(
190-
guards = { "descriptor == frame.getFrameDescriptor()", "slot != null" },
191-
limit = "1",
192-
assumptions = "frameAssumption")
193-
protected SpecialVariableStorage executeGetStorage(VirtualFrame frame,
190+
guards = { "frame.getFrameDescriptor() == descriptor", "slot != null" },
191+
assumptions = "frameAssumption",
192+
limit = "1")
193+
protected SpecialVariableStorage sameFrame(VirtualFrame frame,
194194
@Cached("frame.getFrameDescriptor()") FrameDescriptor descriptor,
195-
@Cached("descriptor.findFrameSlot(SPECIAL_VARIABLLE_STORAGE)") FrameSlot slot,
195+
@Cached("descriptor.findFrameSlot(SPECIAL_VARIABLES_STORAGE)") FrameSlot slot,
196196
@Cached("descriptor.getVersion()") Assumption frameAssumption) {
197197
Object storage = FrameUtil.getObjectSafe(frame, slot);
198198
if (storage == nil) {
@@ -204,16 +204,16 @@ protected SpecialVariableStorage executeGetStorage(VirtualFrame frame,
204204
}
205205

206206
@Specialization(
207-
guards = { "descriptor == frame.getFrameDescriptor()", "slot == null", "declarationFrameSlot != null" },
207+
guards = { "frame.getFrameDescriptor() == descriptor", "slot == null", "declarationFrameSlot != null" },
208208
assumptions = "frameAssumption",
209209
limit = "1")
210-
protected SpecialVariableStorage executeGetStorageDeclarationFrame(VirtualFrame frame,
210+
protected SpecialVariableStorage declarationFrame(VirtualFrame frame,
211211
@Cached("frame.getFrameDescriptor()") FrameDescriptor descriptor,
212-
@Cached("descriptor.findFrameSlot(SPECIAL_VARIABLLE_STORAGE)") FrameSlot slot,
212+
@Cached("descriptor.findFrameSlot(SPECIAL_VARIABLES_STORAGE)") FrameSlot slot,
213213
@Cached("declarationDepth(frame)") int declarationFrameDepth,
214214
@Cached("declarationSlot(frame)") FrameSlot declarationFrameSlot,
215215
@Cached("declarationDescriptor(frame).getVersion()") Assumption frameAssumption) {
216-
VirtualFrame storageFrame = RubyArguments.getDeclarationFrame(frame, declarationFrameDepth);
216+
MaterializedFrame storageFrame = RubyArguments.getDeclarationFrame(frame, declarationFrameDepth);
217217

218218
Object storage = FrameUtil.getObjectSafe(storageFrame, declarationFrameSlot);
219219
if (storage == nil) {
@@ -225,19 +225,19 @@ protected SpecialVariableStorage executeGetStorageDeclarationFrame(VirtualFrame
225225
}
226226

227227
@Specialization(
228-
guards = { "descriptor == frame.getFrameDescriptor()", "slot == null", "declarationFrameSlot == null" },
228+
guards = { "frame.getFrameDescriptor() == descriptor", "slot == null", "declarationFrameSlot == null" },
229229
assumptions = "frameAssumption",
230230
limit = "1")
231-
protected SpecialVariableStorage executeGetStorageDeclarationFrame(VirtualFrame frame,
231+
protected SpecialVariableStorage unset(VirtualFrame frame,
232232
@Cached("frame.getFrameDescriptor()") FrameDescriptor descriptor,
233-
@Cached("descriptor.findFrameSlot(SPECIAL_VARIABLLE_STORAGE)") FrameSlot slot,
233+
@Cached("descriptor.findFrameSlot(SPECIAL_VARIABLES_STORAGE)") FrameSlot slot,
234234
@Cached("declarationSlot(frame)") FrameSlot declarationFrameSlot,
235235
@Cached("declarationDescriptor(frame).getVersion()") Assumption frameAssumption) {
236236
return getSlow(frame.materialize());
237237
}
238238

239-
@Specialization
240-
protected SpecialVariableStorage executeSlow(VirtualFrame frame) {
239+
@Specialization(replaces = { "sameFrame", "declarationFrame", "unset" })
240+
protected SpecialVariableStorage slowPath(VirtualFrame frame) {
241241
return getSlow(frame.materialize());
242242
}
243243

@@ -262,7 +262,7 @@ public static SpecialVariableStorage getSlow(MaterializedFrame aFrame) {
262262
} else {
263263
FrameSlot newSlot = frame
264264
.getFrameDescriptor()
265-
.findOrAddFrameSlot(Layouts.SPECIAL_VARIABLLE_STORAGE);
265+
.findOrAddFrameSlot(Layouts.SPECIAL_VARIABLES_STORAGE);
266266
SpecialVariableStorage storage = new SpecialVariableStorage();
267267
frame.setObject(newSlot, storage);
268268
return storage;
@@ -327,7 +327,7 @@ protected FrameSlot declarationSlot(VirtualFrame topFrame) {
327327
}
328328

329329
private static FrameSlot getVariableSlot(MaterializedFrame frame) {
330-
return frame.getFrameDescriptor().findFrameSlot(Layouts.SPECIAL_VARIABLLE_STORAGE);
330+
return frame.getFrameDescriptor().findFrameSlot(Layouts.SPECIAL_VARIABLES_STORAGE);
331331
}
332332

333333
public static GetSpecialVariableStorage create() {
@@ -362,7 +362,7 @@ public abstract static class SetRegexpMatch extends PrimitiveArrayArgumentsNode
362362
protected Object executeSetRegexpMatch(SpecialVariableStorage storage, Object lastMatch,
363363
@Cached ConditionProfile unsetProfile,
364364
@Cached ConditionProfile sameThreadProfile) {
365-
storage.setRegexpResult(lastMatch, getContext(), unsetProfile, sameThreadProfile);
365+
storage.setLastMatch(lastMatch, getContext(), unsetProfile, sameThreadProfile);
366366
return lastMatch;
367367
}
368368
}
@@ -374,7 +374,7 @@ public abstract static class GetRegexpMatch extends PrimitiveArrayArgumentsNode
374374
protected Object executeSetRegexpMatch(SpecialVariableStorage storage,
375375
@Cached ConditionProfile unsetProfile,
376376
@Cached ConditionProfile sameThreadProfile) {
377-
return storage.getRegexpResult(unsetProfile, sameThreadProfile);
377+
return storage.getLastMatch(unsetProfile, sameThreadProfile);
378378
}
379379
}
380380

@@ -385,19 +385,19 @@ public abstract static class SetLastIO extends PrimitiveArrayArgumentsNode {
385385
protected Object executeSetRegexpMatch(SpecialVariableStorage storage, Object lastIO,
386386
@Cached ConditionProfile unsetProfile,
387387
@Cached ConditionProfile sameThreadProfile) {
388-
storage.setIOResult(lastIO, getContext(), unsetProfile, sameThreadProfile);
388+
storage.setLastLine(lastIO, getContext(), unsetProfile, sameThreadProfile);
389389
return lastIO;
390390
}
391391
}
392392

393393
@Primitive(name = "io_last_line_get")
394-
public abstract static class GETLastIO extends PrimitiveArrayArgumentsNode {
394+
public abstract static class GetLastIO extends PrimitiveArrayArgumentsNode {
395395

396396
@Specialization
397397
protected Object executeSetRegexpMatch(SpecialVariableStorage storage,
398398
@Cached ConditionProfile unsetProfile,
399399
@Cached ConditionProfile sameThreadProfile) {
400-
return storage.getIOResult(unsetProfile, sameThreadProfile);
400+
return storage.getLastLine(unsetProfile, sameThreadProfile);
401401
}
402402
}
403403
}

src/main/java/org/truffleruby/core/proc/RubyProc.java

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.oracle.truffle.api.library.ExportLibrary;
3131
import com.oracle.truffle.api.library.ExportMessage;
3232
import com.oracle.truffle.api.object.Shape;
33-
import com.oracle.truffle.api.object.dsl.Nullable;
3433
import com.oracle.truffle.api.source.SourceSection;
3534

3635
@ExportLibrary(InteropLibrary.class)
@@ -47,33 +46,6 @@ public class RubyProc extends RubyDynamicObject implements ObjectGraphNode {
4746
public final FrameOnStackMarker frameOnStackMarker;
4847
public final DeclarationContext declarationContext;
4948

50-
public RubyProc(
51-
RubyClass rubyClass,
52-
Shape shape,
53-
ProcType type,
54-
SharedMethodInfo sharedMethodInfo,
55-
RootCallTarget callTargetForType,
56-
RootCallTarget callTargetForLambdas,
57-
MaterializedFrame declarationFrame,
58-
@Nullable InternalMethod method,
59-
@Nullable RubyProc block,
60-
@Nullable FrameOnStackMarker frameOnStackMarker,
61-
DeclarationContext declarationContext) {
62-
this(
63-
rubyClass,
64-
shape,
65-
type,
66-
sharedMethodInfo,
67-
callTargetForType,
68-
callTargetForLambdas,
69-
declarationFrame,
70-
null,
71-
method,
72-
block,
73-
frameOnStackMarker,
74-
declarationContext);
75-
}
76-
7749
public RubyProc(
7850
RubyClass rubyClass,
7951
Shape shape,
@@ -83,9 +55,9 @@ public RubyProc(
8355
RootCallTarget callTargetForLambdas,
8456
MaterializedFrame declarationFrame,
8557
SpecialVariableStorage declarationStorage,
86-
@Nullable InternalMethod method,
87-
@Nullable RubyProc block,
88-
@Nullable FrameOnStackMarker frameOnStackMarker,
58+
InternalMethod method,
59+
RubyProc block,
60+
FrameOnStackMarker frameOnStackMarker,
8961
DeclarationContext declarationContext) {
9062
super(rubyClass, shape);
9163
this.type = type;

src/main/java/org/truffleruby/core/string/StringNodes.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ private Object sliceRange(RubyString string, int begin, int end, boolean exclude
708708
// region Regexp Slice Specializations
709709

710710
@Specialization
711-
protected Object slice1(VirtualFrame frame, RubyString string, RubyRegexp regexp, NotProvided capture,
711+
protected Object sliceCapture0(VirtualFrame frame, RubyString string, RubyRegexp regexp, NotProvided capture,
712712
@Cached DispatchNode callNode,
713713
@Cached ReadCallerStorageNode readCallerNode,
714714
@Cached ConditionProfile unsetProfile,
@@ -734,11 +734,11 @@ protected Object sliceCapture(VirtualFrame frame, RubyString string, RubyRegexp
734734

735735
final SpecialVariableStorage storage = readCallerStorageNode.execute(frame);
736736
if (matchStrPair == nil) {
737-
storage.setRegexpResult(nil, getContext(), unsetProfile, sameThreadProfile);
737+
storage.setLastMatch(nil, getContext(), unsetProfile, sameThreadProfile);
738738
return nil;
739739
} else {
740740
final Object[] array = (Object[]) ((RubyArray) matchStrPair).store;
741-
storage.setRegexpResult(array[0], getContext(), unsetProfile, sameThreadProfile);
741+
storage.setLastMatch(array[0], getContext(), unsetProfile, sameThreadProfile);
742742
return array[1];
743743
}
744744
}

src/main/java/org/truffleruby/core/thread/TruffleThreadNodes.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.truffleruby.core.array.ArrayGuards;
1616
import org.truffleruby.core.array.RubyArray;
1717
import org.truffleruby.core.array.library.ArrayStoreLibrary;
18-
import org.truffleruby.core.binding.BindingNodes;
1918
import org.truffleruby.core.kernel.TruffleKernelNodes.GetSpecialVariableStorage;
2019

2120
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
@@ -29,28 +28,6 @@
2928
@CoreModule("Truffle::ThreadOperations")
3029
public class TruffleThreadNodes {
3130

32-
@CoreMethod(names = "ruby_caller", onSingleton = true, required = 1)
33-
@ImportStatic(ArrayGuards.class)
34-
public abstract static class FindRubyCaller extends CoreMethodArrayArgumentsNode {
35-
36-
@TruffleBoundary
37-
@Specialization(limit = "storageStrategyLimit()")
38-
protected Object findRubyCaller(RubyArray modules,
39-
@CachedLibrary("modules.store") ArrayStoreLibrary stores) {
40-
final int modulesSize = modules.size;
41-
Object[] moduleArray = stores.boxedCopyOfRange(modules.store, 0, modulesSize);
42-
Frame rubyCaller = getContext()
43-
.getCallStack()
44-
.getCallerFrameNotInModules(FrameAccess.MATERIALIZE, moduleArray);
45-
if (rubyCaller == null) {
46-
return nil;
47-
} else {
48-
return BindingNodes.createBinding(getContext(), rubyCaller.materialize());
49-
}
50-
}
51-
52-
}
53-
5431
@CoreMethod(names = "ruby_caller_special_variables", onSingleton = true, required = 1)
5532
@ImportStatic(ArrayGuards.class)
5633
public abstract static class FindRubyCallerSpecialStorage extends CoreMethodArrayArgumentsNode {

src/main/java/org/truffleruby/language/FrameOrStorageSendingNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.truffleruby.language.threadlocal.SpecialVariableStorage;
2929

3030
/** Some Ruby methods need access to the caller frame (the frame active when the method call was made) or to the storage
31-
* of special varaibles within that frame: see usages of {@link ReadCallerFrameNode} and {@link ReadCallerStorageNode} .
31+
* of special variables within that frame: see usages of {@link ReadCallerFrameNode} and {@link ReadCallerStorageNode} .
3232
* This is notably used to get hold of instances of {@link DeclarationContext} and {@link RubyBinding} and methods which
3333
* need to access the last regexp match or the last io line.
3434
*

src/main/java/org/truffleruby/language/methods/BlockDefinitionNode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class BlockDefinitionNode extends RubyContextSourceNode {
4242
private final BreakID breakID;
4343

4444
@Child private ReadFrameSlotNode readFrameOnStackMarkerNode;
45-
@Child private GetSpecialVariableStorage readSpecialVariableSotrageNode;
45+
@Child private GetSpecialVariableStorage readSpecialVariableStorageNode;
4646
@Child private WithoutVisibilityNode withoutVisibilityNode;
4747

4848
public BlockDefinitionNode(
@@ -64,7 +64,7 @@ public BlockDefinitionNode(
6464
} else {
6565
readFrameOnStackMarkerNode = ReadFrameSlotNodeGen.create(frameOnStackMarkerSlot);
6666
}
67-
readSpecialVariableSotrageNode = GetSpecialVariableStorage.create();
67+
readSpecialVariableStorageNode = GetSpecialVariableStorage.create();
6868
}
6969

7070
public BreakID getBreakID() {
@@ -95,7 +95,7 @@ public RubyProc execute(VirtualFrame frame) {
9595
callTargetForProcs,
9696
callTargetForLambdas,
9797
frame.materialize(),
98-
readSpecialVariableSotrageNode.execute(frame),
98+
readSpecialVariableStorageNode.execute(frame),
9999
RubyArguments.getMethod(frame),
100100
RubyArguments.getBlock(frame),
101101
frameOnStackMarker,

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

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,14 @@
1212
import com.oracle.truffle.api.Assumption;
1313
import com.oracle.truffle.api.CompilerDirectives;
1414
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
15-
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
15+
import com.oracle.truffle.api.frame.FrameDescriptor;
1616
import com.oracle.truffle.api.frame.FrameSlot;
1717
import com.oracle.truffle.api.frame.VirtualFrame;
1818

1919
import org.truffleruby.Layouts;
20-
import org.truffleruby.RubyContext;
21-
import org.truffleruby.language.RubyNode;
22-
import org.truffleruby.language.methods.InternalMethod;
20+
import org.truffleruby.language.RubyContextSourceNode;
2321

24-
public class MakeSpecialVariableStorageNode extends RubyNode {
25-
26-
private int sourceCharIndex = NO_SOURCE;
27-
private int sourceLength;
28-
private byte flags;
22+
public class MakeSpecialVariableStorageNode extends RubyContextSourceNode {
2923

3024
@CompilationFinal protected FrameSlot storageSlot;
3125
@CompilationFinal protected Assumption frameAssumption;
@@ -34,8 +28,9 @@ public class MakeSpecialVariableStorageNode extends RubyNode {
3428
public Object execute(VirtualFrame frame) {
3529
if (frameAssumption == null) {
3630
CompilerDirectives.transferToInterpreterAndInvalidate();
37-
frameAssumption = frame.getFrameDescriptor().getVersion();
38-
storageSlot = frame.getFrameDescriptor().findOrAddFrameSlot(Layouts.SPECIAL_VARIABLLE_STORAGE);
31+
final FrameDescriptor descriptor = frame.getFrameDescriptor();
32+
frameAssumption = descriptor.getVersion();
33+
storageSlot = descriptor.findOrAddFrameSlot(Layouts.SPECIAL_VARIABLES_STORAGE);
3934
}
4035

4136
if (storageSlot != null) {
@@ -45,44 +40,4 @@ public Object execute(VirtualFrame frame) {
4540
return nil;
4641
}
4742

48-
@TruffleBoundary
49-
private static void debug(InternalMethod method) {
50-
System.err.printf("Starting to send foe %s.\n", method);
51-
}
52-
53-
@Override
54-
public Object isDefined(VirtualFrame frame, RubyContext context) {
55-
return RubyNode.defaultIsDefined(context, this);
56-
}
57-
58-
@Override
59-
protected byte getFlags() {
60-
return flags;
61-
}
62-
63-
@Override
64-
protected void setFlags(byte flags) {
65-
this.flags = flags;
66-
}
67-
68-
@Override
69-
protected int getSourceCharIndex() {
70-
return sourceCharIndex;
71-
}
72-
73-
@Override
74-
protected void setSourceCharIndex(int sourceCharIndex) {
75-
this.sourceCharIndex = sourceCharIndex;
76-
}
77-
78-
@Override
79-
protected int getSourceLength() {
80-
return sourceLength;
81-
}
82-
83-
@Override
84-
protected void setSourceLength(int sourceLength) {
85-
this.sourceLength = sourceLength;
86-
}
87-
8843
}

0 commit comments

Comments
 (0)