Skip to content

Commit

Permalink
Showing 171 changed files with 3,836 additions and 2,629 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ sudo: false

before_script:
- export MAVEN_SKIP_RC=true
- export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=512m"
- export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"
- unset GEM_PATH GEM_HOME IRBRC JRUBY_OPTS
- "export PATH=`pwd`/bin:$PATH"
- echo $HOME
@@ -22,13 +22,15 @@ os:

env:
global:
- JAVA_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xmx512M"
- MALLOC_ARENA_MAX=2
matrix:
- JT='test specs :language'
- JT='test specs :core'
- JT='test specs :library'
- JT='test specs :truffle'
- JT='test integration'
- JT='test integration fast'
- JT='test integration long' JAVA_OPTS="$JAVA_OPTS -Xmx512m"

matrix:
include:
6 changes: 1 addition & 5 deletions bin/jruby.bash
Original file line number Diff line number Diff line change
@@ -91,10 +91,6 @@ if [ -z "$JAVACMD" ] ; then
fi
fi

if [ -z "$JAVA_MEM" ] ; then
JAVA_MEM=-Xmx500m
fi

if [ -z "$JAVA_STACK" ] ; then
JAVA_STACK=-Xss2048k
fi
@@ -250,11 +246,11 @@ do
# Pass -X... and -X? search options through
-X*\.\.\.|-X*\?)
ruby_args=("${ruby_args[@]}" "$1") ;;
# Match -Xa.b.c=d to translate to -Da.b.c=d as a java option
-X+T)
JRUBY_CP="$JRUBY_CP$CP_DELIMITER$JRUBY_HOME/lib/jruby-truffle.jar"
ruby_args=("${ruby_args[@]}" "-X+T")
;;
# Match -Xa.b.c=d to translate to -Da.b.c=d as a java option
-X*)
val=${1:2}
if expr "$val" : '.*[.]' > /dev/null; then
2 changes: 1 addition & 1 deletion bin/jruby.sh
Original file line number Diff line number Diff line change
@@ -196,11 +196,11 @@ do
# Pass -X... and -X? search options through
-X*\.\.\.|-X*\?)
ruby_args="${ruby_args} $1" ;;
# Match -Xa.b.c=d to translate to -Da.b.c=d as a java option
-X+T)
JRUBY_CP="$JRUBY_CP$CP_DELIMITER$JRUBY_HOME/lib/jruby-truffle.jar"
ruby_args="${ruby_args} -X+T"
;;
# Match -Xa.b.c=d to translate to -Da.b.c=d as a java option
-X*)
val=${1:2}
if expr "$val" : '.*[.]' > /dev/null; then
2 changes: 1 addition & 1 deletion core/pom.rb
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@
jar 'com.github.jnr:jnr-x86asm:1.0.2', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.12', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.29', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.1', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.2-SNAPSHOT', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.0.9'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -147,7 +147,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-constants</artifactId>
<version>0.9.1</version>
<version>0.9.2-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
32 changes: 19 additions & 13 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -358,21 +358,32 @@ private Status handleOutOfMemory(OutOfMemoryError oome) {
System.gc(); // try to clean up a bit of space, hopefully, so we can report this error

String oomeMessage = oome.getMessage();
boolean heapError = false;

if (oomeMessage != null) {
if (oomeMessage.contains("PermGen")) {
// report permgen memory error
config.getError().println("Error: Your application exhausted PermGen area of the heap.");
config.getError().println("Specify -J-XX:MaxPermSize=###M to increase it (### = PermGen size in MB).");
} else if (oomeMessage.contains("unable to create new native thread")) {
// report thread exhaustion error
config.getError().println("Error: Your application demanded too many live threads, perhaps for Fiber or Enumerator.");
config.getError().println("Ensure your old Fibers and Enumerators are being cleaned up.");
} else {
heapError = true;
}
}

if (oomeMessage != null && oomeMessage.contains("PermGen")) { // report permgen memory error
config.getError().println("Error: Your application exhausted PermGen area of the heap.");
config.getError().println("Specify -J-XX:MaxPermSize=###M to increase it (### = PermGen size in MB).");

} else { // report heap memory error
if (heapError) { // report heap memory error

String memoryMax = getRuntimeFlagValue("-Xmx");

if (memoryMax != null) {
config.getError().println("Error: Your application used more memory than the safety cap of " + memoryMax + ".");
} else {
config.getError().println("Error: Your application used more memory than the default safety cap.");
config.getError().println("Error: Your application used more memory than the automatic cap of " + Runtime.getRuntime().maxMemory() / 1024 / 1024 + "MB.");
}
config.getError().println("Specify -J-Xmx####m to increase it (#### = cap size in MB).");
config.getError().println("Specify -J-Xmx####M to increase it (#### = cap size in MB).");
}

if (config.isVerbose()) {
@@ -399,7 +410,7 @@ private String getRuntimeFlagValue(String prefix) {

private Status handleMainExit(MainExitException mee) {
if (!mee.isAborted()) {
config.getOutput().println(mee.getMessage());
config.getError().println(mee.getMessage());
if (mee.isUsageError()) {
doPrintUsage(true);
}
@@ -408,7 +419,6 @@ private Status handleMainExit(MainExitException mee) {
}

private Status doRunFromMain(Ruby runtime, InputStream in, String filename) {
long now = -1;
try {
doCheckSecurityManager();

@@ -474,10 +484,6 @@ private void doSetContextClassLoader(Ruby runtime) {
}
}

private void doProcessArguments(InputStream in) {
config.processArguments(config.parseShebangOptions(in));
}

private void doPrintProperties() {
if (config.getShouldPrintProperties()) {
config.getOutput().print(OutputStrings.getPropertyHelp());
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@
package org.jruby;

import org.jcodings.specific.UTF8Encoding;
import org.jruby.anno.TypePopulator;
import org.jruby.ast.ArrayNode;
import org.jruby.ast.BlockNode;
import org.jruby.ast.CallNode;
@@ -5290,4 +5291,11 @@ public void addToObjectSpace(boolean useObjectSpace, IRubyObject object) {
* The nullToNil filter for this runtime.
*/
private MethodHandle nullToNil;

public final ClassValue<TypePopulator> POPULATORS = new ClassValue<TypePopulator>() {
@Override
protected TypePopulator computeValue(Class<?> type) {
return RubyModule.loadPopulatorFor(type);
}
};
}
14 changes: 12 additions & 2 deletions core/src/main/java/org/jruby/RubyClass.java
Original file line number Diff line number Diff line change
@@ -1968,12 +1968,22 @@ private CS_NAMES(String id) {
this.id = id;
}

private static final CS_NAMES[] VALUES = values();
public static final int length = VALUES.length;

public static CS_NAMES fromOrdinal(int ordinal) {
if (ordinal < 0 || ordinal >= VALUES.length) {
throw new RuntimeException("invalid rest: " + ordinal);
}
return VALUES[ordinal];
}

public final String id;
};
private final CallSite[] baseCallSites = new CallSite[CS_NAMES.values().length];
private final CallSite[] baseCallSites = new CallSite[CS_NAMES.length];
{
for(int i = 0; i < baseCallSites.length; i++) {
baseCallSites[i] = MethodIndex.getFunctionalCallSite(CS_NAMES.values()[i].id);
baseCallSites[i] = MethodIndex.getFunctionalCallSite(CS_NAMES.fromOrdinal(i).id);
}
}

25 changes: 16 additions & 9 deletions core/src/main/java/org/jruby/RubyDir.java
Original file line number Diff line number Diff line change
@@ -812,24 +812,31 @@ public static IRubyObject getHomeDirectoryPath(ThreadContext context, String use
throw runtime.newArgumentError("user " + user + " doesn't exist");
}

static final ByteList HOME = new ByteList(new byte[] {'H','O','M','E'}, false);

public static RubyString getHomeDirectoryPath(ThreadContext context) {
Ruby runtime = context.runtime;
IRubyObject systemHash = runtime.getObject().getConstant("ENV_JAVA");
RubyHash envHash = (RubyHash) runtime.getObject().getConstant("ENV");
IRubyObject home = envHash.op_aref(context, runtime.newString("HOME"));
final RubyString homeKey = RubyString.newStringShared(context.runtime, HOME);
return getHomeDirectoryPath(context, context.runtime.getENV().op_aref(context, homeKey));
}

if (home == null || home.isNil()) {
home = systemHash.callMethod(context, "[]", runtime.newString("user.home"));
static RubyString getHomeDirectoryPath(ThreadContext context, IRubyObject home) {
final Ruby runtime = context.runtime;

if (home == null || home == context.nil) {
IRubyObject ENV_JAVA = runtime.getObject().getConstant("ENV_JAVA");
home = ENV_JAVA.callMethod(context, "[]", runtime.newString("user.home"));
}

if (home == null || home.isNil()) {
home = envHash.op_aref(context, runtime.newString("LOGDIR"));
if (home == null || home == context.nil) {
RubyHash ENV = (RubyHash) runtime.getObject().getConstant("ENV");
home = ENV.op_aref(context, runtime.newString("LOGDIR"));
}

if (home == null || home.isNil()) {
if (home == null || home == context.nil) {
throw runtime.newArgumentError("user.home/LOGDIR not set");
}

return (RubyString) home;
}

}
13 changes: 12 additions & 1 deletion core/src/main/java/org/jruby/RubyEnumerator.java
Original file line number Diff line number Diff line change
@@ -700,7 +700,18 @@ public synchronized IRubyObject peek() {
}

private void ensureStarted() {
if (thread == null) future = runtime.getFiberExecutor().submit(this);
try {
if (thread == null) future = runtime.getFiberExecutor().submit(this);
} catch (OutOfMemoryError oome) {
String oomeMessage = oome.getMessage();
if (oomeMessage != null && oomeMessage.contains("unable to create new native thread")) {
// try to clean out stale enumerator threads by forcing GC
System.gc();
future = runtime.getFiberExecutor().submit(this);
} else {
throw oome;
}
}
}

private IRubyObject peekTake() {
Loading

0 comments on commit 07c82ba

Please sign in to comment.