Closed
Description
For
var x = 0
while(x <= 5) {
println(x)
x += 1
}
Dotty generates bytecode like this: (even with -optimise
)
iconst_0
istore_2
goto 20
iload_2
iconst_5
if_icmpgt 19
getstatic scala/Predef$/MODULE$ Lscala/Predef$;
iload_2
invokestatic scala/runtime/BoxesRunTime/boxToInteger(I)Ljava/lang/Integer;
invokevirtual scala/Predef$/println(Ljava/lang/Object;)V
iconst_1
iload_2
iadd
istore_2
goto 4
nop
nop
athrow
goto 21
goto 4
return
while scalac 2.12.3 generates:
iconst_0
istore_2
iload_2
iconst_5
if_icmpgt 15
getstatic scala/Predef$/MODULE$ Lscala/Predef$;
iload_2
invokestatic scala/runtime/BoxesRunTime/boxToInteger(I)Ljava/lang/Integer;
invokevirtual scala/Predef$/println(Ljava/lang/Object;)V
iload_2
iconst_1
iadd
istore_2
goto 3
return