Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
# Conflicts:
#	.travis.yml
  • Loading branch information
chrisseaton committed Jun 16, 2016
2 parents 197a30c + d6c5b01 commit c73342d
Show file tree
Hide file tree
Showing 91 changed files with 555 additions and 307 deletions.
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,20 @@ matrix:
jdk: oraclejdk8
- env: JT='test integration'
jdk: oraclejdk8
- env:
- COMMAND=test/truffle/gems/install-gems.sh
- JT='test gems'
jdk: oraclejdk8
- env:
- JAVA_OPTS="$JAVA_OPTS -Xmx512m"
- HAS_REDIS=true
- JT='test ecosystem'
jdk: oraclejdk8
- env: JT='test tck'
jdk: oraclejdk8
- env: JT=check_ambiguous_arguments SKIP_BUILD=true
- env:
- JT=check_ambiguous_arguments
- SKIP_BUILD=true
jdk: oraclejdk8
allow_failures:
- env: JT='test mri'
Expand Down
62 changes: 52 additions & 10 deletions ci.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ common: {

setup: ${common-setup}

timelimit: "30:00"
timelimit: "01:00:00"
}

no-graal: {
Expand All @@ -35,14 +35,15 @@ no-graal: {

graal-core: {
setup: ${common-setup} [
[rm, -rf, mx.jruby],
[mv, mx.jruby, temp_mx],
[mkdir, graal-workspace],
[cd, graal-workspace],
[mx, sclone, --kind, git, "https://github.com/graalvm/graal-core.git", graal-core],
[cd, graal-core],
[mx, sforceimports],
[mx, --vm, server, build],
[cd, ../..]
[cd, ../..],
[mv, temp_mx, mx.jruby]
]

environment: {
Expand All @@ -68,19 +69,39 @@ graalvm: {
}
}

jruby-noindy: {
jruby-noindy-metrics: {
environment: {
GUEST_VM: jruby,
GUEST_VM_CONFIG: noindy,
JRUBY_OPTS: "-X-T -Xcompile.invokedynamic=false"
JRUBY_OPTS: "-X-T -Xcompile.invokedynamic=false",
MX_BENCHMARK_OPTS: --no-graal
}
}

jruby-indy: {
jruby-noindy-benchmark: {
environment: {
GUEST_VM: jruby,
GUEST_VM_CONFIG: noindy,
JRUBY_OPTS: "-X-T -X+C -Xcompile.invokedynamic=false",
MX_BENCHMARK_OPTS: --no-graal
}
}

jruby-indy-metrics: {
environment: {
GUEST_VM: jruby,
GUEST_VM_CONFIG: indy,
JRUBY_OPTS: "-X-T -Xcompile.invokedynamic=true",
MX_BENCHMARK_OPTS: --no-graal
}
}

jruby-indy-benchmark: {
environment: {
GUEST_VM: jruby,
GUEST_VM_CONFIG: indy,
JRUBY_OPTS: "-X-T -Xcompile.invokedynamic=true"
JRUBY_OPTS: "-X-T -X+C -Xcompile.invokedynamic=true",
MX_BENCHMARK_OPTS: --no-graal
}
}

Expand Down Expand Up @@ -129,6 +150,17 @@ compiler-metrics: {
] ${post-process-and-upload-results}
}

setup-benchmarks: [
[mx, sclone, --kind, git, "https://github.com/jruby/benchmark-interface.git", benchmark-interface],
[mx, sclone, --kind, git, "https://github.com/jruby/all-ruby-benchmarks.git", all-ruby-benchmarks]
]

classic-benchmarks: {
run: ${setup-benchmarks} [
[mx, benchmark, classic]
] ${post-process-and-upload-results}
}

builds: [
{name: ruby-test-fast} ${common} ${gate-caps} {run: [${jt} [test, fast]]},
{name: ruby-test-specs-command-line} ${common} ${gate-caps} {run: [${jt} [test, specs, ":command_line"]]},
Expand All @@ -137,14 +169,24 @@ builds: [
{name: ruby-test-specs-library} ${common} ${gate-caps} {run: [${jt} [test, specs, ":library"]]},
{name: ruby-test-specs-truffle} ${common} ${gate-caps} {run: [${jt} [test, specs, ":truffle"]]},
{name: ruby-test-integration} ${common} ${gate-caps} {run: [${jt} [test, integration]]},
{name: ruby-test-gems} ${common} ${gate-caps} {
setup: ${common-setup} [[mx, sclone, --kind, git, "https://github.com/jruby/jruby-truffle-gem-test-pack.git", jruby-truffle-gem-test-pack]]
environment: {GEM_HOME: jruby-truffle-gem-test-pack/gems}
run: [${jt} [test, gems]]
},
{name: ruby-test-tck} ${common} ${gate-caps} {run: [${jt} [test, tck]]},
{name: ruby-test-tarball} ${common} ${gate-caps} {run: [${jt} [tarball]]},

{name: ruby-test-compiler-graal-core} ${common} ${graal-core} ${gate-caps} {run: [${jt} [test, compiler]]},
{name: ruby-test-compiler-graalvm} ${common} ${graalvm} ${gate-caps} {run: [${jt} [test, compiler]]},

{name: ruby-metrics-noindy} ${common} ${no-graal} ${daily-bench-caps} ${jruby-noindy} ${metrics},
{name: ruby-metrics-indy} ${common} ${no-graal} ${daily-bench-caps} ${jruby-indy} ${metrics},
{name: ruby-metrics-noindy} ${common} ${no-graal} ${daily-bench-caps} ${jruby-noindy-metrics} ${metrics},
{name: ruby-metrics-indy} ${common} ${no-graal} ${daily-bench-caps} ${jruby-indy-metrics} ${metrics},
{name: ruby-metrics-truffle} ${common} ${no-graal} ${bench-caps} ${jruby-truffle} ${metrics},
{name: ruby-metrics-compiler} ${common} ${graalvm} ${bench-caps} ${jruby-truffle} ${compiler-metrics}
{name: ruby-metrics-compiler-graalvm} ${common} ${graalvm} ${bench-caps} ${jruby-truffle} ${compiler-metrics},

{name: ruby-benchmarks-classic-noindy} ${common} ${no-graal} ${daily-bench-caps} ${jruby-noindy-benchmark} ${classic-benchmarks},
{name: ruby-benchmarks-classic-indy} ${common} ${no-graal} ${daily-bench-caps} ${jruby-indy-benchmark} ${classic-benchmarks},
{name: ruby-benchmarks-classic-graal-core} ${common} ${graal-core} ${bench-caps} ${jruby-truffle} ${classic-benchmarks},
{name: ruby-benchmarks-classic-graalvm} ${common} ${graalvm} ${bench-caps} ${jruby-truffle} ${classic-benchmarks}
]
37 changes: 16 additions & 21 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
Expand Up @@ -727,22 +727,10 @@ private RootNode addGetsLoop(RootNode oldRoot, boolean printing, boolean process
*
* @param scriptNode The root node of the script to be executed
* bytecode before execution
* @param wrap whether to wrap the execution in an anonymous module
* @return The result of executing the script
*/
@Deprecated
public IRubyObject runNormally(Node scriptNode, boolean unused) {
return runNormally(scriptNode);
}

/**
* Run the specified script without any of the loop-processing wrapper
* code.
*
* @param scriptNode The root node of the script to be executed
* bytecode before execution
* @return The result of executing the script
*/
public IRubyObject runNormally(Node scriptNode) {
public IRubyObject runNormally(Node scriptNode, boolean wrap) {
ScriptAndCode scriptAndCode = null;
boolean compile = getInstanceConfig().getCompileMode().shouldPrecompileCLI();
if (compile || config.isShowBytecode()) {
Expand All @@ -757,7 +745,7 @@ public IRubyObject runNormally(Node scriptNode) {
return getNil();
}

return runScript(scriptAndCode.script());
return runScript(scriptAndCode.script(), wrap);
} else {
// FIXME: temporarily allowing JIT to fail for $0 and fall back on interpreter
// failForcedCompile(scriptNode);
Expand All @@ -766,6 +754,18 @@ public IRubyObject runNormally(Node scriptNode) {
}
}

/**
* Run the specified script without any of the loop-processing wrapper
* code.
*
* @param scriptNode The root node of the script to be executed
* bytecode before execution
* @return The result of executing the script
*/
public IRubyObject runNormally(Node scriptNode) {
return runNormally(scriptNode, false);
}

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

Expand Down Expand Up @@ -3025,12 +3025,7 @@ public void compileAndLoadFile(String filename, InputStream in, boolean wrap) {
try {
context.setFileAndLine(scriptNode.getFile(), scriptNode.getLine());

if (config.isAssumePrinting() || config.isAssumeLoop()) {
runWithGetsLoop(scriptNode, config.isAssumePrinting(), config.isProcessLineEnds(),
config.isSplit());
} else {
runNormally(scriptNode);
}
runNormally(scriptNode, wrap);
} finally {
context.setFileAndLine(oldFile, oldLine);
}
Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.jruby.runtime.opto.Invalidator;
import org.jruby.util.ByteList;
import org.jruby.util.Pack;
import org.jruby.util.Qsort;
import org.jruby.util.RecursiveComparator;
import org.jruby.util.TypeConverter;
import org.jruby.util.io.EncodingUtils;
Expand Down Expand Up @@ -3276,7 +3275,7 @@ private IRubyObject sortInternal(final ThreadContext context, boolean honorOverr
final boolean stringBypass = !honorOverride || runtime.getString().isMethodBuiltin("<=>");

try {
Qsort.sort(values, begin, begin + realLength, new Comparator() {
Arrays.sort(values, begin, begin + realLength, new Comparator() {
public int compare(Object o1, Object o2) {
if (fixnumBypass && o1 instanceof RubyFixnum && o2 instanceof RubyFixnum) {
return compareFixnums((RubyFixnum) o1, (RubyFixnum) o2);
Expand Down Expand Up @@ -3311,7 +3310,7 @@ private IRubyObject sortInternal(final ThreadContext context, final Block block)
int length = realLength;

safeArrayCopy(values, begin, newValues, 0, length);
Qsort.sort(newValues, 0, length, new Comparator() {
Arrays.sort(newValues, 0, length, new Comparator() {
public int compare(Object o1, Object o2) {
IRubyObject obj1 = (IRubyObject) o1;
IRubyObject obj2 = (IRubyObject) o2;
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
Expand Up @@ -1004,10 +1004,10 @@ public final void view(ByteList bytes) {
shareLevel = SHARE_LEVEL_NONE;
}

private void view(byte[]bytes) {
private void view(byte[] bytes, boolean copy) {
modifyCheck();

value = new ByteList(bytes);
value = new ByteList(bytes, copy);
shareLevel = SHARE_LEVEL_NONE;

value.invalidate();
Expand Down Expand Up @@ -3939,7 +3939,7 @@ private boolean end_with_pCommon(IRubyObject tmp) {
return false;
}

private static final ByteList SPACE_BYTELIST = new ByteList(ByteList.plain(" "));
private static final ByteList SPACE_BYTELIST = new ByteList(new byte[] { ' ' }, false);

private IRubyObject justify19(ThreadContext context, IRubyObject arg0, int jflag) {
Ruby runtime = context.runtime;
Expand Down Expand Up @@ -5444,7 +5444,7 @@ public IRubyObject freeze(ThreadContext context) {
* @deprecated
*/
public void setValue(CharSequence value) {
view(ByteList.plain(value));
view(ByteList.plain(value), false);
}

public void setValue(ByteList value) {
Expand Down
42 changes: 16 additions & 26 deletions core/src/main/java/org/jruby/ext/socket/RubyBasicSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import org.jruby.ast.util.ArgsUtil;
import org.jruby.ext.fcntl.FcntlLibrary;
import org.jruby.platform.Platform;
import org.jruby.runtime.Arity;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
Expand Down Expand Up @@ -200,51 +199,45 @@ private IRubyObject recv(ThreadContext context, IRubyObject length,

@JRubyMethod
public IRubyObject recv_nonblock(ThreadContext context, IRubyObject length) {
return recv_nonblock(context, length, context.nil, context.nil, false);
return recv_nonblock(context, length, context.nil, /* str */ null, true);
}

@JRubyMethod(required = 1, optional = 3) // (length) required = 1 handled above
public IRubyObject recv_nonblock(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;
int argc = args.length;
IRubyObject opts = ArgsUtil.getOptionsArg(context.runtime, args);
IRubyObject opts = ArgsUtil.getOptionsArg(runtime, args);
if (!opts.isNil()) argc--;

IRubyObject length = context.nil;
IRubyObject flags = length;
IRubyObject str = length;
IRubyObject length, flags, str;
length = flags = context.nil; str = null;

switch (argc) {
case 3:
str = args[2];
case 2:
flags = args[1];
case 1:
length = args[0];
case 3: str = args[2];
case 2: flags = args[1];
case 1: length = args[0];
}

boolean exception = ArgsUtil.extractKeywordArg(context, "exception", opts) != runtime.getFalse();

return recv_nonblock(context, length, flags, str, exception);
}

protected IRubyObject recv_nonblock(ThreadContext context, IRubyObject length,
IRubyObject flags, IRubyObject str, boolean ex) {
Ruby runtime = context.runtime;

protected final IRubyObject recv_nonblock(ThreadContext context,
IRubyObject length, IRubyObject flags, IRubyObject str, final boolean exception) {
// TODO: implement flags
final ByteBuffer buffer = ByteBuffer.allocate(RubyNumeric.fix2int(length));

ByteList bytes = doReceiveNonblock(context, buffer);

if (bytes == null) {
if (!ex) return runtime.newSymbol("wait_readable");
if (!exception) return context.runtime.newSymbol("wait_readable");
throw context.runtime.newErrnoEAGAINReadableError("recvfrom(2)");
}

if (str != null && !str.isNil()) {
str = str.convertToString();
((RubyString)str).setValue(bytes);
((RubyString) str).setValue(bytes);
return str;
}
return RubyString.newString(context.runtime, bytes);
Expand Down Expand Up @@ -504,7 +497,6 @@ public IRubyObject readmsg_nonblock(ThreadContext context, IRubyObject[] args) {
}

private ByteList doReceive(ThreadContext context, final ByteBuffer buffer) {
Ruby runtime = context.runtime;
OpenFile fptr;

fptr = getOpenFile();
Expand All @@ -517,8 +509,7 @@ private ByteList doReceive(ThreadContext context, final ByteBuffer buffer) {

if (read == 0) return null;

return new ByteList(buffer.array(), 0, buffer.position());

return new ByteList(buffer.array(), 0, buffer.position(), false);
}
catch (IOException e) {
// All errors to sysread should be SystemCallErrors, but on a closed stream
Expand All @@ -534,8 +525,7 @@ private ByteList doReceive(ThreadContext context, final ByteBuffer buffer) {
}
}

public ByteList doReceiveNonblock(ThreadContext context, final ByteBuffer buffer) {
Ruby runtime = context.runtime;
protected final ByteList doReceiveNonblock(ThreadContext context, final ByteBuffer buffer) {
Channel channel = getChannel();

if ( ! (channel instanceof SelectableChannel) ) {
Expand All @@ -557,8 +547,8 @@ public ByteList doReceiveNonblock(ThreadContext context, final ByteBuffer buffer
selectable.configureBlocking(oldBlocking);
}
}
catch(IOException e) {
throw runtime.newIOErrorFromException(e);
catch (IOException e) {
throw context.runtime.newIOErrorFromException(e);
}
}
}
Expand Down Expand Up @@ -791,7 +781,7 @@ public static IRubyObject set_do_not_reverse_lookup(IRubyObject recv, IRubyObjec
return set_do_not_reverse_lookup(recv.getRuntime().getCurrentContext(), recv, flag);
}

private static final ByteList FORMAT_SMALL_I = new ByteList(ByteList.plain("i"));
private static final ByteList FORMAT_SMALL_I = new ByteList(new byte[] { 'i' }, false);
protected MulticastStateManager multicastStateManager = null;

// By default we always reverse lookup unless do_not_reverse_lookup set.
Expand Down
Loading

0 comments on commit c73342d

Please sign in to comment.