Skip to content

Commit d0df827

Browse files
chrisseatonMattAlpnirvdrum
committed
When a call target supplier is run, that needs to be behind a boundary
This only applies for some implementations of the supplier, so instead of making this the job of the user of the supplier, or making it the same for all suppliers, have the implementor do it. Co-authored-by: Matthew Alt <[email protected]> Co-authored-by: Kevin Menard <[email protected]>
1 parent 5dfef54 commit d0df827

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/main/java/org/truffleruby/builtins/CoreMethodNodeManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ private static void addMethod(
262262
} else {
263263
if (context.getLanguageSlow().options.LAZY_CALLTARGETS) {
264264
callTarget = null;
265-
callTargetSupplier = new CachedSupplier<>(() -> callTargetFactory.apply(sharedMethodInfo));
265+
callTargetSupplier = new CachedSupplier<>(() -> {
266+
CompilerDirectives.transferToInterpreterAndInvalidate();
267+
return callTargetFactory.apply(sharedMethodInfo);
268+
});
266269
} else {
267270
callTarget = callTargetFactory.apply(sharedMethodInfo);
268271
callTargetSupplier = null;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import java.util.Set;
1313

14-
import com.oracle.truffle.api.CompilerDirectives;
1514
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
1615
import com.oracle.truffle.api.dsl.NodeFactory;
1716
import org.truffleruby.RubyContext;
@@ -233,7 +232,6 @@ public RubyProc getProc() {
233232

234233
public RootCallTarget getCallTarget() {
235234
if (callTarget == null) {
236-
CompilerDirectives.transferToInterpreterAndInvalidate();
237235
callTarget = callTargetSupplier.get();
238236
assert RubyRootNode.of(callTarget).getSharedMethodInfo() == sharedMethodInfo;
239237
}

src/main/java/org/truffleruby/parser/MethodTranslator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Arrays;
1313
import java.util.function.Supplier;
1414

15+
import com.oracle.truffle.api.CompilerDirectives;
1516
import org.truffleruby.RubyLanguage;
1617
import org.truffleruby.collections.CachedSupplier;
1718
import org.truffleruby.core.IsNilNode;
@@ -423,6 +424,7 @@ public CachedSupplier<RootCallTarget> buildMethodNodeCompiler(SourceIndexLength
423424

424425
if (shouldLazyTranslate) {
425426
return new CachedSupplier<>(() -> {
427+
CompilerDirectives.transferToInterpreterAndInvalidate();
426428
return translateMethodNode(sourceSection, defNode, bodyNode).getCallTarget();
427429
});
428430
} else {

0 commit comments

Comments
 (0)