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

Commits on Oct 21, 2014

  1. Use NotCompileableException.

    headius committed Oct 21, 2014
    Copy the full SHA
    9ed6065 View commit details
  2. Copy the full SHA
    c0c13a7 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    04ab7fa View commit details
  4. Copy the full SHA
    6a62bd2 View commit details
Showing with 17 additions and 9 deletions.
  1. +10 −2 core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
  2. +7 −7 spec/compiler/general_spec.rb
12 changes: 10 additions & 2 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import com.headius.invokebinder.Signature;
import org.jruby.*;
import org.jruby.compiler.NotCompilableException;
import org.jruby.compiler.impl.SkinnyMethodAdapter;
import org.jruby.internal.runtime.GlobalVariables;
import org.jruby.internal.runtime.methods.DynamicMethod;
@@ -47,6 +48,7 @@ public class JVMVisitor extends IRVisitor {

private static final Logger LOG = LoggerFactory.getLogger("JVMVisitor");
public static final String DYNAMIC_SCOPE = "$dynamicScope";
private static final boolean DEBUG = false;

public JVMVisitor() {
this.jvm = Options.COMPILE_INVOKEDYNAMIC.load() ? new JVM7() : new JVM6();
@@ -154,6 +156,7 @@ public void emitScope(IRScope scope, String name, Signature signature) {
IRBytecodeAdapter m = jvmMethod();

int numberOfLabels = bbs.size();
int ipc = 0; // synthetic, used for debug traces that show which instr failed
for (int i = 0; i < numberOfLabels; i++) {
BasicBlock bb = bbs.get(i);
org.objectweb.asm.Label start = jvm.methodData().getLabel(bb.getLabel());
@@ -180,6 +183,7 @@ public void emitScope(IRScope scope, String name, Signature signature) {

// visit remaining instrs
for (Instr instr : bb.getInstrs()) {
if (DEBUG) instr.setIPC(ipc++); // debug mode uses instr offset for backtrace
visit(instr);
}

@@ -286,6 +290,9 @@ public Handle emitModuleBody(IRModuleBody method) {
}

public void visit(Instr instr) {
if (DEBUG) { // debug will skip emitting actual file line numbers
jvmAdapter().line(instr.getIPC());
}
instr.visit(this);
}

@@ -752,8 +759,7 @@ private void compileCallCommon(IRBytecodeAdapter m, String name, Operand[] args,
m.adapter.invokevirtual(p(RubyArray.class), "toJavaArray", sig(IRubyObject[].class));
arity = -1;
} else if (CallBase.containsArgSplat(args)) {
arity = -1;
throw new RuntimeException("splat in non-initial argument for normal call is unsupported in JIT");
throw new NotCompilableException("splat in non-initial argument for normal call is unsupported in JIT");
} else {
for (Operand operand : args) {
visit(operand);
@@ -1085,6 +1091,8 @@ public void LexicalSearchConstInstr(LexicalSearchConstInstr lexicalsearchconstin

@Override
public void LineNumberInstr(LineNumberInstr linenumberinstr) {
if (DEBUG) return; // debug mode uses IPC for line numbers

jvmAdapter().line(linenumberinstr.getLineNumber() + 1);
}

14 changes: 7 additions & 7 deletions spec/compiler/general_spec.rb
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ def compile_to_method(src, filename = nil, lineno = 0)
handle,
method,
oj.runtime.Visibility::PUBLIC,
JRuby.runtime.top_self.class)
currModule)
end

def next_id
@@ -236,10 +236,10 @@ def foo
end

it "compiles attribute assignment" do
run("def a=(x); 2; end; self.a = 1") {|result| expect(result).to eq 1 }
run("def a; 1; end; def a=(arg); fail; end; self.a ||= 2") {|result| expect(result).to eq 1 }
run("public; def a=(x); 2; end; self.a = 1") {|result| expect(result).to eq 1 }
run("public; def a; 1; end; def a=(arg); fail; end; self.a ||= 2") {|result| expect(result).to eq 1 }
run("public; def a; @a; end; def a=(arg); @a = arg; 4; end; x = self.a ||= 1; [x, self.a]") {|result| expect(result).to eq([1,1]) }
run("def a; nil; end; def a=(arg); fail; end; self.a &&= 2") {|result| expect(result).to be_nil }
run("public; def a; nil; end; def a=(arg); fail; end; self.a &&= 2") {|result| expect(result).to be_nil }
run("public; def a; @a; end; def a=(arg); @a = arg; end; @a = 3; x = self.a &&= 1; [x, self.a]") {|result| expect(result).to eq([1,1]) }
end

@@ -555,14 +555,14 @@ def blank?
it "properly scopes singleton method definitions in a compiled body" do
run("
class GH1239
def self.define; def bar; end; end
def self.remove; remove_method :bar; end
def self.define; def gh1239; end; end
def self.remove; remove_method :gh1239; end
end
GH1239
") do |cls|

cls.define
expect(cls.methods).not_to be_include :bar
expect(cls.methods).not_to be_include :gh1239
expect{cls.remove}.not_to raise_error
end
end