8232602: ZGC: Make ZGranuleMap ZAddress agnostic
Reviewed-by: pliden, eosterlund
This commit is contained in:
parent
acf447e49e
commit
06a479f965
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "gc/z/zAddress.inline.hpp"
|
||||
#include "gc/z/zForwarding.inline.hpp"
|
||||
#include "gc/z/zForwardingTable.inline.hpp"
|
||||
#include "gc/z/zGlobals.hpp"
|
||||
@ -33,17 +32,17 @@ ZForwardingTable::ZForwardingTable() :
|
||||
_map(ZAddressOffsetMax) {}
|
||||
|
||||
void ZForwardingTable::insert(ZForwarding* forwarding) {
|
||||
const uintptr_t addr = ZAddress::good(forwarding->start());
|
||||
const uintptr_t offset = forwarding->start();
|
||||
const size_t size = forwarding->size();
|
||||
|
||||
assert(get(addr) == NULL, "Invalid entry");
|
||||
_map.put(addr, size, forwarding);
|
||||
assert(_map.get(offset) == NULL, "Invalid entry");
|
||||
_map.put(offset, size, forwarding);
|
||||
}
|
||||
|
||||
void ZForwardingTable::remove(ZForwarding* forwarding) {
|
||||
const uintptr_t addr = ZAddress::good(forwarding->start());
|
||||
const uintptr_t offset = forwarding->start();
|
||||
const size_t size = forwarding->size();
|
||||
|
||||
assert(get(addr) == forwarding, "Invalid entry");
|
||||
_map.put(addr, size, NULL);
|
||||
assert(_map.get(offset) == forwarding, "Invalid entry");
|
||||
_map.put(offset, size, NULL);
|
||||
}
|
||||
|
@ -24,11 +24,13 @@
|
||||
#ifndef SHARE_GC_Z_ZFORWARDINGTABLE_INLINE_HPP
|
||||
#define SHARE_GC_Z_ZFORWARDINGTABLE_INLINE_HPP
|
||||
|
||||
#include "gc/z/zAddress.inline.hpp"
|
||||
#include "gc/z/zForwardingTable.hpp"
|
||||
#include "gc/z/zGranuleMap.inline.hpp"
|
||||
|
||||
inline ZForwarding* ZForwardingTable::get(uintptr_t addr) const {
|
||||
return _map.get(addr);
|
||||
assert(!ZAddress::is_null(addr), "Invalid address");
|
||||
return _map.get(ZAddress::offset(addr));
|
||||
}
|
||||
|
||||
#endif // SHARE_GC_Z_ZFORWARDINGTABLE_INLINE_HPP
|
||||
|
@ -38,15 +38,15 @@ private:
|
||||
const size_t _size;
|
||||
T* const _map;
|
||||
|
||||
size_t index_for_addr(uintptr_t addr) const;
|
||||
size_t index_for_offset(uintptr_t offset) const;
|
||||
|
||||
public:
|
||||
ZGranuleMap(size_t max_offset);
|
||||
~ZGranuleMap();
|
||||
|
||||
T get(uintptr_t addr) const;
|
||||
void put(uintptr_t addr, T value);
|
||||
void put(uintptr_t addr, size_t size, T value);
|
||||
T get(uintptr_t offset) const;
|
||||
void put(uintptr_t offset, T value);
|
||||
void put(uintptr_t offset, size_t size, T value);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@ -24,7 +24,6 @@
|
||||
#ifndef SHARE_GC_Z_ZGRANULEMAP_INLINE_HPP
|
||||
#define SHARE_GC_Z_ZGRANULEMAP_INLINE_HPP
|
||||
|
||||
#include "gc/z/zAddress.inline.hpp"
|
||||
#include "gc/z/zGlobals.hpp"
|
||||
#include "gc/z/zGranuleMap.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
@ -44,32 +43,30 @@ inline ZGranuleMap<T>::~ZGranuleMap() {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline size_t ZGranuleMap<T>::index_for_addr(uintptr_t addr) const {
|
||||
assert(!ZAddress::is_null(addr), "Invalid address");
|
||||
|
||||
const size_t index = ZAddress::offset(addr) >> ZGranuleSizeShift;
|
||||
inline size_t ZGranuleMap<T>::index_for_offset(uintptr_t offset) const {
|
||||
const size_t index = offset >> ZGranuleSizeShift;
|
||||
assert(index < _size, "Invalid index");
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T ZGranuleMap<T>::get(uintptr_t addr) const {
|
||||
const size_t index = index_for_addr(addr);
|
||||
inline T ZGranuleMap<T>::get(uintptr_t offset) const {
|
||||
const size_t index = index_for_offset(offset);
|
||||
return _map[index];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void ZGranuleMap<T>::put(uintptr_t addr, T value) {
|
||||
const size_t index = index_for_addr(addr);
|
||||
inline void ZGranuleMap<T>::put(uintptr_t offset, T value) {
|
||||
const size_t index = index_for_offset(offset);
|
||||
_map[index] = value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void ZGranuleMap<T>::put(uintptr_t addr, size_t size, T value) {
|
||||
inline void ZGranuleMap<T>::put(uintptr_t offset, size_t size, T value) {
|
||||
assert(is_aligned(size, ZGranuleSize), "Misaligned");
|
||||
|
||||
const size_t start_index = index_for_addr(addr);
|
||||
const size_t start_index = index_for_offset(offset);
|
||||
const size_t end_index = start_index + (size >> ZGranuleSizeShift);
|
||||
for (size_t index = start_index; index < end_index; index++) {
|
||||
_map[index] = value;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/classLoaderData.hpp"
|
||||
#include "classfile/classLoaderDataGraph.hpp"
|
||||
#include "gc/z/zAddress.inline.hpp"
|
||||
#include "gc/z/zBarrier.inline.hpp"
|
||||
#include "gc/z/zGlobals.hpp"
|
||||
#include "gc/z/zGranuleMap.inline.hpp"
|
||||
@ -148,11 +149,11 @@ static size_t object_index(oop obj) {
|
||||
}
|
||||
|
||||
ZHeapIteratorBitMap* ZHeapIterator::object_map(oop obj) {
|
||||
const uintptr_t addr = ZOop::to_address(obj);
|
||||
ZHeapIteratorBitMap* map = _visit_map.get(addr);
|
||||
const uintptr_t offset = ZAddress::offset(ZOop::to_address(obj));
|
||||
ZHeapIteratorBitMap* map = _visit_map.get(offset);
|
||||
if (map == NULL) {
|
||||
map = new ZHeapIteratorBitMap(object_index_max());
|
||||
_visit_map.put(addr, map);
|
||||
_visit_map.put(offset, map);
|
||||
}
|
||||
|
||||
return map;
|
||||
|
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "gc/z/zAddress.inline.hpp"
|
||||
#include "gc/z/zGlobals.hpp"
|
||||
#include "gc/z/zGranuleMap.inline.hpp"
|
||||
#include "gc/z/zPage.inline.hpp"
|
||||
@ -34,21 +33,21 @@ ZPageTable::ZPageTable() :
|
||||
_map(ZAddressOffsetMax) {}
|
||||
|
||||
void ZPageTable::insert(ZPage* page) {
|
||||
const uintptr_t addr = ZAddress::good(page->start());
|
||||
const uintptr_t offset = page->start();
|
||||
const size_t size = page->size();
|
||||
|
||||
// Make sure a newly created page is
|
||||
// visible before updating the page table.
|
||||
OrderAccess::storestore();
|
||||
|
||||
assert(get(addr) == NULL, "Invalid entry");
|
||||
_map.put(addr, size, page);
|
||||
assert(_map.get(offset) == NULL, "Invalid entry");
|
||||
_map.put(offset, size, page);
|
||||
}
|
||||
|
||||
void ZPageTable::remove(ZPage* page) {
|
||||
const uintptr_t addr = ZAddress::good(page->start());
|
||||
const uintptr_t offset = page->start();
|
||||
const size_t size = page->size();
|
||||
|
||||
assert(get(addr) == page, "Invalid entry");
|
||||
_map.put(addr, size, NULL);
|
||||
assert(_map.get(offset) == page, "Invalid entry");
|
||||
_map.put(offset, size, NULL);
|
||||
}
|
||||
|
@ -29,7 +29,8 @@
|
||||
#include "gc/z/zPageTable.hpp"
|
||||
|
||||
inline ZPage* ZPageTable::get(uintptr_t addr) const {
|
||||
return _map.get(addr);
|
||||
assert(!ZAddress::is_null(addr), "Invalid address");
|
||||
return _map.get(ZAddress::offset(addr));
|
||||
}
|
||||
|
||||
inline ZPageTableIterator::ZPageTableIterator(const ZPageTable* page_table) :
|
||||
|
Loading…
x
Reference in New Issue
Block a user