Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Truffle] Use new API to associate call targets with execution contex…
Browse files Browse the repository at this point in the history
…ts and to set the min value for the max inliner call size.
chrisseaton committed Nov 6, 2014
1 parent afbde81 commit a28ca3a
Showing 8 changed files with 25 additions and 12 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ public void init() {
@Override
public TruffleMethod truffelize(DynamicMethod originalMethod, org.jruby.ast.ArgsNode argsNode, org.jruby.ast.Node bodyNode) {
final MethodDefinitionNode methodDefinitionNode = truffleContext.getTranslator().parse(truffleContext, null, argsNode, bodyNode, null);
return new TruffleMethod(originalMethod, Truffle.getRuntime().createCallTarget(methodDefinitionNode.getMethodRootNode()));
return new TruffleMethod(originalMethod, Truffle.getRuntime().createCallTarget(methodDefinitionNode.getMethodRootNode(), truffleContext));
}

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

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

return callTarget.call(RubyArguments.pack(null, parentFrame, self, null, new Object[]{}));
}
Original file line number Diff line number Diff line change
@@ -2338,7 +2338,7 @@ public MaxBlock(RubyContext context) {
ArrayNodesFactory.MaxBlockNodeFactory.create(context, sourceSection, new RubyNode[]{
ReadLevelVariableNodeFactory.create(context, sourceSection, frameSlot, 1),
new ReadPreArgumentNode(context, sourceSection, 0, MissingArgumentBehaviour.RUNTIME_ERROR)
})));
})), context);
}

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

public FrameDescriptor getFrameDescriptor() {
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ private static void addMethod(RubyClass rubyObjectClass, MethodDetails methodDet
final RubyRootNode rootNode = makeGenericMethod(context, methodDetails, needsSelf);

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

if (anno.isModuleFunction()) {
addMethod(module, method, aliases, Visibility.PRIVATE);
Original file line number Diff line number Diff line change
@@ -271,7 +271,7 @@ public static void attrReader(RubyNode currentNode, RubyContext context, SourceS

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

final SharedMethodInfo sharedMethodInfo = SharedMethodInfo.generated(sourceSection, indicativeName);
final RubyRootNode rootNode = new RubyRootNode(context, sourceSection, null, sharedMethodInfo, block);
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode, context);
final RubyMethod method = new RubyMethod(sharedMethodInfo, name + "=", module, Visibility.PUBLIC, false, callTarget, null);
module.addMethod(currentNode, method);
}
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ public RubyMethod executeMethod(VirtualFrame frame) {
}

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

15 changes: 14 additions & 1 deletion core/src/main/java/org/jruby/truffle/runtime/RubyContext.java
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@ public class RubyContext extends ExecutionContext {
private final SafepointManager safepointManager;
private final Random random = new Random();
private final LexicalScope rootLexicalScope;
private final ExecutionContextOptions executionContextOptions;

private SourceCallback sourceCallback = null;

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

executionContextOptions = Truffle.getRuntime().createExecutionContextOptions();

if (executionContextOptions.isSupported("MinInliningMaxCallerSize")) {
executionContextOptions.set("MinInliningMaxCallerSize", 15000);
}

safepointManager = new SafepointManager(this);

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

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

return callTarget.call(RubyArguments.pack(null, parentFrame, self, null, new Object[]{}));
}
@@ -381,4 +388,10 @@ public Random getRandom() {
public LexicalScope getRootLexicalScope() {
return rootLexicalScope;
}

@Override
public ExecutionContextOptions getOptions() {
return executionContextOptions;
}

}
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ public RubyProc toProc(SourceSection sourceSection, final RubyNode currentNode)
final RubyRootNode rootNode = new RubyRootNode(context, sourceSection, new FrameDescriptor(), sharedMethodInfo,
new SymbolProcNode(context, sourceSection, symbol));

final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode, getContext());

return new RubyProc(context.getCoreLibrary().getProcClass(), RubyProc.Type.PROC, sharedMethodInfo, callTarget,
callTarget, null, getContext().getCoreLibrary().getNilObject(), null);
Original file line number Diff line number Diff line change
@@ -169,7 +169,7 @@ public MethodDefinitionNode compileFunctionNode(SourceSection sourceSection, Str
context, sourceSection, environment.getFrameDescriptor(), environment.getSharedMethodInfo(), body);

if (isBlock) {
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode, context);
final CallTarget callTargetForMethods = withoutBlockDestructureSemantics(callTarget);

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

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

0 comments on commit a28ca3a

Please sign in to comment.