Skip to content

Commit

Permalink
Merge branch 'master' into ruby-2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Dec 14, 2016
2 parents 47d4a09 + 28ab7ed commit d11171e
Show file tree
Hide file tree
Showing 626 changed files with 18,729 additions and 18,585 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -23,6 +23,7 @@ Makefile
cext-output.txt
bench-results.json
bench-results-processed.json
failures

.DS_Store
.debug.properties
Expand Down
5 changes: 4 additions & 1 deletion appveyor.yml
Expand Up @@ -3,6 +3,9 @@ version: '{build}'
build: off

environment:
global:
- MAVEN_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xmn48M -Xmx512M"
- JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xmn48M -Xmx512M"
matrix:
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0
Expand All @@ -13,7 +16,7 @@ install:
- mvn -X -v

cache:
- C:\Users\appveyor\.m2\repository -> pom.xml
- C:\Users\appveyor\.m2\repository -> pom.rb

test_script:
- mvn -Ptest
7 changes: 2 additions & 5 deletions bin/jruby.bash
Expand Up @@ -251,10 +251,6 @@ do
-X+T)
USING_TRUFFLE="true"
;;
-X+TM)
USING_TRUFFLE="true"
java_class=$JAVA_CLASS_JRUBY_TRUFFLE_MAIN
;;
# Match -Xa.b.c=d to translate to -Da.b.c=d as a java option
-X*)
val=${1:2}
Expand Down Expand Up @@ -325,7 +321,8 @@ do
done

if [[ "$USING_TRUFFLE" != "" ]]; then
JRUBY_CP="$JRUBY_CP$CP_DELIMITER$JRUBY_HOME/lib/jruby-truffle.jar"
JRUBY_CP="$JRUBY_HOME/lib/jruby-truffle.jar"
java_class=$JAVA_CLASS_JRUBY_TRUFFLE_MAIN
ruby_args=("-X+T" "${ruby_args[@]}")
fi

Expand Down
4 changes: 0 additions & 4 deletions bin/jruby.sh
Expand Up @@ -200,10 +200,6 @@ do
echo "error: -X+T isn't supported in the shell launcher"
exit 1
;;
-X+TM)
echo "error: -X+TM isn't supported in the shell launcher"
exit 1
;;
-Xclassic)
;;
# Match -Xa.b.c=d to translate to -Da.b.c=d as a java option
Expand Down
8 changes: 4 additions & 4 deletions core/pom.rb
Expand Up @@ -46,12 +46,12 @@

# exclude jnr-ffi to avoid problems with shading and relocation of the asm packages
jar 'com.github.jnr:jnr-netdb:1.1.6', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-enxio:0.14-SNAPSHOT', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-enxio:0.14', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-x86asm:1.0.2', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.14', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.32', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.15', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.33', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.6', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.1.1'
jar 'com.github.jnr:jnr-ffi:2.1.2'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'

Expand Down
8 changes: 4 additions & 4 deletions core/pom.xml
Expand Up @@ -104,7 +104,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-enxio</artifactId>
<version>0.14-SNAPSHOT</version>
<version>0.14</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
Expand All @@ -126,7 +126,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-unixsocket</artifactId>
<version>0.14</version>
<version>0.15</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
Expand All @@ -137,7 +137,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.32</version>
<version>3.0.33</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
Expand All @@ -159,7 +159,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
Expand Down
134 changes: 12 additions & 122 deletions core/src/main/java/org/jruby/Main.java
Expand Up @@ -46,7 +46,6 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.SafePropertyAccessor;
import org.jruby.util.cli.Options;
import org.jruby.util.cli.OutputStrings;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;
Expand All @@ -60,7 +59,6 @@
import java.io.PrintStream;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
Expand Down Expand Up @@ -192,8 +190,6 @@ public static class Status {
* @param args command-line args, provided by the JVM.
*/
public static void main(String[] args) {
printTruffleTimeMetric("before-main");

doGCJCheck();

Main main;
Expand All @@ -207,9 +203,6 @@ public static void main(String[] args) {
try {
Status status = main.run(args);

printTruffleTimeMetric("after-main");
printTruffleMemoryMetric();

if (status.isExit()) {
System.exit(status.getStatus());
}
Expand All @@ -221,19 +214,12 @@ public static void main(String[] args) {
System.exit( handleUnexpectedJump(ex) );
}
catch (Throwable t) {
// If a Truffle exception gets this far it's a hard failure - don't try and dress it up as a Ruby exception

if (main.isTruffle()) {
System.err.println("Truffle internal error: " + t);
t.printStackTrace(System.err);
} else {
// print out as a nice Ruby backtrace
System.err.println("Unhandled Java exception: " + t);
// print out as a nice Ruby backtrace
System.err.println("Unhandled Java exception: " + t);
System.err.println(ThreadContext.createRawBacktraceStringFromThrowable(t, false));
while ((t = t.getCause()) != null) {
System.err.println("Caused by:");
System.err.println(ThreadContext.createRawBacktraceStringFromThrowable(t, false));
while ((t = t.getCause()) != null) {
System.err.println("Caused by:");
System.err.println(ThreadContext.createRawBacktraceStringFromThrowable(t, false));
}
}

System.exit(1);
Expand Down Expand Up @@ -277,16 +263,12 @@ private Status internalRun() {

Ruby _runtime;

if (isTruffle()) {
_runtime = null;
if (DripMain.DRIP_RUNTIME != null) {
// use drip's runtime, reinitializing config
_runtime = DripMain.DRIP_RUNTIME;
_runtime.reinitialize(true);
} else {
if (DripMain.DRIP_RUNTIME != null) {
// use drip's runtime, reinitializing config
_runtime = DripMain.DRIP_RUNTIME;
_runtime.reinitialize(true);
} else {
_runtime = Ruby.newInstance(config);
}
_runtime = Ruby.newInstance(config);
}

final Ruby runtime = _runtime;
Expand Down Expand Up @@ -317,35 +299,10 @@ public void run() {
throw new MainExitException(1, "jruby: no Ruby script found in input (LoadError)");
} else if (config.getShouldCheckSyntax()) {
// check syntax only and exit
if (isTruffle()) {
final TruffleRubyEngineInterface truffle = loadTruffle();

try {
final int exitCode = truffle.doCheckSyntax(in, filename);
return new Status(exitCode);
} finally {
truffle.dispose();
}
} else {
return doCheckSyntax(runtime, in, filename);
}
return doCheckSyntax(runtime, in, filename);
} else {
// proceed to run the script
if (isTruffle()) {
final TruffleRubyEngineInterface truffle = loadTruffle();

printTruffleTimeMetric("before-run");

try {
final int exitCode = truffle.execute(filename);
return new Status(exitCode);
} finally {
printTruffleTimeMetric("after-run");
truffle.dispose();
}
} else {
return doRunFromMain(runtime, in, filename);
}
return doRunFromMain(runtime, in, filename);
}
} finally {
if (runtime != null && didTeardown.compareAndSet(false, true)) {
Expand Down Expand Up @@ -612,73 +569,6 @@ else if ( ex instanceof JumpException.FlowControlException ) {
return 2;
}

private boolean isTruffle() {
return config.getCompileMode().isTruffle();
}

private TruffleRubyEngineInterface loadTruffle() {
Main.printTruffleTimeMetric("before-load-context");

String javaVersion = System.getProperty("java.version");
String[] parts = javaVersion.split("\\D+");
int firstPart = Integer.valueOf(parts[0]);
if (!(firstPart >= 9 || Integer.valueOf(parts[1]) >= 8)) {
System.err.println("JRuby+Truffle needs Java 8 to run (found " + javaVersion + ").");
System.exit(1);
}

final Class<?> truffleRubyEngineClass;

try {
truffleRubyEngineClass = Class.forName("org.jruby.truffle.RubyEngine");
} catch (Exception e) {
throw new RuntimeException("JRuby's Truffle backend not available - either it was not compiled because JRuby was built with Java 7, or it has been removed", e);
}

final TruffleRubyEngineInterface truffleEngine;

try {
final Object truffleEngineInstance = truffleRubyEngineClass.getConstructor(RubyInstanceConfig.class).newInstance(config);

truffleEngine = (TruffleRubyEngineInterface) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{TruffleRubyEngineInterface.class}, new InvocationHandler() {

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return truffleRubyEngineClass.getMethod(method.getName(), method.getParameterTypes()).invoke(truffleEngineInstance, args);
}

});
} catch (Exception e) {
throw new RuntimeException("Error while calling the constructor of Truffle's RubyContext", e);
}

Main.printTruffleTimeMetric("after-load-context");

return truffleEngine;
}

public static void printTruffleTimeMetric(String id) {
if (Options.TRUFFLE_METRICS_TIME.load()) {
final long millis = System.currentTimeMillis();
System.err.printf("%s %d.%03d%n", id, millis / 1000, millis % 1000);
}
}

private static void printTruffleMemoryMetric() {
if (Options.TRUFFLE_METRICS_MEMORY_USED_ON_EXIT.load()) {
for (int n = 0; n < 10; n++) {
System.gc();
}

try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}

System.err.printf("allocated %d%n", ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed());
}
}

private final RubyInstanceConfig config;
}

9 changes: 2 additions & 7 deletions core/src/main/java/org/jruby/NativeException.java
Expand Up @@ -167,18 +167,13 @@ public void trimStackTrace(Member target) {
}

@Override
@SuppressWarnings("deprecation")
public final IRubyObject getMessage() {
if (message == null) {
if (messageAsJavaString == null) {
message = getRuntime().getNil();
} else {
message = getRuntime().newString(messageAsJavaString);
return message = getRuntime().getNil();
}

return message;
return message = getRuntime().newString(messageAsJavaString);
}

return message;
}

Expand Down

0 comments on commit d11171e

Please sign in to comment.