Skip to content

Commit d035d4c

Browse files
committed
Move check for foreign objects after the method lookup
* That way, there is a single check for monomorphic call. Previously, it would be obj = C.new c = metaClass(obj) if (c != Truffle::Interop::Foreign && c == C) { call method } Benchmark: $ jt -u jvm-ce ruby --trace --fg --igv --engine.Inlining=false --vm.Dgraal.LoopPeeling=false bench_call.rb class Callee def foo :foo end end CALLEE = Callee.new def compile i = 0 while i < 100 CALLEE.foo i += 1 end end 11.times do compile end
1 parent ab54d2d commit d035d4c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/java/org/truffleruby/language/dispatch/DispatchNode.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,15 @@ public Object dispatch(VirtualFrame frame, Object receiver, String methodName, R
122122
}
123123

124124
public Object execute(VirtualFrame frame, Object receiver, String methodName, RubyProc block, Object[] arguments) {
125-
126125
final RubyClass metaclass = metaclassNode.execute(receiver);
127126

128-
if (isForeignCall.profile(metaclass == getContext().getCoreLibrary().truffleInteropForeignClass)) {
129-
return callForeign(receiver, methodName, block, arguments);
130-
}
131-
132127
final InternalMethod method = methodLookup.execute(frame, metaclass, methodName, config);
133128

134129
if (methodMissing.profile(method == null || method.isUndefined())) {
130+
if (isForeignCall.profile(metaclass == getContext().getCoreLibrary().truffleInteropForeignClass)) {
131+
return callForeign(receiver, methodName, block, arguments);
132+
}
133+
135134
switch (config.missingBehavior) {
136135
case RETURN_MISSING:
137136
return MISSING;

0 commit comments

Comments
 (0)