Skip to content

Commit 7d1ec13

Browse files
committed
Use @CachedLanguage instead of the slow RubyLanguage.getCurrentLanguage()
1 parent bc20ac6 commit 7d1ec13

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.oracle.truffle.api.Truffle;
1515
import com.oracle.truffle.api.dsl.Cached;
1616
import com.oracle.truffle.api.dsl.CachedContext;
17+
import com.oracle.truffle.api.dsl.CachedLanguage;
1718
import com.oracle.truffle.api.dsl.GenerateUncached;
1819
import com.oracle.truffle.api.dsl.Specialization;
1920
import com.oracle.truffle.api.frame.Frame;
@@ -57,6 +58,7 @@ protected RubyMethod getMethodObject(
5758
Object name,
5859
DispatchConfiguration dispatchConfig,
5960
MaterializedFrame callerFrame,
61+
@CachedLanguage RubyLanguage language,
6062
@CachedContext(RubyLanguage.class) RubyContext context,
6163
@Cached NameToJavaStringNode nameToJavaStringNode,
6264
@Cached LookupMethodOnSelfNode lookupMethodNode,
@@ -89,7 +91,7 @@ protected RubyMethod getMethodObject(
8991
RubyArguments.setDeclarationContext(frame, originalDeclarationContext);
9092
final InternalMethod methodMissing = lookupMethodNode
9193
.execute(frame, self, "method_missing", dispatchConfig);
92-
method = createMissingMethod(self, name, normalizedName, methodMissing, context);
94+
method = createMissingMethod(self, name, normalizedName, methodMissing, language, context);
9395
} else {
9496
throw new RaiseException(
9597
context,
@@ -101,24 +103,23 @@ protected RubyMethod getMethodObject(
101103
}
102104
final RubyMethod instance = new RubyMethod(
103105
context.getCoreLibrary().methodClass,
104-
RubyLanguage.getCurrentLanguage().methodShape,
106+
language.methodShape,
105107
self,
106108
method);
107-
AllocationTracing.trace(RubyLanguage.getCurrentLanguage(), context, instance, this);
109+
AllocationTracing.trace(language, context, instance, this);
108110
return instance;
109111
}
110112

111113
@TruffleBoundary
112114
private InternalMethod createMissingMethod(Object self, Object name, String normalizedName,
113-
InternalMethod methodMissing,
114-
RubyContext context) {
115+
InternalMethod methodMissing, RubyLanguage language, RubyContext context) {
115116
final SharedMethodInfo info = methodMissing
116117
.getSharedMethodInfo()
117118
.convertMethodMissingToMethod(methodMissing.getDeclaringModule(), normalizedName);
118119

119120
final RubyNode newBody = new CallMethodMissingWithStaticName(name);
120121
final RubyRootNode newRootNode = new RubyRootNode(
121-
RubyLanguage.getCurrentLanguage(),
122+
language,
122123
info.getSourceSection(),
123124
new FrameDescriptor(nil),
124125
info,

0 commit comments

Comments
 (0)