--- old/src/share/vm/gc/g1/g1FixedSizeStack.hpp 2016-06-28 14:13:09.343554327 +0200 +++ /dev/null 2016-06-08 17:45:05.423675909 +0200 @@ -1,105 +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_HPP -#define SHARE_VM_GC_G1_G1FIXEDSIZESTACK_HPP - -#include "memory/allocation.hpp" -#include "utilities/debug.hpp" -#include "utilities/globalDefinitions.hpp" - -// Base class for a fixed size stack, i.e. its backing array is of fixed size. Collects -// methods common to any instances of the array. The backing array is preallocated -// on the C heap. -// -// Pushing elements and access to elements below _length is MT safe. Any other -// operations modifying it are not. -class G1FixedSizeStackBase : public CHeapObj { -protected: - address _base; // The real base address. - size_t _max_length; // The length of the array. - - // Current number of elements pushed. The MSB of this value is also used to - // indicate that a concurrent writer is currently pushing to it. - size_t volatile _length; - - static const size_t LengthMask = ~nth_bit(BitsPerWord - 1); - -protected: - - G1FixedSizeStackBase() : _base(NULL), _max_length(0), _length(0) { } - - // Allocate and initialize the backing array. - void initialize(size_t max_length, size_t elem_size); - - void verify_index(size_t index) const PRODUCT_RETURN; - -public: - virtual ~G1FixedSizeStackBase(); - - size_t max_length() const { return _max_length; } - inline size_t length() const; -}; - -template -class G1FixedSizeStack : public G1FixedSizeStackBase { -private: - T* base() const { return (T*)G1FixedSizeStackBase::_base; } - - // Set the element of the given array at the given index to the - // given value. Assume the index is valid. - void set_by_index_raw(size_t index, T const value) { - this->base()[index] = value; - } - -public: - // Return the element of the array at the given index. Assume - // the index is valid. This is a convenience method that does sanity - // checking on the index. - T get_by_index(size_t index) const { - verify_index(index); - return this->base()[index]; - } - - void clear() { -#ifdef ASSERT - _length = _max_length; - for (size_t i = 0; i < _max_length; i++) { - set_by_index_raw(i, T()); - } -#endif - _length = 0; - } - - G1FixedSizeStack() : G1FixedSizeStackBase() {} - - void initialize(size_t max_length) { - G1FixedSizeStackBase::initialize(max_length, sizeof(T)); - this->clear(); - } - - inline void par_push(T const elem); -}; - -#endif // SHARE_VM_GC_G1_G1FIXEDSIZESTACK_HPP