Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Feb 4, 2015
2 parents b158469 + 8105ed9 commit ac75e32
Show file tree
Hide file tree
Showing 157 changed files with 1,345 additions and 698 deletions.
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/RubyDir.java
Expand Up @@ -514,7 +514,9 @@ public IRubyObject inspect() {
Ruby runtime = getRuntime();
StringBuilder part = new StringBuilder();
String cname = getMetaClass().getRealClass().getName();
part.append("#<").append(cname).append(":").append(path.asJavaString()).append(">");
part.append("#<").append(cname).append(":");
if (path != null) { part.append(path.asJavaString()); }
part.append(">");

return runtime.newString(part.toString());
}
Expand Down Expand Up @@ -550,7 +552,7 @@ public IRubyObject set_pos(IRubyObject newPos) {

@JRubyMethod(name = {"path", "to_path"})
public IRubyObject path(ThreadContext context) {
return path.strDup(context.runtime);
return path == null ? context.runtime.getNil() : path.strDup(context.runtime);
}

@JRubyMethod
Expand Down
11 changes: 3 additions & 8 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Expand Up @@ -1665,9 +1665,6 @@ protected void defineMethodInner(MethodDefNode defNode, IRScope parent) {
// Build IR for arguments (including the block arg)
receiveMethodArgs(defNode.getArgsNode());

// Thread poll on entry to method
addInstr(new ThreadPollInstr());

// Build IR for body
Operand rv = build(defNode.getBodyNode());

Expand Down Expand Up @@ -2355,7 +2352,6 @@ private void buildForIterInner(ForNode forNode) {
if (varNode != null && varNode.getNodeType() != null) receiveBlockArgs(forNode);

addCurrentScopeAndModule(); // %current_scope/%current_module
addInstr(new ThreadPollInstr()); // Thread poll on entry of closure
addInstr(new LabelInstr(((IRClosure) scope).startLabel)); // Start label -- used by redo!

// Build closure body and return the result of the closure
Expand Down Expand Up @@ -2498,7 +2494,6 @@ private void buildIterInner(IterNode iterNode) {
if (iterNode.getVarNode().getNodeType() != null) receiveBlockArgs(iterNode);

addCurrentScopeAndModule(); // %current_scope/%current_module
addInstr(new ThreadPollInstr()); // Thread poll on entry of closure
addInstr(new LabelInstr(((IRClosure) scope).startLabel)); // start label -- used by redo!

// Build closure body and return the result of the closure
Expand Down Expand Up @@ -3184,10 +3179,10 @@ public Operand buildReturn(ReturnNode returnNode) {
// If 'm' is a block scope, a return returns from the closest enclosing method.
// If this happens to be a module body, the runtime throws a local jump error if the
// closure is a proc. If the closure is a lambda, then this becomes a normal return.
IRMethod m = scope.getNearestMethod();
addInstr(new RuntimeHelperCall(null, CHECK_FOR_LJE, new Operand[] { m == null ? manager.getTrue() : manager.getFalse() }));
boolean maybeLambda = scope.getNearestMethod() == null;
addInstr(new CheckForLJEInstr(maybeLambda));
retVal = processEnsureRescueBlocks(retVal);
addInstr(new NonlocalReturnInstr(retVal, m == null ? "--none--" : m.getName()));
addInstr(new NonlocalReturnInstr(retVal, maybeLambda ? "--none--" : scope.getNearestMethod().getName()));
} else if (scope.isModuleBody()) {
IRMethod sm = scope.getNearestMethod();

Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ir/IRVisitor.java
Expand Up @@ -49,6 +49,7 @@ private void error(Object object) {
public void CallInstr(CallInstr callinstr) { error(callinstr); }
public void CheckArgsArrayArityInstr(CheckArgsArrayArityInstr checkargsarrayarityinstr) { error(checkargsarrayarityinstr); }
public void CheckArityInstr(CheckArityInstr checkarityinstr) { error(checkarityinstr); }
public void CheckForLJEInstr(CheckForLJEInstr checkforljeinstr) { error(checkforljeinstr); }
public void ClassSuperInstr(ClassSuperInstr classsuperinstr) { error(classsuperinstr); }
public void ConstMissingInstr(ConstMissingInstr constmissinginstr) { error(constmissinginstr); }
public void CopyInstr(CopyInstr copyinstr) { error(copyinstr); }
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ir/Operation.java
Expand Up @@ -151,6 +151,7 @@ public enum Operation {
BACKTICK_STRING(OpFlags.f_can_raise_exception),
CHECK_ARGS_ARRAY_ARITY(OpFlags.f_can_raise_exception),
CHECK_ARITY(OpFlags.f_is_book_keeping_op | OpFlags.f_can_raise_exception),
CHECK_FOR_LJE(OpFlags.f_has_side_effect | OpFlags.f_can_raise_exception),
CLASS_VAR_MODULE(0),
COPY(0),
GET_ENCODING(0),
Expand Down
18 changes: 9 additions & 9 deletions core/src/main/java/org/jruby/ir/instructions/CallInstr.java
Expand Up @@ -19,24 +19,24 @@ public class CallInstr extends CallBase implements ResultInstr {
protected Variable result;

public static CallInstr create(Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
return create(CallType.NORMAL, result, name, receiver, args, closure);
}

public static CallInstr create(CallType callType, Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
if (!containsArgSplat(args)) {
boolean hasClosure = closure != null;

if (args.length == 0 && !hasClosure) {
return new ZeroOperandArgNoBlockCallInstr(result, name, receiver, args);
return new ZeroOperandArgNoBlockCallInstr(callType, result, name, receiver, args);
} else if (args.length == 1) {
if (hasClosure) return new OneOperandArgBlockCallInstr(result, name, receiver, args, closure);
if (isAllFixnums(args)) return new OneFixnumArgNoBlockCallInstr(result, name, receiver, args);
if (isAllFloats(args)) return new OneFloatArgNoBlockCallInstr(result, name, receiver, args);
if (hasClosure) return new OneOperandArgBlockCallInstr(callType, result, name, receiver, args, closure);
if (isAllFixnums(args)) return new OneFixnumArgNoBlockCallInstr(callType, result, name, receiver, args);
if (isAllFloats(args)) return new OneFloatArgNoBlockCallInstr(callType, result, name, receiver, args);

return new OneOperandArgNoBlockCallInstr(result, name, receiver, args);
return new OneOperandArgNoBlockCallInstr(callType, result, name, receiver, args);
}
}

return new CallInstr(CallType.NORMAL, result, name, receiver, args, closure);
}

public static CallInstr create(CallType callType, Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
return new CallInstr(callType, result, name, receiver, args, closure);
}

Expand Down
38 changes: 38 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/CheckForLJEInstr.java
@@ -0,0 +1,38 @@
package org.jruby.ir.instructions;

import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.runtime.Block;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;

/**
*/
public class CheckForLJEInstr extends Instr {
private boolean maybeLambda;

public CheckForLJEInstr(boolean maybeLambda) {
super(Operation.CHECK_FOR_LJE, EMPTY_OPERANDS);

this.maybeLambda = maybeLambda;
}

public boolean maybeLambda() {
return maybeLambda;
}

@Override
public Instr clone(CloneInfo info) {
return new CheckForLJEInstr(maybeLambda);
}

public void visit(IRVisitor visitor) {
visitor.CheckForLJEInstr(this);
}

public void check(ThreadContext context, DynamicScope dynamicScope, Block.Type blockType) {
IRRuntimeHelpers.checkForLJE(context, dynamicScope, maybeLambda, blockType);
}
}
Expand Up @@ -23,7 +23,7 @@ public enum Methods {
HANDLE_PROPAGATE_BREAK, HANDLE_NONLOCAL_RETURN, HANDLE_BREAK_AND_RETURNS_IN_LAMBDA,
IS_DEFINED_BACKREF, IS_DEFINED_NTH_REF, IS_DEFINED_GLOBAL, IS_DEFINED_INSTANCE_VAR,
IS_DEFINED_CLASS_VAR, IS_DEFINED_SUPER, IS_DEFINED_METHOD, IS_DEFINED_CALL,
IS_DEFINED_CONSTANT_OR_METHOD, MERGE_KWARGS(), CHECK_FOR_LJE
IS_DEFINED_CONSTANT_OR_METHOD, MERGE_KWARGS
}

Methods helperMethod;
Expand Down Expand Up @@ -81,9 +81,6 @@ public IRubyObject callHelper(ThreadContext context, StaticScope currScope, Dyna
return IRRuntimeHelpers.isDefinedNthRef(context, (int) ((Fixnum) operands[0]).getValue());
case IS_DEFINED_GLOBAL:
return IRRuntimeHelpers.isDefinedGlobal(context, ((StringLiteral) operands[0]).getString());
case CHECK_FOR_LJE:
IRRuntimeHelpers.checkForLJE(context, currDynScope, ((Boolean)operands[0]).isTrue(), blockType);
return null;
}

Object arg1 = operands[0].retrieve(context, self, currScope, currDynScope, temp);
Expand Down
Expand Up @@ -17,8 +17,8 @@
public class OneFixnumArgNoBlockCallInstr extends CallInstr {
private final long fixNum;

public OneFixnumArgNoBlockCallInstr(Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1F, CallType.NORMAL, result, name, receiver, args, null);
public OneFixnumArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1F, callType, result, name, receiver, args, null);

assert args.length == 1;

Expand All @@ -27,7 +27,7 @@ public OneFixnumArgNoBlockCallInstr(Variable result, String name, Operand receiv

@Override
public Instr clone(CloneInfo ii) {
return new OneFixnumArgNoBlockCallInstr(ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii),
return new OneFixnumArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii),
cloneCallArgs(ii));
}

Expand Down
Expand Up @@ -17,8 +17,8 @@
public class OneFloatArgNoBlockCallInstr extends CallInstr {
private final double flote;

public OneFloatArgNoBlockCallInstr(Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1D, CallType.NORMAL, result, name, receiver, args, null);
public OneFloatArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1D, callType, result, name, receiver, args, null);

assert args.length == 1;

Expand All @@ -27,8 +27,8 @@ public OneFloatArgNoBlockCallInstr(Variable result, String name, Operand receive

@Override
public Instr clone(CloneInfo ii) {
return new OneFloatArgNoBlockCallInstr(ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii),
cloneCallArgs(ii));
return new OneFloatArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(),
getReceiver().cloneForInlining(ii), cloneCallArgs(ii));
}

@Override
Expand Down
Expand Up @@ -14,13 +14,13 @@
import org.jruby.runtime.builtin.IRubyObject;

public class OneOperandArgBlockCallInstr extends CallInstr {
public OneOperandArgBlockCallInstr(Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
super(Operation.CALL_1OB, CallType.NORMAL, result, name, receiver, args, closure);
public OneOperandArgBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
super(Operation.CALL_1OB, callType, result, name, receiver, args, closure);
}

@Override
public Instr clone(CloneInfo ii) {
return new OneOperandArgBlockCallInstr(ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii),
return new OneOperandArgBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii),
cloneCallArgs(ii), getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii));
}

Expand Down
Expand Up @@ -14,14 +14,14 @@
import org.jruby.runtime.builtin.IRubyObject;

public class OneOperandArgNoBlockCallInstr extends CallInstr {
public OneOperandArgNoBlockCallInstr(Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1O, CallType.NORMAL, result, name, receiver, args, null);
public OneOperandArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1O, callType, result, name, receiver, args, null);
}

@Override
public Instr clone(CloneInfo ii) {
return new OneOperandArgNoBlockCallInstr(ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii),
cloneCallArgs(ii));
return new OneOperandArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(),
getReceiver().cloneForInlining(ii), cloneCallArgs(ii));
}

@Override
Expand Down
Expand Up @@ -14,13 +14,13 @@
import org.jruby.runtime.builtin.IRubyObject;

public class ZeroOperandArgNoBlockCallInstr extends CallInstr {
public ZeroOperandArgNoBlockCallInstr(Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_0O, CallType.NORMAL, result, name, receiver, args, null);
public ZeroOperandArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_0O, callType, result, name, receiver, args, null);
}

@Override
public Instr clone(CloneInfo ii) {
return new ZeroOperandArgNoBlockCallInstr(ii.getRenamedVariable(result), getName(),
return new ZeroOperandArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(),
getReceiver().cloneForInlining(ii), cloneCallArgs(ii));
}

Expand Down
10 changes: 6 additions & 4 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Expand Up @@ -441,13 +441,15 @@ private static void processOtherOp(ThreadContext context, Instr instr, Operation

case RUNTIME_HELPER: {
RuntimeHelperCall rhc = (RuntimeHelperCall)instr;
result = rhc.callHelper(context, currScope, currDynScope, self, temp, blockType);
if (rhc.getResult() != null) {
setResult(temp, currDynScope, rhc.getResult(), result);
}
setResult(temp, currDynScope, rhc.getResult(),
rhc.callHelper(context, currScope, currDynScope, self, temp, blockType));
break;
}

case CHECK_FOR_LJE:
((CheckForLJEInstr) instr).check(context, currDynScope, blockType);
break;

case BOX_FLOAT: {
RubyFloat f = context.runtime.newFloat(getFloatArg(floats, ((BoxFloatInstr)instr).getValue()));
setResult(temp, currDynScope, ((BoxInstr)instr).getResult(), f);
Expand Down
16 changes: 9 additions & 7 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Expand Up @@ -875,6 +875,15 @@ public void CheckArityInstr(CheckArityInstr checkarityinstr) {
}

@Override
public void CheckForLJEInstr(CheckForLJEInstr checkForljeinstr) {
jvmMethod().loadContext();
jvmLoadLocal(DYNAMIC_SCOPE);
jvmAdapter().ldc(checkForljeinstr.maybeLambda());
jvmMethod().loadBlockType();
jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "checkForLJE", sig(void.class, ThreadContext.class, DynamicScope.class, boolean.class, Block.Type.class));
}

@Override
public void ClassSuperInstr(ClassSuperInstr classsuperinstr) {
String name = classsuperinstr.getName();
Operand[] args = classsuperinstr.getCallArgs();
Expand Down Expand Up @@ -1725,13 +1734,6 @@ public void RuntimeHelperCall(RuntimeHelperCall runtimehelpercall) {
jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "mergeKeywordArguments", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class));
jvmStoreLocal(runtimehelpercall.getResult());
break;
case CHECK_FOR_LJE:
jvmMethod().loadContext();
jvmLoadLocal(DYNAMIC_SCOPE);
jvmAdapter().ldc(((Boolean)runtimehelpercall.getArgs()[0]).isTrue());
jvmMethod().loadBlockType();
jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "checkForLJE", sig(void.class, ThreadContext.class, DynamicScope.class, boolean.class, Block.Type.class));
break;
default:
throw new NotCompilableException("Unknown IR runtime helper method: " + runtimehelpercall.getHelperMethod() + "; INSTR: " + this);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby/stdlib/win32/registry.rb
Expand Up @@ -280,7 +280,7 @@ def unpackqw(qw)
end

def make_wstr(str)
str.encode(WCHAR)
str.encode(WCHAR) + 0.chr.encode(WCHAR)
end

def OpenKey(hkey, name, opt, desired)
Expand Down
1 change: 1 addition & 0 deletions spec/ruby/shared/mutex/locked.rb
Expand Up @@ -28,6 +28,7 @@
m1.locked?.should be_true
m2.unlock # release th
th.join
# A Thread releases its locks upon termination
m1.locked?.should be_false
end
end
38 changes: 0 additions & 38 deletions spec/truffle/tags/core/array/element_reference_tags.txt

This file was deleted.

0 comments on commit ac75e32

Please sign in to comment.