8219634: ZGC: Rename ZAddressRangeMap to ZGranuleMap
Reviewed-by: eosterlund, stefank
--- a/src/hotspot/share/gc/z/vmStructs_z.hpp Wed Mar 13 11:31:00 2019 +0100
+++ b/src/hotspot/share/gc/z/vmStructs_z.hpp Wed Mar 13 11:31:00 2019 +0100
@@ -24,8 +24,8 @@
#ifndef SHARE_GC_Z_VMSTRUCTS_Z_HPP
#define SHARE_GC_Z_VMSTRUCTS_Z_HPP
-#include "gc/z/zAddressRangeMap.hpp"
#include "gc/z/zCollectedHeap.hpp"
+#include "gc/z/zGranuleMap.hpp"
#include "gc/z/zHeap.hpp"
#include "gc/z/zPageAllocator.hpp"
#include "gc/z/zPhysicalMemory.hpp"
@@ -52,7 +52,7 @@
const int* _ZObjectAlignmentSmall;
};
-typedef ZAddressRangeMap<ZPageTableEntry, ZGranuleSizeShift> ZAddressRangeMapForPageTable;
+typedef ZGranuleMap<ZPageTableEntry> ZGranuleMapForPageTable;
#define VM_STRUCTS_ZGC(nonstatic_field, volatile_nonstatic_field, static_field) \
static_field(ZGlobalsForVMStructs, _instance_p, ZGlobalsForVMStructs*) \
@@ -79,18 +79,18 @@
nonstatic_field(ZPageAllocator, _physical, ZPhysicalMemoryManager) \
nonstatic_field(ZPageAllocator, _used, size_t) \
\
- nonstatic_field(ZPageTable, _map, ZAddressRangeMapForPageTable) \
+ nonstatic_field(ZPageTable, _map, ZGranuleMapForPageTable) \
\
- nonstatic_field(ZAddressRangeMapForPageTable, _map, ZPageTableEntry* const) \
+ nonstatic_field(ZGranuleMapForPageTable, _map, ZPageTableEntry* const) \
\
- nonstatic_field(ZVirtualMemory, _start, uintptr_t) \
- nonstatic_field(ZVirtualMemory, _end, uintptr_t) \
+ nonstatic_field(ZVirtualMemory, _start, uintptr_t) \
+ nonstatic_field(ZVirtualMemory, _end, uintptr_t) \
\
- nonstatic_field(ZForwardingTable, _table, ZForwardingTableEntry*) \
- nonstatic_field(ZForwardingTable, _size, size_t) \
+ nonstatic_field(ZForwardingTable, _table, ZForwardingTableEntry*) \
+ nonstatic_field(ZForwardingTable, _size, size_t) \
\
- nonstatic_field(ZPhysicalMemoryManager, _max_capacity, const size_t) \
- nonstatic_field(ZPhysicalMemoryManager, _capacity, size_t)
+ nonstatic_field(ZPhysicalMemoryManager, _max_capacity, const size_t) \
+ nonstatic_field(ZPhysicalMemoryManager, _capacity, size_t)
#define VM_INT_CONSTANTS_ZGC(declare_constant, declare_constant_with_value) \
declare_constant(ZPhaseRelocate) \
@@ -118,7 +118,7 @@
declare_toplevel_type(ZPageAllocator) \
declare_toplevel_type(ZPageTable) \
declare_toplevel_type(ZPageTableEntry) \
- declare_toplevel_type(ZAddressRangeMapForPageTable) \
+ declare_toplevel_type(ZGranuleMapForPageTable) \
declare_toplevel_type(ZVirtualMemory) \
declare_toplevel_type(ZForwardingTable) \
declare_toplevel_type(ZForwardingTableEntry) \
--- a/src/hotspot/share/gc/z/zAddressRangeMap.hpp Wed Mar 13 11:31:00 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, 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_ZADDRESSRANGEMAP_HPP
-#define SHARE_GC_Z_ZADDRESSRANGEMAP_HPP
-
-#include "memory/allocation.hpp"
-
-template<typename T, size_t AddressRangeShift>
-class ZAddressRangeMapIterator;
-
-template <typename T, size_t AddressRangeShift>
-class ZAddressRangeMap {
- friend class VMStructs;
- friend class ZAddressRangeMapIterator<T, AddressRangeShift>;
-
-private:
- T* const _map;
-
- size_t index_for_addr(uintptr_t addr) const;
- size_t size() const;
-
-public:
- ZAddressRangeMap();
- ~ZAddressRangeMap();
-
- T get(uintptr_t addr) const;
- void put(uintptr_t addr, T value);
-};
-
-template <typename T, size_t AddressRangeShift>
-class ZAddressRangeMapIterator : public StackObj {
-public:
- const ZAddressRangeMap<T, AddressRangeShift>* const _map;
- size_t _next;
-
-public:
- ZAddressRangeMapIterator(const ZAddressRangeMap<T, AddressRangeShift>* map);
-
- bool next(T* value);
-};
-
-#endif // SHARE_GC_Z_ZADDRESSRANGEMAP_HPP
--- a/src/hotspot/share/gc/z/zAddressRangeMap.inline.hpp Wed Mar 13 11:31:00 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * 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_ZADDRESSRANGEMAP_INLINE_HPP
-#define SHARE_GC_Z_ZADDRESSRANGEMAP_INLINE_HPP
-
-#include "gc/z/zAddress.inline.hpp"
-#include "gc/z/zAddressRangeMap.hpp"
-#include "gc/z/zGlobals.hpp"
-#include "memory/allocation.inline.hpp"
-
-template <typename T, size_t AddressRangeShift>
-ZAddressRangeMap<T, AddressRangeShift>::ZAddressRangeMap() :
- _map(MmapArrayAllocator<T>::allocate(size(), mtGC)) {}
-
-template <typename T, size_t AddressRangeShift>
-ZAddressRangeMap<T, AddressRangeShift>::~ZAddressRangeMap() {
- MmapArrayAllocator<T>::free(_map, size());
-}
-
-template <typename T, size_t AddressRangeShift>
-size_t ZAddressRangeMap<T, AddressRangeShift>::index_for_addr(uintptr_t addr) const {
- assert(!ZAddress::is_null(addr), "Invalid address");
-
- const size_t index = ZAddress::offset(addr) >> AddressRangeShift;
- assert(index < size(), "Invalid index");
-
- return index;
-}
-
-template <typename T, size_t AddressRangeShift>
-size_t ZAddressRangeMap<T, AddressRangeShift>::size() const {
- return ZAddressOffsetMax >> AddressRangeShift;
-}
-
-template <typename T, size_t AddressRangeShift>
-T ZAddressRangeMap<T, AddressRangeShift>::get(uintptr_t addr) const {
- const uintptr_t index = index_for_addr(addr);
- return _map[index];
-}
-
-template <typename T, size_t AddressRangeShift>
-void ZAddressRangeMap<T, AddressRangeShift>::put(uintptr_t addr, T value) {
- const uintptr_t index = index_for_addr(addr);
- _map[index] = value;
-}
-
-template <typename T, size_t AddressRangeShift>
-inline ZAddressRangeMapIterator<T, AddressRangeShift>::ZAddressRangeMapIterator(const ZAddressRangeMap<T, AddressRangeShift>* map) :
- _map(map),
- _next(0) {}
-
-template <typename T, size_t AddressRangeShift>
-inline bool ZAddressRangeMapIterator<T, AddressRangeShift>::next(T* value) {
- if (_next < _map->size()) {
- *value = _map->_map[_next++];
- return true;
- }
-
- // End of map
- return false;
-}
-
-#endif // SHARE_GC_Z_ZADDRESSRANGEMAP_INLINE_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/z/zGranuleMap.hpp Wed Mar 13 11:31:00 2019 +0100
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2017, 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_ZGRANULEMAP_HPP
+#define SHARE_GC_Z_ZGRANULEMAP_HPP
+
+#include "memory/allocation.hpp"
+
+template<typename T>
+class ZGranuleMapIterator;
+
+template <typename T>
+class ZGranuleMap {
+ friend class VMStructs;
+ friend class ZGranuleMapIterator<T>;
+
+private:
+ T* const _map;
+
+ size_t index_for_addr(uintptr_t addr) const;
+ size_t size() const;
+
+public:
+ ZGranuleMap();
+ ~ZGranuleMap();
+
+ T get(uintptr_t addr) const;
+ void put(uintptr_t addr, T value);
+};
+
+template <typename T>
+class ZGranuleMapIterator : public StackObj {
+public:
+ const ZGranuleMap<T>* const _map;
+ size_t _next;
+
+public:
+ ZGranuleMapIterator(const ZGranuleMap<T>* map);
+
+ bool next(T* value);
+};
+
+#endif // SHARE_GC_Z_ZGRANULEMAP_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/z/zGranuleMap.inline.hpp Wed Mar 13 11:31:00 2019 +0100
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2017, 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_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"
+
+template <typename T>
+inline ZGranuleMap<T>::ZGranuleMap() :
+ _map(MmapArrayAllocator<T>::allocate(size(), mtGC)) {}
+
+template <typename T>
+inline ZGranuleMap<T>::~ZGranuleMap() {
+ MmapArrayAllocator<T>::free(_map, size());
+}
+
+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;
+ assert(index < size(), "Invalid index");
+
+ return index;
+}
+
+template <typename T>
+inline size_t ZGranuleMap<T>::size() const {
+ return ZAddressOffsetMax >> ZGranuleSizeShift;
+}
+
+template <typename T>
+inline T ZGranuleMap<T>::get(uintptr_t addr) const {
+ const size_t index = index_for_addr(addr);
+ return _map[index];
+}
+
+template <typename T>
+inline void ZGranuleMap<T>::put(uintptr_t addr, T value) {
+ const size_t index = index_for_addr(addr);
+ _map[index] = value;
+}
+
+template <typename T>
+inline ZGranuleMapIterator<T>::ZGranuleMapIterator(const ZGranuleMap<T>* map) :
+ _map(map),
+ _next(0) {}
+
+template <typename T>
+inline bool ZGranuleMapIterator<T>::next(T* value) {
+ if (_next < _map->size()) {
+ *value = _map->_map[_next++];
+ return true;
+ }
+
+ // End of map
+ return false;
+}
+
+#endif // SHARE_GC_Z_ZGRANULEMAP_INLINE_HPP
--- a/src/hotspot/share/gc/z/zHeapIterator.cpp Wed Mar 13 11:31:00 2019 +0100
+++ b/src/hotspot/share/gc/z/zHeapIterator.cpp Wed Mar 13 11:31:00 2019 +0100
@@ -22,9 +22,9 @@
*/
#include "precompiled.hpp"
-#include "gc/z/zAddressRangeMap.inline.hpp"
#include "gc/z/zBarrier.inline.hpp"
#include "gc/z/zGlobals.hpp"
+#include "gc/z/zGranuleMap.inline.hpp"
#include "gc/z/zHeapIterator.hpp"
#include "gc/z/zOop.inline.hpp"
#include "gc/z/zRootsIterator.hpp"
--- a/src/hotspot/share/gc/z/zHeapIterator.hpp Wed Mar 13 11:31:00 2019 +0100
+++ b/src/hotspot/share/gc/z/zHeapIterator.hpp Wed Mar 13 11:31:00 2019 +0100
@@ -24,11 +24,11 @@
#ifndef SHARE_GC_Z_ZHEAPITERATOR_HPP
#define SHARE_GC_Z_ZHEAPITERATOR_HPP
-#include "gc/z/zAddressRangeMap.hpp"
-#include "gc/z/zGlobals.hpp"
+#include "gc/z/zGranuleMap.hpp"
#include "memory/allocation.hpp"
#include "utilities/stack.hpp"
+class ObjectClosure;
class ZHeapIteratorBitMap;
class ZHeapIterator : public StackObj {
@@ -36,9 +36,9 @@
friend class ZHeapIteratorOopClosure;
private:
- typedef ZAddressRangeMap<ZHeapIteratorBitMap*, ZGranuleSizeShift> ZVisitMap;
- typedef ZAddressRangeMapIterator<ZHeapIteratorBitMap*, ZGranuleSizeShift> ZVisitMapIterator;
- typedef Stack<oop, mtGC> ZVisitStack;
+ typedef ZGranuleMap<ZHeapIteratorBitMap*> ZVisitMap;
+ typedef ZGranuleMapIterator<ZHeapIteratorBitMap*> ZVisitMapIterator;
+ typedef Stack<oop, mtGC> ZVisitStack;
ZVisitStack _visit_stack;
ZVisitMap _visit_map;
--- a/src/hotspot/share/gc/z/zPageTable.cpp Wed Mar 13 11:31:00 2019 +0100
+++ b/src/hotspot/share/gc/z/zPageTable.cpp Wed Mar 13 11:31:00 2019 +0100
@@ -22,6 +22,7 @@
*/
#include "precompiled.hpp"
+#include "gc/z/zAddress.inline.hpp"
#include "gc/z/zPage.inline.hpp"
#include "gc/z/zPageTable.inline.hpp"
#include "runtime/orderAccess.hpp"
--- a/src/hotspot/share/gc/z/zPageTable.hpp Wed Mar 13 11:31:00 2019 +0100
+++ b/src/hotspot/share/gc/z/zPageTable.hpp Wed Mar 13 11:31:00 2019 +0100
@@ -24,8 +24,7 @@
#ifndef SHARE_GC_Z_ZPAGETABLE_HPP
#define SHARE_GC_Z_ZPAGETABLE_HPP
-#include "gc/z/zAddressRangeMap.hpp"
-#include "gc/z/zGlobals.hpp"
+#include "gc/z/zGranuleMap.hpp"
#include "gc/z/zPageTableEntry.hpp"
#include "memory/allocation.hpp"
@@ -36,7 +35,7 @@
friend class ZPageTableIterator;
private:
- ZAddressRangeMap<ZPageTableEntry, ZGranuleSizeShift> _map;
+ ZGranuleMap<ZPageTableEntry> _map;
ZPageTableEntry get_entry(ZPage* page) const;
void put_entry(ZPage* page, ZPageTableEntry entry);
@@ -55,8 +54,8 @@
class ZPageTableIterator : public StackObj {
private:
- ZAddressRangeMapIterator<ZPageTableEntry, ZGranuleSizeShift> _iter;
- ZPage* _prev;
+ ZGranuleMapIterator<ZPageTableEntry> _iter;
+ ZPage* _prev;
public:
ZPageTableIterator(const ZPageTable* pagetable);
--- a/src/hotspot/share/gc/z/zPageTable.inline.hpp Wed Mar 13 11:31:00 2019 +0100
+++ b/src/hotspot/share/gc/z/zPageTable.inline.hpp Wed Mar 13 11:31:00 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -25,7 +25,7 @@
#define SHARE_GC_Z_ZPAGETABLE_INLINE_HPP
#include "gc/z/zAddress.inline.hpp"
-#include "gc/z/zAddressRangeMap.inline.hpp"
+#include "gc/z/zGranuleMap.inline.hpp"
#include "gc/z/zPageTable.hpp"
inline ZPage* ZPageTable::get(uintptr_t addr) const {
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZAddressRangeMapForPageTable.java Wed Mar 13 11:31:00 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2018, 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.
- *
- */
-
-package sun.jvm.hotspot.gc.z;
-
-import sun.jvm.hotspot.debugger.Address;
-import sun.jvm.hotspot.runtime.VM;
-import sun.jvm.hotspot.runtime.VMObject;
-import sun.jvm.hotspot.types.AddressField;
-import sun.jvm.hotspot.types.Type;
-import sun.jvm.hotspot.types.TypeDataBase;
-
-public class ZAddressRangeMapForPageTable extends VMObject {
- private static AddressField mapField;
-
- static {
- VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase()));
- }
-
- static private synchronized void initialize(TypeDataBase db) {
- Type type = db.lookupType("ZAddressRangeMapForPageTable");
-
- mapField = type.getAddressField("_map");
- }
-
- public ZAddressRangeMapForPageTable(Address addr) {
- super(addr);
- }
-
- private Address map() {
- return mapField.getValue(addr);
- }
-
- public long size() {
- return ZGlobals.ZAddressOffsetMax >> ZGlobals.ZGranuleSizeShift;
- }
-
- private long index_for_addr(Address addr) {
- long index = ZAddress.offset(addr) >> ZGlobals.ZGranuleSizeShift;
-
- return index;
- }
-
- Address at(long index) {
- return map().getAddressAt(index * VM.getVM().getBytesPerLong());
- }
-
- Address get(Address addr) {
- long index = index_for_addr(addr);
- return at(index);
- }
-
- public class Iterator {
- private long next = 0;
-
- boolean hasNext() {
- return next < size();
- }
-
- Address next() {
- if (next >= size()) {
- throw new RuntimeException("OOIBE");
- }
-
- return at(next++);
- }
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZGranuleMapForPageTable.java Wed Mar 13 11:31:00 2019 +0100
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2018, 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.
+ *
+ */
+
+package sun.jvm.hotspot.gc.z;
+
+import sun.jvm.hotspot.debugger.Address;
+import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.runtime.VMObject;
+import sun.jvm.hotspot.types.AddressField;
+import sun.jvm.hotspot.types.Type;
+import sun.jvm.hotspot.types.TypeDataBase;
+
+public class ZGranuleMapForPageTable extends VMObject {
+ private static AddressField mapField;
+
+ static {
+ VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase()));
+ }
+
+ static private synchronized void initialize(TypeDataBase db) {
+ Type type = db.lookupType("ZGranuleMapForPageTable");
+
+ mapField = type.getAddressField("_map");
+ }
+
+ public ZGranuleMapForPageTable(Address addr) {
+ super(addr);
+ }
+
+ private Address map() {
+ return mapField.getValue(addr);
+ }
+
+ public long size() {
+ return ZGlobals.ZAddressOffsetMax >> ZGlobals.ZGranuleSizeShift;
+ }
+
+ private long index_for_addr(Address addr) {
+ long index = ZAddress.offset(addr) >> ZGlobals.ZGranuleSizeShift;
+
+ return index;
+ }
+
+ Address at(long index) {
+ return map().getAddressAt(index * VM.getVM().getBytesPerLong());
+ }
+
+ Address get(Address addr) {
+ long index = index_for_addr(addr);
+ return at(index);
+ }
+
+ public class Iterator {
+ private long next = 0;
+
+ boolean hasNext() {
+ return next < size();
+ }
+
+ Address next() {
+ if (next >= size()) {
+ throw new RuntimeException("OOIBE");
+ }
+
+ return at(next++);
+ }
+ }
+}
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZPageTable.java Wed Mar 13 11:31:00 2019 +0100
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZPageTable.java Wed Mar 13 11:31:00 2019 +0100
@@ -50,8 +50,8 @@
super(addr);
}
- private ZAddressRangeMapForPageTable map() {
- return (ZAddressRangeMapForPageTable)VMObjectFactory.newObject(ZAddressRangeMapForPageTable.class, addr.addOffsetTo(mapFieldOffset));
+ private ZGranuleMapForPageTable map() {
+ return (ZGranuleMapForPageTable)VMObjectFactory.newObject(ZGranuleMapForPageTable.class, addr.addOffsetTo(mapFieldOffset));
}
private ZPageTableEntry getEntry(Address o) {
@@ -67,7 +67,7 @@
}
private class ZPagesIterator implements Iterator<ZPage> {
- private ZAddressRangeMapForPageTable.Iterator mapIter;
+ private ZGranuleMapForPageTable.Iterator mapIter;
private ZPage next;
ZPagesIterator() {