--- old/src/hotspot/share/gc/z/vmStructs_z.hpp 2019-02-25 10:40:50.274046312 +0100 +++ new/src/hotspot/share/gc/z/vmStructs_z.hpp 2019-02-25 10:40:49.913034766 +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 ZAddressRangeMapForPageTable; +typedef ZGranuleMap 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) \ --- old/src/hotspot/share/gc/z/zHeapIterator.cpp 2019-02-25 10:40:50.814063583 +0100 +++ new/src/hotspot/share/gc/z/zHeapIterator.cpp 2019-02-25 10:40:50.450051941 +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" --- old/src/hotspot/share/gc/z/zHeapIterator.hpp 2019-02-25 10:40:51.350080725 +0100 +++ new/src/hotspot/share/gc/z/zHeapIterator.hpp 2019-02-25 10:40:50.989069180 +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 ZVisitMap; - typedef ZAddressRangeMapIterator ZVisitMapIterator; - typedef Stack ZVisitStack; + typedef ZGranuleMap ZVisitMap; + typedef ZGranuleMapIterator ZVisitMapIterator; + typedef Stack ZVisitStack; ZVisitStack _visit_stack; ZVisitMap _visit_map; --- old/src/hotspot/share/gc/z/zPageTable.cpp 2019-02-25 10:40:51.876097548 +0100 +++ new/src/hotspot/share/gc/z/zPageTable.cpp 2019-02-25 10:40:51.514085970 +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" --- old/src/hotspot/share/gc/z/zPageTable.hpp 2019-02-25 10:40:52.400114307 +0100 +++ new/src/hotspot/share/gc/z/zPageTable.hpp 2019-02-25 10:40:52.038102729 +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 _map; + ZGranuleMap _map; ZPageTableEntry get_entry(ZPage* page) const; void put_entry(ZPage* page, ZPageTableEntry entry); @@ -55,8 +54,8 @@ class ZPageTableIterator : public StackObj { private: - ZAddressRangeMapIterator _iter; - ZPage* _prev; + ZGranuleMapIterator _iter; + ZPage* _prev; public: ZPageTableIterator(const ZPageTable* pagetable); --- old/src/hotspot/share/gc/z/zPageTable.inline.hpp 2019-02-25 10:40:52.935131417 +0100 +++ new/src/hotspot/share/gc/z/zPageTable.inline.hpp 2019-02-25 10:40:52.574119872 +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 { --- old/src/hotspot/share/gc/z/zAddressRangeMap.hpp 2019-02-25 10:40:53.624153453 +0100 +++ /dev/null 2019-02-07 14:09:14.871564351 +0100 @@ -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 -class ZAddressRangeMapIterator; - -template -class ZAddressRangeMap { - friend class VMStructs; - friend class ZAddressRangeMapIterator; - -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 -class ZAddressRangeMapIterator : public StackObj { -public: - const ZAddressRangeMap* const _map; - size_t _next; - -public: - ZAddressRangeMapIterator(const ZAddressRangeMap* map); - - bool next(T* value); -}; - -#endif // SHARE_GC_Z_ZADDRESSRANGEMAP_HPP --- /dev/null 2019-02-07 14:09:14.871564351 +0100 +++ new/src/hotspot/share/gc/z/zGranuleMap.hpp 2019-02-25 10:40:53.102136758 +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 +class ZGranuleMapIterator; + +template +class ZGranuleMap { + friend class VMStructs; + friend class ZGranuleMapIterator; + +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 +class ZGranuleMapIterator : public StackObj { +public: + const ZGranuleMap* const _map; + size_t _next; + +public: + ZGranuleMapIterator(const ZGranuleMap* map); + + bool next(T* value); +}; + +#endif // SHARE_GC_Z_ZGRANULEMAP_HPP --- old/src/hotspot/share/gc/z/zAddressRangeMap.inline.hpp 2019-02-25 10:40:54.328175969 +0100 +++ /dev/null 2019-02-07 14:09:14.871564351 +0100 @@ -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 -ZAddressRangeMap::ZAddressRangeMap() : - _map(MmapArrayAllocator::allocate(size(), mtGC)) {} - -template -ZAddressRangeMap::~ZAddressRangeMap() { - MmapArrayAllocator::free(_map, size()); -} - -template -size_t ZAddressRangeMap::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 -size_t ZAddressRangeMap::size() const { - return ZAddressOffsetMax >> AddressRangeShift; -} - -template -T ZAddressRangeMap::get(uintptr_t addr) const { - const uintptr_t index = index_for_addr(addr); - return _map[index]; -} - -template -void ZAddressRangeMap::put(uintptr_t addr, T value) { - const uintptr_t index = index_for_addr(addr); - _map[index] = value; -} - -template -inline ZAddressRangeMapIterator::ZAddressRangeMapIterator(const ZAddressRangeMap* map) : - _map(map), - _next(0) {} - -template -inline bool ZAddressRangeMapIterator::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 2019-02-07 14:09:14.871564351 +0100 +++ new/src/hotspot/share/gc/z/zGranuleMap.inline.hpp 2019-02-25 10:40:53.809159370 +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 +inline ZGranuleMap::ZGranuleMap() : + _map(MmapArrayAllocator::allocate(size(), mtGC)) {} + +template +inline ZGranuleMap::~ZGranuleMap() { + MmapArrayAllocator::free(_map, size()); +} + +template +inline size_t ZGranuleMap::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 +inline size_t ZGranuleMap::size() const { + return ZAddressOffsetMax >> ZGranuleSizeShift; +} + +template +inline T ZGranuleMap::get(uintptr_t addr) const { + const size_t index = index_for_addr(addr); + return _map[index]; +} + +template +inline void ZGranuleMap::put(uintptr_t addr, T value) { + const size_t index = index_for_addr(addr); + _map[index] = value; +} + +template +inline ZGranuleMapIterator::ZGranuleMapIterator(const ZGranuleMap* map) : + _map(map), + _next(0) {} + +template +inline bool ZGranuleMapIterator::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