File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
ext/com/concurrent_ruby/ext Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -111,10 +111,18 @@ public IRubyObject nsBroadcast(ThreadContext context) {
111
111
112
112
@ JRubyMethod (name = "ensure_ivar_visibility!" , visibility = Visibility .PROTECTED )
113
113
public IRubyObject ensureIvarVisibilityBang (ThreadContext context ) {
114
- if (UnsafeHolder .SUPPORTS_FENCES )
115
- UnsafeHolder .storeFence ();
116
- else
117
- anVolatileField = 1 ;
114
+ if (UnsafeHolder .U == null ) {
115
+ // We are screwed
116
+ throw new UnsupportedOperationException ();
117
+ } else if (UnsafeHolder .SUPPORTS_FENCES )
118
+ // We have to prevent ivar writes to reordered with storing of the final instance reference
119
+ // Therefore wee need a fullFence to prevent reordering in both directions.
120
+ UnsafeHolder .fullFence ();
121
+ else {
122
+ // Assumption that this is not eliminated, if false it will break non x86 platforms.
123
+ UnsafeHolder .U .putIntVolatile (this , AN_VOLATILE_FIELD_OFFSET , 1 );
124
+ UnsafeHolder .U .getIntVolatile (this , AN_VOLATILE_FIELD_OFFSET );
125
+ }
118
126
return context .nil ;
119
127
}
120
128
You can’t perform that action at this time.
0 commit comments