Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Oct 10, 2016
2 parents ff04687 + 7968ff6 commit d2b08d9
Show file tree
Hide file tree
Showing 134 changed files with 1,499 additions and 1,465 deletions.
17 changes: 10 additions & 7 deletions core/pom.rb
Expand Up @@ -45,13 +45,13 @@
jar 'org.ow2.asm:asm-util:${asm.version}'

# exclude jnr-ffi to avoid problems with shading and relocation of the asm packages
jar 'com.github.jnr:jnr-netdb:1.1.5', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-enxio:0.12', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-netdb:1.1.6', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-enxio:0.13', :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.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.3', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.0.9'
jar 'com.github.jnr:jnr-unixsocket:0.13', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.30', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.4', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.1.0'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'

Expand Down Expand Up @@ -81,6 +81,8 @@
jar 'org.slf4j:slf4j-api:1.7.12', :scope => 'provided', :optional => true
jar 'org.slf4j:slf4j-simple:1.7.12', :scope => 'test'

jar 'me.qmx.jitescript:jitescript:0.4.1', :exclusions => ['org.ow2.asm:asm-all']

plugin_management do
plugin( 'org.eclipse.m2e:lifecycle-mapping:1.0.0',
'lifecycleMappingMetadata' => {
Expand Down Expand Up @@ -233,7 +235,8 @@
'argLine' => '-Xmx${jruby.test.memory} -XX:MaxPermSize=${jruby.test.memory.permgen} -Dfile.encoding=UTF-8 -Djava.awt.headless=true',
'includes' => [ 'org/jruby/test/MainTestSuite.java',
'org/jruby/embed/**/*Test*.java',
'org/jruby/util/**/*Test*.java' ],
'org/jruby/util/**/*Test*.java',
'org/jruby/runtime/**/*Test*.java' ],
'additionalClasspathElements' => [ '${basedir}/src/test/ruby' ] )

build do
Expand Down
24 changes: 18 additions & 6 deletions core/pom.xml
Expand Up @@ -93,7 +93,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-netdb</artifactId>
<version>1.1.5</version>
<version>1.1.6</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
Expand All @@ -104,7 +104,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-enxio</artifactId>
<version>0.12</version>
<version>0.13</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.12</version>
<version>0.13</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.29</version>
<version>3.0.30</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
Expand All @@ -148,7 +148,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-constants</artifactId>
<version>0.9.3</version>
<version>0.9.4</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.0.9</version>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
Expand Down Expand Up @@ -277,6 +277,17 @@ DO NOT MODIFIY - GENERATED CODE
<version>1.7.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>me.qmx.jitescript</groupId>
<artifactId>jitescript</artifactId>
<version>0.4.1</version>
<exclusions>
<exclusion>
<artifactId>asm-all</artifactId>
<groupId>org.ow2.asm</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<defaultGoal>package</defaultGoal>
Expand Down Expand Up @@ -596,6 +607,7 @@ DO NOT MODIFIY - GENERATED CODE
<include>org/jruby/test/MainTestSuite.java</include>
<include>org/jruby/embed/**/*Test*.java</include>
<include>org/jruby/util/**/*Test*.java</include>
<include>org/jruby/runtime/**/*Test*.java</include>
</includes>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/src/test/ruby</additionalClasspathElement>
Expand Down
9 changes: 7 additions & 2 deletions core/src/main/java/org/jruby/NativeException.java
Expand Up @@ -167,13 +167,18 @@ public void trimStackTrace(Member target) {
}

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

return message;
}

return message;
}

Expand Down
40 changes: 6 additions & 34 deletions core/src/main/java/org/jruby/Ruby.java
Expand Up @@ -242,10 +242,8 @@ private Ruby(RubyInstanceConfig config) {
this.threadService = new ThreadService(this);

if( config.isProfiling() ) {
this.profiledMethods = new ProfiledMethods(this);
this.profilingServiceLookup = new ProfilingServiceLookup(this);
} else {
this.profiledMethods = null;
this.profilingServiceLookup = null;
}

Expand Down Expand Up @@ -2666,23 +2664,6 @@ public synchronized JRubyClassLoader getJRubyClassLoader() {
else {
jrubyClassLoader = new SelfFirstJRubyClassLoader(config.getLoader());
}

// if jit code cache is used, we need to add the cache directory to the classpath
// so the previously generated class files can be reused.
if( config.JIT_CODE_CACHE != null && !config.JIT_CODE_CACHE.trim().isEmpty() ) {
File file = new File( config.JIT_CODE_CACHE );

if( file.exists() == false || file.isDirectory() == false ) {
getWarnings().warning("The jit.codeCache '" + config.JIT_CODE_CACHE + "' directory doesn't exit.");
} else {
try {
URL url = file.toURI().toURL();
jrubyClassLoader.addURL( url );
} catch (MalformedURLException e) {
getWarnings().warning("Unable to add the jit.codeCache '" + config.JIT_CODE_CACHE + "' directory to the classpath." + e.getMessage());
}
}
}
}

return jrubyClassLoader;
Expand Down Expand Up @@ -4763,28 +4744,17 @@ public RuntimeCache getRuntimeCache() {
return runtimeCache;
}

/**
* Get the list of method holders for methods being profiled.
* @return all known profiled methods
* @deprecated This should be an implementation detail of the ProfilingService and should remove from the Ruby class.
*/
@Deprecated
public ProfiledMethods getProfiledMethods() {
return profiledMethods;
}

/**
* Add a method, so it can be printed out later.
*
* @param name the name of the method
* @param method
*/
@SuppressWarnings("deprecation")
void addProfiledMethod(final String name, final DynamicMethod method) {
if (!config.isProfiling()) return;
if (method.isUndefined()) return;

getProfiledMethods().addProfiledMethod( name, method );
getProfilingService().addProfiledMethod( name, method );
}

/**
Expand Down Expand Up @@ -5089,6 +5059,11 @@ public IRubyObject safeRecurse(RecursiveFunction func, IRubyObject obj, String n
return safeRecurse(LEGACY_RECURSE, getCurrentContext(), func, obj, name, outer);
}

@Deprecated
public ProfiledMethods getProfiledMethods() {
return new ProfiledMethods(this);
}

private static final RecursiveFunctionEx<RecursiveFunction> LEGACY_RECURSE = new RecursiveFunctionEx<RecursiveFunction>() {
@Override
public IRubyObject call(ThreadContext context, RecursiveFunction func, IRubyObject obj, boolean recur) {
Expand Down Expand Up @@ -5297,9 +5272,6 @@ public IRubyObject call(ThreadContext context, RecursiveFunction func, IRubyObje
// A global cache for Java-to-Ruby calls
private final RuntimeCache runtimeCache;

// The method objects for serial numbers
private final ProfiledMethods profiledMethods;

// Message for Errno exceptions that will not generate a backtrace
public static final String ERRNO_BACKTRACE_MESSAGE = "errno backtraces disabled; run with -Xerrno.backtrace=true to enable";

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyClass.java
Expand Up @@ -1407,7 +1407,7 @@ public synchronized void reify(String classDumpDir, boolean useChildLoader) {

// calculate an appropriate name, for anonymous using inspect like format e.g. "Class:0x628fad4a"
final String name = getBaseName() != null ? getName() :
( "Class:0x" + Integer.toHexString(System.identityHashCode(this)) );
( "Class_0x" + Integer.toHexString(System.identityHashCode(this)) );

final String javaName = "rubyobj." + name.replaceAll("::", ".");
final String javaPath = "rubyobj/" + name.replaceAll("::", "/");
Expand Down
14 changes: 6 additions & 8 deletions core/src/main/java/org/jruby/RubyException.java
Expand Up @@ -134,6 +134,7 @@ public RubyException exception(IRubyObject[] args) {
}

@JRubyMethod(name = "to_s")
@SuppressWarnings("deprecation")
public IRubyObject to_s(ThreadContext context) {
final IRubyObject msg = getMessage();
if ( ! msg.isNil() ) return msg.asString();
Expand Down Expand Up @@ -272,7 +273,7 @@ public void initBacktrace() {
}

@Override
@SuppressWarnings("deprecated")
@SuppressWarnings("deprecation")
public void copySpecialInstanceVariables(IRubyObject clone) {
RubyException exception = (RubyException)clone;
exception.backtraceData = backtraceData;
Expand Down Expand Up @@ -392,7 +393,7 @@ public static IRubyObject newException(ThreadContext context, RubyClass exceptio
/**
* @return error message if provided or nil
*/
@SuppressWarnings("deprecated")
@SuppressWarnings("deprecation")
public IRubyObject getMessage() {
return message == null ? getRuntime().getNil() : message;
}
Expand All @@ -401,7 +402,7 @@ public IRubyObject getMessage() {
* Set the message for this NameError.
* @param message the message
*/
@SuppressWarnings("deprecated")
@SuppressWarnings("deprecation")
public void setMessage(IRubyObject message) {
this.message = message;
}
Expand All @@ -413,12 +414,9 @@ public String getMessageAsJavaString() {

private BacktraceData backtraceData;
private IRubyObject backtrace;
/**
* @deprecated do not access the field directly
* @see #getMessage()
*/
@Deprecated
public IRubyObject message;
IRubyObject cause;
protected IRubyObject cause;

public static final int TRACE_HEAD = 8;
public static final int TRACE_TAIL = 4;
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyFile.java
Expand Up @@ -1363,9 +1363,9 @@ private static RubyString filePathConvert(ThreadContext context, RubyString path
if (runtime.getDefaultInternalEncoding() != null &&
pathEncoding != encodingService.getUSAsciiEncoding() &&
pathEncoding != encodingService.getAscii8bitEncoding() &&
pathEncoding != encodingService.getFileSystemEncoding(runtime) &&
pathEncoding != encodingService.getFileSystemEncoding() &&
!path.isAsciiOnly()) {
path = EncodingUtils.strConvEnc(context, path, pathEncoding, encodingService.getFileSystemEncoding(runtime));
path = EncodingUtils.strConvEnc(context, path, pathEncoding, encodingService.getFileSystemEncoding());
}
}

Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/RubyFileStat.java
Expand Up @@ -50,7 +50,6 @@
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.FileResource;
import org.jruby.util.JRubyFile;
import org.jruby.util.JRubyNonExistentFile;
import org.jruby.util.StringSupport;

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyGlobal.java
Expand Up @@ -121,7 +121,7 @@ public static void createGlobals(ThreadContext context, Ruby runtime) {
IRubyObject engine = runtime.newString(Constants.ENGINE).freeze(context);

version = runtime.newString(Constants.RUBY_VERSION).freeze(context);
patchlevel = runtime.newFixnum(Constants.RUBY_PATCHLEVEL);
patchlevel = runtime.newFixnum(0);
runtime.defineGlobalConstant("RUBY_VERSION", version);
runtime.defineGlobalConstant("RUBY_PATCHLEVEL", patchlevel);
runtime.defineGlobalConstant("RUBY_RELEASE_DATE", release);
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/RubyIO.java
Expand Up @@ -3471,7 +3471,7 @@ private static IRubyObject openKeyArgs(ThreadContext context, IRubyObject recv,

RubyArray args = runtime.newArray( ((RubyArray) v).size() + 1 );
args.push(path);
args.concat19(v);
args.concat(v);

return RubyKernel.open19(context, recv, args.toJavaArray(), Block.NULL_BLOCK);
}
Expand Down Expand Up @@ -4096,6 +4096,8 @@ public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv, I
if (!io1.openFile.isReadable()) throw runtime.newIOError("from IO is not readable");
if (!io2.openFile.isWritable()) throw runtime.newIOError("to IO is not writable");

io2.flush(context);

// attempt to preserve position of original
OpenFile fptr = io1.getOpenFileChecked();

Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/RubyInstanceConfig.java
Expand Up @@ -1837,6 +1837,7 @@ public boolean isTruffle() {

public static final boolean JUMPS_HAVE_BACKTRACE = Options.JUMP_BACKTRACE.load();

@Deprecated
public static final boolean JIT_CACHE_ENABLED = Options.JIT_CACHE.load();

public static final boolean REFLECTED_HANDLES = Options.REFLECTED_HANDLES.load();
Expand Down
23 changes: 13 additions & 10 deletions core/src/main/java/org/jruby/RubyKernel.java
Expand Up @@ -657,16 +657,19 @@ public static IRubyObject sleep(ThreadContext context, IRubyObject recv, IRubyOb

final long startTime = System.currentTimeMillis();
final RubyThread rubyThread = context.getThread();
// Spurious wakeup-loop
do {
long loopStartTime = System.currentTimeMillis();
try {
// We break if we know this sleep was explicitly woken up/interrupted
if ( ! rubyThread.sleep(milliseconds) ) break;
} catch (InterruptedException ex) { /* no-op */ }
milliseconds -= (System.currentTimeMillis() - loopStartTime);

try {
// Spurious wakeup-loop
do {
long loopStartTime = System.currentTimeMillis();

if (!rubyThread.sleep(milliseconds)) break;

milliseconds -= (System.currentTimeMillis() - loopStartTime);
} while (milliseconds > 0);
} catch (InterruptedException ie) {
// ignore; sleep gets interrupted
}
while (milliseconds > 0);

return context.runtime.newFixnum(Math.round((System.currentTimeMillis() - startTime) / 1000.0));
}
Expand Down Expand Up @@ -865,7 +868,7 @@ public static IRubyObject raise(ThreadContext context, IRubyObject recv, IRubyOb
printExceptionSummary(context, runtime, raise.getException());
}

if (argc > 0 && raise.getException().getCause() == UNDEF) {
if (argc > 0 && raise.getException().getCause() == UNDEF && cause != raise.getException()) {
raise.getException().setCause(cause);
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyMatchData.java
Expand Up @@ -504,7 +504,7 @@ public IRubyObject op_aref(IRubyObject idx, IRubyObject rest) {
public IRubyObject op_aref19(IRubyObject idx) {
check();
IRubyObject result = op_arefCommon(idx);
return result == null ? to_a().aref19(idx) : result;
return result == null ? to_a().aref(idx) : result;
}

/** match_aref
Expand All @@ -513,7 +513,7 @@ public IRubyObject op_aref19(IRubyObject idx) {
@JRubyMethod(name = "[]")
public IRubyObject op_aref19(IRubyObject idx, IRubyObject rest) {
IRubyObject result;
return !rest.isNil() || (result = op_arefCommon(idx)) == null ? to_a().aref19(idx, rest) : result;
return !rest.isNil() || (result = op_arefCommon(idx)) == null ? to_a().aref(idx, rest) : result;
}

private IRubyObject op_arefCommon(IRubyObject idx) {
Expand Down

0 comments on commit d2b08d9

Please sign in to comment.