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

Commits on Jun 24, 2016

  1. Copy the full SHA
    45d2de4 View commit details
  2. Copy the full SHA
    b2784c9 View commit details
  3. Copy the full SHA
    3a6f562 View commit details
  4. Copy the full SHA
    38b119e View commit details
  5. Copy the full SHA
    5c9c134 View commit details
  6. house keeping in ArgumentProcessor

    - finalize fields
    - remove dead code
    - re-use classes for feature aliases
    - use String length() instead of equals()
    kares committed Jun 24, 2016
    Copy the full SHA
    aa1d615 View commit details
  7. Copy the full SHA
    c8bb1c7 View commit details
  8. Copy the full SHA
    4f3ab44 View commit details
  9. less internal computation - coll resizing on arg processing

    ... also delay '-' + value calculation
    kares committed Jun 24, 2016
    Copy the full SHA
    8721666 View commit details
  10. Copy the full SHA
    c0244be View commit details
  11. Copy the full SHA
    f2d4a91 View commit details
  12. Copy the full SHA
    e78d9d1 View commit details
17 changes: 9 additions & 8 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ private Main(boolean hardExit) {
}

private static List<String> getDotfileDirectories() {
ArrayList<String> searchList = new ArrayList<String>();
final ArrayList<String> searchList = new ArrayList<>(4);
for (String homeProp : new String[] {"user.dir", "user.home"}) {
String home = SafePropertyAccessor.getProperty(homeProp);
if (home != null) searchList.add(home);
@@ -124,8 +124,11 @@ private static List<String> getDotfileDirectories() {
}

public static void processDotfile() {
final StringBuilder path = new StringBuilder();
for (String home : getDotfileDirectories()) {
File dotfile = new File(home + "/.jrubyrc");
path.setLength(0);
path.append(home).append("/.jrubyrc");
final File dotfile = new File(path.toString());
if (dotfile.exists()) loadJRubyProperties(dotfile);
}
}
@@ -144,14 +147,11 @@ private static void loadJRubyProperties(File dotfile) {
sysProps.put("jruby." + entry.getKey(), entry.getValue());
}
}
catch (IOException ioe) {
if (LOG.isDebugEnabled()) LOG.debug("exception loading " + dotfile, ioe);
}
catch (SecurityException se) {
if (LOG.isDebugEnabled()) LOG.debug("exception loading " + dotfile, se);
catch (IOException|SecurityException ex) {
if (LOG.isDebugEnabled()) LOG.debug("exception loading properties from: " + dotfile, ex);
}
finally {
if (fis != null) try {fis.close();} catch (Exception e) {}
if (fis != null) try { fis.close(); } catch (Exception e) {}
}
}

@@ -493,6 +493,7 @@ private void doPrintProperties() {
private void doPrintUsage(boolean force) {
if (config.getShouldPrintUsage() || force) {
config.getOutput().print(OutputStrings.getBasicUsageHelp());
config.getOutput().print(OutputStrings.getFeaturesHelp());
}
}

58 changes: 31 additions & 27 deletions core/src/main/java/org/jruby/ir/passes/CompilerPass.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.jruby.ir.passes;

import org.jruby.ir.IRScope;
import org.jruby.util.StringSupport;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
@@ -21,7 +24,10 @@
* guarantee (re)execution, then you should call invalidate().
*/
public abstract class CompilerPass {
public static List<Class<? extends CompilerPass>> NO_DEPENDENCIES = new ArrayList<Class<? extends CompilerPass>>();

static final Logger LOG = LoggerFactory.getLogger(CompilerPass.class);

protected static final List<Class<? extends CompilerPass>> NO_DEPENDENCIES = Collections.emptyList();

private List<CompilerPassListener> listeners = new ArrayList<CompilerPassListener>();

@@ -135,49 +141,47 @@ private Object makeSureDependencyHasRunOnce(Class<? extends CompilerPass> passCl

public static CompilerPass createPassInstance(Class<? extends CompilerPass> passClass) {
try {
return (CompilerPass) passClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException ex) {
LoggerFactory.getLogger(CompilerPass.class).error(ex);
} catch (IllegalAccessException ex) {
LoggerFactory.getLogger(CompilerPass.class).error(ex);
} catch (IllegalArgumentException ex) {
LoggerFactory.getLogger(CompilerPass.class).error(ex);
} catch (InvocationTargetException ex) {
LoggerFactory.getLogger(CompilerPass.class).error(ex);
} catch (NoSuchMethodException ex) {
LoggerFactory.getLogger(CompilerPass.class).error(ex);
} catch (SecurityException ex) {
LoggerFactory.getLogger(CompilerPass.class).error(ex);
return passClass.getDeclaredConstructor().newInstance();
}
catch (NoSuchMethodException|IllegalAccessException|IllegalArgumentException ex) {
LOG.error("failed to create compiler pass: '" + passClass.getName() + "'", ex);
}
catch (InstantiationException|InvocationTargetException|SecurityException ex) {
LOG.error("failed to create compiler pass: '" + passClass.getName() + "'", ex);
}

return null;
}

public static CompilerPass createPassInstance(String passClassName) {
final String className = "org.jruby.ir.passes." + passClassName;
try {
String clazzName = "org.jruby.ir.passes." + passClassName;
Class<? extends CompilerPass> clazz =
(Class<? extends CompilerPass>) Class.forName(clazzName);
Class<? extends CompilerPass> clazz = (Class<? extends CompilerPass>) Class.forName(className);
return createPassInstance(clazz);
} catch (ClassNotFoundException ex) {
// FIXME: Do this in a nice way even if only for test code
System.out.println("No such pass: " + ex);
System.exit(-1);
}

catch (ClassNotFoundException ex) {
LOG.warn("skipping unknown compiler pass name: '" + className + "'");
}
return null;
}

public static List<CompilerPass> getPassesFromString(String passList, String defaultPassList) {
if (passList == null) passList = defaultPassList;

List<CompilerPass> passes = new ArrayList<CompilerPass>();
final List<CompilerPass> passes;

if (!passList.equals("")) {
for (String passClassName : passList.split(",")) {
passes.add(createPassInstance(passClassName));
if ( ! passList.isEmpty() ) {
List<String> split = StringSupport.split(passList, ',');
passes = new ArrayList<>(split.size());
for ( String passClassName : split ) {
if ( ! passClassName.isEmpty() ) {
CompilerPass pass = createPassInstance(passClassName);
if ( pass != null ) passes.add(pass);
}
}
}
else {
passes = new ArrayList<>(2);
}

return passes;
}
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ static ClassExtensionLibrary tryFind(Ruby runtime, String searchName) {
if (leftmostIdentifier == all.length) return null;

// make service name out of last element
String serviceName = buildServiceName(all[all.length - 1]);
CharSequence serviceName = buildServiceName(all[all.length - 1]);

// allocate once with plenty of space, to reduce object churn
StringBuilder classNameBuilder = new StringBuilder(searchName.length() * 2);
@@ -80,16 +80,14 @@ static ClassExtensionLibrary tryFind(Ruby runtime, String searchName) {
for (int i = all.length - 1; i >= leftmostIdentifier; i--) {
buildClassName(classNameBuilder, classFileBuilder, all, i, serviceName);

String classFileName = classFileBuilder.toString();

// bail out once if see a dash in the name
if (classFileName.contains("-")) return null;
if (classFileBuilder.indexOf("-", 0) >= 0) return null;

// look for the filename in classloader resources
URL resource = runtime.getJRubyClassLoader().getResource(classFileBuilder.toString());
if (resource == null) continue;

String className = classNameBuilder.toString();
final String className = classNameBuilder.toString();

try {
Class theClass = runtime.getJavaSupport().loadJavaClass(className);
@@ -99,7 +97,7 @@ static ClassExtensionLibrary tryFind(Ruby runtime, String searchName) {
continue;
} catch (UnsupportedClassVersionError ucve) {
if (runtime.isDebug()) ucve.printStackTrace();
throw runtime.newLoadError("JRuby ext built for wrong Java version in `" + className + "': " + ucve, className.toString());
throw runtime.newLoadError("JRuby ext built for wrong Java version in `" + className + "': " + ucve, className);
}
}

@@ -126,7 +124,7 @@ private static boolean isJavaIdentifier(String str) {
return true;
}

private static void buildClassName(StringBuilder nameBuilder, StringBuilder fileBuilder, String[] all, int i, String serviceName) {
private static void buildClassName(StringBuilder nameBuilder, StringBuilder fileBuilder, String[] all, int i, CharSequence serviceName) {
nameBuilder.setLength(0);
fileBuilder.setLength(0);
for (int j = i; j < all.length - 1; j++) {
@@ -137,15 +135,16 @@ private static void buildClassName(StringBuilder nameBuilder, StringBuilder file
fileBuilder.append(serviceName).append(".class");
}

private static String buildServiceName(String jarName) {
private static CharSequence buildServiceName(final String jarName) {
String[] last = jarName.split("_");
StringBuilder serviceName = new StringBuilder();
StringBuilder serviceName = new StringBuilder(jarName.length() + 7);
for (int i = 0, j = last.length; i < j; i++) {
if ("".equals(last[i])) break;
serviceName.append(Character.toUpperCase(last[i].charAt(0))).append(last[i].substring(1));
final String l = last[i];
if (l.length() == 0) break;
serviceName.append(Character.toUpperCase(l.charAt(0))).append(l.substring(1));
}
serviceName.append("Service");
return serviceName.toString();
return serviceName;
}

public ClassExtensionLibrary(String name, Class extension) {
Loading