Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
Conflicts:
	truffle/src/main/java/org/jruby/truffle/nodes/control/TraceNode.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/TruffleInteropNodes.java
	truffle/src/main/java/org/jruby/truffle/nodes/interop/InteropNode.java
	truffle/src/main/java/org/jruby/truffle/runtime/core/StringForeignAccessFactory.java
	truffle/src/main/java/org/jruby/truffle/runtime/subsystems/AttachmentsManager.java
	truffle/src/main/java/org/jruby/truffle/runtime/subsystems/TraceManager.java
	truffle/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
chrisseaton committed Jul 10, 2015
2 parents bc78332 + 34c3d90 commit 1317665
Showing 138 changed files with 2,837 additions and 1,388 deletions.
2 changes: 1 addition & 1 deletion core/pom.rb
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@
jar 'com.github.jnr:jnr-enxio:0.9'
jar 'com.github.jnr:jnr-x86asm:1.0.2'
jar 'com.github.jnr:jnr-unixsocket:0.8'
jar 'com.github.jnr:jnr-posix:3.0.15-SNAPSHOT'
jar 'com.github.jnr:jnr-posix:3.0.15'
jar 'com.github.jnr:jnr-constants:0.8.8'
jar 'com.github.jnr:jnr-ffi:2.0.3'
jar 'com.github.jnr:jffi:${jffi.version}'
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.15-SNAPSHOT</version>
<version>3.0.15</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
18 changes: 14 additions & 4 deletions core/src/main/java/org/jruby/RubyProcess.java
Original file line number Diff line number Diff line change
@@ -627,16 +627,23 @@ public static IRubyObject waitpid(ThreadContext context, IRubyObject recv, IRuby
}

public static IRubyObject waitpid(Ruby runtime, IRubyObject[] args) {
int pid = -1;
long pid = -1;
int flags = 0;
if (args.length > 0) {
pid = (int)args[0].convertToInteger().getLongValue();
pid = args[0].convertToInteger().getLongValue();
}
if (args.length > 1) {
flags = (int)args[1].convertToInteger().getLongValue();
}

return runtime.newFixnum(waitpid(runtime, pid, flags));
pid = waitpid(runtime, pid, flags);

if (pid == 0) {
runtime.getCurrentContext().setLastExitStatus(runtime.getNil());
return runtime.getNil();
}

return runtime.newFixnum(pid);
}

public static long waitpid(Ruby runtime, long pid, int flags) {
@@ -645,7 +652,10 @@ public static long waitpid(Ruby runtime, long pid, int flags) {
pid = runtime.getPosix().waitpid(pid, status, flags);
raiseErrnoIfSet(runtime, ECHILD);

runtime.getCurrentContext().setLastExitStatus(RubyProcess.RubyStatus.newProcessStatus(runtime, status[0], pid));
if (pid > 0) {
runtime.getCurrentContext().setLastExitStatus(RubyProcess.RubyStatus.newProcessStatus(runtime, status[0], pid));
}

return pid;
}

4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/ext/socket/RubySocket.java
Original file line number Diff line number Diff line change
@@ -464,7 +464,9 @@ private void initDomain(Ruby runtime, IRubyObject domain) {
}

soDomain = family;
soProtocolFamily = ProtocolFamily.valueOf("PF" + soDomain.name().substring(2));
String name = soDomain.name();
if (name.startsWith("pseudo_")) name = name.substring(7);
soProtocolFamily = ProtocolFamily.valueOf("PF" + name.substring(2));
}

private void doConnectNonblock(ThreadContext context, Channel channel, SocketAddress addr) {
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/ext/stringio/StringIO.java
Original file line number Diff line number Diff line change
@@ -1126,10 +1126,11 @@ public IRubyObject write(ThreadContext context, IRubyObject arg) {

enc = ptr.string.getEncoding();
enc2 = str.getEncoding();
final ByteList strByteList = str.getByteList();
if (enc != enc2 && enc != EncodingUtils.ascii8bitEncoding(runtime)
// this is a hack because we don't seem to handle incoming ASCII-8BIT properly in transcoder
&& enc2 != ASCIIEncoding.INSTANCE) {
str = runtime.newString(EncodingUtils.strConvEnc(context, str.getByteList(), enc2, enc));
str = runtime.newString(EncodingUtils.strConvEnc(context, strByteList, enc2, enc));
}
len = str.size();
if (len == 0) return RubyFixnum.zero(runtime);
@@ -1139,11 +1140,11 @@ public IRubyObject write(ThreadContext context, IRubyObject arg) {
ptr.pos = olen;
}
if (ptr.pos == olen) {
EncodingUtils.encStrBufCat(runtime, ptr.string, str.getByteList(), enc);
EncodingUtils.encStrBufCat(runtime, ptr.string, strByteList, enc);
} else {
strioExtend(ptr.pos, len);
ByteList ptrByteList = ptr.string.getByteList();
System.arraycopy(str.getByteList().getUnsafeBytes(), str.getByteList().getBegin(), ptrByteList.getUnsafeBytes(), ptrByteList.begin + ptr.pos, len);
System.arraycopy(strByteList.getUnsafeBytes(), strByteList.getBegin(), ptrByteList.getUnsafeBytes(), ptrByteList.begin() + ptr.pos, len);
}
ptr.string.infectBy(str);
ptr.string.infectBy(this);
13 changes: 7 additions & 6 deletions core/src/main/java/org/jruby/ext/timeout/Timeout.java
Original file line number Diff line number Diff line change
@@ -85,13 +85,11 @@ public void load(Ruby runtime, boolean wrap) throws IOException {
public static class TimeoutToplevel {
@JRubyMethod(required = 1, optional = 1, visibility = PRIVATE)
public static IRubyObject timeout(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) {
final RubyModule timeout = context.runtime.getModule("Timeout");

switch (args.length) {
case 1:
return Timeout.timeout(context, timeout, args[0], block);
return Timeout.timeout(context, self, args[0], block);
case 2:
return Timeout.timeout(context, timeout, args[0], args[1], block);
return Timeout.timeout(context, self, args[0], args[1], block);
default:
Arity.raiseArgumentError(context.runtime, args.length, 1, 2);
return context.runtime.getNil();
@@ -100,7 +98,9 @@ public static IRubyObject timeout(ThreadContext context, IRubyObject self, IRuby
}

@JRubyMethod(module = true)
public static IRubyObject timeout(final ThreadContext context, IRubyObject timeout, IRubyObject seconds, Block block) {
public static IRubyObject timeout(final ThreadContext context, IRubyObject recv, IRubyObject seconds, Block block) {
IRubyObject timeout = context.runtime.getModule("Timeout");

// No seconds, just yield
if ( nilOrZeroSeconds(context, seconds) ) {
return block.yieldSpecific(context);
@@ -129,7 +129,8 @@ public static IRubyObject timeout(final ThreadContext context, IRubyObject timeo
}

@JRubyMethod(module = true)
public static IRubyObject timeout(final ThreadContext context, IRubyObject timeout, IRubyObject seconds, IRubyObject exceptionType, Block block) {
public static IRubyObject timeout(final ThreadContext context, IRubyObject recv, IRubyObject seconds, IRubyObject exceptionType, Block block) {
IRubyObject timeout = context.runtime.getModule("Timeout");
// No seconds, just yield
if ( nilOrZeroSeconds(context, seconds) ) {
return block.yieldSpecific(context);
Original file line number Diff line number Diff line change
@@ -89,7 +89,6 @@ protected void pre(InterpreterContext ic, ThreadContext context, IRubyObject sel
if (ic.pushNewDynScope()) {
context.pushScope(DynamicScope.newDynamicScope(ic.getStaticScope()));
}
context.setCurrentVisibility(getVisibility());
}

// FIXME: for subclasses we should override this method since it can be simple get
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/JRubyFile.java
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ private static FileResource createResource(Ruby runtime, String cwd, String path

public static String normalizeSeps(String path) {
if (Platform.IS_WINDOWS) {
return path.replace('/', File.separatorChar);
return path.replace(File.separatorChar, '/');
} else {
return path;
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ public class Options {
public static final Option<Integer> TRUFFLE_ARRAYS_SMALL = integer(TRUFFLE, "truffle.arrays.small", 3, "Maximum size of an Array to consider small for optimisations.");
public static final Option<Integer> TRUFFLE_HASH_PACKED_ARRAY_MAX = integer(TRUFFLE, "truffle.hash.packed_array_max", 3, "Maximum size of a Hash to use with the packed array storage strategy.");

public static final Option<Integer> TRUFFLE_PASSALOT = integer(TRUFFLE, "truffle.passalot", 0, "Probabilty between 0 and 100 to randomly insert Thread.pass at a given line.");
public static final Option<Boolean> TRUFFLE_YIELDS = bool(TRUFFLE, "truffle.yields", false, "Insert GIL yieldpoints");
public static final Option<Integer> TRUFFLE_INSTRUMENTATION_SERVER_PORT = integer(TRUFFLE, "truffle.instrumentation_server_port", 0, "Port number to run an HTTP server on that provides instrumentation services");
public static final Option<String> TRUFFLE_TRANSLATOR_PRINT_AST = string(TRUFFLE, "truffle.translator.print_asts", "", "Comma delimited list of method names to print the AST of after translation.");
public static final Option<String> TRUFFLE_TRANSLATOR_PRINT_FULL_AST = string(TRUFFLE, "truffle.translator.print_full_asts", "", "Comma delimited list of method names to print the full AST of after translation.");
9 changes: 4 additions & 5 deletions core/src/test/java/org/jruby/test/TestKernel.java
Original file line number Diff line number Diff line change
@@ -31,7 +31,8 @@
***** END LICENSE BLOCK *****/
package org.jruby.test;

import java.io.File;
import java.util.ArrayList;

import org.jruby.Ruby;
import org.jruby.RubyException;
import org.jruby.RubyFixnum;
@@ -60,16 +61,14 @@ public void testLoad() throws Exception {
assertEquals("load did not load the same file several times", "1", eval("load '../test/loadTest.rb'"));
}


public void testRequire() throws Exception {
char s = File.separatorChar;
//reset the $loadTestvar
eval("$loadTest = nil");
assertEquals("failed to load the file test/loadTest", "0", eval("require '../test/loadTest'"));
assertEquals("incorrectly reloaded the file test/loadTest", "", eval("require '../test/loadTest'"));
assertEquals("incorrect value for $\" variable", "true", eval("print $\"[-1].end_with?('test" + s + "loadTest.rb')"));
}

assertEquals("incorrect value for $\" variable", "true", eval("print $\"[-1].end_with?('test/loadTest.rb')"));
}

public void testPrintf() throws Exception {
assertEquals("hello", eval("printf(\"%s\", \"hello\")"));
Loading

0 comments on commit 1317665

Please sign in to comment.