Skip to content

Commit 3de3817

Browse files
committed
[GR-15990] Move emptyDeclarationDescriptor to RubyLanguage
PullRequest: truffleruby/2871
2 parents 47a444e + 4434371 commit 3de3817

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/main/java/org/truffleruby/RubyLanguage.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import com.oracle.truffle.api.CompilerDirectives;
2424
import com.oracle.truffle.api.ContextThreadLocal;
2525
import com.oracle.truffle.api.TruffleFile;
26+
import com.oracle.truffle.api.frame.FrameDescriptor;
27+
import com.oracle.truffle.api.frame.FrameSlot;
2628
import com.oracle.truffle.api.instrumentation.AllocationReporter;
2729
import com.oracle.truffle.api.instrumentation.Instrumenter;
2830
import com.oracle.truffle.api.nodes.Node;
@@ -95,6 +97,7 @@
9597
import org.truffleruby.core.string.ImmutableRubyString;
9698
import org.truffleruby.interop.RubyInnerContext;
9799
import org.truffleruby.language.LexicalScope;
100+
import org.truffleruby.language.Nil;
98101
import org.truffleruby.language.NotProvided;
99102
import org.truffleruby.language.RubyDynamicObject;
100103
import org.truffleruby.language.RubyEvalInteractiveRootNode;
@@ -280,6 +283,13 @@ private static final class ThreadLocalState {
280283

281284
public final ThreadLocal<ParsingParameters> parsingRequestParams = new ThreadLocal<>();
282285

286+
/* Some things (such as procs created from symbols) require a declaration frame, and this should include a slot for
287+
* special variable storage. This frame descriptor should be used for those frames to provide a constant frame
288+
* descriptor in those cases. */
289+
public final FrameDescriptor emptyDeclarationDescriptor = new FrameDescriptor(Nil.INSTANCE);
290+
public final FrameSlot emptyDeclarationSpecialVariableSlot = emptyDeclarationDescriptor
291+
.addFrameSlot(Layouts.SPECIAL_VARIABLES_STORAGE);
292+
283293
private static final LanguageReference<RubyLanguage> REFERENCE = LanguageReference.create(RubyLanguage.class);
284294

285295
public static RubyLanguage get(Node node) {

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.graalvm.collections.Pair;
2727
import org.jcodings.specific.USASCIIEncoding;
2828
import org.jcodings.transcode.EConvFlags;
29-
import org.truffleruby.Layouts;
3029
import org.truffleruby.RubyContext;
3130
import org.truffleruby.RubyLanguage;
3231
import org.truffleruby.SuppressFBWarnings;
@@ -79,7 +78,6 @@
7978
import com.oracle.truffle.api.Truffle;
8079
import com.oracle.truffle.api.TruffleOptions;
8180
import com.oracle.truffle.api.frame.FrameDescriptor;
82-
import com.oracle.truffle.api.frame.FrameSlot;
8381
import com.oracle.truffle.api.object.DynamicObjectLibrary;
8482
import com.oracle.truffle.api.source.Source;
8583
import com.oracle.truffle.api.source.SourceSection;
@@ -232,11 +230,6 @@ public class CoreLibrary {
232230
public final BindingLocalVariablesObject interactiveBindingLocalVariablesObject;
233231

234232
public final FrameDescriptor emptyDescriptor;
235-
/* Some things (such as procs created from symbols) require a declaration frame, and this should include a slot for
236-
* special variable storage. This frame descriptor should be used for those frames to provide a constant frame
237-
* descriptor in those cases. */
238-
public final FrameDescriptor emptyDeclarationDescriptor;
239-
public final FrameSlot emptyDeclarationSpecialVariableSlot;
240233

241234
@CompilationFinal private RubyClass eagainWaitReadable;
242235
@CompilationFinal private RubyClass eagainWaitWritable;
@@ -546,9 +539,6 @@ public CoreLibrary(RubyContext context, RubyLanguage language) {
546539

547540
mainObject = new RubyBasicObject(objectClass, language.basicObjectShape);
548541
emptyDescriptor = new FrameDescriptor(Nil.INSTANCE);
549-
emptyDeclarationDescriptor = new FrameDescriptor(Nil.INSTANCE);
550-
emptyDeclarationSpecialVariableSlot = emptyDeclarationDescriptor
551-
.addFrameSlot(Layouts.SPECIAL_VARIABLES_STORAGE);
552542
argv = new RubyArray(arrayClass, language.arrayShape, ArrayStoreLibrary.INITIAL_STORE, 0);
553543

554544
globalVariables = new GlobalVariables(context);

src/main/java/org/truffleruby/core/method/MethodNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ private RubyProc createProc(RootCallTarget callTarget, InternalMethod method, Ob
302302
.pack(null, null, method, null, receiver, nil, EMPTY_ARGUMENTS);
303303
final MaterializedFrame declarationFrame = Truffle
304304
.getRuntime()
305-
.createMaterializedFrame(packedArgs, coreLibrary().emptyDeclarationDescriptor);
305+
.createMaterializedFrame(packedArgs, getLanguage().emptyDeclarationDescriptor);
306306
SpecialVariableStorage variables = new SpecialVariableStorage();
307-
declarationFrame.setObject(coreLibrary().emptyDeclarationSpecialVariableSlot, variables);
307+
declarationFrame.setObject(getLanguage().emptyDeclarationSpecialVariableSlot, variables);
308308
return ProcOperations.createRubyProc(
309309
coreLibrary().procClass,
310310
getLanguage().procShape,

src/main/java/org/truffleruby/core/symbol/SymbolNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ public static RubyProc createProc(RubyContext context, RubyLanguage language,
202202
// binding as this simplifies the logic elsewhere in the runtime.
203203
final MaterializedFrame declarationFrame = Truffle
204204
.getRuntime()
205-
.createVirtualFrame(args, context.getCoreLibrary().emptyDeclarationDescriptor)
205+
.createVirtualFrame(args, language.emptyDeclarationDescriptor)
206206
.materialize();
207207
SpecialVariableStorage variables = new SpecialVariableStorage();
208-
declarationFrame.setObject(context.getCoreLibrary().emptyDeclarationSpecialVariableSlot, variables);
208+
declarationFrame.setObject(language.emptyDeclarationSpecialVariableSlot, variables);
209209

210210
return ProcOperations.createRubyProc(
211211
context.getCoreLibrary().procClass,

src/main/java/org/truffleruby/extra/TruffleGraalNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ protected RubyProc copyCapturedLocals(RubyProc proc) {
117117
// declaration frame (to allow Proc#binding) so we shall create an empty one.
118118
final MaterializedFrame newDeclarationFrame = Truffle
119119
.getRuntime()
120-
.createMaterializedFrame(args, coreLibrary().emptyDeclarationDescriptor);
120+
.createMaterializedFrame(args, getLanguage().emptyDeclarationDescriptor);
121121

122-
newDeclarationFrame.setObject(coreLibrary().emptyDeclarationSpecialVariableSlot, variables);
122+
newDeclarationFrame.setObject(getLanguage().emptyDeclarationSpecialVariableSlot, variables);
123123

124124
return new RubyProc(
125125
coreLibrary().procClass,

0 commit comments

Comments
 (0)