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