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/allocation.hpp" 29 #include "runtime/os.hpp" 30 31 // Helper class to manage memory nodes. 32 // G1MemoryMultiNodeManager will be created if UseNUMA is enabled and active 33 // NUMA nodes are more than one. Otherwise, G1MemoryNodeManager will be created. 34 class G1MemoryNodeManager : public CHeapObj<mtGC> { 35 static G1MemoryNodeManager* _inst; 36 37 public: 38 static const uint InvalidNodeIndex = (uint)os::InvalidId; 39 static const uint AnyNodeIndex = (uint)os::AnyId; 40 41 static G1MemoryNodeManager* mgr() { return _inst; } 42 43 static G1MemoryNodeManager* create(); 44 45 virtual ~G1MemoryNodeManager() { } 46 47 // Set page size of Java Heap. 48 virtual void set_page_size(size_t page_size) { } 49 50 // Print current active memory node count. 51 virtual uint num_active_nodes() const { return 1; } 52 53 // Returns memory node ids 54 virtual const int* node_ids() const { static int dummy_id = 0; return &dummy_id; } 55 56 virtual uint index_of_current_thread() const { return 0; } 57 58 // If the given node index is valid return same index, 59 // If it is not valid, generate valid random index. 60 virtual uint valid_node_index(uint node_index) const { return 0; } 61 62 virtual bool is_valid_node_index(uint node_index) const { 63 // Single node index should be always 0. 64 return node_index == 0; 65 } 66 67 // Retrieve node index of the given address. 68 virtual uint index_of_address(HeapWord* addr) const { return 0; } 69 }; 70 71 #endif // SHARE_VM_GC_G1_MEMORY_NODE_MANAGER_HPP