Skip to content

Commit 886caa7

Browse files
committed
Move to an empty frame descriptor on RubyLanguage.
1 parent d1270bc commit 886caa7

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
import org.truffleruby.interop.RubyInnerContext;
101101
import org.truffleruby.interop.RubySourceLocation;
102102
import org.truffleruby.language.LexicalScope;
103+
import org.truffleruby.language.Nil;
103104
import org.truffleruby.language.RubyDynamicObject;
104105
import org.truffleruby.language.RubyEvalInteractiveRootNode;
105106
import org.truffleruby.language.RubyInlineParsingRequestNode;
@@ -181,6 +182,11 @@ public final class RubyLanguage extends TruffleLanguage<RubyContext> {
181182

182183
public static final TruffleLogger LOGGER = TruffleLogger.getLogger(TruffleRuby.LANGUAGE_ID);
183184

185+
/** This is a truly empty frame descriptor and should only by dummy root nodes which require no variables any other
186+
* root nodes should should use {#link
187+
* {@link TranslatorEnvironment#newFrameDescriptorBuilder(org.truffleruby.parser.ParentFrameDescriptor, boolean)}}. */
188+
public static final FrameDescriptor EMPTY_FRAME_DESCRIPTOR = new FrameDescriptor(Nil.INSTANCE);
189+
184190
/** We need an extra indirection added to ContextThreadLocal due to multiple Fibers of different Ruby Threads
185191
* sharing the same Java Thread when using the fiber pool. */
186192
public static final class ThreadLocalState {

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
7979
import com.oracle.truffle.api.Truffle;
8080
import com.oracle.truffle.api.TruffleOptions;
81-
import com.oracle.truffle.api.frame.FrameDescriptor;
8281
import com.oracle.truffle.api.object.DynamicObjectLibrary;
8382
import com.oracle.truffle.api.source.Source;
8483
import com.oracle.truffle.api.source.SourceSection;
@@ -234,8 +233,6 @@ public class CoreLibrary {
234233
public final GlobalVariables globalVariables;
235234
public final BindingLocalVariablesObject interactiveBindingLocalVariablesObject;
236235

237-
public final FrameDescriptor emptyDescriptor;
238-
239236
@CompilationFinal private RubyClass eagainWaitReadable;
240237
@CompilationFinal private RubyClass eagainWaitWritable;
241238

@@ -552,7 +549,6 @@ public CoreLibrary(RubyContext context, RubyLanguage language) {
552549
// Create some key objects
553550

554551
mainObject = new RubyBasicObject(objectClass, language.basicObjectShape);
555-
emptyDescriptor = new FrameDescriptor(Nil.INSTANCE);
556552
argv = new RubyArray(arrayClass, language.arrayShape, ArrayStoreLibrary.INITIAL_STORE, 0);
557553

558554
globalVariables = new GlobalVariables(context);

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
import org.truffleruby.language.RubyBaseRootNode;
1919
import org.truffleruby.language.backtrace.InternalRootNode;
2020

21-
import com.oracle.truffle.api.TruffleLanguage;
2221
import com.oracle.truffle.api.interop.ArityException;
2322
import com.oracle.truffle.api.interop.InteropLibrary;
2423
import com.oracle.truffle.api.interop.UnsupportedMessageException;
2524
import com.oracle.truffle.api.interop.UnsupportedTypeException;
26-
import com.oracle.truffle.api.frame.FrameDescriptor;
2725
import com.oracle.truffle.api.frame.VirtualFrame;
2826

2927
/** Finalizers are implemented with phantom references and reference queues, and are run in a dedicated Ruby thread. */
@@ -32,17 +30,16 @@ public class DataObjectFinalizationService extends ReferenceProcessingService<Da
3230
// We need a base node here, it shoudl extend ruby base root node and implement internal root node.
3331
public static class DataObjectFinalizerRootNode extends RubyBaseRootNode implements InternalRootNode {
3432

35-
private static final FrameDescriptor FINALIZER_FRAME = FrameDescriptor.newBuilder().build();
36-
3733
@Child private InteropLibrary nullNode;
3834
@Child private InteropLibrary callNode;
3935

4036
public DataObjectFinalizerRootNode(
41-
TruffleLanguage<?> language) {
42-
super(language, FINALIZER_FRAME, null);
37+
RubyLanguage language) {
38+
super(language, RubyLanguage.EMPTY_FRAME_DESCRIPTOR, null);
4339

44-
nullNode = insert(InteropLibrary.getFactory().createDispatched(2));
45-
callNode = insert(InteropLibrary.getFactory().createDispatched(2));
40+
nullNode = InteropLibrary.getFactory().createDispatched(2);
41+
callNode = InteropLibrary.getFactory().createDispatched(2);
42+
adoptChildren();
4643
}
4744

4845
@Override

src/main/java/org/truffleruby/debug/MetricsInternalRootNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.truffleruby.debug;
1111

1212
import org.truffleruby.RubyContext;
13+
import org.truffleruby.RubyLanguage;
1314
import org.truffleruby.language.RubyBaseRootNode;
1415
import org.truffleruby.language.RubyNode;
1516
import org.truffleruby.language.backtrace.InternalRootNode;
@@ -31,7 +32,7 @@ class MetricsInternalRootNode extends RubyBaseRootNode implements InternalRootNo
3132
@Child private RubyNode body;
3233

3334
public MetricsInternalRootNode(RubyContext context, String name, RubyNode body) {
34-
super(context.getLanguageSlow(), context.getCoreLibrary().emptyDescriptor, REQUIRE_METRICS_SOURCE_SECTION);
35+
super(context.getLanguageSlow(), RubyLanguage.EMPTY_FRAME_DESCRIPTOR, REQUIRE_METRICS_SOURCE_SECTION);
3536
assert body != null;
3637

3738
this.name = name;

0 commit comments

Comments
 (0)