Skip to content

Commit 9eea6ea

Browse files
committed
Refactor AllocateNode so it can be DSL inlinable
1 parent 6288996 commit 9eea6ea

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

src/main/java/org/truffleruby/core/range/RangeNodes.java

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package org.truffleruby.core.range;
1111

1212
import com.oracle.truffle.api.dsl.Bind;
13-
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
1413
import com.oracle.truffle.api.dsl.GenerateUncached;
1514
import com.oracle.truffle.api.dsl.NeverDefault;
1615
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
@@ -34,7 +33,6 @@
3433
import org.truffleruby.language.RubyContextSourceNode;
3534
import org.truffleruby.language.RubyGuards;
3635
import org.truffleruby.language.RubyNode;
37-
import org.truffleruby.language.RubySourceNode;
3836
import org.truffleruby.annotations.Visibility;
3937
import org.truffleruby.language.arguments.RubyArguments;
4038
import org.truffleruby.language.control.RaiseException;
@@ -467,22 +465,19 @@ protected RubyClass getRangeClass() {
467465
}
468466
}
469467

470-
@GenerateUncached
471-
@GenerateNodeFactory
472468
@CoreMethod(names = { "__allocate__", "__layout_allocate__" }, constructor = true, visibility = Visibility.PRIVATE)
473469
@NodeChild(value = "rubyClassNode", type = RubyNode.class)
474-
public abstract static class AllocateNode extends RubySourceNode {
475-
476-
@NeverDefault
477-
public static AllocateNode create() {
478-
return RangeNodesFactory.AllocateNodeFactory.create(null);
479-
}
470+
public abstract static class RangeAllocateNode extends CoreMethodNode {
480471

481-
public static AllocateNode create(RubyNode rubyClassNode) {
482-
return RangeNodesFactory.AllocateNodeFactory.create(rubyClassNode);
472+
@Specialization
473+
protected RubyObjectRange allocate(RubyClass rubyClass,
474+
@Cached AllocateNode allocateNode) {
475+
return allocateNode.execute(rubyClass);
483476
}
477+
}
484478

485-
abstract RubyNode getRubyClassNode();
479+
@GenerateUncached
480+
public abstract static class AllocateNode extends RubyBaseNode {
486481

487482
public abstract RubyObjectRange execute(RubyClass rubyClass);
488483

@@ -493,12 +488,6 @@ protected RubyObjectRange allocate(RubyClass rubyClass) {
493488
AllocationTracing.trace(range, this);
494489
return range;
495490
}
496-
497-
@Override
498-
public RubyNode cloneUninitialized() {
499-
return create(getRubyClassNode().cloneUninitialized()).copyFlags(this);
500-
}
501-
502491
}
503492

504493
@CoreMethod(names = "initialize_copy", required = 1, raiseIfFrozenSelf = true)

0 commit comments

Comments
 (0)