< prev index next > src/hotspot/share/memory/metaspace.hpp
Print this page
*/
#ifndef SHARE_MEMORY_METASPACE_HPP
#define SHARE_MEMORY_METASPACE_HPP
#include "memory/allocation.hpp"
#include "runtime/globals.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/globalDefinitions.hpp"
class ClassLoaderData;
class MetaspaceShared;
class MetaspaceTracer;
class Mutex;
class outputStream;
- class ReservedSpace;
////////////////// Metaspace ///////////////////////
// Namespace for important central static functions
// (auxiliary stuff goes into MetaspaceUtils)
*/
#ifndef SHARE_MEMORY_METASPACE_HPP
#define SHARE_MEMORY_METASPACE_HPP
#include "memory/allocation.hpp"
+ #include "memory/virtualspace.hpp"
#include "runtime/globals.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/globalDefinitions.hpp"
class ClassLoaderData;
class MetaspaceShared;
class MetaspaceTracer;
class Mutex;
class outputStream;
////////////////// Metaspace ///////////////////////
// Namespace for important central static functions
// (auxiliary stuff goes into MetaspaceUtils)
private:
static const MetaspaceTracer* _tracer;
! static bool _initialized;
public:
static const MetaspaceTracer* tracer() { return _tracer; }
private:
static const MetaspaceTracer* _tracer;
! // For quick pointer testing: extent of class space; nullptr if no class space.
+ static const void* _class_space_start;
+ static const void* _class_space_end;
public:
static const MetaspaceTracer* tracer() { return _tracer; }
static size_t commit_alignment_words();
// The largest possible single allocation
static size_t max_allocation_word_size();
static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size,
MetaspaceObj::Type type, TRAPS);
// Non-TRAPS version of allocate which can be called by a non-Java thread, that returns
// null on failure.
static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size,
MetaspaceObj::Type type);
! static bool contains(const void* ptr);
! static bool contains_non_shared(const void* ptr);
// Free empty virtualspaces
static void purge(bool classes_unloaded);
static void report_metadata_oome(ClassLoaderData* loader_data, size_t word_size,
static size_t commit_alignment_words();
// The largest possible single allocation
static size_t max_allocation_word_size();
+ // Minimum allocation alignment, in bytes. All MetaData shall be aligned correclty
+ // to be able to hold 64-bit data types. Unlike malloc, we don't care for larger
+ // data types.
+ static constexpr size_t min_allocation_alignment_bytes = sizeof(uint64_t);
+
+ // Minimum allocation alignment, in words, Metaspace observes.
+ static constexpr size_t min_allocation_alignment_words = min_allocation_alignment_bytes / BytesPerWord;
+
+ // Every allocation will get rounded up to the minimum word size.
+ static constexpr size_t min_allocation_word_size = min_allocation_alignment_words;
+
static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size,
MetaspaceObj::Type type, TRAPS);
// Non-TRAPS version of allocate which can be called by a non-Java thread, that returns
// null on failure.
static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size,
MetaspaceObj::Type type);
! static bool contains(const void* ptr) {
! return is_in_shared_metaspace(ptr) || // in cds
+ is_in_class_space(ptr) || // in class space
+ is_in_nonclass_metaspace(ptr); // in one of the non-class regions?
+ }
+
+ // kept for now for backward compat reasons, but lets test if callers really need this
+ static bool contains_non_shared(const void* ptr) {
+ return is_in_class_space(ptr) || // in class space
+ is_in_nonclass_metaspace(ptr); // in one of the non-class regions?
+ }
+
+ // Returns true if pointer points into one of the metaspace regions, or
+ // into the class space.
+ static bool is_in_shared_metaspace(const void* ptr);
+
+ // Returns true if pointer points into one of the non-class-space metaspace regions.
+ static bool is_in_nonclass_metaspace(const void* ptr);
+
+ // Returns true if ptr points into class space, false if it doesn't or if
+ // there is no class space.
+ static inline bool is_in_class_space(const void* ptr) {
+ return ptr < _class_space_end && ptr >= _class_space_start;
+ }
// Free empty virtualspaces
static void purge(bool classes_unloaded);
static void report_metadata_oome(ClassLoaderData* loader_data, size_t word_size,
< prev index next >