mfence on i686 with volatile?
Dennis Byrne
dennisbyrne at apache.org
Tue Nov 17 23:28:59 UTC 2009
I am not observing any fences in the output from PrintAssembly. The
following java produces the following assembly, regardless of whether
or not I make v and v2 volatile.
class HelloWorld extends Thread{
public static int v = 0;
public static int v2 = 1;
public static void main(String[] args){
new HelloWorld().start();
new HelloWorld().start();
}
public void run() {
for(int i = 0; i < 1000000; i++){
v += 333;
v2 += v;
}
System.out.println(v);
System.out.println(v2);
}
}
0x02e33d30: mov %eax,-0x3000(%esp) ;
0x02e33d37: push %ebp ;
0x02e33d38: mov %esp,%ebp ;
0x02e33d3a: sub $0x28,%esp ;
0x02e33d3d: mov $0x0,%esi ;
0x02e33d42: jmp 0x02e33d7a ;
0x02e33d47: nop ;
0x02e33d48: mov $0x95ba5348,%edx ;
0x02e33d4d: mov 0x1b8(%edx),%ecx ;
0x02e33d53: add $0x14d,%ecx ; v += 333
0x02e33d59: mov %ecx,0x1b8(%edx) ;
0x02e33d5f: mov 0x1bc(%edx),%ecx ;
0x02e33d65: mov 0x1b8(%edx),%edi ;
0x02e33d6b: add %edi,%ecx ; v2 += v
0x02e33d6d: mov %ecx,0x1bc(%edx) ;
0x02e33d73: inc %esi ; i++
;
;
; - HelloWorld::run at 31 (line 12)
--
Dennis Byrne
More information about the discuss
mailing list