--- /dev/null 2018-04-03 12:55:20.301839954 +0200 +++ new/src/hotspot/share/gc/z/zMarkStackEntry.hpp 2018-06-08 19:46:19.074671994 +0200 @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017, 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_GC_Z_ZMARKSTACKENTRY_HPP +#define SHARE_GC_Z_ZMARKSTACKENTRY_HPP + +#include "gc/z/zBitField.hpp" +#include "memory/allocation.hpp" + +// +// Mark stack entry layout +// ----------------------- +// +// Object entry +// ------------ +// +// 6 +// 3 2 1 0 +// +---------------------------------------------------------------------+-+-+ +// |11111111 11111111 11111111 11111111 11111111 11111111 11111111 111111|1|1| +// +---------------------------------------------------------------------+-+-+ +// | | | +// | 1-1 Partial Array Flag (1-bit) * | +// | | +// | 0-0 Final Flag (1-bit) * +// | +// * 63-2 Object Address (62-bits) +// +// +// Partial array entry +// ------------------- +// +// 6 3 3 +// 3 2 1 2 1 0 +// +------------------------------------+---------------------------------+-+-+ +// |11111111 11111111 11111111 11111111 |11111111 11111111 11111111 111111|1|1| +// +------------------------------------+---------------------------------+-+-+ +// | | | | +// | | 1-1 Partial Array Flag (1-bit) * | +// | | | +// | | 0-0 Final Flag (1-bit) * +// | | +// | * 31-2 Partial Array Length (30-bits) +// | +// * 63-32 Partial Array Address Offset (32-bits) +// + +class ZMarkStackEntry { +private: + typedef ZBitField field_finalizable; + typedef ZBitField field_partial_array; + typedef ZBitField field_object_address; + typedef ZBitField field_partial_array_length; + typedef ZBitField field_partial_array_offset; + + uint64_t _entry; + +public: + ZMarkStackEntry() { + // This constructor is intentionally left emtpy and does not initialize + // _entry to allow it to be optimized out when instantiating ZMarkStack, + // which has a long array of ZMarkStackEntry elements, but doesn't care + // what _entry is initialized to. + } + + ZMarkStackEntry(uintptr_t object_address, bool finalizable) : + _entry(field_object_address::encode(object_address) | + field_partial_array::encode(false) | + field_finalizable::encode(finalizable)) {} + + ZMarkStackEntry(size_t partial_array_offset, size_t partial_array_length, bool finalizable) : + _entry(field_partial_array_offset::encode(partial_array_offset) | + field_partial_array_length::encode(partial_array_length) | + field_partial_array::encode(true) | + field_finalizable::encode(finalizable)) {} + + bool finalizable() const { + return field_finalizable::decode(_entry); + } + + bool partial_array() const { + return field_partial_array::decode(_entry); + } + + size_t partial_array_offset() const { + return field_partial_array_offset::decode(_entry); + } + + size_t partial_array_length() const { + return field_partial_array_length::decode(_entry); + } + + uintptr_t object_address() const { + return field_object_address::decode(_entry); + } +}; + +#endif // SHARE_GC_Z_ZMARKSTACKENTRY_HPP