Skip to content

Commit

Permalink
Merge branch 'master' into ruby-2.3+socket
Browse files Browse the repository at this point in the history
Conflicts:
	core/pom.rb
	core/pom.xml
headius committed Mar 11, 2016
2 parents 913ad2d + da4e236 commit fa5b80f
Showing 1,309 changed files with 121,975 additions and 3,043 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -82,6 +82,10 @@ matrix:
jdk: oraclejdk8
- env: JT='test mri'
- env: JTRCI='lib/ruby/truffle/jruby+truffle/gem_ci/travis.txt'
- env: PHASE='-Pmain'
jdk: oraclejdk8
- env: PHASE='-Pj2ee'
jdk: oraclejdk7
# NOTE: build seems to never start (waited for any to finish for more than a day) - probably a travis-ci bug
#- env: PHASE='-Pmain'
# sudo: required
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@ build: off

environment:
matrix:
- JAVA_HOME: C:\Program Files\Java\jdk1.7.0
- JAVA_HOME: C:\Program Files (x86)\Java\jdk1.7.0
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0

12 changes: 6 additions & 6 deletions core/pom.rb
Original file line number Diff line number Diff line change
@@ -42,16 +42,16 @@

# 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.10', :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-x86asm:1.0.2', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.11-SNAPSHOT', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.28-SNAPSHOT', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.1-SNAPSHOT', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.0.7'
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-ffi:2.0.9'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'

jar 'org.jruby.joni:joni:2.1.10-SNAPSHOT'
jar 'org.jruby.joni:joni:2.1.10'
jar 'org.jruby.extras:bytelist:1.0.13'
jar 'org.jruby.jcodings:jcodings:1.0.17'
jar 'org.jruby:dirgra:0.3'
12 changes: 6 additions & 6 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-enxio</artifactId>
<version>0.10</version>
<version>0.12</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
@@ -125,7 +125,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-unixsocket</artifactId>
<version>0.11-SNAPSHOT</version>
<version>0.12</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
@@ -136,7 +136,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.28-SNAPSHOT</version>
<version>3.0.29</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
@@ -147,7 +147,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-constants</artifactId>
<version>0.9.1-SNAPSHOT</version>
<version>0.9.1</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
@@ -158,7 +158,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
<version>2.0.7</version>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
@@ -174,7 +174,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>org.jruby.joni</groupId>
<artifactId>joni</artifactId>
<version>2.1.10-SNAPSHOT</version>
<version>2.1.10</version>
</dependency>
<dependency>
<groupId>org.jruby.extras</groupId>
5 changes: 3 additions & 2 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -702,14 +702,15 @@ private RootNode addGetsLoop(RootNode oldRoot, boolean printing, boolean process

if (processLineEndings) whileBody.add(new CallNode(pos, dollarUnderscore, "chop!", null, null));
if (split) whileBody.add(new GlobalAsgnNode(pos, "$F", new CallNode(pos, dollarUnderscore, "split", null, null)));
if (printing) whileBody.add(new FCallNode(pos, "puts", new ArrayNode(pos, dollarUnderscore), null));

if (oldRoot.getBodyNode() instanceof BlockNode) { // common case n stmts
whileBody.addAll(oldRoot.getBodyNode());
whileBody.addAll(((BlockNode) oldRoot.getBodyNode()));
} else { // single expr script
whileBody.add(oldRoot.getBodyNode());
}

if (printing) whileBody.add(new FCallNode(pos, "puts", new ArrayNode(pos, dollarUnderscore), null));

return new RootNode(pos, oldRoot.getScope(), newBody, oldRoot.getFile());
}

83 changes: 61 additions & 22 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -128,6 +128,10 @@ public static RubyModule createKernelModule(Ruby runtime) {
runtime.setSuperMethodMissing(new MethodMissingMethod(module, PUBLIC, CallType.SUPER));
runtime.setNormalMethodMissing(new MethodMissingMethod(module, PUBLIC, CallType.NORMAL));

if (runtime.getInstanceConfig().isAssumeLoop()) {
module.defineAnnotatedMethods(LoopMethods.class);
}

recacheBuiltinMethods(runtime);

return module;
@@ -1734,28 +1738,6 @@ public static IRubyObject fork19(ThreadContext context, IRubyObject recv, Block
throw runtime.newNotImplementedError("fork is not available on this platform");
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) {
RubyString str = (RubyString) getLastlineString(context, context.runtime).dup();

if (!str.gsub_bang(context, arg0, block).isNil()) {
context.setLastLine(str);
}

return str;
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) {
RubyString str = (RubyString) getLastlineString(context, context.runtime).dup();

if (!str.gsub_bang(context, arg0, arg1, block).isNil()) {
context.setLastLine(str);
}

return str;
}

@JRubyMethod(module = true)
public static IRubyObject tap(ThreadContext context, IRubyObject recv, Block block) {
block.yield(context, recv);
@@ -2061,6 +2043,63 @@ public static RubyArray instance_variables19(ThreadContext context, IRubyObject
}
/* end delegated bindings */

public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) {
RubyString str = (RubyString) getLastlineString(context, context.runtime).dup();

if (!str.gsub_bang(context, arg0, block).isNil()) {
context.setLastLine(str);
}

return str;
}

public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) {
RubyString str = (RubyString) getLastlineString(context, context.runtime).dup();

if (!str.gsub_bang(context, arg0, arg1, block).isNil()) {
context.setLastLine(str);
}

return str;
}

public static class LoopMethods {
@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) {
return context.setLastLine(getLastlineString(context, context.runtime).gsub(context, arg0, block));
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) {
return context.setLastLine(getLastlineString(context, context.runtime).gsub(context, arg0, arg1, block));
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject sub(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) {
return context.setLastLine(getLastlineString(context, context.runtime).sub(context, arg0, block));
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject sub(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) {
return context.setLastLine(getLastlineString(context, context.runtime).sub(context, arg0, arg1, block));
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject chop(ThreadContext context, IRubyObject recv) {
return context.setLastLine(getLastlineString(context, context.runtime).chop(context));
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject chomp(ThreadContext context, IRubyObject recv) {
return context.setLastLine(getLastlineString(context, context.runtime).chomp(context));
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject chomp(ThreadContext context, IRubyObject recv, IRubyObject arg0) {
return context.setLastLine(getLastlineString(context, context.runtime).chomp(context, arg0));
}
}

@Deprecated
public static IRubyObject methodMissing(ThreadContext context, IRubyObject recv, String name, Visibility lastVis, CallType lastCallType, IRubyObject[] args, Block block) {
return methodMissing(context, recv, name, lastVis, lastCallType, args);
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jruby.ext.securerandom;

import org.jruby.CompatVersion;
import org.jruby.RubyString;
import org.jruby.anno.JRubyMethod;
import org.jruby.runtime.ThreadContext;
@@ -31,13 +30,13 @@ public static IRubyObject hex(ThreadContext context, IRubyObject self, IRubyObje
return RubyString.newStringNoCopy(context.runtime, ConvertBytes.twosComplementToHexBytes(nextBytes(context, n), false));
}

@JRubyMethod(meta = true, compat = CompatVersion.RUBY1_9)
@JRubyMethod(meta = true)
public static IRubyObject uuid(ThreadContext context, IRubyObject self) {
return RubyString.newStringNoCopy(context.runtime, ConvertBytes.bytesToUUIDBytes(nextBytes(context, 16), false));
}

private static byte[] nextBytes(ThreadContext context, IRubyObject n) {
int size = n.isNil() ? 16 : (int)n.convertToInteger().getLongValue();
int size = n.isNil() ? 16 : (int) n.convertToInteger().getLongValue();

return nextBytes(context, size);
}
@@ -46,7 +45,7 @@ private static byte[] nextBytes(ThreadContext context, int size) {
if (size < 0) throw context.runtime.newArgumentError("negative argument: " + size);

byte[] bytes = new byte[size];
context.secureRandom.nextBytes(bytes);
context.getSecureRandom().nextBytes(bytes);

return bytes;
}
15 changes: 8 additions & 7 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -1025,6 +1025,7 @@ public Operand buildCall(CallNode callNode) {

ArrayNode argsAry;
if (
!callNode.isLazy() &&
callNode.getName().equals("[]") &&
callNode.getArgsNode() instanceof ArrayNode &&
(argsAry = (ArrayNode) callNode.getArgsNode()).size() == 1 &&
@@ -1035,14 +1036,13 @@ public Operand buildCall(CallNode callNode) {
return callResult;
}

Operand[] args = setupCallArgs(callArgsNode);

Label lazyLabel = getNewLabel();
Label endLabel = getNewLabel();
if (callNode.isLazy()) {
addInstr(new BNilInstr(lazyLabel, receiver));
}

Operand[] args = setupCallArgs(callArgsNode);
Operand block = setupCallClosure(callNode.getIterNode());

CallInstr callInstr = CallInstr.create(scope, callResult, callNode.getName(), receiver, args, block);
@@ -1914,21 +1914,21 @@ protected void receiveNonBlockArgs(final ArgsNode argsNode) {
// Now for opt args
if (opt > 0) {
int optIndex = argsNode.getOptArgIndex();
Variable temp = createTemporaryVariable();
for (int j = 0; j < opt; j++, argIndex++) {
// Jump to 'l' if this arg is not null. If null, fall through and build the default value!
Label l = getNewLabel();
OptArgNode n = (OptArgNode)args[optIndex + j];
String argName = n.getName();
Variable av = getNewLocalVariable(argName, 0);
if (scope instanceof IRMethod) addArgumentDescription(ArgumentType.opt, argName);
Variable temp = createTemporaryVariable();
// You need at least required+j+1 incoming args for this opt arg to get an arg at all
addInstr(new ReceiveOptArgInstr(temp, signature.required(), signature.pre(), j));
addInstr(BNEInstr.create(l, temp, UndefinedValue.UNDEFINED)); // if 'av' is not undefined, go to default
addInstr(new ReceiveOptArgInstr(av, signature.required(), signature.pre(), j));
addInstr(BNEInstr.create(l, av, UndefinedValue.UNDEFINED)); // if 'av' is not undefined, go to default
addInstr(new CopyInstr(av, buildNil())); // wipe out undefined value with nil
Operand defaultResult = build(n.getValue());
addInstr(new CopyInstr(temp, defaultResult));
addInstr(new CopyInstr(av, defaultResult));
addInstr(new LabelInstr(l));
addInstr(new CopyInstr(av, temp));
}
}

@@ -2024,6 +2024,7 @@ public void receiveArgs(final ArgsNode argsNode) {

// Required kwargs have no value and check_arity will throw if they are not provided.
if (!isRequiredKeywordArgumentValue(kasgn)) {
addInstr(new CopyInstr(av, buildNil())); // wipe out undefined value with nil
build(kasgn);
} else {
addInstr(new RaiseRequiredKeywordArgumentError(argName));
14 changes: 1 addition & 13 deletions core/src/main/java/org/jruby/ir/IRManager.java
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@
public class IRManager {
public static final String SAFE_COMPILER_PASSES = "";
public static final String DEFAULT_BUILD_PASSES = "";
public static final String DEFAULT_JIT_PASSES = "OptimizeDelegationPass,DeadCodeElimination,AddLocalVarLoadStoreInstructions,OptimizeDynScopesPass,AddCallProtocolInstructions,EnsureTempsAssigned";
public static final String DEFAULT_JIT_PASSES = "LocalOptimizationPass,OptimizeDelegationPass,DeadCodeElimination,AddLocalVarLoadStoreInstructions,OptimizeDynScopesPass,AddCallProtocolInstructions,EnsureTempsAssigned";
public static final String DEFAULT_INLINING_COMPILER_PASSES = "LocalOptimizationPass";

private final CompilerPass deadCodeEliminationPass = new DeadCodeElimination();
@@ -53,7 +53,6 @@ public class IRManager {
private InstructionsListener instrsListener = null;
private IRScopeListener irScopeListener = null;


// FIXME: Eventually make these attrs into either a) set b) part of state machine
private List<CompilerPass> compilerPasses;
private List<CompilerPass> inliningCompilerPasses;
@@ -266,17 +265,6 @@ public TemporaryLocalVariable newTemporaryLocalVariable(int index) {
return tempVar;
}

public Instr[] optimizeTemporaryVariablesIfEnabled(IRScope scope, Instr[] instrs) {
// Local opts don't move instrs across basic-block boundaries
// and are safe to run before the opt-tmp-vars pass.
// This ensures that local opts aren't affected by RAW hazards.
(new LocalOptimizationPass()).runLocalOptsOnInstrArray(scope, instrs);
// FIXME: Make this check ir.passes and not run if ir.passes is set and does not contain opttempvars.
// FIXME: LOP + Opttempvars cannot cope with y,d = d,y it propagates the intermediate temp var away
//return OptimizeTempVarsPass.optimizeTmpVars(scope, instrs);
return instrs;
}

/**
* For scopes that don't require a dynamic scope we can run DCE and some other passes which cannot
* be stymied by escaped bindings.
28 changes: 12 additions & 16 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -482,7 +482,6 @@ protected boolean isUnsafeScope() {
}

public List<CompilerPass> getExecutedPasses() {
// FIXME: Super annoying...because OptimizeTempVars is a pre-CFG pass we have no full build info yet
return fullInterpreterContext == null ? new ArrayList<CompilerPass>(1) : fullInterpreterContext.getExecutedPasses();
}

@@ -550,15 +549,9 @@ private void prepareFullBuildCommon() {

// Clone instrs from startup interpreter so we do not swap out instrs out from under the
// startup interpreter as we are building the full interpreter.
Instr[] instrs = cloneInstrs();

// This is a complicating pseudo-pass which needs to be run before CFG is generated. This
// necessitates us needing a clonedInstrs field on IRScope. If we can rewrite this to a full
// CFG using pass we can eliminate this intermediate save and field.
instrs = getManager().optimizeTemporaryVariablesIfEnabled(this, instrs);

fullInterpreterContext = new FullInterpreterContext(this, instrs);
fullInterpreterContext = new FullInterpreterContext(this, cloneInstrs());
}

/**
* This initializes a more complete(full) InterpreterContext which if used in mixed mode will be
* used by the JIT and if used in pure-interpreted mode it will be used by an interpreter engine.
@@ -1020,13 +1013,16 @@ public void resetState() {

// Invalidate compiler pass state.
//
// SSS FIXME: This is to get around concurrent-modification issues
// since CompilerPass.invalidate modifies this, but some passes
// cannot be invalidated.
int i = 0;
while (i < getFullInterpreterContext().getExecutedPasses().size()) {
if (!getFullInterpreterContext().getExecutedPasses().get(i).invalidate(this)) {
i++;
// SSS FIXME: Re-grabbing passes each iter is to get around concurrent-modification issues
// since CompilerPass.invalidate modifies this, but some passes cannot be invalidated. This
// should be wrapped in an iterator.
FullInterpreterContext fic = getFullInterpreterContext();
if (fic != null) {
int i = 0;
while (i < fic.getExecutedPasses().size()) {
if (!fic.getExecutedPasses().get(i).invalidate(this)) {
i++;
}
}
}
}
Loading

0 comments on commit fa5b80f

Please sign in to comment.