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: 86884e7596ab
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9b2151384b0b
Choose a head ref

Commits on Jan 7, 2016

  1. Copy the full SHA
    cd5bb2e View commit details
  2. Copy the full SHA
    c1c80fd View commit details
  3. Copy the full SHA
    5d57f49 View commit details
  4. DRY out (common) real-class generator functionality + delay cw.toByte…

    …Array()
    
    also fixes bug write(null) in DEBUG mode when a the class would be already defined
    kares committed Jan 7, 2016
    Copy the full SHA
    0c73998 View commit details
  5. Copy the full SHA
    a0b7027 View commit details
  6. Copy the full SHA
    2a93fef View commit details
  7. [ji] cleanup Java.java - re-arrange imports, unify exception handling…

    …, split private method
    kares committed Jan 7, 2016
    Copy the full SHA
    c3c1de1 View commit details
  8. Copy the full SHA
    074e661 View commit details
  9. improve interface implementation spec to be "cleaner" in tested behavior

    ... as currently proxy based ifaces do not handle non exact method names
    kares committed Jan 7, 2016
    Copy the full SHA
    730a74e View commit details
  10. Copy the full SHA
    3fdf64a View commit details
  11. Copy the full SHA
    e978231 View commit details
  12. Copy the full SHA
    bc87e05 View commit details
  13. Copy the full SHA
    c0c0e86 View commit details
  14. Copy the full SHA
    6627d62 View commit details
  15. [ji] improve (default) generated Ruby interface impls to handle Objec…

    …t method overrides
    
    so that e.g. java.util.Map#equals when implemented in Ruby picks up the method
    
    RuntimeCache#searchWithCacheNoMethodMissing is added as the Java Object fallback
    need to be triggered when an explicit match is not found instead of method_missing ...
    
    also added LICENSE in *RealClassGenerator.java*
    kares committed Jan 7, 2016
    Copy the full SHA
    32c9627 View commit details
  16. Copy the full SHA
    21b92f5 View commit details
  17. Copy the full SHA
    ce4524c View commit details
  18. Copy the full SHA
    ccfebb1 View commit details
  19. Copy the full SHA
    1d06c29 View commit details
  20. Copy the full SHA
    7f47422 View commit details
  21. Copy the full SHA
    9b21513 View commit details
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -5094,8 +5094,8 @@ public FilenoUtil getFilenoUtil() {
private final Random random;

/** The runtime-local seed for hash randomization */
private long hashSeedK0;
private long hashSeedK1;
private final long hashSeedK0;
private final long hashSeedK1;

private StaticScopeFactory staticScopeFactory;

34 changes: 17 additions & 17 deletions core/src/main/java/org/jruby/RubyClass.java
Original file line number Diff line number Diff line change
@@ -159,27 +159,27 @@ public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
* Set a reflective allocator that calls the "standard" Ruby object
* constructor (Ruby, RubyClass) on the given class.
*
* @param cls The class from which to grab a standard Ruby constructor
* @param clazz The class from which to grab a standard Ruby constructor
*/
public void setRubyClassAllocator(final Class cls) {
public void setRubyClassAllocator(final Class<? extends IRubyObject> clazz) {
try {
final Constructor constructor = cls.getConstructor(Ruby.class, RubyClass.class);
final Constructor<? extends IRubyObject> constructor = clazz.getConstructor(Ruby.class, RubyClass.class);

this.allocator = new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
try {
return (IRubyObject)constructor.newInstance(runtime, klazz);
return constructor.newInstance(runtime, klazz);
} catch (InvocationTargetException ite) {
throw runtime.newTypeError("could not allocate " + cls + " with (Ruby, RubyClass) constructor:\n" + ite);
throw runtime.newTypeError("could not allocate " + clazz + " with (Ruby, RubyClass) constructor:\n" + ite);
} catch (InstantiationException ie) {
throw runtime.newTypeError("could not allocate " + cls + " with (Ruby, RubyClass) constructor:\n" + ie);
throw runtime.newTypeError("could not allocate " + clazz + " with (Ruby, RubyClass) constructor:\n" + ie);
} catch (IllegalAccessException iae) {
throw runtime.newSecurityError("could not allocate " + cls + " due to inaccessible (Ruby, RubyClass) constructor:\n" + iae);
throw runtime.newSecurityError("could not allocate " + clazz + " due to inaccessible (Ruby, RubyClass) constructor:\n" + iae);
}
}
};

this.reifiedClass = cls;
this.reifiedClass = clazz;
} catch (NoSuchMethodException nsme) {
throw new RuntimeException(nsme);
}
@@ -190,26 +190,26 @@ public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
* constructor (Ruby, RubyClass) on the given class via a static
* __allocate__ method intermediate.
*
* @param cls The class from which to grab a standard Ruby __allocate__
* @param clazz The class from which to grab a standard Ruby __allocate__
* method.
*/
public void setRubyStaticAllocator(final Class cls) {
public void setRubyStaticAllocator(final Class<?> clazz) {
try {
final Method method = cls.getDeclaredMethod("__allocate__", Ruby.class, RubyClass.class);
final Method method = clazz.getDeclaredMethod("__allocate__", Ruby.class, RubyClass.class);

this.allocator = new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
try {
return (IRubyObject)method.invoke(null, runtime, klazz);
return (IRubyObject) method.invoke(null, runtime, klazz);
} catch (InvocationTargetException ite) {
throw runtime.newTypeError("could not allocate " + cls + " with (Ruby, RubyClass) constructor:\n" + ite);
throw runtime.newTypeError("could not allocate " + clazz + " with (Ruby, RubyClass) constructor:\n" + ite);
} catch (IllegalAccessException iae) {
throw runtime.newSecurityError("could not allocate " + cls + " due to inaccessible (Ruby, RubyClass) constructor:\n" + iae);
throw runtime.newSecurityError("could not allocate " + clazz + " due to inaccessible (Ruby, RubyClass) constructor:\n" + iae);
}
}
};

this.reifiedClass = cls;
this.reifiedClass = clazz;
} catch (NoSuchMethodException nsme) {
throw new RuntimeException(nsme);
}
@@ -1578,11 +1578,11 @@ public synchronized void reify(String classDumpDir, boolean useChildLoader) {
}
}

public void setReifiedClass(Class newReifiedClass) {
public void setReifiedClass(Class<? extends IRubyObject> newReifiedClass) {
this.reifiedClass = newReifiedClass;
}

public Class getReifiedClass() {
public Class<? extends IRubyObject> getReifiedClass() {
return reifiedClass;
}

48 changes: 17 additions & 31 deletions core/src/main/java/org/jruby/RubyInstanceConfig.java
Original file line number Diff line number Diff line change
@@ -59,7 +59,6 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -114,12 +113,7 @@ public RubyInstanceConfig() {

threadDumpSignal = Options.THREAD_DUMP_SIGNAL.load();

environment = new HashMap<String,String>();
try {
environment.putAll(System.getenv());
} catch (SecurityException se) {
}
setupEnvironment(getJRubyHome());
initEnvironment();
}

public RubyInstanceConfig(RubyInstanceConfig parentConfig) {
@@ -141,11 +135,15 @@ public RubyInstanceConfig(RubyInstanceConfig parentConfig) {
profilingService = parentConfig.profilingService;
profilingMode = parentConfig.profilingMode;

environment = new HashMap<String, String>();
initEnvironment();
}

private void initEnvironment() {
environment = new HashMap<String,String>();
try {
environment.putAll(System.getenv());
} catch (SecurityException se) {
}
catch (SecurityException se) { /* ignore missing getenv permission */ }
setupEnvironment(getJRubyHome());
}

@@ -1611,15 +1609,6 @@ public boolean shouldPrecompileAll() {
// Static configuration fields, used as defaults for new JRuby instances.
////////////////////////////////////////////////////////////////////////////

// NOTE: These BigDecimal fields must be initialized before calls to initGlobalJavaVersion

/** A BigDecimal representing 1.5, for Java spec version matching */
private static final BigDecimal BIGDECIMAL_1_5 = new BigDecimal("1.5");
/** A BigDecimal representing 1.6, for Java spec version matching */
private static final BigDecimal BIGDECIMAL_1_6 = new BigDecimal("1.6");
/** A BigDecimal representing 1.7, for Java spec version matching */
private static final BigDecimal BIGDECIMAL_1_7 = new BigDecimal("1.7");

/**
* The version to use for generated classes. Set to current JVM version by default
*/
@@ -1853,19 +1842,16 @@ public boolean shouldPrecompileAll() {
////////////////////////////////////////////////////////////////////////////

private static int initGlobalJavaVersion() {
String specVersion = Options.BYTECODE_VERSION.load();

// stack map calculation is failing for some compilation scenarios, so
// forcing both 1.5 and 1.6 to use 1.5 bytecode for the moment.
if (specVersion.equals("1.5")) {// || specVersion.equals("1.6")) {
return Opcodes.V1_5;
} else if (specVersion.equals("1.6")) {
return Opcodes.V1_6;
} else if (specVersion.equals("1.7") || specVersion.equals("1.8") || specVersion.equals("1.9") || specVersion.equals("9")) {
return Opcodes.V1_7;
} else {
System.err.println("unsupported Java version \"" + specVersion + "\", defaulting to 1.5");
return Opcodes.V1_5;
final String specVersion = Options.BYTECODE_VERSION.load();
switch ( specVersion ) {
case "1.6" : return Opcodes.V1_6;
case "1.7" : return Opcodes.V1_7;
case "1.8" : return Opcodes.V1_8;
// NOTE: JDK 9 now returns "9" instead of "1.9"
case "1.9" : case "9" : return Opcodes.V1_8; // +1
default :
System.err.println("unsupported Java version \"" + specVersion + "\", defaulting to 1.7");
return Opcodes.V1_7;
}
}

38 changes: 38 additions & 0 deletions core/src/main/java/org/jruby/ast/executable/RuntimeCache.java
Original file line number Diff line number Diff line change
@@ -425,6 +425,44 @@ private DynamicMethod cacheAndGet(ThreadContext context, RubyClass selfType, int
return method;
}

private DynamicMethod searchWithCacheNoMethodMissing(RubyClass clazz, int index, String name1) {
CacheEntry entry = clazz.searchWithCache(name1);
DynamicMethod method = entry.method;
if (entry.method == UndefinedMethod.INSTANCE) {
return null;
}
methodCache[index] = entry;
return method;
}

private DynamicMethod searchWithCacheNoMethodMissing(RubyClass clazz, int index, String name1, String name2) {
CacheEntry entry = clazz.searchWithCache(name1);
DynamicMethod method = entry.method;
if (entry.method == UndefinedMethod.INSTANCE) {
return searchWithCacheNoMethodMissing(clazz, index, name2);
}
methodCache[index] = entry;
return method;
}

// used from byte-code generated by RealClassGenerator
public final DynamicMethod searchWithCacheNoMethodMissing(IRubyObject obj, int index, String name1) {
CacheEntry myCache = getCacheEntry(index);
if (CacheEntry.typeOk(myCache, obj.getMetaClass())) {
return myCache.method;
}
return searchWithCacheNoMethodMissing(obj.getMetaClass(), index, name1);
}

// used from byte-code generated by RealClassGenerator
public final DynamicMethod searchWithCacheNoMethodMissing(IRubyObject obj, int index, String name1, String name2) {
CacheEntry myCache = getCacheEntry(index);
if (CacheEntry.typeOk(myCache, obj.getMetaClass())) {
return myCache.method;
}
return searchWithCacheNoMethodMissing(obj.getMetaClass(), index, name1, name2);
}

public DynamicMethod searchWithCache(RubyClass clazz, int index, String name1) {
CacheEntry entry = clazz.searchWithCache(name1);
DynamicMethod method = entry.method;
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/compiler/JITCompiler.java
Original file line number Diff line number Diff line change
@@ -418,8 +418,8 @@ public MethodJITClassGenerator(String className, String methodName, String key,
} else {
digestString = key;
}
this.className = packageName + "/" + className.replace('.', '/') + CLASS_METHOD_DELIMITER + JavaNameMangler.mangleMethodName(methodName) + "_" + digestString;
this.name = this.className.replaceAll("/", ".");
this.className = packageName + '/' + className.replace('.', '/') + CLASS_METHOD_DELIMITER + JavaNameMangler.mangleMethodName(methodName) + '_' + digestString;
this.name = this.className.replace('/', '.');
this.methodName = methodName;
this.method = method;
this.visitor = visitor;
Loading