Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into non-indy-jit
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Oct 13, 2014
2 parents 66a80ff + 2499589 commit 65189b4
Show file tree
Hide file tree
Showing 16 changed files with 202 additions and 68 deletions.
7 changes: 2 additions & 5 deletions core/src/main/java/org/jruby/ir/IRScope.java
Expand Up @@ -7,13 +7,10 @@
import org.jruby.ir.instructions.*;
import org.jruby.ir.operands.*;
import org.jruby.ir.operands.Float;
import org.jruby.ir.passes.AddLocalVarLoadStoreInstructions;
import org.jruby.ir.passes.CompilerPass;
import org.jruby.ir.passes.CompilerPassScheduler;
import org.jruby.ir.passes.DeadCodeElimination;
import org.jruby.ir.passes.OptimizeDynScopesPass;
import org.jruby.ir.dataflow.analyses.StoreLocalVarPlacementProblem;
import org.jruby.ir.dataflow.analyses.LiveVariablesProblem;
import org.jruby.ir.passes.UnboxingPass;
import org.jruby.ir.persistence.IRReaderDecoder;
import org.jruby.ir.representations.BasicBlock;
Expand Down Expand Up @@ -489,7 +486,7 @@ private synchronized Instr[] prepareInstructions() {
// All same-named labels must be same Java instance for this to work or we would need
// to examine all Label operands and update this as well which would be expensive.
Label l = b.getLabel();
Label newL = cloneInfo.getRenamedLabel(l);
Label newL = l;//cloneInfo.getRenamedLabel(l);
l.setTargetPC(ipc);
newL.setTargetPC(ipc);

Expand All @@ -498,7 +495,7 @@ private synchronized Instr[] prepareInstructions() {
for (int i = 0; i < bbInstrsLength; i++) {
Instr instr = bbInstrs.get(i);
if (!(instr instanceof ReceiveSelfInstr)) {
Instr newInstr = instr.clone(cloneInfo);
Instr newInstr = instr;//.clone(cloneInfo);
// if (newInstr == instr) {
// System.out.println("Instruction " + instr.getOperation() + " returns itself on clone. Probably fragile!");
// }
Expand Down
@@ -0,0 +1,7 @@
package org.jruby.ir.instructions;

/**
* Created by enebo on 10/13/14.
*/
public class InterpreterPrologInstr {
}
29 changes: 16 additions & 13 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Expand Up @@ -23,7 +23,6 @@
import org.jruby.util.log.LoggerFactory;

import java.util.List;
import java.util.Map;

public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {

Expand Down Expand Up @@ -509,6 +508,21 @@ private static void processOtherOp(ThreadContext context, Instr instr, Operation
}
}

private static DynamicScope getNewDynScope(ThreadContext context, IRScope scope, StaticScope currScope) {
// SSS NOTE: Method/module scopes only!
//
// Blocks are a headache -- so, these instrs. are only added to IRMethods.
// Blocks have more complicated logic for pushing a dynamic scope (see InterpretedIRBlockBody)
if (scope instanceof IRMetaClassBody) {
// Add a parent-link to current dynscope to support non-local returns cheaply
// This doesn't affect variable scoping since local variables will all have
// the right scope depth.
return DynamicScope.newDynamicScope(currScope, context.getCurrentScope());
} else {
return DynamicScope.newDynamicScope(currScope);
}
}

private static IRubyObject interpret(ThreadContext context, IRubyObject self,
IRScope scope, Visibility visibility, RubyModule implClass, String name, IRubyObject[] args, Block block, Block.Type blockType) {
Instr[] instrs = scope.getInstrsForInterpretation(blockType == Block.Type.LAMBDA);
Expand Down Expand Up @@ -570,18 +584,7 @@ private static IRubyObject interpret(ThreadContext context, IRubyObject self,
break;
case BOOK_KEEPING_OP:
if (operation == Operation.PUSH_BINDING) {
// SSS NOTE: Method/module scopes only!
//
// Blocks are a headache -- so, these instrs. are only added to IRMethods.
// Blocks have more complicated logic for pushing a dynamic scope (see InterpretedIRBlockBody)
if (scope instanceof IRMetaClassBody) {
// Add a parent-link to current dynscope to support non-local returns cheaply
// This doesn't affect variable scoping since local variables will all have
// the right scope depth.
currDynScope = DynamicScope.newDynamicScope(currScope, context.getCurrentScope());
} else {
currDynScope = DynamicScope.newDynamicScope(currScope);
}
currDynScope = getNewDynScope(context, scope, currScope);
context.pushScope(currDynScope);
} else {
processBookKeepingOp(context, instr, operation, currScope, name, args, self, block, implClass, visibility, temp, currDynScope);
Expand Down
@@ -1,7 +1,6 @@
package org.jruby.ir.passes;

import org.jruby.ir.*;
import org.jruby.ir.dataflow.analyses.LiveVariablesProblem;
import org.jruby.ir.dataflow.analyses.StoreLocalVarPlacementProblem;
import org.jruby.ir.instructions.*;
import org.jruby.ir.operands.Label;
Expand Down Expand Up @@ -71,6 +70,24 @@ public Object execute(IRScope scope, Object... data) {
}
}

/* ----------------------------------------------------------------------
* Turning this off for now since this code is buggy and fails a few tests
* See example below which fails:
*
def y; yield; end
y {
def revivify
Proc::new
end
y {
x = Proc.new {}
y = revivify(&x)
p x.object_id, y.object_id
}
}
*
boolean requireFrame = bindingHasEscaped || scope.usesEval();
for (IRFlags flag : scope.getFlags()) {
Expand All @@ -88,7 +105,9 @@ public Object execute(IRScope scope, Object... data) {
requireFrame = true;
}
}
* ---------------------------------------------------------------------- */

boolean requireFrame = true;
boolean requireBinding = bindingHasEscaped || scopeHasLocalVarStores || !scope.getFlags().contains(IRFlags.DYNSCOPE_ELIMINATED);

// FIXME: Why do we need a push/pop for frame & binding for scopes with unrescued exceptions??
Expand Down
Expand Up @@ -3,7 +3,6 @@
import org.jruby.ir.IRClosure;
import org.jruby.ir.IRFlags;
import org.jruby.ir.IRScope;
import org.jruby.ir.dataflow.analyses.LiveVariablesProblem;
import org.jruby.ir.dataflow.analyses.LoadLocalVarPlacementProblem;
import org.jruby.ir.dataflow.analyses.StoreLocalVarPlacementProblem;
import org.jruby.ir.instructions.Instr;
Expand Down
Expand Up @@ -2,15 +2,11 @@

import org.jruby.RubyInstanceConfig;
import org.jruby.ir.IRManager;
import org.jruby.ir.IRScope;
import org.jruby.ir.instructions.CallBase;
import org.jruby.ir.instructions.Instr;
import org.jruby.ir.instructions.YieldInstr;
import org.jruby.ir.listeners.InstructionsListener;
import org.jruby.ir.listeners.InstructionsListenerDecorator;
import org.jruby.ir.operands.Label;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.WrappedIRClosure;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
Expand Down
Expand Up @@ -17,7 +17,7 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyContext;

@NodeChild("body")
@NodeChild("value")
public abstract class AssertCompilationConstantNode extends RubyNode {

public AssertCompilationConstantNode(RubyContext context, SourceSection sourceSection) {
Expand All @@ -30,27 +30,32 @@ public AssertCompilationConstantNode(AssertCompilationConstantNode prev) {

@Specialization
public boolean assertCompilationConstant(boolean value) {
return CompilerAsserts.compilationConstant(value);
CompilerAsserts.compilationConstant(value);
return value;
}

@Specialization
public int assertCompilationConstant(int value) {
return CompilerAsserts.compilationConstant(value);
CompilerAsserts.compilationConstant(value);
return value;
}

@Specialization
public long assertCompilationConstant(long value) {
return CompilerAsserts.compilationConstant(value);
CompilerAsserts.compilationConstant(value);
return value;
}

@Specialization
public double assertCompilationConstant(double value) {
return CompilerAsserts.compilationConstant(value);
CompilerAsserts.compilationConstant(value);
return value;
}

@Specialization
public Object assertCompilationConstant(Object value) {
return CompilerAsserts.compilationConstant(value);
CompilerAsserts.compilationConstant(value);
return value;
}

}
Expand Up @@ -38,10 +38,7 @@ public static Object[] pack(MethodLike method, MaterializedFrame declarationFram
packed[DECLARATION_FRAME_INDEX] = declarationFrame;
packed[SELF_INDEX] = self;
packed[BLOCK_INDEX] = block;

for (int n = 0; n < arguments.length; n++) {
packed[RUNTIME_ARGUMENT_COUNT + n] = arguments[n];
}
System.arraycopy(arguments, 0, packed, RUNTIME_ARGUMENT_COUNT, arguments.length);

return packed;
}
Expand Down
Expand Up @@ -194,7 +194,8 @@ public RubyNode visitAttrAssignNode(org.jruby.ast.AttrAssignNode node) {
*/
public RubyNode visitAttrAssignNodeExtraArgument(org.jruby.ast.AttrAssignNode node, RubyNode extraArgument) {
final CallNode callNode = new CallNode(node.getPosition(), node.getReceiverNode(), node.getName(), node.getArgsNode(), null);
return visitCallNodeExtraArgument(callNode, extraArgument, false);
boolean isAccessorOnSelf = (node.getReceiverNode() instanceof org.jruby.ast.SelfNode);
return visitCallNodeExtraArgument(callNode, extraArgument, isAccessorOnSelf);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion test/pom.rb
Expand Up @@ -243,7 +243,7 @@
'<exec dir="${jruby.home}" executable="${jruby.home}/bin/jruby" failonerror="true">' +
'<arg value="-J-server" />' +
'<arg value="-J-G:-TruffleBackgroundCompilation" />' +
'<arg value="-J-G:+TruffleCompilationExceptionsAreThrown" />' +
'<arg value="-J-G:+TruffleCompilationExceptionsAreFatal" />' +
'<arg value="-X+T" />' +
'<arg value="-Xtruffle.debug.enable_assert_constant=true" />' +
'<arg value="test/truffle/pe/pe.rb" />' +
Expand Down
2 changes: 1 addition & 1 deletion test/pom.xml
Expand Up @@ -407,7 +407,7 @@
<exec dir="${jruby.home}" executable="${jruby.home}/bin/jruby" failonerror="true">
<arg value="-J-server" />
<arg value="-J-G:-TruffleBackgroundCompilation" />
<arg value="-J-G:+TruffleCompilationExceptionsAreThrown" />
<arg value="-J-G:+TruffleCompilationExceptionsAreFatal" />
<arg value="-X+T" />
<arg value="-Xtruffle.debug.enable_assert_constant=true" />
<arg value="test/truffle/pe/pe.rb" />
Expand Down
22 changes: 19 additions & 3 deletions test/truffle/pe/core/fixnum_pe.rb
@@ -1,4 +1,20 @@
# Literals
PETests.tests do

example { truffle_assert_constant 14 }
example { truffle_assert_constant 0xffffffffffff }
describe "A Fixnum" do

example "literal" do
truffle_assert_constant 14
truffle_assert_constant 0xffffffffffff
end

describe "#+" do

example "a Fixnum" do
truffle_assert_constant 14 + 2
end

end

end

end
12 changes: 10 additions & 2 deletions test/truffle/pe/core/float_pe.rb
@@ -1,3 +1,11 @@
# Literals
PETests.tests do

example { truffle_assert_constant 14.2 }
describe "A Fixnum" do

example "literal" do
truffle_assert_constant 14.2
end

end

end
12 changes: 10 additions & 2 deletions test/truffle/pe/core/symbol_pe.rb
@@ -1,3 +1,11 @@
# Literals
PETests.tests do

example { truffle_assert_constant :foo }
describe "A Symbol" do

example "literal" do
truffle_assert_constant :foo
end

end

end
17 changes: 14 additions & 3 deletions test/truffle/pe/core/truefalse_pe.rb
@@ -1,4 +1,15 @@
# Literals
PETests.tests do

example { truffle_assert_constant true }
example { truffle_assert_constant false }
describe "A boolean" do

example "true literal" do
truffle_assert_constant true
end

example "false literal" do
truffle_assert_constant false
end

end

end

0 comments on commit 65189b4

Please sign in to comment.