Skip to content

Commit

Permalink
8297534: Specify the size of MEMFLAGS
Browse files Browse the repository at this point in the history
Reviewed-by: stuefe, tschatzl
  • Loading branch information
jdksjolen committed Nov 28, 2022
1 parent 012dafe commit 81eb5fb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/hotspot/share/memory/allocation.hpp
Expand Up @@ -26,6 +26,7 @@
#define SHARE_MEMORY_ALLOCATION_HPP

#include "memory/allStatic.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"

Expand Down Expand Up @@ -138,11 +139,13 @@ typedef AllocFailStrategy::AllocFailEnum AllocFailType;
/*
* Memory types
*/
enum class MEMFLAGS {
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;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/services/mallocHeader.hpp
Expand Up @@ -92,7 +92,7 @@ class MallocHeader {
NOT_LP64(uint32_t _alt_canary);
const size_t _size;
const uint32_t _mst_marker;
const uint8_t _flags;
const MEMFLAGS _flags;
const uint8_t _unused;
uint16_t _canary;

Expand All @@ -119,7 +119,7 @@ class MallocHeader {
inline MallocHeader(size_t size, MEMFLAGS flags, uint32_t mst_marker);

inline size_t size() const { return _size; }
inline MEMFLAGS flags() const { return (MEMFLAGS)_flags; }
inline MEMFLAGS flags() const { return _flags; }
inline uint32_t mst_marker() const { return _mst_marker; }
bool get_stack(NativeCallStack& stack) const;

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/services/mallocHeader.inline.hpp
Expand Up @@ -35,7 +35,7 @@
#include "utilities/nativeCallStack.hpp"

inline MallocHeader::MallocHeader(size_t size, MEMFLAGS flags, uint32_t mst_marker)
: _size(size), _mst_marker(mst_marker), _flags(NMTUtil::flag_to_index(flags)),
: _size(size), _mst_marker(mst_marker), _flags(flags),
_unused(0), _canary(_header_canary_life_mark)
{
assert(size < max_reasonable_malloc_size, "Too large allocation size?");
Expand Down

1 comment on commit 81eb5fb

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.