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

Commits on Jan 31, 2015

  1. Copy the full SHA
    b4b70cd View commit details
  2. Copy the full SHA
    2d42faa View commit details
  3. Copy the full SHA
    582ed72 View commit details
  4. Copy the full SHA
    1310672 View commit details
87 changes: 51 additions & 36 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -45,14 +45,13 @@
import org.jruby.ast.FCallNode;
import org.jruby.ast.GlobalAsgnNode;
import org.jruby.ast.GlobalVarNode;
import org.jruby.ast.NewlineNode;
import org.jruby.ast.VCallNode;
import org.jruby.ast.WhileNode;
import org.jruby.compiler.Constantizable;
import org.jruby.compiler.NotCompilableException;
import org.jruby.ext.jruby.JRubyLibrary;
import org.jruby.ext.thread.ThreadLibrary;
import org.jruby.ir.IRScriptBody;
import org.jruby.javasupport.JavaSupport;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.parser.StaticScope;
import org.objectweb.asm.util.TraceClassVisitor;
@@ -98,7 +97,7 @@
import org.jruby.ir.persistence.IRReader;
import org.jruby.ir.persistence.IRReaderFile;
import org.jruby.ir.persistence.util.IRFileExpert;
import org.jruby.javasupport.JavaSupport;
import org.jruby.javasupport.JavaSupportImpl;
import org.jruby.javasupport.proxy.JavaProxyClassFactory;
import org.jruby.management.BeanManager;
import org.jruby.management.BeanManagerFactory;
@@ -733,21 +732,8 @@ public IRubyObject runNormally(Node scriptNode) {
ScriptAndCode scriptAndCode = null;
boolean compile = getInstanceConfig().getCompileMode().shouldPrecompileCLI();
if (compile || config.isShowBytecode()) {
// IR JIT does not handle all scripts yet, so let those that fail run in interpreter instead
// FIXME: restore error once JIT should handle everything
try {
scriptAndCode = tryCompile(scriptNode, new ClassDefininngJRubyClassLoader(getJRubyClassLoader()));
if (scriptAndCode != null && Options.JIT_LOGGING.load()) {
LOG.info("done compiling target script: " + scriptNode.getPosition().getFile());
}
} catch (Exception e) {
if (Options.JIT_LOGGING.load()) {
LOG.error("failed to compile target script '" + scriptNode.getPosition().getFile() + "'");
if (Options.JIT_LOGGING_VERBOSE.load()) {
e.printStackTrace();
}
}
}
scriptAndCode = precompileCLI(scriptNode);

}

if (scriptAndCode != null) {
@@ -767,6 +753,27 @@ public IRubyObject runNormally(Node scriptNode) {
}
}

private ScriptAndCode precompileCLI(Node scriptNode) {
ScriptAndCode scriptAndCode = null;

// IR JIT does not handle all scripts yet, so let those that fail run in interpreter instead
// FIXME: restore error once JIT should handle everything
try {
scriptAndCode = tryCompile(scriptNode, new ClassDefininngJRubyClassLoader(getJRubyClassLoader()));
if (scriptAndCode != null && Options.JIT_LOGGING.load()) {
LOG.info("done compiling target script: " + scriptNode.getPosition().getFile());
}
} catch (Exception e) {
if (Options.JIT_LOGGING.load()) {
LOG.error("failed to compile target script '" + scriptNode.getPosition().getFile() + "'");
if (Options.JIT_LOGGING_VERBOSE.load()) {
e.printStackTrace();
}
}
}
return scriptAndCode;
}

/**
* Try to compile the code associated with the given Node, returning an
* instance of the successfully-compiled Script or null if the script could
@@ -899,29 +906,37 @@ public JITCompiler getJITCompiler() {

public synchronized TruffleBridge getTruffleBridge() {
if (truffleBridge == null) {
/*
* It's possible to remove Truffle classes from the JRuby distribution, so we provide a sensible
* explanation when the classes are not found.
*/
truffleBridge = loadTruffleBridge();
}

final Class<?> clazz;
return truffleBridge;
}

try {
clazz = getJRubyClassLoader().loadClass("org.jruby.truffle.TruffleBridgeImpl");
} catch (Exception e) {
throw new UnsupportedOperationException("Support for Truffle has been removed from this distribution", e);
}
private TruffleBridge loadTruffleBridge() {
/*
* It's possible to remove Truffle classes from the JRuby distribution, so we provide a sensible
* explanation when the classes are not found.
*/

try {
Constructor<?> con = clazz.getConstructor(Ruby.class);
truffleBridge = (TruffleBridge) con.newInstance(this);
} catch (Exception e) {
throw new UnsupportedOperationException("Error while calling the constructor of Truffle Bridge", e);
}
final Class<?> clazz;

try {
clazz = getJRubyClassLoader().loadClass("org.jruby.truffle.TruffleBridgeImpl");
} catch (Exception e) {
throw new UnsupportedOperationException("Support for Truffle has been removed from this distribution", e);
}

final TruffleBridge truffleBridge;

truffleBridge.init();
try {
Constructor<?> con = clazz.getConstructor(Ruby.class);
truffleBridge = (TruffleBridge) con.newInstance(this);
} catch (Exception e) {
throw new UnsupportedOperationException("Error while calling the constructor of Truffle Bridge", e);
}

truffleBridge.init();

return truffleBridge;
}

@@ -1196,7 +1211,7 @@ private void init() {
// Construct key services
loadService = config.createLoadService(this);
posix = POSIXFactory.getPOSIX(new JRubyPOSIXHandler(this), config.isNativeEnabled());
javaSupport = new JavaSupport(this);
javaSupport = new JavaSupportImpl(this);

executor = new ThreadPoolExecutor(
RubyInstanceConfig.POOL_MIN,
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/javasupport/Java.java
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
import org.jruby.java.util.SystemPropertiesMap;
import org.jruby.java.proxies.JavaInterfaceTemplate;
import org.jruby.java.addons.KernelJavaAddons;
import java.io.IOException;

import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
400 changes: 64 additions & 336 deletions core/src/main/java/org/jruby/javasupport/JavaSupport.java

Large diffs are not rendered by default.

406 changes: 406 additions & 0 deletions core/src/main/java/org/jruby/javasupport/JavaSupportImpl.java

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/util/io/FilenoUtil.java
Original file line number Diff line number Diff line change
@@ -82,6 +82,10 @@ public static int filenoFrom(Channel channel) {
return ((NativeSocketChannel)channel).getFD();
}

return getFilenoUsingReflection(channel);
}

private static int getFilenoUsingReflection(Channel channel) {
if (FILE_DESCRIPTOR_FD != null) {
FileDescriptor fd = getDescriptorFromChannel(channel);
if (fd.valid()) {
4 changes: 2 additions & 2 deletions core/src/test/java/org/jruby/test/MockJavaSupport.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.jruby.test;

import org.jruby.Ruby;
import org.jruby.javasupport.JavaSupport;
import org.jruby.javasupport.JavaSupportImpl;

public class MockJavaSupport extends JavaSupport {
public class MockJavaSupport extends JavaSupportImpl {

public MockJavaSupport(Ruby ruby) {
super(ruby);
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ public SubstrateNode(SubstrateNode prev) {

@Specialization
public boolean substrate() {
return false;
return getContext().isSubstrate();
}

}
Original file line number Diff line number Diff line change
@@ -423,4 +423,8 @@ public RubiniusPrimitiveManager getRubiniusPrimitiveManager() {
return rubiniusPrimitiveManager;
}

public boolean isSubstrate() {
return false;
}

}