1 /* 2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_GC_G1_MEMORY_NODE_MANAGER_HPP 26 #define SHARE_VM_GC_G1_MEMORY_NODE_MANAGER_HPP 27 28 #include "memory/virtualspace.hpp" 29 #include "memory/allocation.hpp" 30 #include "runtime/os.hpp" 31 32 // Helper class to manage memory nodes. 33 // G1MemoryMultiNodeManager will be created if UseNUMA is enabled and active 34 // NUMA nodes are more than one. Otherwise, G1MemoryNodeManager will be created. 35 class G1MemoryNodeManager : public CHeapObj<mtGC> { 36 static G1MemoryNodeManager* _inst; 37 38 protected: 39 G1MemoryNodeManager() { } 40 41 public: 42 static const uint InvalidNodeIndex = UINT_MAX; 43 static const uint AnyNodeIndex = InvalidNodeIndex - 1; 44 45 static G1MemoryNodeManager* mgr() { return _inst; } 46 47 static G1MemoryNodeManager* create(); 48 49 virtual ~G1MemoryNodeManager() { } 50 51 virtual void set_page_size(size_t page_size) { } 52 53 // Print current active memory node count. 54 virtual uint num_active_nodes() const { return 1; } 55 56 // Returns memory node ids 57 virtual const int* node_ids() const; 58 59 virtual uint index_of_current_thread() const { return 0; } 60 61 virtual bool is_valid_node_index(uint node_index) const { 62 // Single node index should be always 0. 63 return node_index == 0; 64 } 65 66 virtual uint preferred_index_for_address(HeapWord* addr) const { return 0; } 67 68 // Retrieve node index of the given address. 69 virtual uint index_of_address(HeapWord* addr) const { return 0; } 70 }; 71 72 #endif // SHARE_VM_GC_G1_MEMORY_NODE_MANAGER_HPP