Skip to content

Commit a28ca3a

Browse files
committed
[Truffle] Use new API to associate call targets with execution contexts and to set the min value for the max inliner call size.
1 parent afbde81 commit a28ca3a

File tree

8 files changed

+25
-12
lines changed

8 files changed

+25
-12
lines changed

core/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void init() {
127127
@Override
128128
public TruffleMethod truffelize(DynamicMethod originalMethod, org.jruby.ast.ArgsNode argsNode, org.jruby.ast.Node bodyNode) {
129129
final MethodDefinitionNode methodDefinitionNode = truffleContext.getTranslator().parse(truffleContext, null, argsNode, bodyNode, null);
130-
return new TruffleMethod(originalMethod, Truffle.getRuntime().createCallTarget(methodDefinitionNode.getMethodRootNode()));
130+
return new TruffleMethod(originalMethod, Truffle.getRuntime().createCallTarget(methodDefinitionNode.getMethodRootNode(), truffleContext));
131131
}
132132

133133
@Override
@@ -158,7 +158,7 @@ public Object get() {
158158
}
159159

160160
final RubyRootNode parsedRootNode = truffleContext.getTranslator().parse(truffleContext, source, parserContext, parentFrame, null);
161-
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(parsedRootNode);
161+
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(parsedRootNode, truffleContext);
162162

163163
return callTarget.call(RubyArguments.pack(null, parentFrame, self, null, new Object[]{}));
164164
}

core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,7 +2338,7 @@ public MaxBlock(RubyContext context) {
23382338
ArrayNodesFactory.MaxBlockNodeFactory.create(context, sourceSection, new RubyNode[]{
23392339
ReadLevelVariableNodeFactory.create(context, sourceSection, frameSlot, 1),
23402340
new ReadPreArgumentNode(context, sourceSection, 0, MissingArgumentBehaviour.RUNTIME_ERROR)
2341-
})));
2341+
})), context);
23422342
}
23432343

23442344
public FrameDescriptor getFrameDescriptor() {
@@ -2451,7 +2451,7 @@ public MinBlock(RubyContext context) {
24512451
ArrayNodesFactory.MinBlockNodeFactory.create(context, sourceSection, new RubyNode[]{
24522452
ReadLevelVariableNodeFactory.create(context, sourceSection, frameSlot, 1),
24532453
new ReadPreArgumentNode(context, sourceSection, 0, MissingArgumentBehaviour.RUNTIME_ERROR)
2454-
})));
2454+
})), context);
24552455
}
24562456

24572457
public FrameDescriptor getFrameDescriptor() {

core/src/main/java/org/jruby/truffle/nodes/core/CoreMethodNodeManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private static void addMethod(RubyClass rubyObjectClass, MethodDetails methodDet
9696
final RubyRootNode rootNode = makeGenericMethod(context, methodDetails, needsSelf);
9797

9898
final RubyMethod method = new RubyMethod(rootNode.getSharedMethodInfo(), canonicalName, module, visibility, false,
99-
Truffle.getRuntime().createCallTarget(rootNode), null);
99+
Truffle.getRuntime().createCallTarget(rootNode, context), null);
100100

101101
if (anno.isModuleFunction()) {
102102
addMethod(module, method, aliases, Visibility.PRIVATE);

core/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public static void attrReader(RubyNode currentNode, RubyContext context, SourceS
271271

272272
final SharedMethodInfo sharedMethodInfo = SharedMethodInfo.generated(sourceSection, indicativeName);
273273
final RubyRootNode rootNode = new RubyRootNode(context, sourceSection, null, sharedMethodInfo, block);
274-
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
274+
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode, context);
275275
final RubyMethod method = new RubyMethod(sharedMethodInfo, name, module, Visibility.PUBLIC, false, callTarget, null);
276276
module.addMethod(currentNode, method);
277277
}
@@ -324,7 +324,7 @@ public static void attrWriter(RubyNode currentNode, RubyContext context, SourceS
324324

325325
final SharedMethodInfo sharedMethodInfo = SharedMethodInfo.generated(sourceSection, indicativeName);
326326
final RubyRootNode rootNode = new RubyRootNode(context, sourceSection, null, sharedMethodInfo, block);
327-
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
327+
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode, context);
328328
final RubyMethod method = new RubyMethod(sharedMethodInfo, name + "=", module, Visibility.PUBLIC, false, callTarget, null);
329329
module.addMethod(currentNode, method);
330330
}

core/src/main/java/org/jruby/truffle/nodes/methods/MethodDefinitionNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public RubyMethod executeMethod(VirtualFrame frame) {
8484
}
8585

8686
final RubyRootNode rootNodeClone = NodeUtil.cloneNode(rootNode);
87-
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNodeClone);
87+
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNodeClone, getContext());
8888
return new RubyMethod(sharedMethodInfo, name, null, visibility, false, callTarget, declarationFrame);
8989
}
9090

core/src/main/java/org/jruby/truffle/runtime/RubyContext.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class RubyContext extends ExecutionContext {
6363
private final SafepointManager safepointManager;
6464
private final Random random = new Random();
6565
private final LexicalScope rootLexicalScope;
66+
private final ExecutionContextOptions executionContextOptions;
6667

6768
private SourceCallback sourceCallback = null;
6869

@@ -80,6 +81,12 @@ protected Queue<Object> initialValue() {
8081
public RubyContext(Ruby runtime) {
8182
assert runtime != null;
8283

84+
executionContextOptions = Truffle.getRuntime().createExecutionContextOptions();
85+
86+
if (executionContextOptions.isSupported("MinInliningMaxCallerSize")) {
87+
executionContextOptions.set("MinInliningMaxCallerSize", 15000);
88+
}
89+
8390
safepointManager = new SafepointManager(this);
8491

8592
this.runtime = runtime;
@@ -172,7 +179,7 @@ public Object eval(String code, RubyBinding binding, RubyNode currentNode) {
172179

173180
public Object execute(RubyContext context, Source source, TranslatorDriver.ParserContext parserContext, Object self, MaterializedFrame parentFrame, RubyNode currentNode) {
174181
final RubyRootNode rootNode = translator.parse(context, source, parserContext, parentFrame, currentNode);
175-
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
182+
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode, context);
176183

177184
return callTarget.call(RubyArguments.pack(null, parentFrame, self, null, new Object[]{}));
178185
}
@@ -381,4 +388,10 @@ public Random getRandom() {
381388
public LexicalScope getRootLexicalScope() {
382389
return rootLexicalScope;
383390
}
391+
392+
@Override
393+
public ExecutionContextOptions getOptions() {
394+
return executionContextOptions;
395+
}
396+
384397
}

core/src/main/java/org/jruby/truffle/runtime/core/RubySymbol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public RubyProc toProc(SourceSection sourceSection, final RubyNode currentNode)
5252
final RubyRootNode rootNode = new RubyRootNode(context, sourceSection, new FrameDescriptor(), sharedMethodInfo,
5353
new SymbolProcNode(context, sourceSection, symbol));
5454

55-
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
55+
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode, getContext());
5656

5757
return new RubyProc(context.getCoreLibrary().getProcClass(), RubyProc.Type.PROC, sharedMethodInfo, callTarget,
5858
callTarget, null, getContext().getCoreLibrary().getNilObject(), null);

core/src/main/java/org/jruby/truffle/translator/MethodTranslator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public MethodDefinitionNode compileFunctionNode(SourceSection sourceSection, Str
169169
context, sourceSection, environment.getFrameDescriptor(), environment.getSharedMethodInfo(), body);
170170

171171
if (isBlock) {
172-
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
172+
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode, context);
173173
final CallTarget callTargetForMethods = withoutBlockDestructureSemantics(callTarget);
174174

175175
return new BlockDefinitionNode(context, sourceSection, methodName, environment.getSharedMethodInfo(), environment.needsDeclarationFrame(), callTarget, callTargetForMethods, rootNode);
@@ -192,7 +192,7 @@ private CallTarget withoutBlockDestructureSemantics(CallTarget callTarget) {
192192
newRootNode.getFrameDescriptor(), newRootNode.getSharedMethodInfo(),
193193
new CatchReturnNode(context, newRootNode.getSourceSection(), newRootNode.getBody(), getEnvironment().getReturnID()));
194194

195-
return Truffle.getRuntime().createCallTarget(newRootNodeWithCatchReturn);
195+
return Truffle.getRuntime().createCallTarget(newRootNodeWithCatchReturn, context);
196196
} else {
197197
throw new UnsupportedOperationException("Can't change the semantics of an opaque call target");
198198
}

0 commit comments

Comments
 (0)