Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8.2
-
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:
- Save the following script as Test.groovy
int fib(int n) { if (n < 2) return n return rcfib(n - 1) + rcfib(n - 2) }
- Compile Test.groovy using groovyc
groovyc Test.groovy
- Disassemble the Test.class
javap -c Test
- 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 : :