8332042: Move MEMFLAGS to its own include file

Reviewed-by: jsjolen, stefank
This commit is contained in:
Thomas Stuefe 2024-05-14 14:58:51 +00:00
parent 5a4415a6bd
commit 95a601316d
25 changed files with 135 additions and 102 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, Huawei Technologies Co., Ltd. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -27,7 +27,7 @@
#define SHARE_GC_G1_G1MONOTONICARENA_HPP
#include "gc/shared/freeListAllocator.hpp"
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/lockFreeStack.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, 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 @@
#ifndef SHARE_GC_SHARED_OOPSTORAGESET_HPP
#define SHARE_GC_SHARED_OOPSTORAGESET_HPP
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "utilities/debug.hpp"
#include "utilities/enumIterator.hpp"
#include "utilities/globalDefinitions.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2024, 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
@ -34,8 +34,8 @@
#include "gc/shared/stringdedup/stringDedupStorageUse.hpp"
#include "gc/shared/stringdedup/stringDedupTable.hpp"
#include "logging/log.hpp"
#include "memory/allocation.hpp"
#include "memory/iterator.hpp"
#include "nmt/memflags.hpp"
#include "oops/access.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/cpuTimeCounters.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Red Hat, Inc. All rights reserved.
* Copyright (c) 2016, 2024, Red Hat, Inc. 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
@ -28,7 +28,7 @@
#include "gc/shared/taskTerminator.hpp"
#include "gc/shared/taskqueue.hpp"
#include "gc/shenandoah/shenandoahPadding.hpp"
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "runtime/atomic.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/mutex.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, 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
@ -26,7 +26,7 @@
#include "gc/z/zGlobals.hpp"
#include "gc/z/zNMT.hpp"
#include "gc/z/zVirtualMemory.hpp"
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "nmt/memTracker.hpp"
#include "utilities/nativeCallStack.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, 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 @@
#ifndef SHARE_JFR_LEAKPROFILER_JFRBITSET_HPP
#define SHARE_JFR_LEAKPROFILER_JFRBITSET_HPP
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "utilities/objectBitSet.inline.hpp"
typedef ObjectBitSet<mtTracing> JFRBitSet;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, 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 @@
#ifndef SHARE_JFR_PERIODIC_JFRNATIVEMEMORYEVENT_HPP
#define SHARE_JFR_PERIODIC_JFRNATIVEMEMORYEVENT_HPP
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "nmt/nmtUsage.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/ticks.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, 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
@ -26,6 +26,7 @@
#define SHARE_MEMORY_ALLOCATION_HPP
#include "memory/allStatic.hpp"
#include "nmt/memflags.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
@ -99,63 +100,6 @@ typedef AllocFailStrategy::AllocFailEnum AllocFailType;
// void FreeHeap(void* p);
//
#define MEMORY_TYPES_DO(f) \
/* Memory type by sub systems. It occupies lower byte. */ \
f(mtJavaHeap, "Java Heap") /* Java heap */ \
f(mtClass, "Class") /* Java classes */ \
f(mtThread, "Thread") /* thread objects */ \
f(mtThreadStack, "Thread Stack") \
f(mtCode, "Code") /* generated code */ \
f(mtGC, "GC") \
f(mtGCCardSet, "GCCardSet") /* G1 card set remembered set */ \
f(mtCompiler, "Compiler") \
f(mtJVMCI, "JVMCI") \
f(mtInternal, "Internal") /* memory used by VM, but does not belong to */ \
/* any of above categories, and not used by */ \
/* NMT */ \
f(mtOther, "Other") /* memory not used by VM */ \
f(mtSymbol, "Symbol") \
f(mtNMT, "Native Memory Tracking") /* memory used by NMT */ \
f(mtClassShared, "Shared class space") /* class data sharing */ \
f(mtChunk, "Arena Chunk") /* chunk that holds content of arenas */ \
f(mtTest, "Test") /* Test type for verifying NMT */ \
f(mtTracing, "Tracing") \
f(mtLogging, "Logging") \
f(mtStatistics, "Statistics") \
f(mtArguments, "Arguments") \
f(mtModule, "Module") \
f(mtSafepoint, "Safepoint") \
f(mtSynchronizer, "Synchronization") \
f(mtServiceability, "Serviceability") \
f(mtMetaspace, "Metaspace") \
f(mtStringDedup, "String Deduplication") \
f(mtObjectMonitor, "Object Monitors") \
f(mtNone, "Unknown") \
//end
#define MEMORY_TYPE_DECLARE_ENUM(type, human_readable) \
type,
/*
* Memory types
*/
enum class MEMFLAGS : uint8_t {
MEMORY_TYPES_DO(MEMORY_TYPE_DECLARE_ENUM)
mt_number_of_types // number of memory types (mtDontTrack
// is not included as validate type)
};
// Extra insurance that MEMFLAGS truly has the same size as uint8_t.
STATIC_ASSERT(sizeof(MEMFLAGS) == sizeof(uint8_t));
#define MEMORY_TYPE_SHORTNAME(type, human_readable) \
constexpr MEMFLAGS type = MEMFLAGS::type;
// Generate short aliases for the enum values. E.g. mtGC instead of MEMFLAGS::mtGC.
MEMORY_TYPES_DO(MEMORY_TYPE_SHORTNAME)
// Make an int version of the sentinel end value.
constexpr int mt_number_of_types = static_cast<int>(MEMFLAGS::mt_number_of_types);
extern bool NMT_track_callsite;
class NativeCallStack;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, 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
@ -22,9 +22,8 @@
*
*/
#include "precompiled.hpp"
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/guardedMemory.hpp"
#include "nmt/memflags.hpp"
#include "runtime/os.hpp"
void* GuardedMemory::wrap_copy(const void* ptr, const size_t len, const void* tag) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024, 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 @@
#ifndef SHARE_MEMORY_PADDED_HPP
#define SHARE_MEMORY_PADDED_HPP
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "utilities/align.hpp"
#include "utilities/globalDefinitions.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, 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 @@
#ifndef SHARE_NMT_ALLOCATIONSITE_HPP
#define SHARE_NMT_ALLOCATIONSITE_HPP
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "utilities/nativeCallStack.hpp"
// Allocation site represents a code path that makes a memory

View File

@ -26,11 +26,17 @@
#include "nmt/mallocHeader.inline.hpp"
#include "nmt/mallocSiteTable.hpp"
#include "nmt/memflags.hpp"
#include "runtime/os.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/nativeCallStack.hpp"
#include "utilities/ostream.hpp"
// The malloc header, as well as the coming VMATree implementation, rely on MEMFLAGS
// fitting into eight bits.
STATIC_ASSERT(sizeof(MEMFLAGS) == sizeof(uint8_t));
void MallocHeader::print_block_on_error(outputStream* st, address bad_address) const {
assert(bad_address >= (address)this, "sanity");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -26,7 +26,7 @@
#ifndef SHARE_NMT_MALLOCHEADER_HPP
#define SHARE_NMT_MALLOCHEADER_HPP
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include "utilities/nativeCallStack.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -26,8 +26,8 @@
#ifndef SHARE_NMT_MALLOCTRACKER_HPP
#define SHARE_NMT_MALLOCTRACKER_HPP
#include "memory/allocation.hpp"
#include "nmt/mallocHeader.hpp"
#include "nmt/memflags.hpp"
#include "nmt/nmtCommon.hpp"
#include "runtime/atomic.hpp"
#include "runtime/threadCritical.hpp"

View File

@ -1,5 +1,6 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Red Hat, Inc. All rights reserved.
* Copyright (c) 2023, 2024, 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 +26,8 @@
#ifndef SHARE_NMT_MEMFLAGBITMAP_HPP
#define SHARE_NMT_MEMFLAGBITMAP_HPP
#include "memory/allocation.hpp" // for mt_number_of_types
#include "nmt/memflags.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
class MemFlagBitmap {

View File

@ -29,8 +29,8 @@
#include "logging/logAsyncWriter.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "memory/allocation.hpp"
#include "memory/universe.hpp"
#include "nmt/memflags.hpp"
#include "runtime/nonJavaThread.hpp"
#include "runtime/osThread.hpp"
#include "runtime/thread.hpp"

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, Red Hat, Inc. and/or its affiliates.
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,8 +26,8 @@
#ifndef SHARE_SERVICES_MEMMAPPRINTER_HPP
#define SHARE_SERVICES_MEMMAPPRINTER_HPP
#include "memory/allocation.hpp"
#include "memory/allStatic.hpp"
#include "nmt/memflags.hpp"
#include "utilities/globalDefinitions.hpp"
#ifdef LINUX

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, 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
@ -23,10 +23,10 @@
*/
#include "precompiled.hpp"
#include "cds/filemap.hpp"
#include "memory/allocation.hpp"
#include "memory/metaspace.hpp"
#include "memory/metaspaceUtils.hpp"
#include "nmt/mallocTracker.hpp"
#include "nmt/memflags.hpp"
#include "nmt/memReporter.hpp"
#include "nmt/threadStackTracker.hpp"
#include "nmt/virtualMemoryTracker.hpp"

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2012, 2024, 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_NMT_MEMFLAGS_HPP
#define SHARE_NMT_MEMFLAGS_HPP
#include "utilities/globalDefinitions.hpp"
#define MEMORY_TYPES_DO(f) \
/* Memory type by sub systems. It occupies lower byte. */ \
f(mtJavaHeap, "Java Heap") /* Java heap */ \
f(mtClass, "Class") /* Java classes */ \
f(mtThread, "Thread") /* thread objects */ \
f(mtThreadStack, "Thread Stack") \
f(mtCode, "Code") /* generated code */ \
f(mtGC, "GC") \
f(mtGCCardSet, "GCCardSet") /* G1 card set remembered set */ \
f(mtCompiler, "Compiler") \
f(mtJVMCI, "JVMCI") \
f(mtInternal, "Internal") /* memory used by VM, but does not belong to */ \
/* any of above categories, and not used by */ \
/* NMT */ \
f(mtOther, "Other") /* memory not used by VM */ \
f(mtSymbol, "Symbol") \
f(mtNMT, "Native Memory Tracking") /* memory used by NMT */ \
f(mtClassShared, "Shared class space") /* class data sharing */ \
f(mtChunk, "Arena Chunk") /* chunk that holds content of arenas */ \
f(mtTest, "Test") /* Test type for verifying NMT */ \
f(mtTracing, "Tracing") \
f(mtLogging, "Logging") \
f(mtStatistics, "Statistics") \
f(mtArguments, "Arguments") \
f(mtModule, "Module") \
f(mtSafepoint, "Safepoint") \
f(mtSynchronizer, "Synchronization") \
f(mtServiceability, "Serviceability") \
f(mtMetaspace, "Metaspace") \
f(mtStringDedup, "String Deduplication") \
f(mtObjectMonitor, "Object Monitors") \
f(mtNone, "Unknown") \
//end
#define MEMORY_TYPE_DECLARE_ENUM(type, human_readable) \
type,
enum class MEMFLAGS : uint8_t {
MEMORY_TYPES_DO(MEMORY_TYPE_DECLARE_ENUM)
mt_number_of_types // number of memory types (mtDontTrack
// is not included as validate type)
};
#define MEMORY_TYPE_SHORTNAME(type, human_readable) \
constexpr MEMFLAGS type = MEMFLAGS::type;
// Generate short aliases for the enum values. E.g. mtGC instead of MEMFLAGS::mtGC.
MEMORY_TYPES_DO(MEMORY_TYPE_SHORTNAME)
// Make an int version of the sentinel end value.
constexpr int mt_number_of_types = static_cast<int>(MEMFLAGS::mt_number_of_types);
#endif // SHARE_NMT_MEMFLAGS_HPP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@ -27,7 +27,8 @@
#ifndef SHARE_NMT_NMTCOMMON_HPP
#define SHARE_NMT_NMTCOMMON_HPP
#include "memory/allocation.hpp" // for MEMFLAGS only
#include "memory/allStatic.hpp"
#include "nmt/memflags.hpp"
#include "utilities/align.hpp"
#include "utilities/globalDefinitions.hpp"

View File

@ -25,7 +25,7 @@
#ifndef SHARE_PRIMS_JVMTIAGENTLIST_HPP
#define SHARE_PRIMS_JVMTIAGENTLIST_HPP
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "prims/jvmtiAgent.hpp"
#include "utilities/growableArray.hpp"

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2023 SAP SE. All rights reserved.
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, 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
@ -24,8 +24,7 @@
*/
#include "precompiled.hpp"
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "nmt/nmtCommon.hpp"
#include "runtime/java.hpp"
#include "runtime/globals.hpp"

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2023 SAP SE. All rights reserved.
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, 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
@ -26,7 +26,7 @@
#ifndef SHARE_SERVICES_MALLOCLIMIT_HPP
#define SHARE_SERVICES_MALLOCLIMIT_HPP
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2024, 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
@ -28,11 +28,11 @@
#include "classfile/vmClasses.hpp"
#include "classfile/vmSymbols.hpp"
#include "gc/shared/oopStorageSet.hpp"
#include "memory/allocation.hpp"
#include "memory/heapInspection.hpp"
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
#include "nmt/memflags.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/klass.inline.hpp"
#include "oops/objArrayKlass.hpp"

View File

@ -25,7 +25,7 @@
#ifndef SHARE_UTILITIES_BITMAP_HPP
#define SHARE_UTILITIES_BITMAP_HPP
#include "memory/allocation.hpp"
#include "nmt/memflags.hpp"
#include "runtime/atomic.hpp"
#include "utilities/globalDefinitions.hpp"