--- old/src/share/vm/gc/g1/g1FixedSizeStack.inline.hpp 2016-06-28 14:13:09.624562792 +0200 +++ /dev/null 2016-06-08 17:45:05.423675909 +0200 @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_GC_G1_G1FIXEDSIZESTACK_INLINE_HPP -#define SHARE_VM_GC_G1_G1FIXEDSIZESTACK_INLINE_HPP - -#include "gc/g1/g1FixedSizeStack.hpp" -#include "runtime/atomic.inline.hpp" -#include "runtime/orderAccess.inline.hpp" -#include "utilities/debug.hpp" - -size_t G1FixedSizeStackBase::length() const { - return OrderAccess::load_acquire((volatile intptr_t*)&_length) & LengthMask; -} -// This is required for the use of Atomic::cmpxchg_ptr in par_push(). -STATIC_ASSERT(sizeof(intptr_t) == sizeof(size_t)); - -template -void G1FixedSizeStack::par_push(const T elem) { - // Try to set exclusive access to the length field by setting its upper bit. - size_t cur_length = length(); - while (true) { - size_t old_length = (size_t)Atomic::cmpxchg_ptr((intptr_t)cur_length | nth_bit(BitsPerWord - 1), (volatile intptr_t*)&_length, (intptr_t)cur_length); - if (old_length == cur_length) { - assert((cur_length & nth_bit(BitsPerWord - 1)) == 0, "Topmost bit must not be set in old value."); - break; - } - cur_length = old_length & LengthMask; - } - assert(cur_length < _max_length, "Tried to push more objects than there is space."); - set_by_index_raw(cur_length, elem); - OrderAccess::release_store_ptr((volatile intptr_t*)&_length, cur_length + 1); -} - -#endif /* SHARE_VM_GC_G1_G1FIXEDSIZESTACK_INLINE_HPP */