@@ -121,10 +121,12 @@ public IRubyObject ensureIvarVisibilityBang(ThreadContext context) {
121121 @ JRubyMethod (name = "instance_variable_get_volatile" , visibility = Visibility .PROTECTED )
122122 public IRubyObject instanceVariableGetVolatile (ThreadContext context , IRubyObject name ) {
123123 if (UnsafeHolder .U == null ) {
124+ // TODO: Possibly dangerous, there may be a deadlock on the this
124125 synchronized (this ) {
125126 return instance_variable_get (context , name );
126127 }
127128 } else if (UnsafeHolder .SUPPORTS_FENCES ) {
129+ // ensure we see latest value
128130 UnsafeHolder .loadFence ();
129131 return instance_variable_get (context , name );
130132 } else {
@@ -136,11 +138,13 @@ public IRubyObject instanceVariableGetVolatile(ThreadContext context, IRubyObjec
136138 @ JRubyMethod (name = "instance_variable_set_volatile" , visibility = Visibility .PROTECTED )
137139 public IRubyObject InstanceVariableSetVolatile (ThreadContext context , IRubyObject name , IRubyObject value ) {
138140 if (UnsafeHolder .U == null ) {
141+ // TODO: Possibly dangerous, there may be a deadlock on the this
139142 synchronized (this ) {
140143 return instance_variable_set (name , value );
141144 }
142145 } else if (UnsafeHolder .SUPPORTS_FENCES ) {
143- IRubyObject result = instance_variable_set (name , value );
146+ final IRubyObject result = instance_variable_set (name , value );
147+ // ensure we make latest value visible
144148 UnsafeHolder .storeFence ();
145149 return result ;
146150 } else {
0 commit comments