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

Commits on Jan 6, 2015

  1. Copy the full SHA
    02beaf0 View commit details
  2. Copy the full SHA
    131970a View commit details
13 changes: 5 additions & 8 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -1037,14 +1037,11 @@ public Operand buildCase(CaseNode caseNode, IRScope s) {
Variable eqqResult = s.createTemporaryVariable();
labels.add(bodyLabel);
Operand v1, v2;
if (whenNode.getExpressionNodes() instanceof DNode) {
// DNode produces a proper result, so we don't want the special ListNode handling below
// FIXME: This is obviously gross, and we need a better way to filter out non-expression ListNode here
// See GH #2423
s.addInstr(new EQQInstr(eqqResult, build(whenNode.getExpressionNodes(), s), value));
v1 = eqqResult;
v2 = manager.getTrue();
} else if (whenNode.getExpressionNodes() instanceof ListNode) {
if (whenNode.getExpressionNodes() instanceof ListNode
// DNode produces a proper result, so we don't want the special ListNode handling below
// FIXME: This is obviously gross, and we need a better way to filter out non-expression ListNode here
// See GH #2423
&& !(whenNode.getExpressionNodes() instanceof DNode)) {
// Note about refactoring:
// - BEQInstr has a quick implementation when the second operand is a boolean literal
// If it can be fixed to do this even on the first operand, we can switch around
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
import org.jruby.runtime.*;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.callsite.FunctionalCachingCallSite;
import org.jruby.runtime.callsite.NormalCachingCallSite;
import org.jruby.util.ByteList;
import org.jruby.util.DefinedMessage;
import org.jruby.util.RegexpOptions;
@@ -1298,4 +1299,9 @@ public static void pushExitBlock(ThreadContext context, Block blk) {
public static FunctionalCachingCallSite newFunctionalCachingCallSite(String name) {
return new FunctionalCachingCallSite(name);
}

@JIT
public static NormalCachingCallSite newNormalCachingCallSite(String name) {
return new NormalCachingCallSite(name);
}
}
15 changes: 11 additions & 4 deletions core/src/main/java/org/jruby/ir/targets/IRBytecodeAdapter6.java
Original file line number Diff line number Diff line change
@@ -25,11 +25,13 @@
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Block;
import org.jruby.runtime.CallType;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.callsite.CachingCallSite;
import org.jruby.runtime.callsite.FunctionalCachingCallSite;
import org.jruby.runtime.callsite.NormalCachingCallSite;
import org.jruby.util.ByteList;
import org.jruby.util.JavaNameMangler;
import org.jruby.util.RegexpOptions;
@@ -191,6 +193,10 @@ public void pushEncoding(Encoding encoding) {
}

public void invokeOther(String name, int arity, boolean hasClosure) {
invoke(name, arity, hasClosure, CallType.NORMAL);
}

public void invoke(String name, int arity, boolean hasClosure, CallType callType) {
if (arity > MAX_ARGUMENTS) throw new NotCompilableException("call to `" + name + "' has more than " + MAX_ARGUMENTS + " arguments");

SkinnyMethodAdapter adapter2;
@@ -255,7 +261,8 @@ public void invokeOther(String name, int arity, boolean hasClosure) {
adapter2.ifnonnull(doCall);
adapter2.pop();
adapter2.ldc(name);
adapter2.invokestatic(p(IRRuntimeHelpers.class), "newFunctionalCachingCallSite", sig(FunctionalCachingCallSite.class, String.class));
Class siteClass = callType == CallType.NORMAL ? NormalCachingCallSite.class : FunctionalCachingCallSite.class;
adapter2.invokestatic(p(IRRuntimeHelpers.class), "new" + siteClass.getSimpleName(), sig(siteClass, String.class));
adapter2.dup();
adapter2.putstatic(getClassData().clsName, methodName, ci(CachingCallSite.class));

@@ -345,7 +352,7 @@ public void invokeOtherOneFixnum(String name, long fixnum) {
adapter2.ifnonnull(doCall);
adapter2.pop();
adapter2.ldc(name);
adapter2.invokestatic(p(IRRuntimeHelpers.class), "newFunctionalCachingCallSite", sig(FunctionalCachingCallSite.class, String.class));
adapter2.invokestatic(p(IRRuntimeHelpers.class), "newNormalCachingCallSite", sig(NormalCachingCallSite.class, String.class));
adapter2.dup();
adapter2.putstatic(getClassData().clsName, methodName, ci(CachingCallSite.class));

@@ -389,7 +396,7 @@ public void invokeOtherOneFloat(String name, double flote) {
adapter2.ifnonnull(doCall);
adapter2.pop();
adapter2.ldc(name);
adapter2.invokestatic(p(IRRuntimeHelpers.class), "newFunctionalCachingCallSite", sig(FunctionalCachingCallSite.class, String.class));
adapter2.invokestatic(p(IRRuntimeHelpers.class), "newNormalCachingCallSite", sig(NormalCachingCallSite.class, String.class));
adapter2.dup();
adapter2.putstatic(getClassData().clsName, methodName, ci(CachingCallSite.class));

@@ -411,7 +418,7 @@ public void invokeOtherOneFloat(String name, double flote) {
public void invokeSelf(String name, int arity, boolean hasClosure) {
if (arity > MAX_ARGUMENTS) throw new NotCompilableException("call to `" + name + "' has more than " + MAX_ARGUMENTS + " arguments");

invokeOther(name, arity, hasClosure);
invoke(name, arity, hasClosure, CallType.FUNCTIONAL);
}

public void invokeInstanceSuper(String name, int arity, boolean hasClosure, boolean[] splatmap) {
11 changes: 11 additions & 0 deletions spec/compiler/general_spec.rb
Original file line number Diff line number Diff line change
@@ -987,5 +987,16 @@ def foo(str: "bar", num: 45, **opts)
expect(x).to eq(true)
end
end

it "enforces visibility" do
run('obj = Class.new do
def a; true; end
private def b; true; end
protected; def c; true; end
end.new
[obj.a, (obj.b rescue false), (obj.c rescue false)]') do |x|
x.should == [true, false, false]
end
end
end
end