Skip to content

Commit

Permalink
Un-bitrot + code cleanup + refactor unboxing code. More to do.
Browse files Browse the repository at this point in the history
This code had bit rotted quite a lot. It continues to be broken
and doesn't run anymore. But, this is much further along than it
was over the weekend. Pushing this version as is for now. Will
fix up as when I get more free time.
subbuss committed Jan 14, 2015

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 0fb7e04 commit 8f3a5ac
Showing 4 changed files with 204 additions and 221 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -53,8 +53,5 @@ public void unbox() {
for (UnboxableOpsAnalysisNode n : generateWorkList()) {
n.unbox(unboxMap);
}

// SSS FIXME: This should be done differently
getScope().setDataFlowSolution(DataFlowConstants.LVP_NAME, null);
}
}
12 changes: 10 additions & 2 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Original file line number Diff line number Diff line change
@@ -147,8 +147,12 @@ private static Object retrieveOp(Operand r, ThreadContext context, IRubyObject s
private static double getFloatArg(double[] floats, Operand arg) {
if (arg instanceof Float) {
return ((Float)arg).value;
} else if (arg instanceof UnboxedFloat) {
return ((UnboxedFloat)arg).value;
} else if (arg instanceof Fixnum) {
return (double)((Fixnum)arg).value;
} else if (arg instanceof UnboxedFixnum) {
return (double)((UnboxedFixnum)arg).value;
} else if (arg instanceof Bignum) {
return ((Bignum)arg).value.doubleValue();
} else if (arg instanceof TemporaryLocalVariable) {
@@ -161,6 +165,8 @@ private static double getFloatArg(double[] floats, Operand arg) {
private static long getFixnumArg(long[] fixnums, Operand arg) {
if (arg instanceof Float) {
return (long)((Float)arg).value;
} else if (arg instanceof UnboxedFixnum) {
return ((UnboxedFixnum)arg).value;
} else if (arg instanceof Fixnum) {
return ((Fixnum)arg).value;
} else if (arg instanceof Bignum) {
@@ -569,9 +575,11 @@ private static IRubyObject interpret(ThreadContext context, IRubyObject self,
} catch (Throwable t) {
extractToMethodToAvoidC2Crash(context, instr, t);

if (debug) LOG.info("in : " + interpreterContext.getStaticScope().getIRScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
ipc = instr.getRPC();
if (debug) LOG.info("ipc for rescuer: " + ipc);
if (debug) {
LOG.info("in : " + interpreterContext.getStaticScope().getIRScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
LOG.info("ipc for rescuer: " + ipc);
}

if (ipc == -1) {
Helpers.throwException(t);
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/ir/passes/UnboxingPass.java
Original file line number Diff line number Diff line change
@@ -25,10 +25,20 @@ public Object execute(IRScope scope, Object... data) {
problem.compute_MOP_Solution();
problem.unbox();

// LVA information is no longer valid after the pass
// FIXME: Grrr ... this seems broken to have to create a new object to invalidate
(new LiveVariableAnalysis()).invalidate(scope);

return true;
}

@Override
public Object previouslyRun(IRScope scope) {
return scope.getDataFlowSolution(UnboxableOpsAnalysisProblem.NAME);
}

public boolean invalidate(IRScope scope) {
// Cannot run unboxing more than once on a scope in its current form
return false;
}
}

0 comments on commit 8f3a5ac

Please sign in to comment.