Skip to content

Commit

Permalink
Showing 188 changed files with 514 additions and 6,498 deletions.
2 changes: 1 addition & 1 deletion ci.hocon
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ gate-caps: {
}

bench-caps: {
capabilities: [x52, linux, amd64, bench, post-merge]
capabilities: [x52, linux, amd64, bench, post-push]
}

daily-bench-caps: {
Original file line number Diff line number Diff line change
@@ -18,9 +18,8 @@ public DefinedVariableNode(DefinedVariablesProblem prob, BasicBlock n) {

@Override
public void init() {
setSize = problem.getDFVarsCount();
out = new BitSet(setSize);
computed = false;
// 'null' acts as the TOP for this dataflow analysis
out = null;
}

private void addDFVar(Variable v) {
@@ -37,23 +36,31 @@ public void buildDataFlowVars(Instr i) {

@Override
public void applyPreMeetHandler() {
in = new BitSet(setSize);
// Init to all 1's so that when we 'and' with the
// first predecessor, we don't go to all 0's right away!
in.set(0, setSize);
// 'null' acts as the TOP for this dataflow analysis
setSize = problem.getDFVarsCount();
in = null;
}

@Override
public void compute_MEET(Edge e, DefinedVariableNode pred) {
// Only vars defined at the exit of all predecessors are considered defined on entry
if (pred.computed) {
// If pred.out is TOP, in doesn't change.
if (pred.out != null) {
// if in is TOP, init in to a bitset with all 1's
// so the intersection computes the right value.
if (in == null) {
// Make sure 'in' and 'out' are the same size!
int n = pred.out.size();
in = new BitSet(n);
in.set(0, n);
}

in.and(pred.out);
}
}

@Override
public void initSolution() {
tmp = (BitSet) in.clone();
tmp = in == null ? new BitSet(setSize) : (BitSet) in.clone();
}

@Override
@@ -78,6 +85,8 @@ public void identifyInits(Set<Variable> undefinedVars) {
parentScopeDepth = 0;
}

// System.out.println("BB " + basicBlock + "; state\n" + toString());

initSolution();
for (Instr i: basicBlock.getInstrs()) {
// Variables that belong to outer scopes should always
@@ -89,7 +98,7 @@ public void identifyInits(Set<Variable> undefinedVars) {
}

if (!tmp.get(problem.getDFVar(v))) {
// System.out.println("Variable " + v + " in instr " + i + " isn't defined!");
// System.out.println("Variable " + v + " in instr " + i + " in " + basicBlock + " isn't defined!");
undefinedVars.add(v);
}
}
@@ -110,12 +119,45 @@ public boolean solutionChanged() {
@Override
public void finalizeSolution() {
out = tmp;
computed = true;
}

private boolean computed;
private String printSet(BitSet set) {
StringBuilder buf = new StringBuilder();
int count = 0;
for (int i = 0; i < set.size(); i++) {
if (set.get(i)) {
count++;
buf.append(' ').append(problem.getVariable(i));
if (count % 10 == 0) buf.append("\t\n");
}
}

if (count % 10 != 0) buf.append("\t\t");
return buf.append('\n').toString();
}

@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append("\tVars defined on Entry: ");
if (in == null) {
System.out.println("-- NO in!");
} else {
buf.append(printSet(in));
}

buf.append("\n\tVars defined on Exit: ");
if (out == null) {
System.out.println("-- NO out!");
} else {
buf.append(printSet(out));
}

return buf.append('\n').toString();
}

private BitSet in; // Variables defined at entry of this node
private BitSet out; // Variables defined at exit of node
private BitSet tmp; // Temporary state while applying transfer function
private BitSet tmp; // Temporary state while applying transfer function
private int setSize; // Size of the "this.in" and "this.out" bit sets
}
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ public IRubyObject interpret(ThreadContext context, Block block, IRubyObject sel

Operation operation = instr.getOperation();
if (debug) {
Interpreter.LOG.info("I: {" + ipc + "} ", instr);
Interpreter.LOG.info("I: {" + ipc + "} " + instr);
Interpreter.interpInstrsCount++;
}

Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ public IRubyObject interpret(ThreadContext context, Block block, IRubyObject sel

Operation operation = instr.getOperation();
if (debug) {
Interpreter.LOG.info("I: {" + ipc + "} ", instr);
Interpreter.LOG.info("I: {" + ipc + "} " + instr);
Interpreter.interpInstrsCount++;
} else if (profile) {
Profiler.instrTick(operation);
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ public IRubyObject interpret(ThreadContext context, Block block, IRubyObject sel

Operation operation = instr.getOperation();
if (debug) {
Interpreter.LOG.info("I: {" + ipc + "} ", instr + "; <#RPCs=" + (rescuePCs == null ? 0 : rescuePCs.size()) + ">");
Interpreter.LOG.info("I: {" + ipc + "} " + instr + "; <#RPCs=" + (rescuePCs == null ? 0 : rescuePCs.size()) + ">");
Interpreter.interpInstrsCount++;
} else if (profile) {
Profiler.instrTick(operation);
18 changes: 12 additions & 6 deletions core/src/main/java/org/jruby/ir/passes/AddMissingInitsPass.java
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

import org.jruby.ir.IRScope;
import org.jruby.ir.operands.Nil;
import org.jruby.ir.operands.LocalVariable;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.representations.BasicBlock;
import org.jruby.ir.representations.CFG;
@@ -28,15 +29,20 @@ public Object execute(IRScope scope, Object... data) {

// Add inits to entry
BasicBlock bb = scope.getCFG().getEntryBB();
int i = 0;
Variable first = null;
for (Variable v : undefinedVars) {
// System.out.println("Adding missing init for " + v + " in " + scope);
if (first == null) {
bb.getInstrs().add(i++, new CopyInstr(v, new Nil()));
first = v;

// Add lvar inits to the end of the BB
// (so that scopes are pushed before its vars are updated)
// and tmpvar inits to the beginning of the BB
// (so that if a bad analysis causes an already initialized tmp
// to be found uninitialized, this unnecessary init doesn't
// clobber an already updated tmp. The entryBB will not have
// any loads of lvars, so lvars aren't subject to this problem).
if (v instanceof LocalVariable) {
bb.getInstrs().add(new CopyInstr(v, new Nil()));
} else {
bb.getInstrs().add(i++, new CopyInstr(v, first));
bb.getInstrs().add(0, new CopyInstr(v, new Nil()));
}
}

4 changes: 2 additions & 2 deletions mx.jruby/mx_jruby.py
Original file line number Diff line number Diff line change
@@ -177,9 +177,9 @@ def runBenchmark(self, benchmark, bmSuiteArgs):

return [{
'benchmark': benchmark,
'metric.name': 'time',
'metric.name': 'memory',
'metric.value': data['median'],
'metric.unit': 's',
'metric.unit': 'B',
'metric.better': 'lower',
'extra.metric.human': data['human']
}]
2 changes: 1 addition & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
@@ -924,7 +924,7 @@ def get_times(trace, total)
end
times[' jvm'] = total - times[' main']
times['total'] = total
times['unaccounted'] = total - accounted_for
times['unaccounted'] = total - accounted_for if times[' load-core']
times
end

Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ public Object execute(VirtualFrame frame) {

if (noBlockProfile.profile(block == null)) {
if (toEnumNode == null) {
CompilerDirectives.transferToInterpreter();
CompilerDirectives.transferToInterpreterAndInvalidate();
toEnumNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
}

Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ public YieldingCoreMethodNode(RubyContext context, SourceSection sourceSection)

private boolean booleanCast(VirtualFrame frame, Object value) {
if (booleanCastNode == null) {
CompilerDirectives.transferToInterpreter();
CompilerDirectives.transferToInterpreterAndInvalidate();
booleanCastNode = insert(BooleanCastNodeGen.create(getContext(), getSourceSection(), null));
}
return booleanCastNode.executeBoolean(frame, value);
Original file line number Diff line number Diff line change
@@ -1090,7 +1090,7 @@ public static double toDouble(Object value, DynamicObject nil) {
return (double) value;
}

CompilerDirectives.transferToInterpreter();
CompilerDirectives.transferToInterpreterAndInvalidate();
throw new UnsupportedOperationException();
}

@@ -1178,6 +1178,10 @@ public DynamicObject getRangeClass() {
return rangeClass;
}

public DynamicObject getRationalClass() {
return rationalClass;
}

public DynamicObject getRegexpClass() {
return regexpClass;
}
Loading

0 comments on commit 221bd6c

Please sign in to comment.