You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the loop (de-)compiles to this. Notice the series of if statements and the dispatch on code().
privatefinaldoubleloop$2(intsp, intdp, intpc) {
byteby;
while (true) {
if (pc == IArray.package.IArray$.MODULE$.size((Object)this.program())) {
returnthis.stack[sp - 1];
}
by = IArray.package.IArray$.MODULE$.apply(this.program(), pc);
if (ByteCode.Op$.Lit.code() == by) {
this.stack[sp] = IArray.package.IArray$.MODULE$.apply(this.data(), dp);
intn = sp + 1;
intn2 = dp + 1;
intn3 = pc + 1;
sp = n;
dp = n2;
pc = n3;
continue;
}
if (ByteCode.Op$.Add.code() == by) {
doublea = this.stack[sp - 1];
doubleb = this.stack[sp - 2];
this.stack[sp - 2] = a + b;
intn = sp - 1;
intn4 = pc + 1;
sp = n;
pc = n4;
continue;
}
if (ByteCode.Op$.Sub.code() == by) {
doublea = this.stack[sp - 1];
doubleb = this.stack[sp - 2];
this.stack[sp - 2] = a - b;
intn = sp - 1;
intn5 = pc + 1;
sp = n;
pc = n5;
continue;
}
if (ByteCode.Op$.Mul.code() == by) {
doublea = this.stack[sp - 1];
doubleb = this.stack[sp - 2];
this.stack[sp - 2] = a * b;
intn = sp - 1;
intn6 = pc + 1;
sp = n;
pc = n6;
continue;
}
if (ByteCode.Op$.Div.code() != by) break;
doublea = this.stack[sp - 1];
doubleb = this.stack[sp - 2];
this.stack[sp - 2] = a / b;
intn = sp - 1;
intn7 = pc + 1;
sp = n;
pc = n7;
}
thrownewMatchError((Object)BoxesRunTime.boxToByte((byte)by));
}
If I apply this patch ...
--- a/core/src/main/scala/arithmetic/ByteCode.scala+++ b/core/src/main/scala/arithmetic/ByteCode.scala@@ -117,25 +117,25 @@ object ByteCode {
if (pc == program.size) stack(sp - 1)
else
program(pc) match {
- case Op.Lit.code =>+ case 0 =>
stack(sp) = data(dp)
loop(sp + 1, dp + 1, pc + 1)
- case Op.Add.code =>+ case 1 =>
val a = stack(sp - 1)
val b = stack(sp - 2)
stack(sp - 2) = (a + b)
loop(sp - 1, dp, pc + 1)
- case Op.Sub.code =>+ case 2 =>
val a = stack(sp - 1)
val b = stack(sp - 2)
stack(sp - 2) = (a - b)
loop(sp - 1, dp, pc + 1)
- case Op.Mul.code =>+ case 3 =>
val a = stack(sp - 1)
val b = stack(sp - 2)
stack(sp - 2) = (a * b)
loop(sp - 1, dp, pc + 1)
- case Op.Div.code =>+ case 4 =>
val a = stack(sp - 1)
val b = stack(sp - 2)
stack(sp - 2) = (a / b)
Currently the loop (de-)compiles to this. Notice the series of
if
statements and the dispatch oncode()
.If I apply this patch ...
Then it decompiles to this
switch
statement.I wonder if this explains some of your performance results.
The text was updated successfully, but these errors were encountered: