You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/10/16 13:48:00 UTC

[jira] [Updated] (GROOVY-10314) finally block produces long sequence of nop instructions

     [ https://issues.apache.org/jira/browse/GROOVY-10314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-10314:
---------------------------------
    Labels: bytecode  (was: )

> finally block produces long sequence of nop instructions
> --------------------------------------------------------
>
>                 Key: GROOVY-10314
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10314
>             Project: Groovy
>          Issue Type: Bug
>          Components: class generator, Compiler
>            Reporter: Eric Milles
>            Priority: Minor
>              Labels: bytecode
>
> Consider the following:
> {code:groovy}
> def test() {
>   try {
>     print 'hello'
>   } finally {
>     print ' world'
>   }
> }
> {code}
> For any non-void method where the {{try}}/{{finally}} is part of the return value, a long sequence of {{nop}} bytecode instructions is produced. The sample code from GROOVY-4721 produces 18 {{nop}} in a row.
> {code}
>   // Method descriptor #42 ()Ljava/lang/Object;
>   // Stack: 2, Locals: 3
>   public java.lang.Object test();
>      0  aload_0 [this]
>      1  ldc <String "hello"> [47]
>      3  invokedynamic 1 invoke(Scratch, java.lang.String) : java.lang.Object [53]
>      8  astore_1
>      9  nop
>     10  aload_0 [this]
>     11  ldc <String " world"> [55]
>     13  invokedynamic 1 invoke(Scratch, java.lang.String) : java.lang.Object [53]
>     18  pop
>     19  nop
>     20  aload_1
>     21  areturn
>     22  nop
>     23  nop
>     24  athrow
>     25  nop
>     26  nop
>     27  nop
>     28  nop
>     29  nop
>     30  nop
>     31  nop
>     32  nop
>     33  athrow
>     34  nop
>     35  nop
>     36  athrow
>     37  astore_2
>     38  aload_0 [this]
>     39  ldc <String " world"> [55]
>     41  invokedynamic 1 invoke(Scratch, java.lang.String) : java.lang.Object [53]
>     46  pop
>     47  aload_2
>     48  athrow
>     49  nop
>     50  athrow
>       Exception Table:
>         [pc: 0, pc: 10] -> 37 when : any
>         [pc: 20, pc: 22] -> 37 when : any
>       Line numbers:
>         [pc: 0, line: 3]
>         [pc: 10, line: 5]
>         [pc: 49, line: 7]
>       Local variable table:
>         [pc: 0, pc: 49] local: this index: 0 type: Scratch
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)