Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a51620e29012
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 93e2addf2e29
Choose a head ref
  • 3 commits
  • 12 files changed
  • 1 contributor

Commits on Aug 19, 2015

  1. [Truffle] Fix typo.

    eregon committed Aug 19, 2015
    Copy the full SHA
    c15e34c View commit details
  2. Copy the full SHA
    e9c8fee View commit details
  3. Copy the full SHA
    93e2add View commit details
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ public boolean executeBoolean(VirtualFrame frame) {
}

// If the single argument is a RubyArray, destructure
// TODO(CS): can we not just reply on the respondToCheck? Should experiment.
// TODO(CS): can we not just rely on the respondToCheck? Should experiment.

if (RubyGuards.isRubyArray(RubyArguments.getUserArgument(frame.getArguments(), 0))) {
return true;
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ public void trace(VirtualFrame frame) {
traceFunc = context.getTraceManager().getTraceFunc();

if (traceFunc != null) {
callNode = insert(Truffle.getRuntime().createDirectCallNode(Layouts.PROC.getCallTargetForBlocks(traceFunc)));
callNode = insert(Truffle.getRuntime().createDirectCallNode(Layouts.PROC.getCallTargetForProcs(traceFunc)));
} else {
callNode = null;
}
Original file line number Diff line number Diff line change
@@ -1143,7 +1143,6 @@ public DynamicObject proc(DynamicObject block) {
Layouts.PROC.getSharedMethodInfo(block),
Layouts.PROC.getCallTargetForLambdas(block),
Layouts.PROC.getCallTargetForLambdas(block),
Layouts.PROC.getCallTargetForLambdas(block),
Layouts.PROC.getDeclarationFrame(block),
Layouts.PROC.getMethod(block),
Layouts.PROC.getSelf(block),
@@ -1362,7 +1361,6 @@ public DynamicObject proc(DynamicObject block) {
ProcNodes.Type.PROC,
Layouts.PROC.getSharedMethodInfo(block),
Layouts.PROC.getCallTargetForProcs(block),
Layouts.PROC.getCallTargetForProcs(block),
Layouts.PROC.getCallTargetForLambdas(block),
Layouts.PROC.getDeclarationFrame(block),
Layouts.PROC.getMethod(block),
Original file line number Diff line number Diff line change
@@ -252,7 +252,6 @@ public DynamicObject toProcUncached(DynamicObject methodObject) {
method.getSharedMethodInfo(),
callTarget,
callTarget,
callTarget,
method.getDeclarationFrame(),
method,
Layouts.METHOD.getReceiver(methodObject),
41 changes: 19 additions & 22 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/ProcNodes.java
Original file line number Diff line number Diff line change
@@ -42,8 +42,6 @@ public abstract class ProcNodes {

public static CallTarget getCallTargetForType(DynamicObject proc) {
switch (Layouts.PROC.getType(proc)) {
case BLOCK:
return Layouts.PROC.getCallTargetForBlocks(proc);
case PROC:
return Layouts.PROC.getCallTargetForProcs(proc);
case LAMBDA:
@@ -64,13 +62,12 @@ public static Object rootCall(DynamicObject proc, Object... args) {
args));
}

public static void initialize(DynamicObject proc, SharedMethodInfo sharedMethodInfo, CallTarget callTargetForBlocks, CallTarget callTargetForProcs,
CallTarget callTargetForLambdas, MaterializedFrame declarationFrame, InternalMethod method,
Object self, DynamicObject block) {
public static void initialize(DynamicObject proc, SharedMethodInfo sharedMethodInfo, CallTarget callTargetForProcs, CallTarget callTargetForLambdas,
MaterializedFrame declarationFrame, InternalMethod method, Object self,
DynamicObject block) {
assert RubyGuards.isRubyProc(proc);

Layouts.PROC.setSharedMethodInfo(proc, sharedMethodInfo);
Layouts.PROC.setCallTargetForBlocks(proc, callTargetForBlocks);
Layouts.PROC.setCallTargetForProcs(proc, callTargetForProcs);
Layouts.PROC.setCallTargetForLambdas(proc, callTargetForLambdas);
Layouts.PROC.setDeclarationFrame(proc, declarationFrame);
@@ -81,28 +78,28 @@ public static void initialize(DynamicObject proc, SharedMethodInfo sharedMethodI
}

public static DynamicObject createRubyProc(DynamicObject procClass, Type type) {
return createRubyProc(procClass, type, null, null, null, null, null, null, null, null);
return createRubyProc(procClass, type, null, null, null, null, null, null, null);
}

public static DynamicObject createRubyProc(DynamicObject procClass, Type type, SharedMethodInfo sharedMethodInfo, CallTarget callTargetForBlocks,
CallTarget callTargetForProcs, CallTarget callTargetForLambdas, MaterializedFrame declarationFrame,
InternalMethod method, Object self, DynamicObject block) {
return createRubyProc(Layouts.CLASS.getInstanceFactory(procClass), type, sharedMethodInfo, callTargetForBlocks,
callTargetForProcs, callTargetForLambdas, declarationFrame,
method, self, block);
public static DynamicObject createRubyProc(DynamicObject procClass, Type type, SharedMethodInfo sharedMethodInfo, CallTarget callTargetForProcs,
CallTarget callTargetForLambdas, MaterializedFrame declarationFrame, InternalMethod method,
Object self, DynamicObject block) {
return createRubyProc(Layouts.CLASS.getInstanceFactory(procClass), type, sharedMethodInfo, callTargetForProcs,
callTargetForLambdas, declarationFrame, method,
self, block);
}

public static DynamicObject createRubyProc(DynamicObjectFactory instanceFactory, Type type, SharedMethodInfo sharedMethodInfo, CallTarget callTargetForBlocks,
CallTarget callTargetForProcs, CallTarget callTargetForLambdas, MaterializedFrame declarationFrame,
InternalMethod method, Object self, DynamicObject block) {
final DynamicObject proc = Layouts.PROC.createProc(instanceFactory, type, null, null, null, null, null, null, null, null);
ProcNodes.initialize(proc, sharedMethodInfo, callTargetForBlocks, callTargetForProcs, callTargetForLambdas, declarationFrame,
method, self, block);
public static DynamicObject createRubyProc(DynamicObjectFactory instanceFactory, Type type, SharedMethodInfo sharedMethodInfo, CallTarget callTargetForProcs,
CallTarget callTargetForLambdas, MaterializedFrame declarationFrame, InternalMethod method,
Object self, DynamicObject block) {
final DynamicObject proc = Layouts.PROC.createProc(instanceFactory, type, null, null, null, null, null, null, null);
ProcNodes.initialize(proc, sharedMethodInfo, callTargetForProcs, callTargetForLambdas, declarationFrame, method,
self, block);
return proc;
}

public enum Type {
BLOCK, PROC, LAMBDA
PROC, LAMBDA
}

@CoreMethod(names = "arity")
@@ -169,8 +166,8 @@ public InitializeNode(RubyContext context, SourceSection sourceSection) {
@Specialization(guards = "isRubyProc(block)")
public DynamicObject initialize(DynamicObject proc, DynamicObject block) {
ProcNodes.initialize(proc, Layouts.PROC.getSharedMethodInfo(block), Layouts.PROC.getCallTargetForProcs(block),
Layouts.PROC.getCallTargetForProcs(block), Layouts.PROC.getCallTargetForLambdas(block), Layouts.PROC.getDeclarationFrame(block),
Layouts.PROC.getMethod(block), Layouts.PROC.getSelf(block), Layouts.PROC.getBlock(block));
Layouts.PROC.getCallTargetForLambdas(block), Layouts.PROC.getDeclarationFrame(block), Layouts.PROC.getMethod(block),
Layouts.PROC.getSelf(block), Layouts.PROC.getBlock(block));

return nil();
}
Original file line number Diff line number Diff line change
@@ -150,9 +150,8 @@ protected DynamicObject createProc(DynamicObject symbol) {
getContext().getCoreLibrary().getProcClass(),
ProcNodes.Type.PROC,
sharedMethodInfo,
callTarget, callTarget, callTarget,
null, null,
Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(symbol)).getContext().getCoreLibrary().getNilObject(),
callTarget, callTarget, null,
null, Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(symbol)).getContext().getCoreLibrary().getNilObject(),
null);
}

Original file line number Diff line number Diff line change
@@ -2474,7 +2474,7 @@ public Object max(VirtualFrame frame, DynamicObject array) {

final DynamicObject block = ProcNodes.createRubyProc(getContext().getCoreLibrary().getProcClass(), ProcNodes.Type.PROC,
maxBlock.getSharedMethodInfo(), maxBlock.getCallTarget(), maxBlock.getCallTarget(),
maxBlock.getCallTarget(), maximumClosureFrame.materialize(), null, array, null);
maximumClosureFrame.materialize(), null, array, null);

eachNode.call(frame, array, "each", block);

@@ -2576,7 +2576,7 @@ public Object min(VirtualFrame frame, DynamicObject array) {

final DynamicObject block = ProcNodes.createRubyProc(getContext().getCoreLibrary().getProcClass(), ProcNodes.Type.PROC,
minBlock.getSharedMethodInfo(), minBlock.getCallTarget(), minBlock.getCallTarget(),
minBlock.getCallTarget(), minimumClosureFrame.materialize(), null, array, null);
minimumClosureFrame.materialize(), null, array, null);

eachNode.call(frame, array, "each", block);

Original file line number Diff line number Diff line change
@@ -30,23 +30,20 @@ public class BlockDefinitionNode extends RubyNode {
private final Type type;
private final SharedMethodInfo sharedMethodInfo;

// TODO(CS, 10-Jan-15) having three call targets isn't ideal, but they all have different semantics, and we don't
// TODO(CS, 10-Jan-15) having two call targets isn't ideal, but they all have different semantics, and we don't
// want to move logic into the call site

private final CallTarget callTargetForBlocks;
private final CallTarget callTargetForProcs;
private final CallTarget callTargetForLambdas;

private final BreakID breakID;

public BlockDefinitionNode(RubyContext context, SourceSection sourceSection, Type type, SharedMethodInfo sharedMethodInfo,
CallTarget callTargetForBlocks, CallTarget callTargetForProcs, CallTarget callTargetForLambdas,
BreakID breakID) {
CallTarget callTargetForProcs, CallTarget callTargetForLambdas, BreakID breakID) {
super(context, sourceSection);
this.type = type;
this.sharedMethodInfo = sharedMethodInfo;

this.callTargetForBlocks = callTargetForBlocks;
this.callTargetForProcs = callTargetForProcs;
this.callTargetForLambdas = callTargetForLambdas;
this.breakID = breakID;
@@ -59,8 +56,7 @@ public BreakID getBreakID() {
@Override
public Object execute(VirtualFrame frame) {
return ProcNodes.createRubyProc(getContext().getCoreLibrary().getProcFactory(), type, sharedMethodInfo,
callTargetForBlocks, callTargetForProcs, callTargetForLambdas,
frame.materialize(),
callTargetForProcs, callTargetForLambdas, frame.materialize(),
RubyArguments.getMethod(frame.getArguments()),
RubyArguments.getSelf(frame.getArguments()),
RubyArguments.getBlock(frame.getArguments()));
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ public CachedYieldDispatchNode(RubyContext context, DynamicObject block, YieldDi

assert RubyGuards.isRubyProc(block);

callNode = Truffle.getRuntime().createDirectCallNode(Layouts.PROC.getCallTargetForBlocks(block));
callNode = Truffle.getRuntime().createDirectCallNode(Layouts.PROC.getCallTargetForProcs(block));
insert(callNode);

if (INLINER_ALWAYS_CLONE_YIELD && callNode.isCallTargetCloningAllowed()) {
@@ -51,7 +51,7 @@ public CachedYieldDispatchNode(RubyContext context, DynamicObject block, YieldDi

@Override
protected boolean guard(DynamicObject block) {
return Layouts.PROC.getCallTargetForBlocks(block) == callNode.getCallTarget();
return Layouts.PROC.getCallTargetForProcs(block) == callNode.getCallTarget();
}

@Override
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ protected boolean guard(DynamicObject block) {

@Override
public Object dispatchWithSelfAndBlock(VirtualFrame frame, DynamicObject block, Object self, DynamicObject modifiedBlock, Object... argumentsObjects) {
return callNode.call(frame, Layouts.PROC.getCallTargetForBlocks(block),
return callNode.call(frame, Layouts.PROC.getCallTargetForProcs(block),
RubyArguments.pack(Layouts.PROC.getMethod(block), Layouts.PROC.getDeclarationFrame(block), self, modifiedBlock, argumentsObjects));
}

Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@ DynamicObject createProc(
DynamicObjectFactory factory,
@Nullable ProcNodes.Type type,
@Nullable SharedMethodInfo sharedMethodInfo,
@Nullable CallTarget callTargetForBlocks,
@Nullable CallTarget callTargetForProcs,
@Nullable CallTarget callTargetForLambdas,
@Nullable MaterializedFrame declarationFrame,
@@ -45,9 +44,6 @@ DynamicObject createProc(
SharedMethodInfo getSharedMethodInfo(DynamicObject object);
void setSharedMethodInfo(DynamicObject object, SharedMethodInfo value);

CallTarget getCallTargetForBlocks(DynamicObject object);
void setCallTargetForBlocks(DynamicObject object, CallTarget value);

CallTarget getCallTargetForProcs(DynamicObject object);
void setCallTargetForProcs(DynamicObject object, CallTarget value);

Original file line number Diff line number Diff line change
@@ -134,16 +134,6 @@ public BlockDefinitionNode compileBlockNode(SourceSection sourceSection, String

body = new CatchRetryAsErrorNode(context, sourceSection, body);

// Blocks
final RubyNode newNodeForBlocks = NodeUtil.cloneNode(body);

for (BehaveAsBlockNode behaveAsBlockNode : NodeUtil.findAllNodeInstances(newNodeForBlocks, BehaveAsBlockNode.class)) {
behaveAsBlockNode.replace(behaveAsBlockNode.getAsBlock());
}

final RubyRootNode newRootNodeForBlocks = new RubyRootNode(context, sourceSection, environment.getFrameDescriptor(), environment.getSharedMethodInfo(),
newNodeForBlocks, environment.needsDeclarationFrame());

// Procs
final RubyNode newNodeForProcs = NodeUtil.cloneNode(body);

@@ -169,12 +159,11 @@ public BlockDefinitionNode compileBlockNode(SourceSection sourceSection, String
newNodeForLambdas, environment.getReturnID())),
environment.needsDeclarationFrame());

final CallTarget callTargetAsBlock = Truffle.getRuntime().createCallTarget(newRootNodeForBlocks);
final CallTarget callTargetAsProc = Truffle.getRuntime().createCallTarget(newRootNodeForProcs);
final CallTarget callTargetAsLambda = Truffle.getRuntime().createCallTarget(newRootNodeForLambdas);

return new BlockDefinitionNode(context, sourceSection, type, environment.getSharedMethodInfo(),
callTargetAsBlock, callTargetAsProc, callTargetAsLambda, environment.getBreakID());
callTargetAsProc, callTargetAsLambda, environment.getBreakID());
}

public MethodDefinitionNode compileMethodNode(SourceSection sourceSection, String methodName, org.jruby.ast.Node bodyNode, SharedMethodInfo sharedMethodInfo) {