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

Commits on Jul 14, 2016

  1. Copy the full SHA
    c79c46d View commit details
  2. Copy the full SHA
    e3bb19e View commit details
Showing with 12 additions and 2 deletions.
  1. +12 −2 truffle/src/main/java/org/jruby/truffle/language/arguments/ReadBlockNode.java
Original file line number Diff line number Diff line change
@@ -9,16 +9,19 @@
*/
package org.jruby.truffle.language.arguments;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.language.RubyNode;

public class ReadBlockNode extends RubyNode {

private final Object valueIfAbsent;

private final ConditionProfile blockProfile = ConditionProfile.createBinaryProfile();
private final ConditionProfile nullProfile = ConditionProfile.createBinaryProfile();
private final ConditionProfile unusualShapeProfile = ConditionProfile.createBinaryProfile();

public ReadBlockNode(Object valueIfAbsent) {
this.valueIfAbsent = valueIfAbsent;
@@ -28,9 +31,16 @@ public ReadBlockNode(Object valueIfAbsent) {
public Object execute(VirtualFrame frame) {
final DynamicObject block = RubyArguments.getBlock(frame);

if (blockProfile.profile(block == null)) {
if (nullProfile.profile(block == null)) {
return valueIfAbsent;
} else {
if (unusualShapeProfile.profile(block.getShape() != getContext().getCoreLibrary().getProcFactory().getShape())) {
if (!Layouts.PROC.isProc(block)) {
CompilerDirectives.transferToInterpreter();
throw new UnsupportedOperationException("Method passed something that isn't a Proc as a block");
}
}

return block;
}
}