https://kotlinlang.org logo
#announcements
Title
# announcements
j

Johan Luttu

11/21/2019, 10:41 AM
Why does Kotlin 1.3.60 push a constant 0 to the operand stack and then store it away before printing?
Copy code
fun hello() {
    println("hello")
}
Bytecode:
Copy code
public static final void hello();
    Code:
       0: ldc           #7                  // String hello
       2: astore_0
       3: iconst_0
       4: istore_1
       5: getstatic     #13                 // Field java/lang/System.out:Ljava/io/PrintStream;
       8: aload_0
       9: invokevirtual #19                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      12: return
s

spand

11/21/2019, 10:41 AM
I would expect that to be the return value of main
1
m

Marko Mitic

11/21/2019, 10:47 AM
Make sure you're making release build, debug one has lots of silly operations for helping debbuger
j

Johan Luttu

11/21/2019, 10:59 AM
I'm using command line
kotlinc-jvm
1.3.60 and
kotlin
1.3.60-release-155. But okay, it's probably nothing special
2 Views