精华帖 (3) :: 良好帖 (1) :: 新手帖 (15) :: 隐藏帖 (2)
|
|
---|---|
作者 | 正文 |
发表时间:2010-08-04
看了下那个帖子,感觉应该分场合看问题。把优化寄希望于编译器,那肯定是有利有弊啊,当然,光写JAVA,了解JVM就不用考虑弊了。个人感觉,JAVA里,“数组长度的的写法,应该先用变量保存,循环里不要直接计算...”的最大意义,在于不让人误用其他线性容器,比如ArrayList, LinkedList,因为在循环里可能出现改变其长度的算法,所以先保存长度,再循环,是不容易出错的实践习惯。
|
|
返回顶楼 | |
发表时间:2010-08-04
好强啊!楼主想解析 jdk 啊!哈哈...按楼主的这种做法的确可以透彻看清基层实现。
学习了.... |
|
返回顶楼 | |
发表时间:2010-08-04
只想看结果的太多了。分析过程才是授人以渔啊。
|
|
返回顶楼 | |
发表时间:2010-08-04
最后修改:2010-08-04
AlwenS 写道 不如直接上cpu assembly分析了,离事实更近一步。
真的有人想看么……嘛,代码可以贴出来,*分析*就等高人来了,坐观。 测试的源码取自蛋疼,实例对比循环的各种写法: package performance; public class Performance { public static void main(String[] args) { Strategy strategy = new VariableAndIndexInLoop(); strategy.measure(); strategy.measure(); strategy = new SingleVariableIndexInLoop(); strategy.measure(); strategy.measure(); strategy = new SingleVariableIndexOutLoop(); strategy.measure(); strategy.measure(); strategy = new NoVariableIndexOutLoop(); strategy.measure(); strategy.measure(); } static abstract class Strategy { static final int loop = 10000000; static final int[] data = new int[loop]; static { for(int i = 0; i < loop;) { data[i++] = i; } } protected int sum; long measure() { long time = System.nanoTime(); howToDo(); time = System.nanoTime() - time; System.out.println(getClass().getSimpleName() + "-->" + time); return time; } abstract void howToDo(); } static class VariableAndIndexInLoop extends Strategy { void howToDo() { for(int i = 0; i < data.length; i++) { int num = data[i]; sum += num; } } } static class SingleVariableIndexInLoop extends Strategy { void howToDo() { int num; for(int i = 0; i < data.length; i++) { num = data[i]; sum += num; } } } static class SingleVariableIndexOutLoop extends Strategy { void howToDo() { int i, num; for(i = 0; i < data.length;) { num = data[i++]; sum += num; } } } static class NoVariableIndexOutLoop extends Strategy { void howToDo() { int i; for(i = 0; i < data.length;) { sum += data[i++]; } } } } 比原本的代码多调用了几次measure(),让JIT有机会标准编译。 测试环境是Sun JDK 6 update 21,x86,32-bit,server模式,Windows XP。关注的4个测试方法都有OSR编译与标准编译两个版本的生成代码。下面把按顺序把每个方法的OSR编译与标准编译的代码帖出来。 OSR编译: Decoding compiled method 0x00be6e48: Code: [Disassembling for mach='i386'] [Entry Point] [Verified Entry Point] # {method} 'howToDo' '()V' in 'performance/Performance$VariableAndIndexInLoop' 0x00be6f40: int3 0x00be6f41: nop 0x00be6f42: nop 0x00be6f43: nop 0x00be6f44: mov %eax,-0x4000(%esp) 0x00be6f4b: push %ebp 0x00be6f4c: sub $0x18,%esp 0x00be6f52: mov 0x4(%ecx),%edi 0x00be6f55: mov 0x8(%ecx),%ebp 0x00be6f58: mov %ecx,(%esp) 0x00be6f5b: call 0x084b6ca0 ; {runtime_call} 0x00be6f60: test %ebp,%ebp 0x00be6f62: je 0x00be7054 0x00be6f68: mov 0x4(%ebp),%ebx 0x00be6f6b: cmp $0x1024f470,%ebx ; {oop('performance/Performance$VariableAndIndexInLoop')} 0x00be6f71: jne 0x00be7081 ;*iload_1 ; - performance.Performance$VariableAndIndexInLoop::howToDo@2 (line 44) 0x00be6f77: cmp $0x989680,%edi 0x00be6f7d: jge 0x00be7049 ;*if_icmpge ; - performance.Performance$VariableAndIndexInLoop::howToDo@7 (line 44) 0x00be6f83: test %ebp,%ebp 0x00be6f85: je 0x00be7071 0x00be6f8b: mov %edi,%edx 0x00be6f8d: inc %edx 0x00be6f8e: xor %ebx,%ebx 0x00be6f90: cmp %ebx,%edx 0x00be6f92: jg 0x00be6f96 0x00be6f94: mov %ebx,%edx 0x00be6f96: mov $0x158,%ebx 0x00be6f9b: mov 0x1024f058(%ebx),%eax ;*getstatic data ; - performance.Performance$VariableAndIndexInLoop::howToDo@10 (line 45) ; {oop('performance/Performance$Strategy')} 0x00be6fa1: cmp $0x989680,%edi 0x00be6fa7: jae 0x00be705e 0x00be6fad: mov 0xc(%eax,%edi,4),%ebx ;*iaload ; - performance.Performance$VariableAndIndexInLoop::howToDo@14 (line 45) 0x00be6fb1: mov 0x8(%ebp),%ecx ;*getfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@18 (line 46) 0x00be6fb4: add %ebx,%ecx ;*iadd ; - performance.Performance$VariableAndIndexInLoop::howToDo@22 (line 46) 0x00be6fb6: mov %ecx,0x8(%ebp) ;*putfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@23 (line 46) 0x00be6fb9: inc %edi ;*iinc ; - performance.Performance$VariableAndIndexInLoop::howToDo@26 (line 44) 0x00be6fba: cmp %edx,%edi 0x00be6fbc: jl 0x00be6fa1 0x00be6fbe: mov $0x989680,%ebx 0x00be6fc3: sub %edi,%ebx 0x00be6fc5: and $0xfffffff0,%ebx 0x00be6fc8: add %edi,%ebx 0x00be6fca: cmp %ebx,%edi 0x00be6fcc: jge 0x00be7021 0x00be6fce: jmp 0x00be6fd2 0x00be6fd0: mov %esi,%ecx ;*getfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@18 (line 46) 0x00be6fd2: add 0xc(%eax,%edi,4),%ecx 0x00be6fd6: add 0x10(%eax,%edi,4),%ecx 0x00be6fda: add 0x14(%eax,%edi,4),%ecx 0x00be6fde: add 0x18(%eax,%edi,4),%ecx 0x00be6fe2: add 0x1c(%eax,%edi,4),%ecx 0x00be6fe6: add 0x20(%eax,%edi,4),%ecx 0x00be6fea: add 0x24(%eax,%edi,4),%ecx 0x00be6fee: add 0x28(%eax,%edi,4),%ecx 0x00be6ff2: add 0x2c(%eax,%edi,4),%ecx 0x00be6ff6: add 0x30(%eax,%edi,4),%ecx 0x00be6ffa: add 0x34(%eax,%edi,4),%ecx 0x00be6ffe: add 0x38(%eax,%edi,4),%ecx 0x00be7002: add 0x3c(%eax,%edi,4),%ecx 0x00be7006: add 0x40(%eax,%edi,4),%ecx 0x00be700a: add 0x44(%eax,%edi,4),%ecx 0x00be700e: mov %ecx,%esi 0x00be7010: add 0x48(%eax,%edi,4),%esi ;*iadd ; - performance.Performance$VariableAndIndexInLoop::howToDo@22 (line 46) 0x00be7014: mov %ecx,0x8(%ebp) 0x00be7017: mov %esi,0x8(%ebp) ;*putfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@23 (line 46) 0x00be701a: add $0x10,%edi ;*iinc ; - performance.Performance$VariableAndIndexInLoop::howToDo@26 (line 44) 0x00be701d: cmp %ebx,%edi 0x00be701f: jl 0x00be6fd0 0x00be7021: cmp $0x989680,%edi 0x00be7027: jge 0x00be7049 0x00be7029: nop 0x00be702a: nop 0x00be702b: nop ;*getstatic data ; - performance.Performance$VariableAndIndexInLoop::howToDo@10 (line 45) 0x00be702c: cmp $0x989680,%edi 0x00be7032: jae 0x00be705e 0x00be7034: mov 0xc(%eax,%edi,4),%ebx ;*iaload ; - performance.Performance$VariableAndIndexInLoop::howToDo@14 (line 45) 0x00be7038: mov 0x8(%ebp),%ecx ;*getfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@18 (line 46) 0x00be703b: add %ebx,%ecx 0x00be703d: mov %ecx,0x8(%ebp) ;*putfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@23 (line 46) 0x00be7040: inc %edi ;*iinc ; - performance.Performance$VariableAndIndexInLoop::howToDo@26 (line 44) 0x00be7041: cmp $0x989680,%edi 0x00be7047: jl 0x00be702c ;*iload_1 ; - performance.Performance$VariableAndIndexInLoop::howToDo@2 (line 44) 0x00be7049: add $0x18,%esp 0x00be704c: pop %ebp 0x00be704d: test %eax,0x9c0000 ; {poll_return} 0x00be7053: ret 0x00be7054: mov $0x0,%ebp 0x00be7059: jmp 0x00be6f77 0x00be705e: mov $0xffffffe4,%ecx 0x00be7063: mov %eax,0x8(%esp) 0x00be7067: mov %edi,0xc(%esp) 0x00be706b: call 0x00bca680 ; OopMap{ebp=Oop [8]=Oop off=304} ;*iaload ; - performance.Performance$VariableAndIndexInLoop::howToDo@14 (line 45) ; {runtime_call} 0x00be7070: int3 ;*getstatic data ; - performance.Performance$VariableAndIndexInLoop::howToDo@10 (line 45) 0x00be7071: mov $0xffffff86,%ecx 0x00be7076: mov %edi,0x4(%esp) 0x00be707a: nop 0x00be707b: call 0x00bca680 ; OopMap{ebp=Oop off=320} ;*getstatic data ; - performance.Performance$VariableAndIndexInLoop::howToDo@10 (line 45) ; {runtime_call} 0x00be7080: int3 0x00be7081: mov $0xffffffad,%ecx 0x00be7086: mov %edi,0x4(%esp) 0x00be708a: nop 0x00be708b: call 0x00bca680 ; OopMap{ebp=Oop off=336} ;*iload_1 ; - performance.Performance$VariableAndIndexInLoop::howToDo@2 (line 44) ; {runtime_call} 0x00be7090: int3 ;*getstatic data ; - performance.Performance$VariableAndIndexInLoop::howToDo@10 (line 45) 0x00be7091: hlt 0x00be7092: hlt 0x00be7093: hlt 0x00be7094: hlt 0x00be7095: hlt 0x00be7096: hlt 0x00be7097: hlt 0x00be7098: hlt 0x00be7099: hlt 0x00be709a: hlt 0x00be709b: hlt 0x00be709c: hlt 0x00be709d: hlt 0x00be709e: hlt [Deopt MH Handler Code] 0x00be709f: hlt [Exception Handler] [Stub Code] 0x00be70a0: jmp 0x00be4d40 ; {no_reloc} [Deopt Handler Code] 0x00be70a5: push $0xbe70a5 ; {section_word} 0x00be70aa: jmp 0x00bcbb40 ; {runtime_call} [Constants] 0x00be70af: int3 标准编译: Decoding compiled method 0x00be72c8: Code: [Disassembling for mach='i386'] [Entry Point] # {method} 'howToDo' '()V' in 'performance/Performance$VariableAndIndexInLoop' # [sp+0x20] (sp of caller) 0x00be73a0: cmp 0x4(%ecx),%eax 0x00be73a3: jne 0x00bcae20 ; {runtime_call} 0x00be73a9: nop 0x00be73aa: nop 0x00be73ab: nop [Verified Entry Point] 0x00be73ac: mov %eax,-0x4000(%esp) 0x00be73b3: push %ebp 0x00be73b4: sub $0x18,%esp ;*synchronization entry ; - performance.Performance$VariableAndIndexInLoop::howToDo@-1 (line 44) 0x00be73ba: mov %ecx,%ebx 0x00be73bc: xor %eax,%eax 0x00be73be: mov $0x158,%ebp 0x00be73c3: mov 0x1024f058(%ebp),%edi ;*getstatic data ; - performance.Performance$VariableAndIndexInLoop::howToDo@10 (line 45) ; {oop('performance/Performance$Strategy')} 0x00be73c9: cmp $0x989680,%eax ; loop invariant code motion/array bounds check hoisting 0x00be73cf: jae 0x00be747c 0x00be73d5: mov 0xc(%edi,%eax,4),%edx ;*iaload ; - performance.Performance$VariableAndIndexInLoop::howToDo@14 (line 45) 0x00be73d9: mov 0x8(%ebx),%ebp ;*getfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@18 (line 46) 0x00be73dc: add %ebp,%edx ;*iadd ; - performance.Performance$VariableAndIndexInLoop::howToDo@22 (line 46) 0x00be73de: mov %edx,0x8(%ebx) ;*putfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@23 (line 46) 0x00be73e1: inc %eax ;*iinc ; - performance.Performance$VariableAndIndexInLoop::howToDo@26 (line 44) 0x00be73e2: cmp $0x1,%eax 0x00be73e5: jl 0x00be73c9 0x00be73e7: mov $0x989680,%ebp 0x00be73ec: sub %eax,%ebp 0x00be73ee: and $0xfffffff0,%ebp 0x00be73f1: add %eax,%ebp 0x00be73f3: cmp %ebp,%eax 0x00be73f5: jge 0x00be744a 0x00be73f7: nop 0x00be73f8: nop 0x00be73f9: nop 0x00be73fa: nop 0x00be73fb: nop 0x00be73fc: nop 0x00be73fd: nop 0x00be73fe: nop 0x00be73ff: nop ;*getfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@18 (line 46) 0x00be7400: add 0xc(%edi,%eax,4),%edx 0x00be7404: add 0x10(%edi,%eax,4),%edx 0x00be7408: add 0x14(%edi,%eax,4),%edx 0x00be740c: add 0x18(%edi,%eax,4),%edx 0x00be7410: add 0x1c(%edi,%eax,4),%edx 0x00be7414: add 0x20(%edi,%eax,4),%edx 0x00be7418: add 0x24(%edi,%eax,4),%edx 0x00be741c: add 0x28(%edi,%eax,4),%edx 0x00be7420: add 0x2c(%edi,%eax,4),%edx 0x00be7424: add 0x30(%edi,%eax,4),%edx 0x00be7428: add 0x34(%edi,%eax,4),%edx 0x00be742c: add 0x38(%edi,%eax,4),%edx 0x00be7430: add 0x3c(%edi,%eax,4),%edx 0x00be7434: add 0x40(%edi,%eax,4),%edx 0x00be7438: add 0x44(%edi,%eax,4),%edx 0x00be743c: add 0x48(%edi,%eax,4),%edx ;*iadd ; - performance.Performance$VariableAndIndexInLoop::howToDo@22 (line 46) 0x00be7440: mov %edx,0x8(%ebx) ;*putfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@23 (line 46) 0x00be7443: add $0x10,%eax ;*iinc ; - performance.Performance$VariableAndIndexInLoop::howToDo@26 (line 44) 0x00be7446: cmp %ebp,%eax 0x00be7448: jl 0x00be7400 0x00be744a: cmp $0x989680,%eax 0x00be7450: jge 0x00be7471 0x00be7452: nop 0x00be7453: nop ;*getstatic data ; - performance.Performance$VariableAndIndexInLoop::howToDo@10 (line 45) 0x00be7454: cmp $0x989680,%eax 0x00be745a: jae 0x00be747c 0x00be745c: mov 0xc(%edi,%eax,4),%ecx ;*iaload ; - performance.Performance$VariableAndIndexInLoop::howToDo@14 (line 45) 0x00be7460: mov 0x8(%ebx),%edx ;*getfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@18 (line 46) 0x00be7463: add %edx,%ecx 0x00be7465: mov %ecx,0x8(%ebx) ;*putfield sum ; - performance.Performance$VariableAndIndexInLoop::howToDo@23 (line 46) 0x00be7468: inc %eax ;*iinc ; - performance.Performance$VariableAndIndexInLoop::howToDo@26 (line 44) 0x00be7469: cmp $0x989680,%eax 0x00be746f: jl 0x00be7454 0x00be7471: add $0x18,%esp 0x00be7474: pop %ebp 0x00be7475: test %eax,0x9c0000 ; {poll_return} 0x00be747b: ret ;*getstatic data ; - performance.Performance$VariableAndIndexInLoop::howToDo@10 (line 45) 0x00be747c: mov $0xffffffe4,%ecx 0x00be7481: mov %ebx,%ebp 0x00be7483: mov %edi,0x4(%esp) 0x00be7487: mov %eax,0x8(%esp) 0x00be748b: call 0x00bca680 ; OopMap{ebp=Oop [4]=Oop off=240} ;*iaload ; - performance.Performance$VariableAndIndexInLoop::howToDo@14 (line 45) ; {runtime_call} 0x00be7490: int3 ;*iaload ; - performance.Performance$VariableAndIndexInLoop::howToDo@14 (line 45) 0x00be7491: hlt 0x00be7492: hlt 0x00be7493: hlt 0x00be7494: hlt 0x00be7495: hlt 0x00be7496: hlt 0x00be7497: hlt 0x00be7498: hlt 0x00be7499: hlt 0x00be749a: hlt 0x00be749b: hlt 0x00be749c: hlt 0x00be749d: hlt 0x00be749e: hlt [Deopt MH Handler Code] 0x00be749f: hlt [Exception Handler] [Stub Code] 0x00be74a0: jmp 0x00be4d40 ; {no_reloc} [Deopt Handler Code] 0x00be74a5: push $0xbe74a5 ; {section_word} 0x00be74aa: jmp 0x00bcbb40 ; {runtime_call} [Constants] 0x00be74af: int3 OSR编译: Decoding compiled method 0x00be7688: Code: [Disassembling for mach='i386'] [Entry Point] [Verified Entry Point] # {method} 'howToDo' '()V' in 'performance/Performance$SingleVariableIndexInLoop' 0x00be7780: int3 0x00be7781: nop 0x00be7782: nop 0x00be7783: nop 0x00be7784: mov %eax,-0x4000(%esp) 0x00be778b: push %ebp 0x00be778c: sub $0x18,%esp 0x00be7792: mov (%ecx),%edi 0x00be7794: mov 0x8(%ecx),%ebp 0x00be7797: mov %ecx,(%esp) 0x00be779a: call 0x084b6ca0 ; {runtime_call} 0x00be779f: test %ebp,%ebp 0x00be77a1: je 0x00be7894 0x00be77a7: mov 0x4(%ebp),%ebx 0x00be77aa: cmp $0x1024f888,%ebx ; {oop('performance/Performance$SingleVariableIndexInLoop')} 0x00be77b0: jne 0x00be78c1 ;*iload_2 ; - performance.Performance$SingleVariableIndexInLoop::howToDo@2 (line 54) 0x00be77b6: cmp $0x989680,%edi 0x00be77bc: jge 0x00be7889 ;*if_icmpge ; - performance.Performance$SingleVariableIndexInLoop::howToDo@7 (line 54) 0x00be77c2: test %ebp,%ebp 0x00be77c4: je 0x00be78b1 0x00be77ca: mov %edi,%edx 0x00be77cc: inc %edx 0x00be77cd: xor %ebx,%ebx 0x00be77cf: cmp %ebx,%edx 0x00be77d1: jg 0x00be77d5 0x00be77d3: mov %ebx,%edx 0x00be77d5: mov $0x158,%ebx 0x00be77da: mov 0x1024f058(%ebx),%eax ;*getstatic data ; - performance.Performance$SingleVariableIndexInLoop::howToDo@10 (line 55) ; {oop('performance/Performance$Strategy')} 0x00be77e0: cmp $0x989680,%edi 0x00be77e6: jae 0x00be789e 0x00be77ec: mov 0xc(%eax,%edi,4),%ebx ;*iaload ; - performance.Performance$SingleVariableIndexInLoop::howToDo@14 (line 55) 0x00be77f0: mov 0x8(%ebp),%ecx ;*getfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@18 (line 56) 0x00be77f3: add %ebx,%ecx ;*iadd ; - performance.Performance$SingleVariableIndexInLoop::howToDo@22 (line 56) 0x00be77f5: mov %ecx,0x8(%ebp) ;*putfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@23 (line 56) 0x00be77f8: inc %edi ;*iinc ; - performance.Performance$SingleVariableIndexInLoop::howToDo@26 (line 54) 0x00be77f9: cmp %edx,%edi 0x00be77fb: jl 0x00be77e0 0x00be77fd: mov $0x989680,%ebx 0x00be7802: sub %edi,%ebx 0x00be7804: and $0xfffffff0,%ebx 0x00be7807: add %edi,%ebx 0x00be7809: cmp %ebx,%edi 0x00be780b: jge 0x00be7861 0x00be780d: jmp 0x00be7812 0x00be780f: nop 0x00be7810: mov %esi,%ecx ;*getfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@18 (line 56) 0x00be7812: add 0xc(%eax,%edi,4),%ecx 0x00be7816: add 0x10(%eax,%edi,4),%ecx 0x00be781a: add 0x14(%eax,%edi,4),%ecx 0x00be781e: add 0x18(%eax,%edi,4),%ecx 0x00be7822: add 0x1c(%eax,%edi,4),%ecx 0x00be7826: add 0x20(%eax,%edi,4),%ecx 0x00be782a: add 0x24(%eax,%edi,4),%ecx 0x00be782e: add 0x28(%eax,%edi,4),%ecx 0x00be7832: add 0x2c(%eax,%edi,4),%ecx 0x00be7836: add 0x30(%eax,%edi,4),%ecx 0x00be783a: add 0x34(%eax,%edi,4),%ecx 0x00be783e: add 0x38(%eax,%edi,4),%ecx 0x00be7842: add 0x3c(%eax,%edi,4),%ecx 0x00be7846: add 0x40(%eax,%edi,4),%ecx 0x00be784a: add 0x44(%eax,%edi,4),%ecx 0x00be784e: mov %ecx,%esi 0x00be7850: add 0x48(%eax,%edi,4),%esi ;*iadd ; - performance.Performance$SingleVariableIndexInLoop::howToDo@22 (line 56) 0x00be7854: mov %ecx,0x8(%ebp) 0x00be7857: mov %esi,0x8(%ebp) ;*putfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@23 (line 56) 0x00be785a: add $0x10,%edi ;*iinc ; - performance.Performance$SingleVariableIndexInLoop::howToDo@26 (line 54) 0x00be785d: cmp %ebx,%edi 0x00be785f: jl 0x00be7810 0x00be7861: cmp $0x989680,%edi 0x00be7867: jge 0x00be7889 0x00be7869: nop 0x00be786a: nop 0x00be786b: nop ;*getstatic data ; - performance.Performance$SingleVariableIndexInLoop::howToDo@10 (line 55) 0x00be786c: cmp $0x989680,%edi 0x00be7872: jae 0x00be789e 0x00be7874: mov 0xc(%eax,%edi,4),%ebx ;*iaload ; - performance.Performance$SingleVariableIndexInLoop::howToDo@14 (line 55) 0x00be7878: mov 0x8(%ebp),%ecx ;*getfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@18 (line 56) 0x00be787b: add %ebx,%ecx 0x00be787d: mov %ecx,0x8(%ebp) ;*putfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@23 (line 56) 0x00be7880: inc %edi ;*iinc ; - performance.Performance$SingleVariableIndexInLoop::howToDo@26 (line 54) 0x00be7881: cmp $0x989680,%edi 0x00be7887: jl 0x00be786c ;*iload_2 ; - performance.Performance$SingleVariableIndexInLoop::howToDo@2 (line 54) 0x00be7889: add $0x18,%esp 0x00be788c: pop %ebp 0x00be788d: test %eax,0x9c0000 ; {poll_return} 0x00be7893: ret 0x00be7894: mov $0x0,%ebp 0x00be7899: jmp 0x00be77b6 0x00be789e: mov $0xffffffe4,%ecx 0x00be78a3: mov %eax,0x8(%esp) 0x00be78a7: mov %edi,0xc(%esp) 0x00be78ab: call 0x00bca680 ; OopMap{ebp=Oop [8]=Oop off=304} ;*iaload ; - performance.Performance$SingleVariableIndexInLoop::howToDo@14 (line 55) ; {runtime_call} 0x00be78b0: int3 ;*getstatic data ; - performance.Performance$SingleVariableIndexInLoop::howToDo@10 (line 55) 0x00be78b1: mov $0xffffff86,%ecx 0x00be78b6: mov %edi,0x4(%esp) 0x00be78ba: nop 0x00be78bb: call 0x00bca680 ; OopMap{ebp=Oop off=320} ;*getstatic data ; - performance.Performance$SingleVariableIndexInLoop::howToDo@10 (line 55) ; {runtime_call} 0x00be78c0: int3 0x00be78c1: mov $0xffffffad,%ecx 0x00be78c6: mov %edi,0x4(%esp) 0x00be78ca: nop 0x00be78cb: call 0x00bca680 ; OopMap{ebp=Oop off=336} ;*iload_2 ; - performance.Performance$SingleVariableIndexInLoop::howToDo@2 (line 54) ; {runtime_call} 0x00be78d0: int3 ;*getstatic data ; - performance.Performance$SingleVariableIndexInLoop::howToDo@10 (line 55) 0x00be78d1: hlt 0x00be78d2: hlt 0x00be78d3: hlt 0x00be78d4: hlt 0x00be78d5: hlt 0x00be78d6: hlt 0x00be78d7: hlt 0x00be78d8: hlt 0x00be78d9: hlt 0x00be78da: hlt 0x00be78db: hlt 0x00be78dc: hlt 0x00be78dd: hlt 0x00be78de: hlt [Deopt MH Handler Code] 0x00be78df: hlt [Exception Handler] [Stub Code] 0x00be78e0: jmp 0x00be4d40 ; {no_reloc} [Deopt Handler Code] 0x00be78e5: push $0xbe78e5 ; {section_word} 0x00be78ea: jmp 0x00bcbb40 ; {runtime_call} [Constants] 0x00be78ef: int3 标准编译: Decoding compiled method 0x00be7b08: Code: [Disassembling for mach='i386'] [Entry Point] # {method} 'howToDo' '()V' in 'performance/Performance$SingleVariableIndexInLoop' # [sp+0x20] (sp of caller) 0x00be7be0: cmp 0x4(%ecx),%eax 0x00be7be3: jne 0x00bcae20 ; {runtime_call} 0x00be7be9: nop 0x00be7bea: nop 0x00be7beb: nop [Verified Entry Point] 0x00be7bec: mov %eax,-0x4000(%esp) 0x00be7bf3: push %ebp 0x00be7bf4: sub $0x18,%esp ;*synchronization entry ; - performance.Performance$SingleVariableIndexInLoop::howToDo@-1 (line 54) 0x00be7bfa: mov %ecx,%ebx 0x00be7bfc: xor %eax,%eax 0x00be7bfe: mov $0x158,%ebp 0x00be7c03: mov 0x1024f058(%ebp),%edi ;*getstatic data ; - performance.Performance$SingleVariableIndexInLoop::howToDo@10 (line 55) ; {oop('performance/Performance$Strategy')} 0x00be7c09: cmp $0x989680,%eax 0x00be7c0f: jae 0x00be7cbc 0x00be7c15: mov 0xc(%edi,%eax,4),%edx ;*iaload ; - performance.Performance$SingleVariableIndexInLoop::howToDo@14 (line 55) 0x00be7c19: mov 0x8(%ebx),%ebp ;*getfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@18 (line 56) 0x00be7c1c: add %ebp,%edx ;*iadd ; - performance.Performance$SingleVariableIndexInLoop::howToDo@22 (line 56) 0x00be7c1e: mov %edx,0x8(%ebx) ;*putfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@23 (line 56) 0x00be7c21: inc %eax ;*iinc ; - performance.Performance$SingleVariableIndexInLoop::howToDo@26 (line 54) 0x00be7c22: cmp $0x1,%eax 0x00be7c25: jl 0x00be7c09 0x00be7c27: mov $0x989680,%ebp 0x00be7c2c: sub %eax,%ebp 0x00be7c2e: and $0xfffffff0,%ebp 0x00be7c31: add %eax,%ebp 0x00be7c33: cmp %ebp,%eax 0x00be7c35: jge 0x00be7c8a 0x00be7c37: nop 0x00be7c38: nop 0x00be7c39: nop 0x00be7c3a: nop 0x00be7c3b: nop 0x00be7c3c: nop 0x00be7c3d: nop 0x00be7c3e: nop 0x00be7c3f: nop ;*getfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@18 (line 56) 0x00be7c40: add 0xc(%edi,%eax,4),%edx 0x00be7c44: add 0x10(%edi,%eax,4),%edx 0x00be7c48: add 0x14(%edi,%eax,4),%edx 0x00be7c4c: add 0x18(%edi,%eax,4),%edx 0x00be7c50: add 0x1c(%edi,%eax,4),%edx 0x00be7c54: add 0x20(%edi,%eax,4),%edx 0x00be7c58: add 0x24(%edi,%eax,4),%edx 0x00be7c5c: add 0x28(%edi,%eax,4),%edx 0x00be7c60: add 0x2c(%edi,%eax,4),%edx 0x00be7c64: add 0x30(%edi,%eax,4),%edx 0x00be7c68: add 0x34(%edi,%eax,4),%edx 0x00be7c6c: add 0x38(%edi,%eax,4),%edx 0x00be7c70: add 0x3c(%edi,%eax,4),%edx 0x00be7c74: add 0x40(%edi,%eax,4),%edx 0x00be7c78: add 0x44(%edi,%eax,4),%edx 0x00be7c7c: add 0x48(%edi,%eax,4),%edx ;*iadd ; - performance.Performance$SingleVariableIndexInLoop::howToDo@22 (line 56) 0x00be7c80: mov %edx,0x8(%ebx) ;*putfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@23 (line 56) 0x00be7c83: add $0x10,%eax ;*iinc ; - performance.Performance$SingleVariableIndexInLoop::howToDo@26 (line 54) 0x00be7c86: cmp %ebp,%eax 0x00be7c88: jl 0x00be7c40 0x00be7c8a: cmp $0x989680,%eax 0x00be7c90: jge 0x00be7cb1 0x00be7c92: nop 0x00be7c93: nop ;*getstatic data ; - performance.Performance$SingleVariableIndexInLoop::howToDo@10 (line 55) 0x00be7c94: cmp $0x989680,%eax 0x00be7c9a: jae 0x00be7cbc 0x00be7c9c: mov 0xc(%edi,%eax,4),%ecx ;*iaload ; - performance.Performance$SingleVariableIndexInLoop::howToDo@14 (line 55) 0x00be7ca0: mov 0x8(%ebx),%edx ;*getfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@18 (line 56) 0x00be7ca3: add %edx,%ecx 0x00be7ca5: mov %ecx,0x8(%ebx) ;*putfield sum ; - performance.Performance$SingleVariableIndexInLoop::howToDo@23 (line 56) 0x00be7ca8: inc %eax ;*iinc ; - performance.Performance$SingleVariableIndexInLoop::howToDo@26 (line 54) 0x00be7ca9: cmp $0x989680,%eax 0x00be7caf: jl 0x00be7c94 0x00be7cb1: add $0x18,%esp 0x00be7cb4: pop %ebp 0x00be7cb5: test %eax,0x9c0000 ; {poll_return} 0x00be7cbb: ret ;*getstatic data ; - performance.Performance$SingleVariableIndexInLoop::howToDo@10 (line 55) 0x00be7cbc: mov $0xffffffe4,%ecx 0x00be7cc1: mov %ebx,%ebp 0x00be7cc3: mov %edi,0x4(%esp) 0x00be7cc7: mov %eax,0x8(%esp) 0x00be7ccb: call 0x00bca680 ; OopMap{ebp=Oop [4]=Oop off=240} ;*iaload ; - performance.Performance$SingleVariableIndexInLoop::howToDo@14 (line 55) ; {runtime_call} 0x00be7cd0: int3 ;*iaload ; - performance.Performance$SingleVariableIndexInLoop::howToDo@14 (line 55) 0x00be7cd1: hlt 0x00be7cd2: hlt 0x00be7cd3: hlt 0x00be7cd4: hlt 0x00be7cd5: hlt 0x00be7cd6: hlt 0x00be7cd7: hlt 0x00be7cd8: hlt 0x00be7cd9: hlt 0x00be7cda: hlt 0x00be7cdb: hlt 0x00be7cdc: hlt 0x00be7cdd: hlt 0x00be7cde: hlt [Deopt MH Handler Code] 0x00be7cdf: hlt [Exception Handler] [Stub Code] 0x00be7ce0: jmp 0x00be4d40 ; {no_reloc} [Deopt Handler Code] 0x00be7ce5: push $0xbe7ce5 ; {section_word} 0x00be7cea: jmp 0x00bcbb40 ; {runtime_call} [Constants] 0x00be7cef: int3 OSR编译: Decoding compiled method 0x00be7ec8: Code: [Disassembling for mach='i386'] [Entry Point] [Verified Entry Point] # {method} 'howToDo' '()V' in 'performance/Performance$SingleVariableIndexOutLoop' 0x00be7fc0: int3 0x00be7fc1: nop 0x00be7fc2: nop 0x00be7fc3: nop 0x00be7fc4: mov %eax,-0x4000(%esp) 0x00be7fcb: push %ebp 0x00be7fcc: sub $0x18,%esp 0x00be7fd2: mov 0x4(%ecx),%ebx 0x00be7fd5: mov 0x8(%ecx),%esi 0x00be7fd8: mov %ecx,(%esp) 0x00be7fdb: call 0x084b6ca0 ; {runtime_call} 0x00be7fe0: test %esi,%esi 0x00be7fe2: je 0x00be80e8 0x00be7fe8: mov 0x4(%esi),%ecx 0x00be7feb: cmp $0x1024fc98,%ecx ; {oop('performance/Performance$SingleVariableIndexOutLoop')} 0x00be7ff1: jne 0x00be8121 ;*iload_1 ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@2 (line 64) 0x00be7ff7: cmp $0x989680,%ebx 0x00be7ffd: jge 0x00be80dd ;*if_icmpge ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@7 (line 64) 0x00be8003: test %esi,%esi 0x00be8005: je 0x00be810d 0x00be800b: mov %ebx,%edi 0x00be800d: inc %edi 0x00be800e: xor %ecx,%ecx 0x00be8010: cmp %ecx,%edi 0x00be8012: jg 0x00be8016 0x00be8014: mov %ecx,%edi 0x00be8016: mov $0x158,%ebp 0x00be801b: mov 0x1024f058(%ebp),%eax ;*getstatic data ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@10 (line 65) ; {oop('performance/Performance$Strategy')} 0x00be8021: mov %ebx,%edx 0x00be8023: inc %edx ;*iinc ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@14 (line 65) 0x00be8024: cmp $0x989680,%ebx 0x00be802a: jae 0x00be80f2 0x00be8030: mov 0xc(%eax,%ebx,4),%ecx ;*iaload ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@17 (line 65) 0x00be8034: mov 0x8(%esi),%ebp ;*getfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@21 (line 66) 0x00be8037: add %ecx,%ebp ;*iadd ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@25 (line 66) 0x00be8039: mov %ebp,0x8(%esi) ;*putfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@26 (line 66) 0x00be803c: cmp %edi,%edx 0x00be803e: jge 0x00be8044 0x00be8040: mov %edx,%ebx 0x00be8042: jmp 0x00be8021 0x00be8044: mov $0x989680,%ebx 0x00be8049: sub %edx,%ebx 0x00be804b: and $0xfffffff0,%ebx 0x00be804e: add %edx,%ebx 0x00be8050: cmp %ebx,%edx 0x00be8052: jge 0x00be80b1 0x00be8054: jmp 0x00be8062 0x00be8056: nop 0x00be8057: nop 0x00be8058: nop 0x00be8059: nop 0x00be805a: nop 0x00be805b: nop 0x00be805c: nop 0x00be805d: nop 0x00be805e: nop 0x00be805f: nop 0x00be8060: mov %ecx,%ebp ;*getfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@21 (line 66) 0x00be8062: add 0xc(%eax,%edx,4),%ebp 0x00be8066: add 0x10(%eax,%edx,4),%ebp 0x00be806a: add 0x14(%eax,%edx,4),%ebp 0x00be806e: add 0x18(%eax,%edx,4),%ebp 0x00be8072: add 0x1c(%eax,%edx,4),%ebp 0x00be8076: add 0x20(%eax,%edx,4),%ebp 0x00be807a: add 0x24(%eax,%edx,4),%ebp 0x00be807e: add 0x28(%eax,%edx,4),%ebp 0x00be8082: add 0x2c(%eax,%edx,4),%ebp 0x00be8086: add 0x30(%eax,%edx,4),%ebp 0x00be808a: add 0x34(%eax,%edx,4),%ebp 0x00be808e: add 0x38(%eax,%edx,4),%ebp 0x00be8092: add 0x3c(%eax,%edx,4),%ebp 0x00be8096: add 0x40(%eax,%edx,4),%ebp 0x00be809a: add 0x44(%eax,%edx,4),%ebp 0x00be809e: mov %ebp,%ecx 0x00be80a0: add 0x48(%eax,%edx,4),%ecx ;*iadd ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@25 (line 66) 0x00be80a4: mov %ebp,0x8(%esi) 0x00be80a7: mov %ecx,0x8(%esi) ;*putfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@26 (line 66) 0x00be80aa: add $0x10,%edx ;*iinc ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@14 (line 65) 0x00be80ad: cmp %ebx,%edx 0x00be80af: jl 0x00be8060 0x00be80b1: cmp $0x989680,%edx 0x00be80b7: jl 0x00be80be 0x00be80b9: jmp 0x00be80dd 0x00be80bb: nop 0x00be80bc: mov %ebp,%edx ;*getstatic data ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@10 (line 65) 0x00be80be: mov %edx,%ebp 0x00be80c0: inc %ebp ;*iinc ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@14 (line 65) 0x00be80c1: cmp $0x989680,%edx 0x00be80c7: jae 0x00be80f6 0x00be80c9: mov 0xc(%eax,%edx,4),%ebx ;*iaload ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@17 (line 65) 0x00be80cd: mov 0x8(%esi),%ecx ;*getfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@21 (line 66) 0x00be80d0: add %ebx,%ecx 0x00be80d2: mov %ecx,0x8(%esi) ;*putfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@26 (line 66) 0x00be80d5: cmp $0x989680,%ebp 0x00be80db: jl 0x00be80bc ;*iload_1 ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@2 (line 64) 0x00be80dd: add $0x18,%esp 0x00be80e0: pop %ebp 0x00be80e1: test %eax,0x9c0000 ; {poll_return} 0x00be80e7: ret 0x00be80e8: mov $0x0,%esi 0x00be80ed: jmp 0x00be7ff7 0x00be80f2: mov %edx,%ebp 0x00be80f4: mov %ebx,%edx 0x00be80f6: mov $0xffffffe4,%ecx 0x00be80fb: mov %esi,0x4(%esp) 0x00be80ff: mov %eax,0x8(%esp) 0x00be8103: mov %edx,0xc(%esp) 0x00be8107: call 0x00bca680 ; OopMap{[4]=Oop [8]=Oop off=332} ;*iaload ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@17 (line 65) ; {runtime_call} 0x00be810c: int3 ;*getstatic data ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@10 (line 65) 0x00be810d: mov $0xffffff86,%ecx 0x00be8112: mov %esi,%ebp 0x00be8114: mov %ebx,0x4(%esp) 0x00be8118: nop 0x00be8119: nop 0x00be811a: nop 0x00be811b: call 0x00bca680 ; OopMap{ebp=Oop off=352} ;*getstatic data ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@10 (line 65) ; {runtime_call} 0x00be8120: int3 0x00be8121: mov $0xffffffad,%ecx 0x00be8126: mov %esi,%ebp 0x00be8128: mov %ebx,0x4(%esp) 0x00be812c: nop 0x00be812d: nop 0x00be812e: nop 0x00be812f: call 0x00bca680 ; OopMap{ebp=Oop off=372} ;*iload_1 ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@2 (line 64) ; {runtime_call} 0x00be8134: int3 ;*getstatic data ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@10 (line 65) 0x00be8135: hlt 0x00be8136: hlt 0x00be8137: hlt 0x00be8138: hlt 0x00be8139: hlt 0x00be813a: hlt 0x00be813b: hlt 0x00be813c: hlt 0x00be813d: hlt 0x00be813e: hlt [Deopt MH Handler Code] 0x00be813f: hlt [Exception Handler] [Stub Code] 0x00be8140: jmp 0x00be4d40 ; {no_reloc} [Deopt Handler Code] 0x00be8145: push $0xbe8145 ; {section_word} 0x00be814a: jmp 0x00bcbb40 ; {runtime_call} [Constants] 0x00be814f: int3 标准编译: Decoding compiled method 0x00be8388: Code: [Disassembling for mach='i386'] [Entry Point] # {method} 'howToDo' '()V' in 'performance/Performance$SingleVariableIndexOutLoop' # [sp+0x20] (sp of caller) 0x00be8460: cmp 0x4(%ecx),%eax 0x00be8463: jne 0x00bcae20 ; {runtime_call} 0x00be8469: nop 0x00be846a: nop 0x00be846b: nop [Verified Entry Point] 0x00be846c: mov %eax,-0x4000(%esp) 0x00be8473: push %ebp 0x00be8474: sub $0x18,%esp ;*synchronization entry ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@-1 (line 64) 0x00be847a: mov %ecx,%ebx 0x00be847c: xor %ecx,%ecx 0x00be847e: mov $0x158,%ebp 0x00be8483: mov 0x1024f058(%ebp),%edi ;*getstatic data ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@10 (line 65) ; {oop('performance/Performance$Strategy')} 0x00be8489: mov %ecx,%edx 0x00be848b: inc %edx ;*iinc ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@14 (line 65) 0x00be848c: cmp $0x989680,%ecx 0x00be8492: jae 0x00be8540 0x00be8498: mov 0xc(%edi,%ecx,4),%eax ;*iaload ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@17 (line 65) 0x00be849c: mov 0x8(%ebx),%ebp ;*getfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@21 (line 66) 0x00be849f: add %ebp,%eax ;*iadd ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@25 (line 66) 0x00be84a1: mov %eax,0x8(%ebx) ;*putfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@26 (line 66) 0x00be84a4: cmp $0x1,%edx 0x00be84a7: jge 0x00be84ad 0x00be84a9: mov %edx,%ecx 0x00be84ab: jmp 0x00be8489 0x00be84ad: mov $0x989680,%ecx 0x00be84b2: sub %edx,%ecx 0x00be84b4: and $0xfffffff0,%ecx 0x00be84b7: add %edx,%ecx 0x00be84b9: cmp %ecx,%edx 0x00be84bb: jge 0x00be850a 0x00be84bd: nop 0x00be84be: nop 0x00be84bf: nop ;*getfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@21 (line 66) 0x00be84c0: add 0xc(%edi,%edx,4),%eax 0x00be84c4: add 0x10(%edi,%edx,4),%eax 0x00be84c8: add 0x14(%edi,%edx,4),%eax 0x00be84cc: add 0x18(%edi,%edx,4),%eax 0x00be84d0: add 0x1c(%edi,%edx,4),%eax 0x00be84d4: add 0x20(%edi,%edx,4),%eax 0x00be84d8: add 0x24(%edi,%edx,4),%eax 0x00be84dc: add 0x28(%edi,%edx,4),%eax 0x00be84e0: add 0x2c(%edi,%edx,4),%eax 0x00be84e4: add 0x30(%edi,%edx,4),%eax 0x00be84e8: add 0x34(%edi,%edx,4),%eax 0x00be84ec: add 0x38(%edi,%edx,4),%eax 0x00be84f0: add 0x3c(%edi,%edx,4),%eax 0x00be84f4: add 0x40(%edi,%edx,4),%eax 0x00be84f8: add 0x44(%edi,%edx,4),%eax 0x00be84fc: add 0x48(%edi,%edx,4),%eax ;*iadd ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@25 (line 66) 0x00be8500: mov %eax,0x8(%ebx) ;*putfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@26 (line 66) 0x00be8503: add $0x10,%edx ;*iinc ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@14 (line 65) 0x00be8506: cmp %ecx,%edx 0x00be8508: jl 0x00be84c0 0x00be850a: cmp $0x989680,%edx 0x00be8510: jl 0x00be8516 0x00be8512: jmp 0x00be8535 0x00be8514: mov %ebp,%edx ;*getstatic data ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@10 (line 65) 0x00be8516: mov %edx,%ebp 0x00be8518: inc %ebp ;*iinc ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@14 (line 65) 0x00be8519: cmp $0x989680,%edx 0x00be851f: jae 0x00be8544 0x00be8521: mov 0xc(%edi,%edx,4),%ecx ;*iaload ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@17 (line 65) 0x00be8525: mov 0x8(%ebx),%edx ;*getfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@21 (line 66) 0x00be8528: add %edx,%ecx 0x00be852a: mov %ecx,0x8(%ebx) ;*putfield sum ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@26 (line 66) 0x00be852d: cmp $0x989680,%ebp 0x00be8533: jl 0x00be8514 0x00be8535: add $0x18,%esp 0x00be8538: pop %ebp 0x00be8539: test %eax,0x9c0000 ; {poll_return} 0x00be853f: ret 0x00be8540: mov %edx,%ebp 0x00be8542: mov %ecx,%edx ;*getstatic data ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@10 (line 65) 0x00be8544: mov $0xffffffe4,%ecx 0x00be8549: mov %ebx,(%esp) 0x00be854c: mov %edi,0x4(%esp) 0x00be8550: mov %edx,0x8(%esp) 0x00be8554: nop 0x00be8555: nop 0x00be8556: nop 0x00be8557: call 0x00bca680 ; OopMap{[0]=Oop [4]=Oop off=252} ;*iaload ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@17 (line 65) ; {runtime_call} 0x00be855c: int3 ;*iaload ; - performance.Performance$SingleVariableIndexOutLoop::howToDo@17 (line 65) 0x00be855d: hlt 0x00be855e: hlt [Deopt MH Handler Code] 0x00be855f: hlt [Exception Handler] [Stub Code] 0x00be8560: jmp 0x00be4d40 ; {no_reloc} [Deopt Handler Code] 0x00be8565: push $0xbe8565 ; {section_word} 0x00be856a: jmp 0x00bcbb40 ; {runtime_call} [Constants] 0x00be856f: int3 OSR编译: Decoding compiled method 0x00be8748: Code: [Disassembling for mach='i386'] [Entry Point] [Verified Entry Point] # {method} 'howToDo' '()V' in 'performance/Performance$NoVariableIndexOutLoop' 0x00be8840: int3 0x00be8841: nop 0x00be8842: nop 0x00be8843: nop 0x00be8844: mov %eax,-0x4000(%esp) 0x00be884b: push %ebp 0x00be884c: sub $0x28,%esp 0x00be8852: mov (%ecx),%ebx 0x00be8854: mov 0x4(%ecx),%esi 0x00be8857: mov %ecx,(%esp) 0x00be885a: call 0x084b6ca0 ; {runtime_call} 0x00be885f: test %esi,%esi 0x00be8861: je 0x00be8968 0x00be8867: mov 0x4(%esi),%ecx 0x00be886a: cmp $0x102500a8,%ecx ; {oop('performance/Performance$NoVariableIndexOutLoop')} 0x00be8870: jne 0x00be89a5 ;*iload_1 ; - performance.Performance$NoVariableIndexOutLoop::howToDo@2 (line 74) 0x00be8876: cmp $0x989680,%ebx 0x00be887c: jge 0x00be895d ;*if_icmpge ; - performance.Performance$NoVariableIndexOutLoop::howToDo@7 (line 74) 0x00be8882: test %esi,%esi 0x00be8884: je 0x00be8991 0x00be888a: mov %ebx,%ebp 0x00be888c: inc %ebp 0x00be888d: xor %ecx,%ecx 0x00be888f: cmp %ecx,%ebp 0x00be8891: jg 0x00be8895 0x00be8893: mov %ecx,%ebp 0x00be8895: mov $0x158,%ecx 0x00be889a: mov 0x1024f058(%ecx),%edi ;*aload_0 ; - performance.Performance$NoVariableIndexOutLoop::howToDo@10 (line 75) ; {oop('performance/Performance$Strategy')} 0x00be88a0: mov 0x8(%esi),%edx ;*getfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@12 (line 75) 0x00be88a3: mov %ebx,%eax 0x00be88a5: inc %eax ;*iinc ; - performance.Performance$NoVariableIndexOutLoop::howToDo@19 (line 75) 0x00be88a6: cmp $0x989680,%ebx 0x00be88ac: jae 0x00be8972 0x00be88b2: mov 0xc(%edi,%ebx,4),%ecx ;*iaload ; - performance.Performance$NoVariableIndexOutLoop::howToDo@22 (line 75) 0x00be88b6: add %edx,%ecx ;*iadd ; - performance.Performance$NoVariableIndexOutLoop::howToDo@23 (line 75) 0x00be88b8: mov %ecx,0x8(%esi) ;*putfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@24 (line 75) 0x00be88bb: cmp %ebp,%eax 0x00be88bd: jge 0x00be88c3 0x00be88bf: mov %eax,%ebx 0x00be88c1: jmp 0x00be88a0 0x00be88c3: mov $0x989680,%ebx 0x00be88c8: sub %eax,%ebx 0x00be88ca: and $0xfffffff0,%ebx 0x00be88cd: add %eax,%ebx 0x00be88cf: cmp %ebx,%eax 0x00be88d1: jge 0x00be8931 0x00be88d3: jmp 0x00be88e2 0x00be88d5: nop 0x00be88d6: nop 0x00be88d7: nop 0x00be88d8: nop 0x00be88d9: nop 0x00be88da: nop 0x00be88db: nop 0x00be88dc: nop 0x00be88dd: nop 0x00be88de: nop 0x00be88df: nop 0x00be88e0: mov %ebp,%ecx ;*getfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@12 (line 75) 0x00be88e2: add 0xc(%edi,%eax,4),%ecx 0x00be88e6: add 0x10(%edi,%eax,4),%ecx 0x00be88ea: add 0x14(%edi,%eax,4),%ecx 0x00be88ee: add 0x18(%edi,%eax,4),%ecx 0x00be88f2: add 0x1c(%edi,%eax,4),%ecx 0x00be88f6: add 0x20(%edi,%eax,4),%ecx 0x00be88fa: add 0x24(%edi,%eax,4),%ecx 0x00be88fe: add 0x28(%edi,%eax,4),%ecx 0x00be8902: add 0x2c(%edi,%eax,4),%ecx 0x00be8906: add 0x30(%edi,%eax,4),%ecx 0x00be890a: add 0x34(%edi,%eax,4),%ecx 0x00be890e: add 0x38(%edi,%eax,4),%ecx 0x00be8912: add 0x3c(%edi,%eax,4),%ecx 0x00be8916: add 0x40(%edi,%eax,4),%ecx 0x00be891a: add 0x44(%edi,%eax,4),%ecx 0x00be891e: mov %ecx,%ebp 0x00be8920: add 0x48(%edi,%eax,4),%ebp ;*iadd ; - performance.Performance$NoVariableIndexOutLoop::howToDo@23 (line 75) 0x00be8924: mov %ecx,0x8(%esi) 0x00be8927: mov %ebp,0x8(%esi) ;*putfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@24 (line 75) 0x00be892a: add $0x10,%eax ;*iinc ; - performance.Performance$NoVariableIndexOutLoop::howToDo@19 (line 75) 0x00be892d: cmp %ebx,%eax 0x00be892f: jl 0x00be88e0 0x00be8931: cmp $0x989680,%eax 0x00be8937: jl 0x00be893e 0x00be8939: jmp 0x00be895d 0x00be893b: nop 0x00be893c: mov %ebp,%eax ;*aload_0 ; - performance.Performance$NoVariableIndexOutLoop::howToDo@10 (line 75) 0x00be893e: mov 0x8(%esi),%edx ;*getfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@12 (line 75) 0x00be8941: mov %eax,%ebp 0x00be8943: inc %ebp ;*iinc ; - performance.Performance$NoVariableIndexOutLoop::howToDo@19 (line 75) 0x00be8944: cmp $0x989680,%eax 0x00be894a: jae 0x00be8976 0x00be894c: mov 0xc(%edi,%eax,4),%ebx ;*iaload ; - performance.Performance$NoVariableIndexOutLoop::howToDo@22 (line 75) 0x00be8950: add %edx,%ebx 0x00be8952: mov %ebx,0x8(%esi) ;*putfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@24 (line 75) 0x00be8955: cmp $0x989680,%ebp 0x00be895b: jl 0x00be893c ;*iload_1 ; - performance.Performance$NoVariableIndexOutLoop::howToDo@2 (line 74) 0x00be895d: add $0x28,%esp 0x00be8960: pop %ebp 0x00be8961: test %eax,0x9c0000 ; {poll_return} 0x00be8967: ret 0x00be8968: mov $0x0,%esi 0x00be896d: jmp 0x00be8876 0x00be8972: mov %eax,%ebp 0x00be8974: mov %ebx,%eax 0x00be8976: mov $0xffffffe4,%ecx 0x00be897b: mov %esi,0x8(%esp) 0x00be897f: mov %edx,0xc(%esp) 0x00be8983: mov %edi,0x10(%esp) 0x00be8987: mov %eax,0x14(%esp) 0x00be898b: call 0x00bca680 ; OopMap{[8]=Oop [16]=Oop off=336} ;*iaload ; - performance.Performance$NoVariableIndexOutLoop::howToDo@22 (line 75) ; {runtime_call} 0x00be8990: int3 0x00be8991: mov $0xffffff86,%ecx 0x00be8996: mov %esi,%ebp 0x00be8998: mov %ebx,0x4(%esp) 0x00be899c: nop 0x00be899d: nop 0x00be899e: nop 0x00be899f: call 0x00bca680 ; OopMap{ebp=Oop off=356} ;*aload_0 ; - performance.Performance$NoVariableIndexOutLoop::howToDo@10 (line 75) ; {runtime_call} 0x00be89a4: int3 0x00be89a5: mov $0xffffffad,%ecx 0x00be89aa: mov %esi,%ebp 0x00be89ac: mov %ebx,0x4(%esp) 0x00be89b0: nop 0x00be89b1: nop 0x00be89b2: nop 0x00be89b3: call 0x00bca680 ; OopMap{ebp=Oop off=376} ;*iload_1 ; - performance.Performance$NoVariableIndexOutLoop::howToDo@2 (line 74) ; {runtime_call} 0x00be89b8: int3 ;*aload_0 ; - performance.Performance$NoVariableIndexOutLoop::howToDo@10 (line 75) 0x00be89b9: hlt 0x00be89ba: hlt 0x00be89bb: hlt 0x00be89bc: hlt 0x00be89bd: hlt 0x00be89be: hlt [Deopt MH Handler Code] 0x00be89bf: hlt [Exception Handler] [Stub Code] 0x00be89c0: jmp 0x00be4d40 ; {no_reloc} [Deopt Handler Code] 0x00be89c5: push $0xbe89c5 ; {section_word} 0x00be89ca: jmp 0x00bcbb40 ; {runtime_call} [Constants] 0x00be89cf: int3 标准编译: Decoding compiled method 0x00be8bc8: Code: [Disassembling for mach='i386'] [Entry Point] # {method} 'howToDo' '()V' in 'performance/Performance$NoVariableIndexOutLoop' # [sp+0x30] (sp of caller) 0x00be8ca0: cmp 0x4(%ecx),%eax 0x00be8ca3: jne 0x00bcae20 ; {runtime_call} 0x00be8ca9: nop 0x00be8caa: nop 0x00be8cab: nop [Verified Entry Point] 0x00be8cac: mov %eax,-0x4000(%esp) 0x00be8cb3: push %ebp 0x00be8cb4: sub $0x28,%esp ;*synchronization entry ; - performance.Performance$NoVariableIndexOutLoop::howToDo@-1 (line 74) 0x00be8cba: mov %ecx,%ebx 0x00be8cbc: xor %ecx,%ecx 0x00be8cbe: mov $0x158,%ebp 0x00be8cc3: mov 0x1024f058(%ebp),%edi ;*aload_0 ; - performance.Performance$NoVariableIndexOutLoop::howToDo@10 (line 75) ; {oop('performance/Performance$Strategy')} 0x00be8cc9: mov 0x8(%ebx),%eax ;*getfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@12 (line 75) 0x00be8ccc: mov %ecx,%esi 0x00be8cce: inc %esi ;*iinc ; - performance.Performance$NoVariableIndexOutLoop::howToDo@19 (line 75) 0x00be8ccf: cmp $0x989680,%ecx ; loop invariant code motion/array bounds check hoisting 0x00be8cd5: jae 0x00be8d80 0x00be8cdb: mov 0xc(%edi,%ecx,4),%edx ;*iaload ; - performance.Performance$NoVariableIndexOutLoop::howToDo@22 (line 75) 0x00be8cdf: add %eax,%edx ;*iadd ; - performance.Performance$NoVariableIndexOutLoop::howToDo@23 (line 75) 0x00be8ce1: mov %edx,0x8(%ebx) ;*putfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@24 (line 75) 0x00be8ce4: cmp $0x1,%esi 0x00be8ce7: jge 0x00be8ced 0x00be8ce9: mov %esi,%ecx 0x00be8ceb: jmp 0x00be8cc9 0x00be8ced: mov $0x989680,%ecx 0x00be8cf2: sub %esi,%ecx 0x00be8cf4: and $0xfffffff0,%ecx 0x00be8cf7: add %esi,%ecx 0x00be8cf9: cmp %ecx,%esi 0x00be8cfb: jge 0x00be8d4a 0x00be8cfd: nop 0x00be8cfe: nop 0x00be8cff: nop ;*getfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@12 (line 75) 0x00be8d00: add 0xc(%edi,%esi,4),%edx 0x00be8d04: add 0x10(%edi,%esi,4),%edx 0x00be8d08: add 0x14(%edi,%esi,4),%edx 0x00be8d0c: add 0x18(%edi,%esi,4),%edx 0x00be8d10: add 0x1c(%edi,%esi,4),%edx 0x00be8d14: add 0x20(%edi,%esi,4),%edx 0x00be8d18: add 0x24(%edi,%esi,4),%edx 0x00be8d1c: add 0x28(%edi,%esi,4),%edx 0x00be8d20: add 0x2c(%edi,%esi,4),%edx 0x00be8d24: add 0x30(%edi,%esi,4),%edx 0x00be8d28: add 0x34(%edi,%esi,4),%edx 0x00be8d2c: add 0x38(%edi,%esi,4),%edx 0x00be8d30: add 0x3c(%edi,%esi,4),%edx 0x00be8d34: add 0x40(%edi,%esi,4),%edx 0x00be8d38: add 0x44(%edi,%esi,4),%edx 0x00be8d3c: add 0x48(%edi,%esi,4),%edx ;*iadd ; - performance.Performance$NoVariableIndexOutLoop::howToDo@23 (line 75) 0x00be8d40: mov %edx,0x8(%ebx) ;*putfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@24 (line 75) 0x00be8d43: add $0x10,%esi ;*iinc ; - performance.Performance$NoVariableIndexOutLoop::howToDo@19 (line 75) 0x00be8d46: cmp %ecx,%esi 0x00be8d48: jl 0x00be8d00 0x00be8d4a: cmp $0x989680,%esi 0x00be8d50: jl 0x00be8d56 0x00be8d52: jmp 0x00be8d75 0x00be8d54: mov %ebp,%esi ;*aload_0 ; - performance.Performance$NoVariableIndexOutLoop::howToDo@10 (line 75) 0x00be8d56: mov 0x8(%ebx),%eax ;*getfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@12 (line 75) 0x00be8d59: mov %esi,%ebp 0x00be8d5b: inc %ebp ;*iinc ; - performance.Performance$NoVariableIndexOutLoop::howToDo@19 (line 75) 0x00be8d5c: cmp $0x989680,%esi 0x00be8d62: jae 0x00be8d84 0x00be8d64: mov 0xc(%edi,%esi,4),%ecx ;*iaload ; - performance.Performance$NoVariableIndexOutLoop::howToDo@22 (line 75) 0x00be8d68: add %eax,%ecx 0x00be8d6a: mov %ecx,0x8(%ebx) ;*putfield sum ; - performance.Performance$NoVariableIndexOutLoop::howToDo@24 (line 75) 0x00be8d6d: cmp $0x989680,%ebp 0x00be8d73: jl 0x00be8d54 0x00be8d75: add $0x28,%esp 0x00be8d78: pop %ebp 0x00be8d79: test %eax,0x9c0000 ; {poll_return} 0x00be8d7f: ret 0x00be8d80: mov %esi,%ebp 0x00be8d82: mov %ecx,%esi ;*aload_0 ; - performance.Performance$NoVariableIndexOutLoop::howToDo@10 (line 75) 0x00be8d84: mov $0xffffffe4,%ecx 0x00be8d89: mov %ebx,0x4(%esp) 0x00be8d8d: mov %eax,0x8(%esp) 0x00be8d91: mov %edi,0xc(%esp) 0x00be8d95: mov %esi,0x10(%esp) 0x00be8d99: nop 0x00be8d9a: nop 0x00be8d9b: call 0x00bca680 ; OopMap{[4]=Oop [12]=Oop off=256} ;*iaload ; - performance.Performance$NoVariableIndexOutLoop::howToDo@22 (line 75) ; {runtime_call} 0x00be8da0: int3 ;*iaload ; - performance.Performance$NoVariableIndexOutLoop::howToDo@22 (line 75) 0x00be8da1: hlt 0x00be8da2: hlt 0x00be8da3: hlt 0x00be8da4: hlt 0x00be8da5: hlt 0x00be8da6: hlt 0x00be8da7: hlt 0x00be8da8: hlt 0x00be8da9: hlt 0x00be8daa: hlt 0x00be8dab: hlt 0x00be8dac: hlt 0x00be8dad: hlt 0x00be8dae: hlt 0x00be8daf: hlt 0x00be8db0: hlt 0x00be8db1: hlt 0x00be8db2: hlt 0x00be8db3: hlt 0x00be8db4: hlt 0x00be8db5: hlt 0x00be8db6: hlt 0x00be8db7: hlt 0x00be8db8: hlt 0x00be8db9: hlt 0x00be8dba: hlt 0x00be8dbb: hlt 0x00be8dbc: hlt 0x00be8dbd: hlt 0x00be8dbe: hlt [Deopt MH Handler Code] 0x00be8dbf: hlt [Exception Handler] [Stub Code] 0x00be8dc0: jmp 0x00be4d40 ; {no_reloc} [Deopt Handler Code] 0x00be8dc5: push $0xbe8dc5 ; {section_word} 0x00be8dca: jmp 0x00bcbb40 ; {runtime_call} [Constants] 0x00be8dcf: int3 |
|
返回顶楼 | |
发表时间:2010-08-04
楼上的很bt啊
piao_bo_yi 写道 看了下那个帖子,感觉应该分场合看问题。把优化寄希望于编译器,那肯定是有利有弊啊,当然,光写JAVA,了解JVM就不用考虑弊了。个人感觉,JAVA里,“数组长度的的写法,应该先用变量保存,循环里不要直接计算...”的最大意义,在于不让人误用其他线性容器,比如ArrayList, LinkedList,因为在循环里可能出现改变其长度的算法,所以先保存长度,再循环,是不容易出错的实践习惯。
这个不一定吧。也许就是为了能变长的时候可以用呢? |
|
返回顶楼 | |
发表时间:2010-08-04
总的来说,企业级开发来说,这点消耗的所谓内存或者cpu实在微不足道,把算法解决好了就行了.让评审不是评审这些鸡毛蒜皮的,是评审业务,算法的正确,有本事让那些评审的把N降到logn的级别?所以说,这些评审的唧唧歪歪的,实在烦人.只能说,他们做过几年编码?
|
|
返回顶楼 | |
发表时间:2010-08-04
楼主授人以渔的好心被当成不给结论的驴肝肺了,安慰下
|
|
返回顶楼 | |
发表时间:2011-03-04
javap - c 现在学习了.
|
|
返回顶楼 | |
发表时间:2011-04-03
数组不是固定长度的对象吗?有必要“计算”长度吗?
难道数组就是记录起始地址和末端地址? |
|
返回顶楼 | |