Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5008

Integer optimization is not executed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.2
    • 1.8.3, 1.9-beta-4
    • primtive opts
    • None
    • Groovy version: 1.8.2, 1.9.0-2-SNAPSHOT
      JVM version: 1.7.0
    • Patch

    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
              :
              :
        

      Attachments

        1. patch
          0.7 kB
          Masato Nagai

        Activity

          People

            blackdrag Jochen Theodorou
            nagai_masato Masato Nagai
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: