@@ -148,10 +148,6 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
148
148
if (!m.is_forwarded ()) {
149
149
return copy_unmarked_to_survivor_space<promote_immediately>(o, m);
150
150
} else {
151
- // Ensure any loads from the forwardee follow all changes that precede
152
- // the release-cmpxchg that performed the forwarding, possibly in some
153
- // other thread.
154
- OrderAccess::acquire ();
155
151
// Return the already installed forwardee.
156
152
return m.forwardee ();
157
153
}
@@ -258,8 +254,11 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
258
254
ContinuationGCSupport::transform_stack_chunk (new_obj);
259
255
260
256
// Now we have to CAS in the header.
261
- // Make copy visible to threads reading the forwardee.
262
- oop forwardee = o->forward_to_atomic (new_obj, test_mark, memory_order_release);
257
+ // Because the forwarding is done with memory_order_relaxed there is no
258
+ // ordering with the above copy. Clients that get the forwardee must not
259
+ // examine its contents without other synchronization, since the contents
260
+ // may not be up to date for them.
261
+ oop forwardee = o->forward_to_atomic (new_obj, test_mark, memory_order_relaxed);
263
262
if (forwardee == nullptr ) { // forwardee is null when forwarding is successful
264
263
// We won any races, we "own" this object.
265
264
assert (new_obj == o->forwardee (), " Sanity" );
@@ -295,9 +294,6 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
295
294
return new_obj;
296
295
} else {
297
296
// We lost, someone else "owns" this object.
298
- // Ensure loads from the forwardee follow all changes that preceded the
299
- // release-cmpxchg that performed the forwarding in another thread.
300
- OrderAccess::acquire ();
301
297
302
298
assert (o->is_forwarded (), " Object must be forwarded if the cas failed." );
303
299
assert (o->forwardee () == forwardee, " invariant" );
0 commit comments