groovy
  1. groovy
  2. GROOVY-5008

Integer optimization is not executed

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.2
    • Fix Version/s: 1.8.3, 1.9-beta-4
    • Component/s: primtive opts
    • Labels:
      None
    • Environment:
      Groovy version: 1.8.2, 1.9.0-2-SNAPSHOT
      JVM version: 1.7.0
    • Patch Submitted:
      Yes
    • Number of attachments :
      1

      Description

      Integer optimization is not executed because BytecodeInterface8.isOrigZ() which is for boolean optimization and always returns false is called instead of BytecodeInterface8.isOrigInt().

      Steps to confirm the problem:

      1. Save the following script as Test.groovy
        int fib(int n) {
            if (n < 2) return n
            return rcfib(n - 1) + rcfib(n - 2)
        }
        
      2. Compile Test.groovy using groovyc
        groovyc Test.groovy
      3. Disassemble the Test.class
        javap -c Test
      4. You can see BytecodeInterface8.isOrigZ is called
          public int fib(int);
            Code:
               0: invokestatic  #20                 // Method $getCallSiteArray:()[Lorg/codehaus/groovy/runtime/callsite/CallSite;
               3: astore_2      
               4: invokestatic  #66                 // Method org/codehaus/groovy/runtime/BytecodeInterface8.isOrigZ:()Z
               7: ifeq          25
              10: getstatic     #68                 // Field __$stMC:Z
              13: ifne          25
              16: invokestatic  #71                 // Method org/codehaus/groovy/runtime/BytecodeInterface8.disabledStandardMetaClass:()Z
              19: ifne          25
              :
              :
        
      1. patch
        0.7 kB
        Masato Nagai

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            blackdrag blackdrag
            Reporter:
            Masato Nagai
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: