[ 
https://issues.apache.org/jira/browse/GROOVY-12162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18095959#comment-18095959
 ] 

ASF GitHub Bot commented on GROOVY-12162:
-----------------------------------------

codecov-commenter commented on PR #2707:
URL: https://github.com/apache/groovy/pull/2707#issuecomment-4960674483

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2707?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :x: Patch coverage is `67.10526%` with `25 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 69.0978%. Comparing base 
([`86c6648`](https://app.codecov.io/gh/apache/groovy/commit/86c6648d1e61436fe513afaa85d8d0c403de3cda?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`58dcf7a`](https://app.codecov.io/gh/apache/groovy/commit/58dcf7a33f674af711d1dada3ed22ba8cacf7318?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2707?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[.../classgen/asm/PeepholeOptimizingMethodVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FPeepholeOptimizingMethodVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9QZWVwaG9sZU9wdGltaXppbmdNZXRob2RWaXNpdG9yLmphdmE=)
 | 67.9245% | [9 Missing and 8 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...rg/codehaus/groovy/classgen/AsmClassGenerator.java](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2FAsmClassGenerator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL0FzbUNsYXNzR2VuZXJhdG9yLmphdmE=)
 | 58.3333% | [5 Missing :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...codehaus/groovy/classgen/asm/WriterController.java](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FWriterController.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9Xcml0ZXJDb250cm9sbGVyLmphdmE=)
 | 50.0000% | [1 Missing and 2 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/2707/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2707        +/-   ##
   ==================================================
   - Coverage     69.1077%   69.0978%   -0.0100%     
   - Complexity      34235      34247        +12     
   ==================================================
     Files            1537       1538         +1     
     Lines          129356     129379        +23     
     Branches        23503      23514        +11     
   ==================================================
   + Hits            89395      89398         +3     
   - Misses          31941      31953        +12     
   - Partials         8020       8028         +8     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2707?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...g/codehaus/groovy/classgen/asm/CallSiteWriter.java](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FCallSiteWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9DYWxsU2l0ZVdyaXRlci5qYXZh)
 | `85.5769% <100.0000%> (-0.1374%)` | :arrow_down: |
   | 
[...y/classgen/asm/PeepholeOptimizingClassVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FPeepholeOptimizingClassVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9QZWVwaG9sZU9wdGltaXppbmdDbGFzc1Zpc2l0b3IuamF2YQ==)
 | `100.0000% <100.0000%> (ø)` | |
   | 
[...codehaus/groovy/classgen/asm/WriterController.java](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FWriterController.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9Xcml0ZXJDb250cm9sbGVyLmphdmE=)
 | `86.1111% <50.0000%> (-1.1229%)` | :arrow_down: |
   | 
[...rg/codehaus/groovy/classgen/AsmClassGenerator.java](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2FAsmClassGenerator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL0FzbUNsYXNzR2VuZXJhdG9yLmphdmE=)
 | `85.0399% <58.3333%> (-0.0217%)` | :arrow_down: |
   | 
[.../classgen/asm/PeepholeOptimizingMethodVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/2707?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FPeepholeOptimizingMethodVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9QZWVwaG9sZU9wdGltaXppbmdNZXRob2RWaXNpdG9yLmphdmE=)
 | `90.8861% <67.9245%> (-3.7663%)` | :arrow_down: |
   
   ... and [7 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/2707/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test 
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, 
report on failures, and find test suite problems.
   - :package: [JS Bundle 
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save 
yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>




> Harden and extend bytecode peephole optimization
> ------------------------------------------------
>
>                 Key: GROOVY-12162
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12162
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Daniel Sun
>            Priority: Major
>
> h2. Overview
> Follow-up to GROOVY-12065. The initial peephole layer
> ({{{}PeepholeOptimizingMethodVisitor{}}}) only wrapped selected
> {{visitMethod}} call sites. After {{OperandStack}} started
> emitting constants via {{visitLdcInsn}} and relying on the
> peephole visitor for compaction, any method that was *not* wrapped
> regressed to non-compact forms. Class-generation error diagnostics
> that depended on {{TraceMethodVisitor}} were also broken once
> the peephole wrapper sat in front of the trace visitor.
> This improvement applies peephole compaction uniformly, restores
> diagnostics, and adds several safe local-window rewrites that
> further shrink generated bytecode without changing runtime
> semantics.
> h2. Problems Addressed
>  * *Inconsistent application:* MOP bridges, call-site helpers,
> {{{}class${}}}, and other synthetic methods often bypassed the
> peephole wrapper while user methods did not.
>  * *Broken classgen diagnostics:*
> {{mv instanceof TraceMethodVisitor}} no longer matched after
> wrapping, so "Last known generated bytecode" was never printed
> when {{visitMaxs}} failed under classgen logging.
>  * *Incomplete dead-code patterns:*
> {{{}ALOAD{}}}/reference {{{}LDC{}}}; {{{}CHECKCAST{}}}; {{POP}}
> only dropped the cast (the load remained); bare
> {{{}DUP{}}}/{{{}DUP2{}}}; matching {{{}POP{}}}/{{{}POP2{}}} was left
> untouched; {{{}ACONST_NULL{}}}; {{IF_ACMP*}} was not rewritten
> to {{{}IFNULL{}}}/{{{}IFNONNULL{}}}.
>  * *Side-effect caution:* dropping a standalone {{CHECKCAST}}
> immediately before void {{RETURN}} could discard a type-check
> side effect for a value already committed to the stack.
> h2. Changes
> h3. Uniform application
>  * Introduce {{{}PeepholeOptimizingClassVisitor{}}}, installed once
> from {{{}WriterController{}}}, so every method body (including
> synthetic helpers) is routed through
> {{{}PeepholeOptimizingMethodVisitor{}}}.
>  * Remove ad-hoc {{new PeepholeOptimizingMethodVisitor(...)}}
> wraps from {{AsmClassGenerator}} and {{{}CallSiteWriter{}}}.
> h3. Diagnostics
>  * Add {{PeepholeOptimizingMethodVisitor.printTraceBytecode}} to
> walk the visitor chain and print a nested
> {{TraceMethodVisitor}} when present.
> h3. Additional rewrites (still single-pass / stack-local)
>  * Attach {{CHECKCAST}} to a pending {{ALOAD}} or reference
> constant so load + cast + {{POP}} collapses completely when
> the value is unused; keep the cast when the value is used.
>  * Rewrite {{{}ACONST_NULL{}}}; {{{}IF_ACMPEQ{}}}/{{{}IF_ACMPNE{}}} to
> {{{}IFNULL{}}}/{{{}IFNONNULL{}}}.
>  * Eliminate bare {{{}DUP{}}}/{{{}DUP2{}}} followed by a matching pop
> (with or without an intervening store → store-only form).
>  * On void {{{}RETURN{}}}, drop only pending variable/constant loads
> (preserving {{{}IINC{}}}); flush a standalone {{CHECKCAST}}
> instead of discarding it.
>  * Buffer replacement flushes prior pending state instead of
> silently clearing it; integer constant emission reuses
> {{BytecodeHelper.pushConstant}} on the delegate.
> h2. Safety
> The visitor remains a single candidate window: pending state is
> flushed at labels, frames, line numbers, invokes, and other
> non-local boundaries. Signed zero constants continue to use raw-bit
> comparisons (GROOVY-9797). 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to