Skip to content

Commit b8e88cd

Browse files
committed
Convert CanBindMethodToModuleNode to DSL inlinable node
1 parent f32d0b7 commit b8e88cd

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ RubyMethod bind(RubyUnboundMethod unboundMethod, Object object,
8484
final RubyClass objectMetaClass = metaClassNode.execute(this, object);
8585

8686
if (!canBindMethodToModuleNode
87-
.executeCanBindMethodToModule(unboundMethod.method, objectMetaClass)) {
87+
.executeCanBindMethodToModule(this, unboundMethod.method, objectMetaClass)) {
8888
errorProfile.enter(this);
8989
final RubyModule declaringModule = unboundMethod.method.getDeclaringModule();
9090
if (RubyGuards.isSingletonClass(declaringModule)) {

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
*/
1010
package org.truffleruby.language.methods;
1111

12+
import com.oracle.truffle.api.dsl.GenerateCached;
13+
import com.oracle.truffle.api.dsl.GenerateInline;
14+
import com.oracle.truffle.api.nodes.Node;
1215
import org.truffleruby.core.module.ModuleOperations;
1316
import org.truffleruby.core.module.RubyModule;
1417
import org.truffleruby.language.RubyBaseNode;
@@ -17,28 +20,30 @@
1720
import com.oracle.truffle.api.dsl.Specialization;
1821

1922
/** Caches {@link ModuleOperations#canBindMethodTo} for a method. */
23+
@GenerateInline
24+
@GenerateCached(false)
2025
public abstract class CanBindMethodToModuleNode extends RubyBaseNode {
2126

22-
public abstract boolean executeCanBindMethodToModule(InternalMethod method, RubyModule module);
27+
public abstract boolean executeCanBindMethodToModule(Node node, InternalMethod method, RubyModule module);
2328

2429
@Specialization(
2530
guards = {
2631
"method.getDeclaringModule() == declaringModule",
2732
"module == cachedModule" },
2833
limit = "getCacheLimit()")
29-
boolean canBindMethodToCached(InternalMethod method, RubyModule module,
34+
static boolean canBindMethodToCached(InternalMethod method, RubyModule module,
3035
@Cached("method.getDeclaringModule()") RubyModule declaringModule,
3136
@Cached("module") RubyModule cachedModule,
3237
@Cached("canBindMethodTo(method, cachedModule)") boolean canBindMethodTo) {
3338
return canBindMethodTo;
3439
}
3540

3641
@Specialization
37-
boolean canBindMethodToUncached(InternalMethod method, RubyModule module) {
42+
static boolean canBindMethodToUncached(InternalMethod method, RubyModule module) {
3843
return canBindMethodTo(method, module);
3944
}
4045

41-
protected boolean canBindMethodTo(InternalMethod method, RubyModule module) {
46+
protected static boolean canBindMethodTo(InternalMethod method, RubyModule module) {
4247
return ModuleOperations.canBindMethodTo(method, module);
4348
}
4449

0 commit comments

Comments
 (0)