Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c57a47e5b3be
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 43d80c3a2a0f
Choose a head ref
  • 15 commits
  • 35 files changed
  • 3 contributors

Commits on Nov 25, 2015

  1. Copy the full SHA
    de0dd50 View commit details
  2. [Truffle] fix Time#localtime

    pitr-ch committed Nov 25, 2015
    Copy the full SHA
    2476aef View commit details
  3. [Truffle] code style

    pitr-ch committed Nov 25, 2015
    Copy the full SHA
    22a6c09 View commit details
  4. Copy the full SHA
    f919454 View commit details
  5. Copy the full SHA
    5efdd34 View commit details
  6. Rename arguments in blockBody signatures for easier understanding

    * block used to be the block argument passed in to surrounding
      scopes. It is now renamed blockArg for clarity.
    
    * b used to be the block that was being executed. It is now
      renamed block for clarity.
    subbuss committed Nov 25, 2015
    Copy the full SHA
    5e13527 View commit details
  7. Next step in refactoring block body signature for improved clarity

    * Moved block after context to separate it from self, args, and blockArg.
    subbuss committed Nov 25, 2015
    6
    Copy the full SHA
    6bb6149 View commit details
  8. Copy the full SHA
    a195645 View commit details
  9. Copy the full SHA
    9f46b76 View commit details
  10. Copy the full SHA
    913b44f View commit details
  11. Change interpret sigs to distinguish between executing block and bloc…

    …kArg
    
    * Added executing block as second arg to interpret methods
    * Removed blockType arg since it can be recoverd as block.type
    subbuss committed Nov 25, 2015
    Copy the full SHA
    6f62dda View commit details

Commits on Nov 26, 2015

  1. Push/PopFrameInstr --> Push/PopMethodFrameInstr

    * We also need Push/PopBlockFrameInstr
    subbuss committed Nov 26, 2015
    Copy the full SHA
    2368dcd View commit details
  2. PushBindingInstr -> PushMethodBindingInstr

    * We also need a PushBlockBindingInstr
    subbuss committed Nov 26, 2015
    Copy the full SHA
    c661202 View commit details
  3. Copy the full SHA
    55fdd00 View commit details
  4. Merge branch 'master' into ruby-2.3

    * master:
      PushBindingInstr -> PushMethodBindingInstr
      Push/PopFrameInstr --> Push/PopMethodFrameInstr
      Change interpret sigs to distinguish between executing block and blockArg
      Rename block to blockArg in interpreter for clarity
      Remove one more line of code left behind that broke the build
      Remove changes to Block.java accidentally committed in 5e13527
      Next step in refactoring block body signature for improved clarity
      Rename arguments in blockBody signatures for easier understanding
      [Truffle] findbugs: fix missing locale in toUpperCase
      [Truffle] code style
      [Truffle] fix Time#localtime
    kares committed Nov 26, 2015
    Copy the full SHA
    43d80c3 View commit details
Showing with 533 additions and 333 deletions.
  1. +61 −2 core/src/main/java/org/jruby/RubyHash.java
  2. +1 −1 core/src/main/java/org/jruby/RubyProc.java
  3. +12 −18 core/src/main/java/org/jruby/RubySymbol.java
  4. +1 −1 core/src/main/java/org/jruby/internal/runtime/methods/InterpretedIRBodyMethod.java
  5. +10 −10 core/src/main/java/org/jruby/internal/runtime/methods/InterpretedIRMethod.java
  6. +10 −10 core/src/main/java/org/jruby/internal/runtime/methods/MixedModeIRMethod.java
  7. +3 −3 core/src/main/java/org/jruby/ir/IRVisitor.java
  8. +3 −3 core/src/main/java/org/jruby/ir/Operation.java
  9. +5 −5 core/src/main/java/org/jruby/ir/instructions/{PopFrameInstr.java → PopMethodFrameInstr.java}
  10. +5 −5 core/src/main/java/org/jruby/ir/instructions/{PushBindingInstr.java → PushMethodBindingInstr.java}
  11. +5 −5 core/src/main/java/org/jruby/ir/instructions/{PushFrameInstr.java → PushMethodFrameInstr.java}
  12. +9 −8 core/src/main/java/org/jruby/ir/interpreter/BodyInterpreterEngine.java
  13. +8 −8 core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
  14. +27 −29 core/src/main/java/org/jruby/ir/interpreter/InterpreterEngine.java
  15. +40 −35 core/src/main/java/org/jruby/ir/interpreter/SimpleMethodInterpreterEngine.java
  16. +6 −5 core/src/main/java/org/jruby/ir/interpreter/StartupInterpreterEngine.java
  17. +5 −5 core/src/main/java/org/jruby/ir/passes/AddCallProtocolInstructions.java
  18. +3 −3 core/src/main/java/org/jruby/ir/persistence/IRReaderStream.java
  19. +3 −3 core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
  20. +20 −20 core/src/main/java/org/jruby/runtime/Block.java
  21. +47 −47 core/src/main/java/org/jruby/runtime/BlockBody.java
  22. +7 −7 core/src/main/java/org/jruby/runtime/CallBlock.java
  23. +9 −9 core/src/main/java/org/jruby/runtime/CallBlock19.java
  24. +3 −3 core/src/main/java/org/jruby/runtime/CompiledIRBlockBody.java
  25. +5 −5 core/src/main/java/org/jruby/runtime/ContextAwareBlockBody.java
  26. +36 −36 core/src/main/java/org/jruby/runtime/IRBlockBody.java
  27. +4 −5 core/src/main/java/org/jruby/runtime/InterpretedIRBlockBody.java
  28. +6 −6 core/src/main/java/org/jruby/runtime/JavaInternalBlockBody.java
  29. +8 −8 core/src/main/java/org/jruby/runtime/MethodBlockBody.java
  30. +5 −5 core/src/main/java/org/jruby/runtime/MixedModeIRBlockBody.java
  31. +11 −11 core/src/main/java/org/jruby/runtime/NullBlockBody.java
  32. +0 −1 spec/truffle/tags/core/time/localtime_tags.txt
  33. +0 −2 spec/truffle/tags/core/time/zone_tags.txt
  34. +15 −0 test/jruby/test_hash.rb
  35. +140 −9 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/TimePrimitiveNodes.java
63 changes: 61 additions & 2 deletions core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
@@ -46,8 +46,10 @@
import org.jruby.common.IRubyWarnings.ID;
import org.jruby.exceptions.RaiseException;
import org.jruby.javasupport.JavaUtil;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Arity;
import org.jruby.runtime.Block;
import org.jruby.runtime.BlockBody;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ObjectAllocator;
@@ -900,6 +902,63 @@ public void visit(IRubyObject key, IRubyObject value) {
}
}

@JRubyMethod(name = "to_proc")
public RubyProc to_proc(ThreadContext context) {
final BlockBody body = new BlockBody(Signature.ONE_ARGUMENT) {
@Override
protected IRubyObject doYield(ThreadContext context, IRubyObject key, Block block) {
// NOTE: the way currently RubyProc works this version is never dispatched!
return op_aref(context, key);
}

@Override
protected IRubyObject doYield(ThreadContext context, IRubyObject[] args, IRubyObject self, Block block) {
// NOTE: at this point we get the args normalized into [ one ]
// signature.checkArity(context.runtime, args);
return op_aref(context, args[0]);
}

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

@Override
public int getLine() { return -1; }

@Override
public StaticScope getStaticScope() {
return getRuntime().getStaticScopeFactory().getDummyScope();
}

@Override
public void setStaticScope(StaticScope newScope) { /* noop */ }
};

return new StrictProc(context.runtime, new Block(body, context.currentBinding()));
}

// TODO this is a hack due the impossibility of validating arguments for a non-lambda
private static class StrictProc extends RubyProc {

StrictProc(final Ruby runtime, final Block block) {
super(runtime, runtime.getProc(), Block.Type.PROC);
// setup :
//block.getBinding().setFile(block.getBody().getFile());
//block.getBinding().setLine(block.getBody().getLine());
//
this.block = block;
block.type = Block.Type.PROC;
block.setProcObject(this);
}

@Override
public IRubyObject call19(ThreadContext context, IRubyObject[] args, Block blockCallArg) {
// validate args like a lambda :
getBlock().getBody().getSignature().checkArity(context.runtime, args);
return call(context, args, null, blockCallArg);
}

}

/** rb_hash_to_s & to_s_hash
*
*/
@@ -1781,7 +1840,7 @@ private RubyHash replaceCommon19(final ThreadContext context, IRubyObject other,
*/
@JRubyMethod(name = "values_at", rest = true)
public RubyArray values_at(ThreadContext context, IRubyObject[] args) {
RubyArray result = RubyArray.newArray(getRuntime(), args.length);
RubyArray result = RubyArray.newArray(context.runtime, args.length);
for (int i = 0; i < args.length; i++) {
result.append(op_aref(context, args[i]));
}
@@ -1790,7 +1849,7 @@ public RubyArray values_at(ThreadContext context, IRubyObject[] args) {

@JRubyMethod(name = "fetch_values", rest = true)
public RubyArray fetch_values(ThreadContext context, IRubyObject[] args, Block block) {
RubyArray result = RubyArray.newArray(getRuntime(), args.length);
RubyArray result = RubyArray.newArray(context.runtime, args.length);

for (int i = 0; i < args.length; i++) {
result.append(fetch(context, args[i], block));
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyProc.java
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@
*/
@JRubyClass(name="Proc")
public class RubyProc extends RubyObject implements DataType {
private Block block = Block.NULL_BLOCK;
protected Block block = Block.NULL_BLOCK;
private Block.Type type;
private String file = null;
private int line = -1;
30 changes: 12 additions & 18 deletions core/src/main/java/org/jruby/RubySymbol.java
Original file line number Diff line number Diff line change
@@ -42,12 +42,8 @@
import org.jruby.anno.JRubyMethod;
import org.jruby.ast.util.ArgsUtil;
import org.jruby.compiler.Constantizable;
import org.jruby.RubyEncoding;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Arity;
import org.jruby.runtime.Binding;
import org.jruby.runtime.Block;
import org.jruby.runtime.Block.Type;
import org.jruby.runtime.BlockBody;
import org.jruby.runtime.CallSite;
import org.jruby.runtime.ClassIndex;
@@ -66,7 +62,6 @@

import java.lang.ref.WeakReference;
import java.util.concurrent.locks.ReentrantLock;
import java.util.Arrays;

import static org.jruby.util.StringSupport.codeLength;
import static org.jruby.util.StringSupport.codePoint;
@@ -469,50 +464,49 @@ 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) {
private IRubyObject yieldInner(ThreadContext context, RubyArray array, Block block) {
private IRubyObject yieldInner(ThreadContext context, RubyArray array, Block blockArg) {
if (array.isEmpty()) {
throw context.runtime.newArgumentError("no receiver given");
}

IRubyObject self = array.shift(context);

return site.call(context, self, self, array.toJavaArray(), block);
return site.call(context, self, self, array.toJavaArray(), blockArg);
}

@Override
public IRubyObject yield(ThreadContext context, IRubyObject[] args, IRubyObject self, Block b, Block block) {
RubyProc.prepareArgs(context, b.type, block.getBody(), args);
return yieldInner(context, context.runtime.newArrayNoCopyLight(args), block);
public IRubyObject yield(ThreadContext context, Block block, IRubyObject[] args, IRubyObject self, Block blockArg) {
RubyProc.prepareArgs(context, block.type, blockArg.getBody(), args);
return yieldInner(context, context.runtime.newArrayNoCopyLight(args), blockArg);
}

@Override
public IRubyObject yield(ThreadContext context, IRubyObject value,
Block b, Block block) {
return yieldInner(context, ArgsUtil.convertToRubyArray(context.runtime, value, false), block);
public IRubyObject yield(ThreadContext context, Block block, IRubyObject value, Block blockArg) {
return yieldInner(context, ArgsUtil.convertToRubyArray(context.runtime, value, false), blockArg);
}

@Override
protected IRubyObject doYield(ThreadContext context, IRubyObject value, Block b) {
protected IRubyObject doYield(ThreadContext context, Block block, IRubyObject value) {
return yieldInner(context, ArgsUtil.convertToRubyArray(context.runtime, value, false), Block.NULL_BLOCK);
}

@Override
protected IRubyObject doYield(ThreadContext context, IRubyObject[] args, IRubyObject self, Block b) {
protected IRubyObject doYield(ThreadContext context, Block block, IRubyObject[] args, IRubyObject self) {
return yieldInner(context, context.runtime.newArrayNoCopyLight(args), Block.NULL_BLOCK);
}

@Override
public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, Block b) {
public IRubyObject yieldSpecific(ThreadContext context, Block block, IRubyObject arg0) {
return site.call(context, arg0, arg0);
}

@Override
public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block b) {
public IRubyObject yieldSpecific(ThreadContext context, Block block, IRubyObject arg0, IRubyObject arg1) {
return site.call(context, arg0, arg0, arg1);
}

@Override
public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block b) {
public IRubyObject yieldSpecific(ThreadContext context, Block block, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) {
return site.call(context, arg0, arg0, arg1, arg2);
}

Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ private IRubyObject INTERPRET_CLASS(InterpreterContext ic, ThreadContext context
private IRubyObject interpretWithBacktrace(InterpreterContext ic, ThreadContext context, IRubyObject self, String name, Block block) {
try {
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());
return ic.engine.interpret(context, self, ic, getImplementationClass().getMethodLocation(), name, block, null);
return ic.engine.interpret(context, null, self, ic, getImplementationClass().getMethodLocation(), name, block);
} finally {
ThreadContext.popBacktrace(context);
}
Original file line number Diff line number Diff line change
@@ -115,11 +115,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, args, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, args, block);
} else {
try {
pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, args, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, args, block);
} finally {
post(ic, context);
}
@@ -144,11 +144,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, block);
} else {
try {
pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, block);
} finally {
post(ic, context);
}
@@ -172,11 +172,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, block);
} else {
try {
pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, block);
} finally {
post(ic, context);
}
@@ -200,11 +200,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, block);
} else {
try {
pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, block);
} finally {
post(ic, context);
}
@@ -228,11 +228,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, arg3, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, arg3, block);
} else {
try {
pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, arg3, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, arg3, block);
} finally {
post(ic, context);
}
Original file line number Diff line number Diff line change
@@ -120,11 +120,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, args, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, args, block);
} else {
try {
this.pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, args, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, args, block);
} finally {
this.post(ic, context);
}
@@ -155,11 +155,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, block);
} else {
try {
this.pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, block);
} finally {
this.post(ic, context);
}
@@ -190,11 +190,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, block);
} else {
try {
this.pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, block);
} finally {
this.post(ic, context);
}
@@ -225,11 +225,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, block);
} else {
try {
this.pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, block);
} finally {
this.post(ic, context);
}
@@ -260,11 +260,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, arg3, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, arg3, block);
} else {
try {
this.pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, arg3, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, arg3, block);
} finally {
this.post(ic, context);
}
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/ir/IRVisitor.java
Original file line number Diff line number Diff line change
@@ -86,14 +86,14 @@ private void error(Object object) {
public void OneOperandArgNoBlockCallInstr(OneOperandArgNoBlockCallInstr oneOperandArgNoBlockCallInstr) { error(oneOperandArgNoBlockCallInstr); }
public void OptArgMultipleAsgnInstr(OptArgMultipleAsgnInstr optargmultipleasgninstr) { error(optargmultipleasgninstr); }
public void PopBindingInstr(PopBindingInstr popbindinginstr) { error(popbindinginstr); }
public void PopFrameInstr(PopFrameInstr popframeinstr) { error(popframeinstr); }
public void PopFrameInstr(PopMethodFrameInstr popframeinstr) { error(popframeinstr); }
public void ProcessModuleBodyInstr(ProcessModuleBodyInstr processmodulebodyinstr) { error(processmodulebodyinstr); }
public void PutClassVariableInstr(PutClassVariableInstr putclassvariableinstr) { error(putclassvariableinstr); }
public void PutConstInstr(PutConstInstr putconstinstr) { error(putconstinstr); }
public void PutFieldInstr(PutFieldInstr putfieldinstr) { error(putfieldinstr); }
public void PutGlobalVarInstr(PutGlobalVarInstr putglobalvarinstr) { error(putglobalvarinstr); }
public void PushBindingInstr(PushBindingInstr pushbindinginstr) { error(pushbindinginstr); }
public void PushFrameInstr(PushFrameInstr pushframeinstr) { error(pushframeinstr); }
public void PushBindingInstr(PushMethodBindingInstr pushbindinginstr) { error(pushbindinginstr); }
public void PushFrameInstr(PushMethodFrameInstr pushframeinstr) { error(pushframeinstr); }
public void RaiseArgumentErrorInstr(RaiseArgumentErrorInstr raiseargumenterrorinstr) { error(raiseargumenterrorinstr); }
public void RaiseRequiredKeywordArgumentErrorInstr(RaiseRequiredKeywordArgumentError instr) { error(instr); }
public void ReifyClosureInstr(ReifyClosureInstr reifyclosureinstr) { error(reifyclosureinstr); }
Loading