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/cast/CmpIntNode.java
	truffle/src/main/java/org/jruby/truffle/nodes/coerce/SymbolOrToStrNode.java
	truffle/src/main/java/org/jruby/truffle/nodes/coerce/ToIntNode.java
	truffle/src/main/java/org/jruby/truffle/nodes/coerce/ToStrNode.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/FiberNodes.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/FileNodes.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/IONodes.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/TrufflePrimitiveNodes.java
	truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
	truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  • Loading branch information
chrisseaton committed Apr 23, 2015
2 parents 2961673 + 9bed84f commit 00fbf5a
Show file tree
Hide file tree
Showing 391 changed files with 7,944 additions and 2,650 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Expand Up @@ -2,9 +2,9 @@ language: java

sudo: false

cache:
directories:
- $HOME/.m2
#cache:
# directories:
# - $HOME/.m2

before_script:
- unset GEM_PATH GEM_HOME IRBRC JRUBY_OPTS
Expand All @@ -21,6 +21,7 @@ os:
env:
global:
- JAVA_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
- MALLOC_ARENA_MAX=2
matrix:
- PHASE='-Ptest'
- PHASE='-Prake -Dtask=test:jruby'
Expand Down
6 changes: 3 additions & 3 deletions README.md
@@ -1,6 +1,6 @@
# JRuby - an implementation of the Ruby language on the JVM

Master: [![Build Status](https://travis-ci.org/jruby/jruby.png?branch=master)](https://travis-ci.org/jruby/jruby)
Master: [![Build Status](https://travis-ci.org/jruby/jruby.png?branch=master)](https://travis-ci.org/jruby/jruby)
1.7 branch: [![Build Status](https://travis-ci.org/jruby/jruby.png?branch=jruby-1_7)](https://travis-ci.org/jruby/jruby/branches)

## About
Expand Down Expand Up @@ -40,7 +40,7 @@ For [`rbenv`](https://github.com/sstephenson/rbenv) you will need the
package manager can provide these. Then you can run:

```
$ rbenv install rbenv install jruby-9.0.0.0-dev
$ rbenv install jruby-9.0.0.0-dev
```

For [`rvm`](https://rvm.io) you can simply do:
Expand Down Expand Up @@ -69,7 +69,7 @@ Stefan Matthias Aust, Anders Bengtsson, Geert Bevin, Ola Bini,
Daiki Ueno, Matthias Veit, Jason Voegele, Sergey Yevtushenko, Robert Yokota,
and many gracious contributors from the community.

JRuby uses code generously shared by the creator of the Ruby language,
JRuby uses code generously shared by the creator of the Ruby language,
Yukihiro Matsumoto <matz@netlab.co.jp>.

Project Contact: Thomas E Enebo <tom.enebo@gmail.com>
Expand Down
12 changes: 6 additions & 6 deletions core/pom.rb
Expand Up @@ -41,18 +41,18 @@
jar 'org.ow2.asm:asm-util:${asm.version}'

jar 'com.github.jnr:jnr-netdb:1.1.4'
jar 'com.github.jnr:jnr-enxio:0.7'
jar 'com.github.jnr:jnr-enxio:0.8'
jar 'com.github.jnr:jnr-x86asm:1.0.2'
jar 'com.github.jnr:jnr-unixsocket:0.6'
jar 'com.github.jnr:jnr-posix:3.0.10'
jar 'com.github.jnr:jnr-unixsocket:0.7'
jar 'com.github.jnr:jnr-posix:3.0.11'
jar 'com.github.jnr:jnr-constants:0.8.6'
jar 'com.github.jnr:jnr-ffi:2.0.2'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'

jar 'org.jruby.joni:joni:2.1.6-SNAPSHOT'
jar 'org.jruby.extras:bytelist:1.0.12'
jar 'org.jruby.jcodings:jcodings:1.0.13-SNAPSHOT'
jar 'org.jruby.joni:joni:2.1.6'
jar 'org.jruby.extras:bytelist:1.0.13'
jar 'org.jruby.jcodings:jcodings:1.0.13'
jar 'org.jruby:dirgra:0.2'

jar 'com.headius:invokebinder:1.5'
Expand Down
16 changes: 7 additions & 9 deletions core/pom.xml
Expand Up @@ -21,7 +21,7 @@
<installer.gems>${jruby.win32ole.gem}</installer.gems>
<tesla.dump.readonly>true</tesla.dump.readonly>
<prawn.git.repo>git://github.com/sandal/prawn.git</prawn.git.repo>
<version.ruby.minor>0</version.ruby.minor>
<version.ruby.minor>2</version.ruby.minor>
<tzdata.version>2013d</tzdata.version>
<install4j.executable>/Applications/install4j 4/bin/install4jc</install4j.executable>
<jay.bin>jay</jay.bin>
Expand Down Expand Up @@ -90,8 +90,7 @@
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-enxio</artifactId>
<version>0.8-SNAPSHOT</version>
<type>jar</type>
<version>0.8</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
Expand All @@ -101,13 +100,12 @@
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-unixsocket</artifactId>
<version>0.7-SNAPSHOT</version>
<type>jar</type>
<version>0.7</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.11</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
Expand All @@ -133,17 +131,17 @@
<dependency>
<groupId>org.jruby.joni</groupId>
<artifactId>joni</artifactId>
<version>2.1.6-SNAPSHOT</version>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>org.jruby.extras</groupId>
<artifactId>bytelist</artifactId>
<version>1.0.13-SNAPSHOT</version>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>org.jruby.jcodings</groupId>
<artifactId>jcodings</artifactId>
<version>1.0.13-SNAPSHOT</version>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
Expand Down
10 changes: 6 additions & 4 deletions core/src/main/java/org/jruby/IncludedModuleWrapper.java
Expand Up @@ -208,14 +208,16 @@ public IRubyObject getAutoloadConstant(String name) {

@Override
protected DynamicMethod searchMethodCommon(String name) {
// IncludedModuleWrapper needs to search prepended modules too, but not included ones.
RubyModule module = this;
for (; module.isPrepended(); module = module.getSuperClass()) {
// IncludedModuleWrapper needs to search prepended modules too, so search until we find methodLocation
RubyModule module = origin;
RubyModule methodLoc = origin.getMethodLocation();

for (; module != methodLoc; module = module.getSuperClass()) {
DynamicMethod method = module.getMethods().get(name);
if (method != null) return method.isNull() ? null : method;
}

// Last non-prepended module should be our regular module, do one last search.
// one last search for method location
DynamicMethod method = module.getMethods().get(name);
if (method != null) return method.isNull() ? null : method;

Expand Down
9 changes: 5 additions & 4 deletions core/src/main/java/org/jruby/Ruby.java
Expand Up @@ -39,6 +39,7 @@
***** END LICENSE BLOCK *****/
package org.jruby;

import org.jcodings.specific.UTF8Encoding;
import org.jruby.ast.ArrayNode;
import org.jruby.ast.BlockNode;
import org.jruby.ast.CallNode;
Expand Down Expand Up @@ -2731,26 +2732,26 @@ private Node parseFileFromMainAndGetAST(InputStream in, String file, DynamicScop
private Node parseFileAndGetAST(InputStream in, String file, DynamicScope scope, int lineNumber, boolean isFromMain) {
ParserConfiguration parserConfig =
new ParserConfiguration(this, lineNumber, false, true, config);
setupSourceEncoding(parserConfig);
setupSourceEncoding(parserConfig, UTF8Encoding.INSTANCE);
return parser.parse(file, in, scope, parserConfig);
}

public Node parseInline(InputStream in, String file, DynamicScope scope) {
addEvalParseToStats();
ParserConfiguration parserConfig =
new ParserConfiguration(this, 0, false, true, false, config);
setupSourceEncoding(parserConfig);
setupSourceEncoding(parserConfig, getEncodingService().getLocaleEncoding());
return parser.parse(file, in, scope, parserConfig);
}

private void setupSourceEncoding(ParserConfiguration parserConfig) {
private void setupSourceEncoding(ParserConfiguration parserConfig, Encoding defaultEncoding) {
if (config.getSourceEncoding() != null) {
if (config.isVerbose()) {
config.getError().println("-K is specified; it is for 1.8 compatibility and may cause odd behavior");
}
parserConfig.setDefaultEncoding(getEncodingService().getEncodingFromString(config.getSourceEncoding()));
} else {
parserConfig.setDefaultEncoding(getEncodingService().getLocaleEncoding());
parserConfig.setDefaultEncoding(defaultEncoding);
}
}

Expand Down
100 changes: 47 additions & 53 deletions core/src/main/java/org/jruby/RubyIO.java
Expand Up @@ -3432,7 +3432,7 @@ private static IRubyObject openKeyArgs(ThreadContext context, IRubyObject recv,
IRubyObject path, v;

path = StringSupport.checkEmbeddedNulls(runtime, RubyFile.get_path(context, argv[0]));
failIfDirectory(runtime, (RubyString)path); // only in JRuby
failIfDirectory(runtime, (RubyString) path); // only in JRuby
// MRI increments args past 0 now, so remaining uses of args only see non-path args

if (opt.isNil()) {
Expand Down Expand Up @@ -3762,61 +3762,53 @@ private static class Ruby19POpen {

public Ruby19POpen(Ruby runtime, IRubyObject[] args) {
IRubyObject[] _cmdPlusArgs = null;
RubyHash _env = null;
IRubyObject _env = null;
IRubyObject _cmd;
IRubyObject arg0 = args[0].checkArrayType();

if (args[0] instanceof RubyHash) {
// use leading hash as env
if (args.length > 1) {
_env = (RubyHash)args[0];
} else {
Arity.raiseArgumentError(runtime, 0, 1, 2);
}
int firstArg = 0;
int argc = args.length;

if (Platform.IS_WINDOWS) {
String[] tokens = args[1].convertToString().toString().split(" ", 2);
String commandString = tokens[0].replace('/', '\\') +
(tokens.length > 1 ? ' ' + tokens[1] : "");
_cmd = runtime.newString(commandString);
} else {
_cmd = args[1].convertToString();
if (argc > 0 && !(_env = TypeConverter.checkHashType(runtime, args[0])).isNil()) {
if (argc < 2) throw runtime.newArgumentError(1, 2);
firstArg++;
argc--;
} else {
_env = null;
}

IRubyObject arg0 = args[firstArg].checkArrayType();

if (arg0.isNil()) {
if ((arg0 = TypeConverter.checkStringType(runtime, args[firstArg])).isNil()) {
throw runtime.newTypeError(args[firstArg], runtime.getString());
}
} else if (args[0] instanceof RubyArray) {
RubyArray arg0Ary = (RubyArray)arg0;
_cmdPlusArgs = new IRubyObject[]{arg0};
} else {
RubyArray arg0Ary = (RubyArray) arg0;
if (arg0Ary.isEmpty()) throw runtime.newArgumentError("wrong number of arguments");
if (arg0Ary.eltOk(0) instanceof RubyHash) {
// leading hash, use for env
_env = (RubyHash)arg0Ary.delete_at(0);
_env = arg0Ary.delete_at(0);
}
if (arg0Ary.isEmpty()) throw runtime.newArgumentError("wrong number of arguments");
if (arg0Ary.size() > 1 && arg0Ary.eltOk(arg0Ary.size() - 1) instanceof RubyHash) {
// trailing hash, use for opts
_env = (RubyHash)arg0Ary.eltOk(arg0Ary.size() - 1);
_env = arg0Ary.eltOk(arg0Ary.size() - 1);
}
_cmdPlusArgs = (IRubyObject[])arg0Ary.toJavaArray();
_cmdPlusArgs = arg0Ary.toJavaArray();
}

if (Platform.IS_WINDOWS) {
String commandString = _cmdPlusArgs[0].convertToString().toString().replace('/', '\\');
_cmdPlusArgs[0] = runtime.newString(commandString);
} else {
_cmdPlusArgs[0] = _cmdPlusArgs[0].convertToString();
}
_cmd = _cmdPlusArgs[0];
if (Platform.IS_WINDOWS) {
String commandString = _cmdPlusArgs[0].convertToString().toString().replace('/', '\\');
_cmdPlusArgs[0] = runtime.newString(commandString);
} else {
if (Platform.IS_WINDOWS) {
String[] tokens = args[0].convertToString().toString().split(" ", 2);
String commandString = tokens[0].replace('/', '\\') +
(tokens.length > 1 ? ' ' + tokens[1] : "");
_cmd = runtime.newString(commandString);
} else {
_cmd = args[0].convertToString();
}
_cmdPlusArgs[0] = _cmdPlusArgs[0].convertToString();
}
_cmd = _cmdPlusArgs[0];

this.cmd = (RubyString)_cmd;
this.cmdPlusArgs = _cmdPlusArgs;
this.env = _env;
this.env = (RubyHash)_env;
}
}

Expand All @@ -3832,21 +3824,23 @@ public static IRubyObject popen(ThreadContext context, IRubyObject recv, IRubyOb
// old JDK popen logic
IRubyObject pmode = null;
RubyHash options = null;

switch(args.length) {
case 1:
break;
case 2:
if (args[1] instanceof RubyHash) {
options = (RubyHash) args[1];
} else {
pmode = args[1];
}
break;
case 3:
options = args[2].convertToHash();
pmode = args[1];
break;
IRubyObject tmp;

int firstArg = 0;
int argc = args.length;

if (argc > 0 && !TypeConverter.checkHashType(runtime, args[0]).isNil()) {
firstArg++;
argc--;
}

if (argc > 0 && !(tmp = TypeConverter.checkHashType(runtime, args[args.length - 1])).isNil()) {
options = (RubyHash)tmp;
argc--;
}

if (argc > 1) {
pmode = args[firstArg + 1];
}

RubyIO io = new RubyIO(runtime, (RubyClass) recv);
Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/org/jruby/RubyModule.java
Expand Up @@ -3151,11 +3151,10 @@ public Collection<String> constantsCommon(Ruby runtime, boolean replaceModule, b
return constantsCommon(runtime, replaceModule, allConstants, true);
}


public Collection<String> constantsCommon(Ruby runtime, boolean replaceModule, boolean allConstants, boolean includePrivate) {
RubyModule objectClass = runtime.getObject();
final RubyModule objectClass = runtime.getObject();

Collection<String> constantNames = new HashSet<String>();
final Collection<String> constantNames;
if (allConstants) {
if ((replaceModule && runtime.getModule() == this) || objectClass == this) {
constantNames = objectClass.getConstantNames(includePrivate);
Expand Down
Expand Up @@ -230,7 +230,7 @@ public void load(Ruby runtime, boolean wrap) {
setConfig(configHash, "MAJOR", versionParts[0]);
setConfig(configHash, "MINOR", versionParts[1]);
setConfig(configHash, "TEENY", versionParts[2]);
setConfig(configHash, "ruby_version", versionParts[0] + '.' + versionParts[1]);
setConfig(configHash, "ruby_version", versionParts[0] + '.' + versionParts[1] + ".0");
// Rubygems is too specific on host cpu so until we have real need lets default to universal
//setConfig(configHash, "arch", System.getProperty("os.arch") + "-java" + System.getProperty("java.specification.version"));
setConfig(configHash, "arch", "universal-java" + System.getProperty("java.specification.version"));
Expand Down
31 changes: 30 additions & 1 deletion core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Expand Up @@ -735,7 +735,36 @@ public static RubyModule findInstanceMethodContainer(ThreadContext context, Dyna
for (DynamicScope ds = currDynScope; ds != null; ) {
IRScopeType scopeType = ds.getStaticScope().getScopeType();
switch (ds.getEvalType()) {
case MODULE_EVAL : return (RubyModule) self;
// The most common use case here is where :
// - a method is defined inside a closure
// that is nested inside a module_eval.
// here self = the module
// - in the rare case where it is not (looks like it can
// happen in some testing frameworks), we have to add
// the method to self itself => its metaclass.
//
// SSS FIXME: Looks like this rare case happens when
// the closure is used in a "define_method &block" scenario
// => in reality the scope is not a closure but an
// instance_method. So, when we fix define_method implementation
// to actually convert blocks to real instance_method scopes,
// we will not have this edge case since the code will then
// be covered by the (scopeType == IRScopeType.INSTANCE_METHOD)
// scenario below. Whenever we get to fixing define_method
// implementation, we should rip out this code here.
//
// Verify that this test runs:
// -------------
// require "minitest/autorun"
//
// describe "A" do
// it "should do something" do
// def foo
// end
// end
// end
// -------------
case MODULE_EVAL : return self instanceof RubyModule ? (RubyModule) self : self.getMetaClass();
case INSTANCE_EVAL: return self.getSingletonClass();
case BINDING_EVAL : ds = ds.getParentScope(); break;
case NONE:
Expand Down
Expand Up @@ -21,6 +21,10 @@ public StaticMethodInvoker(RubyClass host, Method method) {
super(host, method);
}

public StaticMethodInvoker(RubyModule host, Method method) {
super(host, method);
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args) {
JavaMethod method = (JavaMethod) findCallable(self, name, args, args.length);
Expand Down

0 comments on commit 00fbf5a

Please sign in to comment.