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: bbc88e590cfd
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0679dd072fbb
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Aug 19, 2015

  1. [Truffle] Use ProcNodes.getCallTargetForType().

    * One should not assume the type of a Proc.
    * Fixes a bunch of MRI tests.
    eregon committed Aug 19, 2015
    Copy the full SHA
    3e3e5ee View commit details
  2. [Truffle] Fix Kernel#proc.

    * It does not change the type of the given block.
    eregon committed Aug 19, 2015
    Copy the full SHA
    0679dd0 View commit details
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/kernel/proc_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -17,8 +17,10 @@
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.BindingNodes;
import org.jruby.truffle.nodes.core.ProcNodes;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;
@@ -65,7 +67,7 @@ public void trace(VirtualFrame frame) {
traceFunc = context.getTraceManager().getTraceFunc();

if (traceFunc != null) {
callNode = insert(Truffle.getRuntime().createDirectCallNode(Layouts.PROC.getCallTargetForProcs(traceFunc)));
callNode = insert(Truffle.getRuntime().createDirectCallNode(ProcNodes.getCallTargetForType(traceFunc)));
} else {
callNode = null;
}
Original file line number Diff line number Diff line change
@@ -1124,19 +1124,19 @@ public LambdaNode(RubyContext context, SourceSection sourceSection) {

@TruffleBoundary
@Specialization
public DynamicObject proc(NotProvided block) {
public DynamicObject lambda(NotProvided block) {
final Frame parentFrame = RubyCallStack.getCallerFrame(getContext()).getFrame(FrameAccess.READ_ONLY, true);
final DynamicObject parentBlock = RubyArguments.getBlock(parentFrame.getArguments());

if (parentBlock == null) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentError("tried to create Proc object without a block", this));
}
return proc(parentBlock);
return lambda(parentBlock);
}

@Specialization(guards = "isRubyProc(block)")
public DynamicObject proc(DynamicObject block) {
public DynamicObject lambda(DynamicObject block) {
return ProcNodes.createRubyProc(
getContext().getCoreLibrary().getProcClass(),
ProcNodes.Type.LAMBDA,
@@ -1352,13 +1352,35 @@ public ProcNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = "isRubyProc(block)")
public DynamicObject proc(DynamicObject block) {
CompilerDirectives.transferToInterpreter();
@TruffleBoundary
@Specialization
public DynamicObject proc(NotProvided block) {
final Frame parentFrame = RubyCallStack.getCallerFrame(getContext()).getFrame(FrameAccess.READ_ONLY, true);
final DynamicObject parentBlock = RubyArguments.getBlock(parentFrame.getArguments());

if (parentBlock == null) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentError("tried to create Proc object without a block", this));
}

if (isANormalProc(parentBlock)) {
return procNormal(parentBlock);
} else {
return procSpecial(parentBlock);
}
}

@Specialization(guards = { "isRubyProc(block)", "isANormalProc(block)" })
public DynamicObject procNormal(DynamicObject block) {
return block;
}

@Specialization(guards = { "isRubyProc(block)", "!isANormalProc(block)" })
public DynamicObject procSpecial(DynamicObject block) {
// Just make it a normal Proc without a singleton class
return ProcNodes.createRubyProc(
getContext().getCoreLibrary().getProcClass(),
ProcNodes.Type.PROC,
Layouts.PROC.getType(block),
Layouts.PROC.getSharedMethodInfo(block),
Layouts.PROC.getCallTargetForProcs(block),
Layouts.PROC.getCallTargetForLambdas(block),
@@ -1367,6 +1389,11 @@ public DynamicObject proc(DynamicObject block) {
Layouts.PROC.getSelf(block),
Layouts.PROC.getBlock(block));
}

protected boolean isANormalProc(DynamicObject block) {
return Layouts.BASIC_OBJECT.getMetaClass(block) == getContext().getCoreLibrary().getProcClass();
}

}

@CoreMethod(names = "protected_methods", optional = 1)
Original file line number Diff line number Diff line change
@@ -15,7 +15,9 @@
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.object.DynamicObject;

import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.core.ProcNodes;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;
@@ -35,7 +37,7 @@ public CachedYieldDispatchNode(RubyContext context, DynamicObject block, YieldDi

assert RubyGuards.isRubyProc(block);

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

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

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

@Override
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.object.DynamicObject;

import org.jruby.truffle.nodes.core.ProcNodes;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;
@@ -36,7 +38,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.getCallTargetForProcs(block),
return callNode.call(frame, ProcNodes.getCallTargetForType(block),
RubyArguments.pack(Layouts.PROC.getMethod(block), Layouts.PROC.getDeclarationFrame(block), self, modifiedBlock, argumentsObjects));
}