- 浏览: 420011 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (114)
- C++ (1)
- JAVA (58)
- sql,oracle,mysql (7)
- struts (2)
- tomcat (6)
- JS CSS (6)
- 其他 (7)
- javascript (4)
- exception (1)
- error (1)
- hashmap (1)
- hashset (1)
- python (1)
- sql (2)
- oracle (4)
- mysql (2)
- weblogic (3)
- session (2)
- http-only-cookie (1)
- httponly (1)
- cookie (1)
- ide (0)
- intellij (1)
- eclipse (2)
- idea (1)
- connection (2)
- maven (4)
- m2eclipse (2)
- m2e (2)
- InetAddress (1)
- DNS (1)
- web (1)
- goals (1)
- copy-dependencies (1)
- unpack (1)
- hash (1)
- 分布式 (1)
- gc (4)
- volatile (1)
- rsa (1)
- 加密 (1)
- 签名 (1)
- socket (1)
- tcp (1)
最新评论
-
xuxiaoyinliu:
谢谢,不错哦
有关cookie的httponly属性相关 -
雁行:
svn根本就不需要这么罗嗦的实现。
版本比较,直接出增量文件, ...
ant+cvs实现增量部署 -
ludatong110:
这个东西在IE里面会很明显的,我就碰到过IE中因为这个HTML ...
有关jqGrid应用里的字体大小不能控制的问题 -
labchy:
非常感谢 解决了问题
有关jqGrid应用里的字体大小不能控制的问题 -
tengyue5i5j:
Crusader 写道竟然有这么多人投良好。。。
楼主的思路有 ...
java实现一个栈,并提供取该栈中最大数的方法,复杂度O(1)
分析java的for循环和数组初始化的执行过程
上周论坛有个帖子讨论有关for的写法,说是有个代码评审批评了下属的代码写法问题,具体见链接:
http://www.iteye.com/topic/722599
大家的一致意见是楼主写法没有问题,"问题是数组长度的的写法,应该先用变量保存,循环里不要直接计算",这里我感到怀疑。
我也回复了该贴,说是看下for的"源码",这里的意思是for的执行过程,有同学问我怎么看,这里做下分析,
过程很简单,就是用javap 命令来反编译.class文件即可,下面我们从数组构建开始,一个一个的分析.
1:javap -c 命令分析数组的构建
public class E{ public static void main(String...args){ int[] arr={1,2,3}; int[] arr2={1,2,3}; } }
分析结果如下:
0:iconst_3 //常数3装载到操作数栈:需要初始化数组的长度
1:newarray int //堆中new一个新的int类型的数组
3:dup //直接操纵操作数栈,打开操作
4:iconst_0 //常数0装载到操作数栈:数组下标
5:iconst_1 //常数1装载到操作数栈:对应的值
6:iastore //把一个值从操作数栈存入到数组成分:arr[0]=1
7:dup //...
8:iconst_1 //...
9:iconst_2 //...
10:iastore //...arr[1]=2
11:dup //...
12:iconst_2 //...
13:iconst_3 //...
14:iastore //...arr[2]=3
15:astore_1 //...为局部变量存入第一个值,该值为以上在操作数栈构造完成的数组类型16:iconst_3 //---------开始构造第二个数组
17:newarray int //
19:dup //
20:iconst_0 //
21:iconst_1 //
22:iastore //
23:dup //
24:iconst_1 //
25:iconst_2 //
26:iastore //
27:dup //
28:iconst_2 //
29:iconst_3 //
30:iastore //
31:astore_2 //----------存入第二个数组完成
33:return //结束返回
2:javap -c 命令分析循环的构建
public class D{ public static void main(String...args){ for(int j=0;j<2;){ } } }
分析结果如下:
0:iconst_0 //常数0装载到操作数栈
1:istore_1 //存入第一个值到局部变量:j=0的赋值操作
2:iload_1 //调出第一个局部变量到操作数栈:取出j的值
3:iconst_2 //常数2装载到操作数栈
4:if_icmpge 10 //判断大小:j<2,若不成立直接跳转到10行
7:goto 2 //跳转到2行继续执行
10:return //结束返回
3:有了以上基础知识,我们来分析http://www.iteye.com/topic/722599中的两种模式的循环结构
3.1:javap -c 分析String类型的数组循环的构建
...吃饭去,回来接着写
继续:变量声明在外部的情况
public class D{ public static void main(String...args){ String[] arr={"1","2","3"}; String i=null; for(int j=0;j<arr.length;j++){ i=arr[j]; } } }
分析结果如下:
0:iconst_3
1:anewarray #2;//class java/lang/String
4:dup
5:iconst_0
6:ldc #3;//String 1 //将字符串1的引用push到操作数栈
8:aastore //将一个值(数组类型)从栈存入到数组成分
9:dup
10:iconst_1
11:ldc #4;//String 2
13:aastore
14:dup
15:iconst_2
16:ldc #5;//String 3
18:aastore
19:astore_1 //存入第一个值到局变(数组类型)chushihua
20:aconst_null //申明数组类型常量为null
21:astore_2 //存入第二个值到局变(数组类型)初始化i完成
22:iconst_0 //装载常数0到操作数栈(整形)
23:istore_3 //从栈存入第三个值到局变(整形)
24:iload_3 //将第三个局变调入栈(整形)
25:aload_1 //将第一个局变调入栈(数组类型)
26:arraylength //计算数组长度
27:if_icmpge 40 //比较大小
30:aload_1 //将第一个局变调入栈(数组类型)
31:iload_3 //将第三个局变调入栈(整形)
32:aaload //将一个数组成分装载到操作数栈(该数组的成员类型为数组类型)
33:astore_2 //从栈把第二个值存入到局变(数组型),覆盖之前第21行的存入局变的值
34:iinc 3,1 //第三个局变自增1(整型)
37:goto 24 //转向第24步
40:return //结束返回
3.2变量声明在内部的情况
public class D{ public static void main(String...args){ String[] arr={"1","2","3"}; for(int j=0;j<arr.length;j++){ String i=arr[j]; } } }
分析结果如下:
0:iconst_3
1:anewarray #2;//class java/lang/String
4:dup
5:iconst_0
6:ldc #3;//String 1
8:aastore
9:dup
10;iconst_1
11:ldc #4;//String 2
13:aastore
14:dup
15:iconst_2
16:ldc #5;//String 3
18:aastore
19:astore_1 //初始化arr完成
20:iconst_0
21:istore_2
22:iload_2
23:aload_1
24:arraylength
25:if_icmpge 38
28:aload_1
29:iload_2
30:aaload
31:astore_3 //从栈存入第三个值到局变(数组类型),在下次循环的时候会被覆盖
32:iinc 2,1
35:goto 22
38:return
从上面两个例子可以得出两种写法的差别,至于那个评审所说的浪费空间?????????
结束.
评论
难道数组就是记录起始地址和末端地址?
这个不一定吧。也许就是为了能变长的时候可以用呢?
真的有人想看么……嘛,代码可以贴出来,*分析*就等高人来了,坐观。
测试的源码取自蛋疼,实例对比循环的各种写法:
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
学习了....
相关推荐
此外,Java还提供了增强型For循环,也称为foreach循环,特别适合遍历集合和数组: ```java for (int num : numbers) { System.out.println(num); } ``` 在这个视频教程中,你将学习如何使用For循环进行各种操作,...
3. **使用增强型for循环(foreach)**:对于集合和数组,增强型for循环更简洁且效率高。 了解并熟练掌握这些循环结构和控制语句,对于编写高效的Java代码至关重要。在实际编程中,要根据具体需求选择合适的循环类型...
)**:这种形式的`for`循环没有初始化、条件判断和后置操作,因此除非在循环体内主动退出,否则将一直执行下去。 2. **while(true)**:与`for(;;)`类似,此循环也会一直执行,除非遇到`break`或程序异常终止。 ###...
1. 指针初始化:根据问题定义,确定初始位置,如数组首尾、特定索引等。 2. 移动规则:每次迭代,更新一个或两个指针的位置,直至满足结束条件。 3. 循环控制:使用while或for循环,注意边界条件的处理。 4. 更新...
Java中的for循环是最常用的循环结构之一,它由三个部分组成:初始化、条件检查和更新。基本语法如下: ``` for (初始化; 条件; 更新) { // 循环体 } ``` 例如,遍历数组可以这样实现: ```java int[] array...
通过上述实验,我们不仅掌握了如何使用Java处理基本数据类型和数组,还学会了如何编写代码来解决实际问题。这对于我们理解Java编程的基本概念和技巧非常有帮助。此外,通过实验报告的形式呈现结果,也有助于培养良好...
for (初始化; 条件; 更新) { // 循环体 } ``` 例如,打印1到10的数字: ``` for (int i = 1; i ; i++) { System.out.println(i); } ``` 2. **while循环**:当循环的次数在运行时才可确定时,可以使用...
Java集合和数组是Java编程语言中的基础数据结构,它们用于存储和管理数据。数组是一种简单的数据结构,可以存储同类型的元素序列,而集合是Java集合框架的核心部分,提供了更高级的数据管理和操作功能。 ### 数组 ...
在这个实验中,学生不仅会学习到Java的基本数据类型,如int和char,还会接触到数组的定义、初始化和操作,包括一维数组和二维数组。同时,通过转置二维数组,学生可以理解数组元素的索引操作,以及如何通过循环实现...
Java 5引入了一种更简洁的循环方式,称为`for-each`循环,特别适用于遍历集合和数组。例如,遍历一个ArrayList: ```java List<String> list = new ArrayList(); list.add("Apple"); list.add("Banana"); list.add...
- `setUp()`方法:在每个测试方法之前运行,用于初始化必要的环境。 - `tearDown()`方法:在每个测试方法之后运行,用于清理测试留下的资源。 - 测试方法:以`test`开头的方法,每个方法对应一个特定的测试场景,...
【JAVA循环数组字符串】是Java编程中的基础概念,主要用于处理数据和控制程序流程。在学习这部分内容时,你需要掌握以下几个核心知识点: 1. **循环的含义**:循环是一种控制结构,允许程序重复执行一段代码,直到...
Java 语言中数组数据操作包括数组的初始化、数组的基本操作和数组的遍历等。数组是一种重要的数据结构,在 Java 语言中广泛应用。 Java 语言是一种功能强大且灵活的编程语言,它提供了强大的功能和灵活的编程模型。...
- **for 循环**:由三个部分组成:初始化(一般设置循环变量的初始值)、条件判断(决定是否继续循环)和更新(改变循环变量)。例如:`for(int i=1; i; i++)`。 - **while 循环**:只有条件判断,当条件为真时...
总的来说,流程控制和数组是Java编程中不可或缺的概念,它们共同构建了程序的逻辑框架。通过理解和熟练运用这些概念,开发者可以编写出能够根据条件变化动态响应的、具有复杂逻辑的游戏和其他应用程序。
Java 增强 for 循环语法格式如下:for(声明语句 : 表达式){ //代码句子}声明语句:声明新的局部变量,该变量的类型必须和数组元素的类型匹配。其作用域限定在循环语句块,其值与此时数组元素的值相等。表达式:...
ArrayList的核心是内部的数组对象,它在初始化时会创建一个默认大小(通常是10)的数组。当添加元素超过当前数组容量时,ArrayList会自动扩容,通常会将其容量扩大为原来的1.5倍,以确保有足够的空间存放新元素。...
程序计数器记录线程执行的字节码行号,本地方法栈服务于native方法,方法区存储类信息、常量、静态变量等,Java虚拟机栈存储方法的局部变量和操作栈,而Java堆是所有线程共享的内存区域,用于存放对象实例和数组。...
同时,章节讨论了垃圾收集和finalizer方法,以及成员初始化和数组初始化,特别是多维数组的处理。 第5章"隐藏实施过程"讲解了包作为组织代码的基本单位,以及访问控制修饰符如public、private和protected的作用。...