2019-03-18 11:50:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015, 2019, 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_ZFORWARDING_HPP
|
|
|
|
#define SHARE_GC_Z_ZFORWARDING_HPP
|
|
|
|
|
2019-03-18 11:50:40 +01:00
|
|
|
#include "gc/z/zAttachedArray.hpp"
|
2019-03-18 11:50:39 +01:00
|
|
|
#include "gc/z/zForwardingEntry.hpp"
|
2019-03-18 11:50:39 +01:00
|
|
|
#include "gc/z/zVirtualMemory.hpp"
|
|
|
|
|
|
|
|
class ZPage;
|
2019-03-18 11:50:39 +01:00
|
|
|
|
2019-09-11 09:47:42 +02:00
|
|
|
typedef size_t ZForwardingCursor;
|
2019-03-18 11:50:39 +01:00
|
|
|
|
|
|
|
class ZForwarding {
|
|
|
|
friend class VMStructs;
|
|
|
|
friend class ZForwardingTest;
|
|
|
|
|
|
|
|
private:
|
2019-03-18 11:50:40 +01:00
|
|
|
typedef ZAttachedArray<ZForwarding, ZForwardingEntry> AttachedArray;
|
|
|
|
|
2019-03-18 11:50:39 +01:00
|
|
|
const ZVirtualMemory _virtual;
|
|
|
|
const size_t _object_alignment_shift;
|
2019-03-18 11:50:40 +01:00
|
|
|
const AttachedArray _entries;
|
2019-03-18 11:50:39 +01:00
|
|
|
ZPage* _page;
|
|
|
|
volatile uint32_t _refcount;
|
|
|
|
volatile bool _pinned;
|
|
|
|
|
|
|
|
bool inc_refcount();
|
|
|
|
bool dec_refcount();
|
2019-03-18 11:50:39 +01:00
|
|
|
|
|
|
|
ZForwardingEntry* entries() const;
|
|
|
|
ZForwardingEntry at(ZForwardingCursor* cursor) const;
|
|
|
|
ZForwardingEntry first(uintptr_t from_index, ZForwardingCursor* cursor) const;
|
|
|
|
ZForwardingEntry next(ZForwardingCursor* cursor) const;
|
|
|
|
|
2019-09-11 09:47:42 +02:00
|
|
|
ZForwarding(ZPage* page, size_t nentries);
|
2019-03-18 11:50:39 +01:00
|
|
|
|
|
|
|
public:
|
2019-03-18 11:50:39 +01:00
|
|
|
static ZForwarding* create(ZPage* page);
|
2019-03-18 11:50:39 +01:00
|
|
|
static void destroy(ZForwarding* forwarding);
|
|
|
|
|
|
|
|
uintptr_t start() const;
|
2019-03-18 11:50:39 +01:00
|
|
|
size_t size() const;
|
2019-03-18 11:50:39 +01:00
|
|
|
size_t object_alignment_shift() const;
|
2019-03-18 11:50:39 +01:00
|
|
|
ZPage* page() const;
|
2019-03-18 11:50:39 +01:00
|
|
|
|
|
|
|
bool is_pinned() const;
|
|
|
|
void set_pinned();
|
|
|
|
|
2019-03-18 11:50:39 +01:00
|
|
|
bool retain_page();
|
|
|
|
void release_page();
|
|
|
|
|
2019-03-18 11:50:39 +01:00
|
|
|
ZForwardingEntry find(uintptr_t from_index) const;
|
|
|
|
ZForwardingEntry find(uintptr_t from_index, ZForwardingCursor* cursor) const;
|
|
|
|
uintptr_t insert(uintptr_t from_index, uintptr_t to_offset, ZForwardingCursor* cursor);
|
|
|
|
|
2019-03-18 11:50:39 +01:00
|
|
|
void verify() const;
|
2019-03-18 11:50:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SHARE_GC_Z_ZFORWARDING_HPP
|