/* * Copyright (c) 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_VM_GC_G1_MEMORY_NODE_MANAGER_HPP #define SHARE_VM_GC_G1_MEMORY_NODE_MANAGER_HPP #include "memory/allocation.hpp" #include "runtime/os.hpp" // Helper class to manage memory nodes. // G1MemoryMultiNodeManager will be created if UseNUMA is enabled and active // NUMA nodes are more than one. Otherwise, G1MemoryNodeManager will be created. class G1MemoryNodeManager : public CHeapObj { static G1MemoryNodeManager* _inst; protected: G1MemoryNodeManager() { } public: static const uint UnknownNodeIndex = UINT_MAX; static const uint AnyNodeIndex = UnknownNodeIndex - 1; static G1MemoryNodeManager* mgr() { return _inst; } static G1MemoryNodeManager* create(); virtual ~G1MemoryNodeManager() { } // Set heap region size and page size after those values are determined // at G1CollectedHeap::initialize(). virtual void set_region_info(size_t region_size, size_t page_size) { } // Print current active memory node count. virtual uint num_active_nodes() const { return 1; } virtual bool has_multi_nodes() const { return false; } // Returns memory node ids virtual const int* node_ids() const; // Returns node index of current calling thread. virtual uint index_of_current_thread() const { return 0; } // Returns the preferred index for the given HeapRegion index. // This assumes that HeapRegions are evenly spit, so we can decide preferred index // with the given HeapRegion index. // Result is less than num_active_nodes(). virtual uint preferred_node_index_for_index(uint region_index) const { return 0; } // Retrieve node index of the given address. // Result is less than num_active_nodes() or is UnknownNodeIndex. // Precondition: address is in reserved range for heap. virtual uint index_of_address(HeapWord* address) const { return 0; } // Request the given memory area to be located at the given node index. virtual void request_memory_on_node(char* aligned_address, size_t size_in_bytes, uint node_index) { } // Returns maximum search depth which is used to limit heap region search iterations. // The number of active nodes, page size and heap region size are considered. virtual const uint max_search_depth() const { return 1; } }; #endif // SHARE_VM_GC_G1_MEMORY_NODE_MANAGER_HPP