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

Commits on Oct 20, 2014

  1. Copy the full SHA
    9ac0aed View commit details
  2. Copy the full SHA
    fe76c37 View commit details
  3. Copy the full SHA
    ad8ac98 View commit details
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubyFixnum.java
Original file line number Diff line number Diff line change
@@ -136,13 +136,13 @@ public Object constant() {
Object constant = null;
long value = this.value;

if (value <= 255 && value >= -256) {
if (value < CACHE_OFFSET && value >= -CACHE_OFFSET) {
Object[] fixnumConstants = getRuntime().fixnumConstants;
constant = fixnumConstants[(int) value];
constant = fixnumConstants[(int) value + CACHE_OFFSET];

if (constant == null) {
constant = OptoFactory.newConstantWrapper(IRubyObject.class, this);
fixnumConstants[(int) value] = constant;
fixnumConstants[(int) value + CACHE_OFFSET] = constant;
}
}

4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -933,8 +933,8 @@ public static RubyEncoding retrieveEncoding(ThreadContext context, String name)
// Used by JIT
public static RubyHash constructHashFromArray(Ruby runtime, IRubyObject[] pairs) {
RubyHash hash = RubyHash.newHash(runtime);
for (int i = 0; i < pairs.length / 2; i++) {
hash.fastASet(runtime, pairs[i], pairs[i + 1], true);
for (int i = 0; i < pairs.length;) {
hash.fastASet(runtime, pairs[i++], pairs[i++], true);
}
return hash;
}
Original file line number Diff line number Diff line change
@@ -33,6 +33,8 @@
* @author headius
*/
public abstract class IRBytecodeAdapter {
public static final int MAX_ARGUMENTS = 250;

public IRBytecodeAdapter(SkinnyMethodAdapter adapter, Signature signature, ClassData classData) {
this.adapter = adapter;
this.signature = signature;
17 changes: 17 additions & 0 deletions core/src/main/java/org/jruby/ir/targets/IRBytecodeAdapter6.java
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.jruby.RubyRegexp;
import org.jruby.RubyString;
import org.jruby.RubySymbol;
import org.jruby.compiler.NotCompilableException;
import org.jruby.compiler.impl.SkinnyMethodAdapter;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.parser.StaticScope;
@@ -98,6 +99,8 @@ public void pushEncoding(Encoding encoding) {
}

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

SkinnyMethodAdapter adapter2;
String incomingSig;
String outgoingSig;
@@ -184,22 +187,32 @@ public static void buildArrayFromLocals(SkinnyMethodAdapter adapter2, int base,
}

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);
}

public void invokeInstanceSuper(String name, int arity, boolean hasClosure, boolean[] splatmap) {
if (arity > MAX_ARGUMENTS) throw new NotCompilableException("call to instance super has more than " + MAX_ARGUMENTS + " arguments");

performSuper(name, arity, hasClosure, splatmap, "instanceSuperSplatArgs", false);
}

public void invokeClassSuper(String name, int arity, boolean hasClosure, boolean[] splatmap) {
if (arity > MAX_ARGUMENTS) throw new NotCompilableException("call to class super has more than " + MAX_ARGUMENTS + " arguments");

performSuper(name, arity, hasClosure, splatmap, "classSuperSplatArgs", false);
}

public void invokeUnresolvedSuper(String name, int arity, boolean hasClosure, boolean[] splatmap) {
if (arity > MAX_ARGUMENTS) throw new NotCompilableException("call to unresolved super has more than " + MAX_ARGUMENTS + " arguments");

performSuper(name, arity, hasClosure, splatmap, "unresolvedSuperSplatArgs", true);
}

public void invokeZSuper(String name, int arity, boolean hasClosure, boolean[] splatmap) {
if (arity > MAX_ARGUMENTS) throw new NotCompilableException("call to zsuper has more than " + MAX_ARGUMENTS + " arguments");

performSuper(name, arity, hasClosure, splatmap, "zSuperSplatArgs", true);
}

@@ -311,6 +324,8 @@ public void getField(String name) {
}

public void array(int length) {
if (length > MAX_ARGUMENTS) throw new NotCompilableException("literal array has more than " + MAX_ARGUMENTS + " elements");

SkinnyMethodAdapter adapter2;
String incomingSig = sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, length));

@@ -339,6 +354,8 @@ public void array(int length) {
}

public void hash(int length) {
if (length > MAX_ARGUMENTS) throw new NotCompilableException("literal hash has more than " + (MAX_ARGUMENTS / 2) + " pairs");

SkinnyMethodAdapter adapter2;
String incomingSig = sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, length * 2));

28 changes: 18 additions & 10 deletions core/src/main/java/org/jruby/ir/targets/IRBytecodeAdapter7.java
Original file line number Diff line number Diff line change
@@ -12,28 +12,19 @@
import org.jruby.RubyEncoding;
import org.jruby.RubyRegexp;
import org.jruby.RubyString;
import org.jruby.compiler.NotCompilableException;
import org.jruby.compiler.impl.SkinnyMethodAdapter;
import org.jruby.ir.operands.UndefinedValue;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Block;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.invokedynamic.InvokeDynamicSupport;
import org.jruby.util.ByteList;
import org.jruby.util.JavaNameMangler;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.Method;

import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;

import static org.jruby.util.CodegenUtils.ci;
import static org.jruby.util.CodegenUtils.p;
import static org.jruby.util.CodegenUtils.params;
import static org.jruby.util.CodegenUtils.sig;

@@ -42,6 +33,7 @@
* @author headius
*/
public class IRBytecodeAdapter7 extends IRBytecodeAdapter {

public IRBytecodeAdapter7(SkinnyMethodAdapter adapter, Signature signature, ClassData classData) {
super(adapter, signature, classData);
}
@@ -89,6 +81,8 @@ public void pushEncoding(Encoding encoding) {
}

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

if (hasClosure) {
if (arity == -1) {
adapter.invokedynamic("invoke:" + JavaNameMangler.mangleMethodName(name), sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT, JVM.OBJECT_ARRAY, Block.class)), Bootstrap.invoke());
@@ -105,6 +99,8 @@ public void invokeOther(String name, int arity, boolean hasClosure) {
}

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");

if (hasClosure) {
if (arity == -1) {
adapter.invokedynamic("invokeSelf:" + JavaNameMangler.mangleMethodName(name), sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT, JVM.OBJECT_ARRAY, Block.class)), Bootstrap.invokeSelf());
@@ -121,6 +117,8 @@ public void invokeSelf(String name, int arity, boolean hasClosure) {
}

public void invokeInstanceSuper(String name, int arity, boolean hasClosure, boolean[] splatmap) {
if (arity > MAX_ARGUMENTS) throw new NotCompilableException("call to instance super has more than " + MAX_ARGUMENTS + " arguments");

String splatmapString = IRRuntimeHelpers.encodeSplatmap(splatmap);
if (hasClosure) {
adapter.invokedynamic("invokeInstanceSuper:" + JavaNameMangler.mangleMethodName(name), sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT, RubyClass.class, JVM.OBJECT, arity, Block.class)), Bootstrap.invokeSuper(), splatmapString);
@@ -130,6 +128,8 @@ public void invokeInstanceSuper(String name, int arity, boolean hasClosure, bool
}

public void invokeClassSuper(String name, int arity, boolean hasClosure, boolean[] splatmap) {
if (arity > MAX_ARGUMENTS) throw new NotCompilableException("call to class super has more than " + MAX_ARGUMENTS + " arguments");

String splatmapString = IRRuntimeHelpers.encodeSplatmap(splatmap);
if (hasClosure) {
adapter.invokedynamic("invokeClassSuper:" + JavaNameMangler.mangleMethodName(name), sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT, RubyClass.class, JVM.OBJECT, arity, Block.class)), Bootstrap.invokeSuper(), splatmapString);
@@ -139,6 +139,8 @@ public void invokeClassSuper(String name, int arity, boolean hasClosure, boolean
}

public void invokeUnresolvedSuper(String name, int arity, boolean hasClosure, boolean[] splatmap) {
if (arity > MAX_ARGUMENTS) throw new NotCompilableException("call to unresolved super has more than " + MAX_ARGUMENTS + " arguments");

String splatmapString = IRRuntimeHelpers.encodeSplatmap(splatmap);
if (hasClosure) {
adapter.invokedynamic("invokeUnresolvedSuper:" + JavaNameMangler.mangleMethodName(name), sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT, RubyClass.class, JVM.OBJECT, arity, Block.class)), Bootstrap.invokeSuper(), splatmapString);
@@ -148,6 +150,8 @@ public void invokeUnresolvedSuper(String name, int arity, boolean hasClosure, bo
}

public void invokeZSuper(String name, int arity, boolean hasClosure, boolean[] splatmap) {
if (arity > MAX_ARGUMENTS) throw new NotCompilableException("call to zsuper has more than " + MAX_ARGUMENTS + " arguments");

String splatmapString = IRRuntimeHelpers.encodeSplatmap(splatmap);
if (hasClosure) {
adapter.invokedynamic("invokeUnresolvedSuper:" + JavaNameMangler.mangleMethodName(name), sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT, RubyClass.class, JVM.OBJECT, arity, Block.class)), Bootstrap.invokeSuper(), splatmapString);
@@ -195,10 +199,14 @@ public void getField(String name) {
}

public void array(int length) {
if (length > MAX_ARGUMENTS) throw new NotCompilableException("literal array has more than " + MAX_ARGUMENTS + " elements");

adapter.invokedynamic("array", sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, length)), Bootstrap.array());
}

public void hash(int length) {
if (length > MAX_ARGUMENTS / 2) throw new NotCompilableException("literal hash has more than " + (MAX_ARGUMENTS / 2) + " pairs");

adapter.invokedynamic("hash", sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, length * 2)), Bootstrap.hash());
}