mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8297534: Specify the size of MEMFLAGS
Reviewed-by: stuefe, tschatzl
This commit is contained in:
parent
012dafee5b
commit
81eb5fbff5
3 changed files with 7 additions and 4 deletions
|
@ -26,6 +26,7 @@
|
||||||
#define SHARE_MEMORY_ALLOCATION_HPP
|
#define SHARE_MEMORY_ALLOCATION_HPP
|
||||||
|
|
||||||
#include "memory/allStatic.hpp"
|
#include "memory/allStatic.hpp"
|
||||||
|
#include "utilities/debug.hpp"
|
||||||
#include "utilities/globalDefinitions.hpp"
|
#include "utilities/globalDefinitions.hpp"
|
||||||
#include "utilities/macros.hpp"
|
#include "utilities/macros.hpp"
|
||||||
|
|
||||||
|
@ -138,11 +139,13 @@ typedef AllocFailStrategy::AllocFailEnum AllocFailType;
|
||||||
/*
|
/*
|
||||||
* Memory types
|
* Memory types
|
||||||
*/
|
*/
|
||||||
enum class MEMFLAGS {
|
enum class MEMFLAGS : uint8_t {
|
||||||
MEMORY_TYPES_DO(MEMORY_TYPE_DECLARE_ENUM)
|
MEMORY_TYPES_DO(MEMORY_TYPE_DECLARE_ENUM)
|
||||||
mt_number_of_types // number of memory types (mtDontTrack
|
mt_number_of_types // number of memory types (mtDontTrack
|
||||||
// is not included as validate type)
|
// 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) \
|
#define MEMORY_TYPE_SHORTNAME(type, human_readable) \
|
||||||
constexpr MEMFLAGS type = MEMFLAGS::type;
|
constexpr MEMFLAGS type = MEMFLAGS::type;
|
||||||
|
|
|
@ -92,7 +92,7 @@ class MallocHeader {
|
||||||
NOT_LP64(uint32_t _alt_canary);
|
NOT_LP64(uint32_t _alt_canary);
|
||||||
const size_t _size;
|
const size_t _size;
|
||||||
const uint32_t _mst_marker;
|
const uint32_t _mst_marker;
|
||||||
const uint8_t _flags;
|
const MEMFLAGS _flags;
|
||||||
const uint8_t _unused;
|
const uint8_t _unused;
|
||||||
uint16_t _canary;
|
uint16_t _canary;
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class MallocHeader {
|
||||||
inline MallocHeader(size_t size, MEMFLAGS flags, uint32_t mst_marker);
|
inline MallocHeader(size_t size, MEMFLAGS flags, uint32_t mst_marker);
|
||||||
|
|
||||||
inline size_t size() const { return _size; }
|
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; }
|
inline uint32_t mst_marker() const { return _mst_marker; }
|
||||||
bool get_stack(NativeCallStack& stack) const;
|
bool get_stack(NativeCallStack& stack) const;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "utilities/nativeCallStack.hpp"
|
#include "utilities/nativeCallStack.hpp"
|
||||||
|
|
||||||
inline MallocHeader::MallocHeader(size_t size, MEMFLAGS flags, uint32_t mst_marker)
|
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)
|
_unused(0), _canary(_header_canary_life_mark)
|
||||||
{
|
{
|
||||||
assert(size < max_reasonable_malloc_size, "Too large allocation size?");
|
assert(size < max_reasonable_malloc_size, "Too large allocation size?");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue