Fri, 25 May 2012 11:39:13 -0700
7170145: C1 doesn't respect the JMM with volatile field loads
Reviewed-by: kvn, roland
src/share/vm/c1/c1_ValueMap.hpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/c1/c1_ValueMap.hpp Fri May 25 07:53:11 2012 -0700 1.2 +++ b/src/share/vm/c1/c1_ValueMap.hpp Fri May 25 11:39:13 2012 -0700 1.3 @@ -141,8 +141,11 @@ 1.4 1.5 // visitor functions 1.6 void do_StoreField (StoreField* x) { 1.7 - if (x->is_init_point()) { 1.8 - // putstatic is an initialization point so treat it as a wide kill 1.9 + if (x->is_init_point() || // putstatic is an initialization point so treat it as a wide kill 1.10 + // This is actually too strict and the JMM doesn't require 1.11 + // this in all cases (e.g. load a; volatile store b; load a) 1.12 + // but possible future optimizations might require this. 1.13 + x->field()->is_volatile()) { 1.14 kill_memory(); 1.15 } else { 1.16 kill_field(x->field()); 1.17 @@ -160,8 +163,8 @@ 1.18 void do_Local (Local* x) { /* nothing to do */ } 1.19 void do_Constant (Constant* x) { /* nothing to do */ } 1.20 void do_LoadField (LoadField* x) { 1.21 - if (x->is_init_point()) { 1.22 - // getstatic is an initialization point so treat it as a wide kill 1.23 + if (x->is_init_point() || // getstatic is an initialization point so treat it as a wide kill 1.24 + x->field()->is_volatile()) { // the JMM requires this 1.25 kill_memory(); 1.26 } 1.27 }