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/core/BindingNodes.java
  • Loading branch information
chrisseaton committed May 9, 2015
2 parents bd54763 + 60600db commit 08193c6
Show file tree
Hide file tree
Showing 104 changed files with 1,128 additions and 2,427 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ build.eclipse
truffle-findbugs-report.html
findbugs-noUpdateChecks-3.0.0.tar.gz
findbugs-3.0.0

# Vagrant
/.vagrant
1 change: 0 additions & 1 deletion antlib/extra.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ build jruby-complete.jar
<arg value='test/test_irubyobject_java_passing.rb'/>
<arg value='test/test_jruby_object_input_stream.rb'/>
<arg value='test/test_jar_on_load_path.rb'/>
<arg value='test/test_jruby_ext.rb'/>
<arg value='test/test_jruby_core_ext.rb'/>
<arg value='test/test_thread_context_frame_dereferences_unreachable_variables.rb'/>
<arg value='test/test_context_classloader.rb'/>
Expand Down
12 changes: 1 addition & 11 deletions core/src/main/java/org/jruby/AbstractRubyMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,13 @@
***** END LICENSE BLOCK *****/
package org.jruby;

import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
import org.jruby.ext.jruby.JRubyLibrary;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.internal.runtime.methods.IRMethodArgs;
import org.jruby.internal.runtime.methods.ProcMethod;
import org.jruby.internal.runtime.methods.UndefinedMethod;
import org.jruby.runtime.Block;
import org.jruby.runtime.BlockBody;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.CompiledBlockCallback19;
import org.jruby.runtime.CompiledBlockLight19;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.PositionAware;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.marshal.DataType;

Expand Down Expand Up @@ -145,7 +135,7 @@ public int getLine() {

@JRubyMethod(name = "parameters")
public IRubyObject parameters(ThreadContext context) {
return JRubyLibrary.MethodExtensions.methodArgs(this);
return Helpers.methodToParameters(context.runtime, this);
}

protected IRubyObject super_method(ThreadContext context, IRubyObject receiver, RubyModule superClass) {
Expand Down
10 changes: 0 additions & 10 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
import org.jruby.runtime.Binding;
import org.jruby.runtime.Block;
import org.jruby.runtime.CallSite;
import org.jruby.runtime.CallbackFactory;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.EventHook;
Expand Down Expand Up @@ -4804,15 +4803,6 @@ private void addEvalParseToStats() {
if (parserStats != null) parserStats.addEvalParse();
}

private void addJRubyModuleParseToStats() {
if (parserStats != null) parserStats.addJRubyModuleParse();
}

@Deprecated
public CallbackFactory callbackFactory(Class<?> type) {
throw new RuntimeException("callback-style handles are no longer supported in JRuby");
}

@Deprecated
public boolean is1_8() {
return false;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ private IRubyObject initializeCommon(ThreadContext context, IRubyObject arg0, IR
runtime.getWarnings().warn(ID.BLOCK_BEATS_DEFAULT_VALUE, "block supersedes default value argument");
}

if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) {
if (block.getSignature() == Signature.NO_ARGUMENTS) {
IRubyObject nil = runtime.getNil();
for (int i = 0; i < ilen; i++) {
store(i, block.yield(context, nil));
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/org/jruby/RubyFixnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ public IRubyObject times(ThreadContext context, Block block) {
long lvalue = this.value;
boolean checkArity = block.type.checkArity;

if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS ||
block.getSignature() == Signature.NO_ARGUMENTS) {
if (block.getSignature() == Signature.NO_ARGUMENTS) {
if (checkArity) {
// must pass arg
IRubyObject nil = runtime.getNil();
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/org/jruby/RubyInteger.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.jruby.runtime.BlockBody;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.Signature;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
Expand Down Expand Up @@ -141,7 +142,7 @@ public IRubyObject upto(ThreadContext context, IRubyObject to, Block block) {
private static void fixnumUpto(ThreadContext context, long from, long to, Block block) {
// We must avoid "i++" integer overflow when (to == Long.MAX_VALUE).
Ruby runtime = context.runtime;
if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) {
if (block.getSignature() == Signature.NO_ARGUMENTS) {
IRubyObject nil = runtime.getNil();
long i;
for (i = from; i < to; i++) {
Expand Down Expand Up @@ -204,7 +205,7 @@ public IRubyObject downto(ThreadContext context, IRubyObject to, Block block) {
private static void fixnumDownto(ThreadContext context, long from, long to, Block block) {
// We must avoid "i--" integer overflow when (to == Long.MIN_VALUE).
Ruby runtime = context.runtime;
if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) {
if (block.getSignature() == Signature.NO_ARGUMENTS) {
IRubyObject nil = runtime.getNil();
long i;
for (i = from; i > to; i--) {
Expand Down
58 changes: 16 additions & 42 deletions core/src/main/java/org/jruby/RubyMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,21 @@
***** END LICENSE BLOCK *****/
package org.jruby;

import org.jruby.ext.jruby.JRubyLibrary;
import org.jruby.anno.JRubyMethod;
import org.jruby.anno.JRubyClass;
import org.jruby.internal.runtime.methods.AliasMethod;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.internal.runtime.methods.IRMethodArgs;
import org.jruby.internal.runtime.methods.ProcMethod;
import org.jruby.runtime.Arity;
import org.jruby.runtime.ArgumentDescriptor;
import org.jruby.runtime.Block;
import org.jruby.runtime.BlockBody;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.CompiledBlockCallback19;
import org.jruby.runtime.CompiledBlockLight;
import org.jruby.runtime.CompiledBlockLight19;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.MethodBlockBody;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.PositionAware;
import org.jruby.runtime.Signature;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;

/**
Expand Down Expand Up @@ -188,48 +183,26 @@ public RubyMethod rbClone() {
*
*/
@JRubyMethod
public IRubyObject to_proc(ThreadContext context, Block unusedBlock) {
public IRubyObject to_proc(ThreadContext context) {
Ruby runtime = context.runtime;
CompiledBlockCallback19 callback = new CompiledBlockCallback19() {
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) {
return method.call(context, receiver, originModule, originName, args, block);
}

@Override
public String getFile() {
return getFilename();
}

@Override
public int getLine() {
return RubyMethod.this.getLine();
}
};

BlockBody body;
MethodBlockBody body;
Signature signature;
ArgumentDescriptor[] argsDesc;
if (method instanceof IRMethodArgs) {
Signature signature = ((IRMethodArgs) method).getSignature();
int argumentType = resolveArgumentType(signature.isFixed(), signature.required());
body = CompiledBlockLight19.newCompiledBlockLight(((IRMethodArgs) method).getSignature(),
runtime.getStaticScopeFactory().getDummyScope(), callback, false, argumentType, JRubyLibrary.MethodExtensions.methodParameters(runtime, method));
signature = ((IRMethodArgs) method).getSignature();
argsDesc = ((IRMethodArgs) method).getArgumentDescriptors();
} else {
Arity arity = method.getArity();
int argumentType = resolveArgumentType(arity.isFixed(), arity.required());
body = CompiledBlockLight19.newCompiledBlockLight(method.getArity(),
runtime.getStaticScopeFactory().getDummyScope(), callback, false, argumentType, JRubyLibrary.MethodExtensions.methodParameters(runtime, method));
signature = Signature.from(method.getArity());
argsDesc = Helpers.methodToArgumentDescriptors(method);
}
Block b = new Block(body, context.currentBinding(receiver, Visibility.PUBLIC));

body = new MethodBlockBody(runtime.getStaticScopeFactory().getDummyScope(), signature, method, argsDesc, receiver, originModule, originName, getFilename(), getLine());
Block b = MethodBlockBody.createMethodBlock(body);

return RubyProc.newProc(runtime, b, Block.Type.LAMBDA);
}

private int resolveArgumentType(boolean isFixed, int required) {
if (!isFixed) return BlockBody.MULTIPLE_ASSIGNMENT;
if (required > 0) return BlockBody.MULTIPLE_ASSIGNMENT;
return BlockBody.ZERO_ARGS;
}

@JRubyMethod
public RubyUnboundMethod unbind() {
RubyUnboundMethod unboundMethod =
Expand Down Expand Up @@ -316,12 +289,12 @@ public int getLine() {

@JRubyMethod
public IRubyObject parameters(ThreadContext context) {
return JRubyLibrary.MethodExtensions.methodArgs(this);
return Helpers.methodToParameters(context.runtime, this);
}

@JRubyMethod(optional = 1)
public IRubyObject curry(ThreadContext context, IRubyObject[] args) {
return to_proc(context, Block.NULL_BLOCK).callMethod(context, "curry", args);
return to_proc(context).callMethod(context, "curry", args);
}

@JRubyMethod
Expand All @@ -337,5 +310,6 @@ public IRubyObject original_name(ThreadContext context) {
}
return name(context);
}

}

10 changes: 2 additions & 8 deletions core/src/main/java/org/jruby/RubyProc.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.IRBlockBody;
import org.jruby.runtime.MethodBlock;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.Signature;
import org.jruby.runtime.ThreadContext;
Expand Down Expand Up @@ -241,9 +240,6 @@ public IRubyObject call(ThreadContext context, IRubyObject[] args) {
public static IRubyObject[] prepareArgs(ThreadContext context, Block.Type type, BlockBody blockBody, IRubyObject[] args) {
Signature signature = blockBody.getSignature();

// FIXME: which blocks have no signature (and no arity before that?)
if (signature == null) return args;

if (args == null) return IRubyObject.NULL_ARRAY;

if (type == Block.Type.LAMBDA) {
Expand Down Expand Up @@ -349,10 +345,8 @@ public IRubyObject source_location(ThreadContext context) {
public IRubyObject parameters(ThreadContext context) {
BlockBody body = this.getBlock().getBody();

if (body instanceof MethodBlock) return ((MethodBlock) body).getMethod().parameters(context);

return Helpers.parameterListToParameters(context.runtime,
body.getParameterList(), isLambda());
return Helpers.argumentDescriptorsToParameters(context.runtime,
body.getArgumentDescriptors(), isLambda());
}

@JRubyMethod(name = "lambda?")
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyRange.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ private void fixnumEach(ThreadContext context, Ruby runtime, Block block) {
to--;
}
long from = ((RubyFixnum) begin).getLongValue();
if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) {
if (block.getSignature() == Signature.NO_ARGUMENTS) {
IRubyObject nil = runtime.getNil();
long i;
for (i = from; i < to; i++) {
Expand Down
10 changes: 8 additions & 2 deletions core/src/main/java/org/jruby/RubySymbol.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,13 @@ public IRubyObject id2name(ThreadContext context) {
@JRubyMethod(name = "===", required = 1)
@Override
public IRubyObject op_eqq(ThreadContext context, IRubyObject other) {
return super.op_equal(context, other);
return context.runtime.newBoolean(this == other);
}

@JRubyMethod(name = "==", required = 1)
@Override
public IRubyObject op_equal(ThreadContext context, IRubyObject other) {
return context.runtime.newBoolean(this == other);
}

@Deprecated
Expand Down Expand Up @@ -419,7 +425,7 @@ public IRubyObject encoding(ThreadContext context) {
public IRubyObject to_proc(ThreadContext context) {
StaticScope scope = context.runtime.getStaticScopeFactory().getDummyScope();
final CallSite site = new FunctionalCachingCallSite(symbol);
BlockBody body = new ContextAwareBlockBody(scope, Signature.OPTIONAL, BlockBody.SINGLE_RESTARG) {
BlockBody body = new ContextAwareBlockBody(scope, Signature.OPTIONAL) {
private IRubyObject yieldInner(ThreadContext context, RubyArray array, Block block) {
if (array.isEmpty()) {
throw context.runtime.newArgumentError("no receiver given");
Expand Down
46 changes: 2 additions & 44 deletions core/src/main/java/org/jruby/ast/executable/AbstractScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@

package org.jruby.ast.executable;

import java.math.BigInteger;
import org.jcodings.Encoding;
import org.jcodings.EncodingDB;
import org.jruby.Ruby;
import org.jruby.RubyFixnum;
import org.jruby.RubyFloat;
import org.jruby.RubyModule;
Expand All @@ -18,14 +16,14 @@
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Block;
import org.jruby.runtime.BlockBody;
import org.jruby.runtime.CompiledBlockCallback;
import org.jruby.runtime.CallSite;
import org.jruby.runtime.MethodIndex;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

import java.math.BigInteger;

/**
*
* @author headius
Expand Down Expand Up @@ -105,46 +103,6 @@ public IRubyObject run(ThreadContext context, IRubyObject self, IRubyObject[] ar
public final CallSite getCallSite8() {return runtimeCache.callSites[8];}
public final CallSite getCallSite9() {return runtimeCache.callSites[9];}

public static final int NUMBERED_BLOCKBODY_COUNT = 10;

public final BlockBody getBlockBody(ThreadContext context, StaticScope scope, int i, String descriptor) {return runtimeCache.getBlockBody(this, context, scope, i, descriptor);}
public final BlockBody getBlockBody0(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody(this, context, scope, 0, descriptor);}
public final BlockBody getBlockBody1(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody(this, context, scope, 1, descriptor);}
public final BlockBody getBlockBody2(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody(this, context, scope, 2, descriptor);}
public final BlockBody getBlockBody3(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody(this, context, scope, 3, descriptor);}
public final BlockBody getBlockBody4(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody(this, context, scope, 4, descriptor);}
public final BlockBody getBlockBody5(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody(this, context, scope, 5, descriptor);}
public final BlockBody getBlockBody6(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody(this, context, scope, 6, descriptor);}
public final BlockBody getBlockBody7(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody(this, context, scope, 7, descriptor);}
public final BlockBody getBlockBody8(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody(this, context, scope, 8, descriptor);}
public final BlockBody getBlockBody9(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody(this, context, scope, 9, descriptor);}

public final BlockBody getBlockBody19(ThreadContext context, StaticScope scope, int i, String descriptor) {return runtimeCache.getBlockBody19(this, context, scope, i, descriptor);}
public final BlockBody getBlockBody190(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody19(this, context, scope, 0, descriptor);}
public final BlockBody getBlockBody191(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody19(this, context, scope, 1, descriptor);}
public final BlockBody getBlockBody192(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody19(this, context, scope, 2, descriptor);}
public final BlockBody getBlockBody193(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody19(this, context, scope, 3, descriptor);}
public final BlockBody getBlockBody194(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody19(this, context, scope, 4, descriptor);}
public final BlockBody getBlockBody195(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody19(this, context, scope, 5, descriptor);}
public final BlockBody getBlockBody196(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody19(this, context, scope, 6, descriptor);}
public final BlockBody getBlockBody197(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody19(this, context, scope, 7, descriptor);}
public final BlockBody getBlockBody198(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody19(this, context, scope, 8, descriptor);}
public final BlockBody getBlockBody199(ThreadContext context, StaticScope scope, String descriptor) {return runtimeCache.getBlockBody19(this, context, scope, 9, descriptor);}

public static final int NUMBERED_BLOCKCALLBACK_COUNT = 10;

public final CompiledBlockCallback getBlockCallback(int i, String method) {return runtimeCache.getBlockCallback(this, i, method);}
public final CompiledBlockCallback getBlockCallback0(String method) {return runtimeCache.getBlockCallback(this, 0, method);}
public final CompiledBlockCallback getBlockCallback1(String method) {return runtimeCache.getBlockCallback(this, 1, method);}
public final CompiledBlockCallback getBlockCallback2(String method) {return runtimeCache.getBlockCallback(this, 2, method);}
public final CompiledBlockCallback getBlockCallback3(String method) {return runtimeCache.getBlockCallback(this, 3, method);}
public final CompiledBlockCallback getBlockCallback4(String method) {return runtimeCache.getBlockCallback(this, 4, method);}
public final CompiledBlockCallback getBlockCallback5(String method) {return runtimeCache.getBlockCallback(this, 5, method);}
public final CompiledBlockCallback getBlockCallback6(String method) {return runtimeCache.getBlockCallback(this, 6, method);}
public final CompiledBlockCallback getBlockCallback7(String method) {return runtimeCache.getBlockCallback(this, 7, method);}
public final CompiledBlockCallback getBlockCallback8(String method) {return runtimeCache.getBlockCallback(this, 8, method);}
public final CompiledBlockCallback getBlockCallback9(String method) {return runtimeCache.getBlockCallback(this, 9, method);}

public static final int NUMBERED_SYMBOL_COUNT = 10;

public final RubySymbol getSymbol(ThreadContext context, int i, String name, String encoding) {return runtimeCache.getSymbol(context, i, name, encoding);}
Expand Down

0 comments on commit 08193c6

Please sign in to comment.