--- /dev/null 2019-09-04 10:58:08.784555846 -0700 +++ new/src/hotspot/share/gc/g1/g1MemoryNodeManager.hpp 2019-09-21 06:25:33.421961305 -0700 @@ -0,0 +1,71 @@ +/* + * 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; + +public: + static const uint InvalidNodeIndex = (uint)os::InvalidId; + static const uint AnyNodeIndex = (uint)os::AnyId; + + static G1MemoryNodeManager* mgr() { return _inst; } + + static G1MemoryNodeManager* create(); + + virtual ~G1MemoryNodeManager() { } + + // Set page size of Java Heap. + virtual void set_page_size(size_t page_size) { } + + // Print current active memory node count. + virtual uint num_active_nodes() const { return 1; } + + // Returns memory node ids + virtual const int* node_ids() const { static int dummy_id = 0; return &dummy_id; } + + virtual uint index_of_current_thread() const { return 0; } + + // If the given node index is valid return same index, + // If it is not valid, generate valid random index. + virtual uint valid_node_index(uint node_index) const { return 0; } + + virtual bool is_valid_node_index(uint node_index) const { + // Single node index should be always 0. + return node_index == 0; + } + + // Retrieve node index of the given address. + virtual uint index_of_address(HeapWord* addr) const { return 0; } +}; + +#endif // SHARE_VM_GC_G1_MEMORY_NODE_MANAGER_HPP