groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jochen Theodorou" <>
Subject Aw: Groovy 2.5.4 generates dead code
Date Wed, 21 Nov 2018 14:02:49 GMT
<html><head></head><body><div style="font-family: Verdana;font-size:
<div>Hi Andres,</div>


<div>there was at some point in the past (I think it was related to Java8) a problem
with us doing entries into the exception table (I think it was that table). There was no fix
to this on any simple or middle level. The entry was made like that because of how the data
is processed in AsmClassGenerator. That is why we added an additional instruction at the end,
which then gets compiled by asm as nop; athrow; even though we do something else here. I vagually
remember it had to do with us using asm to create a label for marking a range, then not having
any instructions anymore and then marking the end of the range, followed by no further instructions...
take it with care, this was 3 or 4 years ago or so - and I do not remember any JIRA issue
for this right now either, but I think the riginal issue mentioned VerificationErrors.</div>


<div>It is possible that this original issue no longer exists.</div>


<div>bye Jochen</div>

<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px
solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b>&nbsp;Mittwoch, 21.
November 2018 um 11:19 Uhr<br/>
<b>Von:</b>&nbsp;&quot;Andres Almiray&quot; &lt;;<br/>
<b>Betreff:</b>&nbsp;Groovy 2.5.4 generates dead code</div>

<div name="quoted-content">
<div>Hello everyone,</div>


<div>Evgeny Mandrikov (from JaCoCo) sent me a message regarding dead code produced by
Groovy 2.5.4 (see <a href=""
in context).</div>


<div>Reproducing full message:</div>


<p><a class="gmail-user-mention" href="" target="_blank">@aalmiray</a>
while playing further with Groovy, I noticed that groovyc 2.5.4 generates dead bytecode for
the following <code>Example.groovy</code></p>

<div class="gmail-highlight gmail-highlight-source-groovy">
<pre><span class="gmail-pl-k">Closure</span> closure <span class="gmail-pl-k">=</span>
  <span class="gmail-pl-c1">println</span>(<span class="gmail-pl-s"><span
class="gmail-pl-pds">&quot;</span>Hello,<span class="gmail-pl-pds">&quot;</span></span>)
  <span class="gmail-pl-c1">println</span>(<span class="gmail-pl-s"><span
class="gmail-pl-pds">&quot;</span>World!<span class="gmail-pl-pds">&quot;</span></span>)

<p>here is corresponding part from <code>javap -v -p Example&#92;&#36;_run_closure1</code>

<pre><code>  public java.lang.Object doCall(java.lang.Object);
    descriptor: (Ljava/lang/Object;)Ljava/lang/Object;
    flags: ACC_PUBLIC
      stack=3, locals=3, args_size=2
         0: invokestatic  #22                 // Method &#36;getCallSiteArray:()[Lorg/codehaus/groovy/runtime/callsite/CallSite;
         3: astore_2
         4: aload_2
         5: ldc           #32                 // int 0
         7: aaload
         8: aload_0
         9: ldc           #34                 // String Hello,
        11: invokeinterface #40,  3           // InterfaceMethod org/codehaus/groovy/runtime/callsite/CallSite.callCurrent:(Lgroovy/lang/GroovyObject;Ljava/lang/Object;)Ljava/lang/Object;
        16: pop
        17: aload_2
        18: ldc           #41                 // int 1
        20: aaload
        21: aload_0
        22: ldc           #43                 // String World!
        24: invokeinterface #40,  3           // InterfaceMethod org/codehaus/groovy/runtime/callsite/CallSite.callCurrent:(Lgroovy/lang/GroovyObject;Ljava/lang/Object;)Ljava/lang/Object;
        29: areturn
        30: nop
        31: athrow
      StackMapTable: number_of_entries = 1
        frame_type = 255 /* full_frame */
          offset_delta = 30
          locals = []
          stack = [ class java/lang/Throwable ]
        line 2: 4
        line 3: 17
        Start  Length  Slot  Name   Signature
            0      30     0  this   LExample&#36;_run_closure1;
            0      30     1    it   Ljava/lang/Object;

<p>instructions at offsets <code>30</code> and <code>31</code>
are not reachable, therefore line <code>3</code> that starts at instruction with
offset <code>17</code> will always be marked as uncovered.</p>

<div>Any ideas on what may be causing this behavior?</div>





<div class="gmail_signature">
Java Champion; Groovy Enthusiast<br/>
JCP EC Associate Seat<br/>
<a href="" target="_blank"></a><br/>
<a href="" target="_blank"></a><br/>
What goes up, must come down. Ask any system administrator.<br/>
There are 10 types of people in the world: Those who understand binary, and those who don&#39;t.<br/>
To understand recursion, we must first understand recursion.</div>

View raw message