--- old/src/share/vm/utilities/taskqueue.hpp 2013-07-08 20:16:51.369625927 -0400 +++ new/src/share/vm/utilities/taskqueue.hpp 2013-07-08 20:16:48.040105517 -0400 @@ -391,7 +391,14 @@ template bool GenericTaskQueue::pop_global(E& t) { Age oldAge = _age.get(); - uint localBot = _bottom; + // Architectures with weak memory model require a fence here. The + // fence has a cumulative effect on getting age and getting bottom. + // This way it is guaranteed that bottom is not older than age, + // which is crucial for the correctness of the algorithm. +#if !(defined SPARC || defined IA32 || defined AMD64) + OrderAccess::fence(); +#endif + uint localBot = OrderAccess::load_acquire((volatile juint*)&_bottom); uint n_elems = size(localBot, oldAge.top()); if (n_elems == 0) { return false; @@ -677,7 +684,7 @@ template inline bool GenericTaskQueue::push(E t) { uint localBot = _bottom; - assert((localBot >= 0) && (localBot < N), "_bottom out of range."); + assert(localBot < N, "_bottom out of range."); idx_t top = _age.top(); uint dirty_n_elems = dirty_size(localBot, top); assert(dirty_n_elems < N, "n_elems out of range.");