Skip to content

Commit

Permalink
Merge branch 'ruby-2.3' into ruby-2.3+socket
Browse files Browse the repository at this point in the history
headius committed Feb 7, 2016
2 parents 5f0985f + 68071f8 commit 2029231
Showing 816 changed files with 7,414 additions and 5,994 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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 jruby-9.0.0.0-dev
$ rbenv install jruby-9.0.5.0
```

For [`rvm`](https://rvm.io) you can simply do:
5 changes: 1 addition & 4 deletions bin/jruby+truffle
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env bash
"exec" "`dirname $BASH_SOURCE[0]`/jruby" "$0" "$@"

require File.join(JRuby.runtime.instance_config.jruby_home, 'lib/ruby/truffle/jruby+truffle/runner')

JRubyTruffleRunner.new
exec `dirname $BASH_SOURCE[0]`/jruby `dirname $BASH_SOURCE[0]`/../lib/ruby/truffle/jruby+truffle/bin/jruby+truffle "$@"
23 changes: 23 additions & 0 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -4860,6 +4860,24 @@ public Object constant() {
return constant;
}

/**
* Set the base Class#new method.
*
* @param baseNewMethod
*/
public void setBaseNewMethod(DynamicMethod baseNewMethod) {
this.baseNewMethod = baseNewMethod;
}

/**
* Get the base Class#new method.
*
* @return the base Class#new method
*/
public DynamicMethod getBaseNewMethod() {
return baseNewMethod;
}

@Deprecated
public int getSafeLevel() {
return 0;
@@ -5213,4 +5231,9 @@ public void addToObjectSpace(boolean useObjectSpace, IRubyObject object) {
* accesses.
*/
private final Object constant;

/**
* The built-in Class#new method, so we can bind more directly to allocate and initialize.
*/
private DynamicMethod baseNewMethod;
}
11 changes: 10 additions & 1 deletion core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -233,10 +233,19 @@ static void recacheBuiltinMethods(Ruby runtime) {
}

@JRubyMethod(name = "initialize", visibility = PRIVATE)
public IRubyObject initialize19(ThreadContext context) {
public IRubyObject initialize(ThreadContext context) {
return context.nil;
}

@Deprecated
public IRubyObject initialize19(ThreadContext context) {
return initialize(context);
}

//public IRubyObject initialize(ThreadContext context, IRubyObject[] args) {
// return initialize(context);
//}

/**
* Standard path for object creation. Objects are entered into ObjectSpace
* only if ObjectSpace is enabled.
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/RubyClass.java
Original file line number Diff line number Diff line change
@@ -113,6 +113,8 @@ public static void createClassClass(Ruby runtime, RubyClass classClass) {
classClass.undefineMethod("extend_object");

classClass.defineAnnotatedMethods(RubyClass.class);

runtime.setBaseNewMethod(classClass.searchMethod("new"));
}

public static final ObjectAllocator CLASS_ALLOCATOR = new ObjectAllocator() {
10 changes: 0 additions & 10 deletions core/src/main/java/org/jruby/RubyObject.java
Original file line number Diff line number Diff line change
@@ -279,16 +279,6 @@ public IRubyObject allocate(Ruby runtime, RubyClass klass) {
}
};

@Deprecated
@Override
public IRubyObject initialize() {
return getRuntime().getNil();
}

public IRubyObject initialize(ThreadContext context) {
return initialize19(context);
}

/**
* Will make sure that this object is added to the current object
* space.
34 changes: 7 additions & 27 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -1497,40 +1497,20 @@ public static RubyString newInstance(IRubyObject recv, IRubyObject[] args, Block
}

@Override
@JRubyMethod(name = "initialize", visibility = PRIVATE)
public IRubyObject initialize(ThreadContext context) {
return initialize19(context);
}

public IRubyObject initialize(ThreadContext context, IRubyObject arg0) {
return initialize19(context, new IRubyObject[] { arg0 });
return this;
}

@JRubyMethod(name = "initialize", visibility = PRIVATE)
@Override
public IRubyObject initialize19(ThreadContext context) {
public IRubyObject initialize(ThreadContext context, IRubyObject arg0) {
replace19(arg0);
return this;
}

@JRubyMethod(name = "initialize", visibility = PRIVATE, optional = 2)
public IRubyObject initialize19(ThreadContext context, IRubyObject[] args) {
if ( args.length == 0 ) return this;

IRubyObject arg = args[ args.length - 1 ];

final IRubyObject string; final IRubyObject encoding;
if ( arg instanceof RubyHash ) { // new encoding: ...
final RubySymbol enc = context.runtime.newSymbol("encoding");
encoding = ( (RubyHash) arg ).fastARef(enc);
string = args.length > 1 ? args[0] : null;
}
else {
string = arg; encoding = null;
}

if ( string != null ) replace19(string);
if ( encoding != null ) force_encoding(context, encoding);

return this;
@Deprecated
public IRubyObject initialize19(ThreadContext context, IRubyObject arg0) {
return initialize(context, arg0);
}

public IRubyObject casecmp(ThreadContext context, IRubyObject other) {
40 changes: 21 additions & 19 deletions core/src/main/java/org/jruby/compiler/JITCompiler.java
Original file line number Diff line number Diff line change
@@ -49,10 +49,12 @@
import org.jruby.util.JavaNameMangler;
import org.jruby.util.OneShotClassLoader;
import org.jruby.util.cli.Options;
import org.jruby.util.collections.IntHashMap;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;
import org.objectweb.asm.Opcodes;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.security.MessageDigest;
@@ -185,9 +187,9 @@ public void buildThresholdReached(ThreadContext context, final Compilable method
private static final MethodHandles.Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup().in(Ruby.class);

private class FullBuildTask implements Runnable {
private final Compilable method;
private final Compilable<InterpreterContext> method;

public FullBuildTask(Compilable method) {
FullBuildTask(Compilable<InterpreterContext> method) {
this.method = method;
}

@@ -278,41 +280,41 @@ public void run() {
}

if (config.isJitLogging()) {
log(method.getImplementationClass(), method.getFile(), method.getLine(), className + "." + methodName, "done jitting");
log(method.getImplementationClass(), method.getFile(), method.getLine(), className + '.' + methodName, "done jitting");
}

Map<Integer, MethodType> signatures = context.getNativeSignatures();
String jittedName = context.getJittedName();
if (signatures.size() == 1) {
final String jittedName = context.getJittedName();
MethodHandle variable = PUBLIC_LOOKUP.findStatic(sourceClass, jittedName, context.getNativeSignature(-1));
IntHashMap<MethodType> signatures = context.getNativeSignaturesExceptVariable();

if (signatures.size() == 0) {
// only variable-arity
method.completeBuild(
new CompiledIRMethod(
PUBLIC_LOOKUP.findStatic(sourceClass, jittedName, signatures.get(-1)),
variable,
method.getIRScope(),
method.getVisibility(),
method.getImplementationClass(),
method.getIRScope().receivesKeywordArgs()));

} else {
// also specific-arity
for (Map.Entry<Integer, MethodType> entry : signatures.entrySet()) {
if (entry.getKey() == -1) continue; // variable arity handle pushed above

for (IntHashMap.Entry<MethodType> entry : signatures.entrySet()) {
method.completeBuild(
new CompiledIRMethod(
PUBLIC_LOOKUP.findStatic(sourceClass, jittedName, signatures.get(-1)),
variable,
PUBLIC_LOOKUP.findStatic(sourceClass, jittedName, entry.getValue()),
entry.getKey(),
method.getIRScope(),
method.getVisibility(),
method.getImplementationClass(),
method.getIRScope().receivesKeywordArgs()));
break;
break; // FIXME: only supports one arity
}
}
} catch (Throwable t) {
if (config.isJitLogging()) {
log(method.getImplementationClass(), method.getFile(), method.getLine(), className + "." + methodName, "Could not compile; passes run: " + method.getIRScope().getExecutedPasses(), t.getMessage());
log(method.getImplementationClass(), method.getFile(), method.getLine(), className + '.' + methodName, "Could not compile; passes run: " + method.getIRScope().getExecutedPasses(), t.getMessage());
if (config.isJitLoggingVerbose()) {
t.printStackTrace();
}
@@ -475,7 +477,7 @@ public String name() {

@Override
public String toString() {
return methodName + "() at " + method.getFile() + ":" + method.getLine();
return methodName + "() at " + method.getFile() + ':' + method.getLine();
}

private final String packageName;
@@ -487,7 +489,7 @@ public String toString() {

private byte[] bytecode;
private long compileTime;
private String name;
private final String name;
}

public static class BlockJITClassGenerator {
@@ -505,8 +507,8 @@ public BlockJITClassGenerator(String className, String methodName, String key, R
} else {
digestString = key;
}
this.className = packageName + "/" + className.replace('.', '/') + CLASS_METHOD_DELIMITER + JavaNameMangler.mangleMethodName(methodName) + "_" + digestString;
this.name = this.className.replaceAll("/", ".");
this.className = packageName + '/' + className.replace('.', '/') + CLASS_METHOD_DELIMITER + JavaNameMangler.mangleMethodName(methodName) + '_' + digestString;
this.name = this.className.replace('/', '.');
this.methodName = methodName;
this.body = body;
this.visitor = visitor;
@@ -562,7 +564,7 @@ public String name() {

@Override
public String toString() {
return "{} at " + body.getFile() + ":" + body.getLine();
return "{} at " + body.getFile() + ':' + body.getLine();
}

private final String packageName;
@@ -574,7 +576,7 @@ public String toString() {

private byte[] bytecode;
private long compileTime;
private String name;
private final String name;
}

static void log(RubyModule implementationClass, String file, int line, String name, String message, String... reason) {
3 changes: 1 addition & 2 deletions core/src/main/java/org/jruby/ext/ffi/Struct.java
Original file line number Diff line number Diff line change
@@ -123,11 +123,10 @@ static final StructLayout getStructLayout(Ruby runtime, IRubyObject structClass)
}
}

@Override
@JRubyMethod(name = "initialize", visibility = PRIVATE)
public IRubyObject initialize(ThreadContext context) {

memory = MemoryPointer.allocate(context.runtime, layout.getSize(), 1, true);

return this;
}

1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java
Original file line number Diff line number Diff line change
@@ -95,6 +95,7 @@ public RubyUDPSocket(Ruby runtime, RubyClass type) {
super(runtime, type);
}

@Override
@JRubyMethod(visibility = Visibility.PRIVATE)
public IRubyObject initialize(ThreadContext context) {
return initialize(context, StandardProtocolFamily.INET);
Loading

0 comments on commit 2029231

Please sign in to comment.