< prev index next >

src/hotspot/share/memory/metaspace/testHelpers.hpp

Print this page

 58     return _arena;
 59   }
 60 
 61   MetaspaceTestArena(Mutex* lock, MetaspaceArena* arena);
 62   ~MetaspaceTestArena();
 63 
 64   MetaWord* allocate(size_t word_size);
 65   void deallocate(MetaWord* p, size_t word_size);
 66 
 67 };
 68 
 69 // Wraps an instance of a MetaspaceContext together with some side objects for easy use in test beds (whitebox, gtests)
 70 class MetaspaceTestContext : public CHeapObj<mtInternal> {
 71 
 72   const char* const _name;
 73   const size_t _reserve_limit;
 74   const size_t _commit_limit;
 75 
 76   MetaspaceContext* _context;
 77   CommitLimiter _commit_limiter;
 78   SizeAtomicCounter _used_words_counter;
 79 
 80   // For non-expandable contexts we keep track of the space
 81   // and delete it at destruction time.
 82   ReservedSpace _rs;
 83 
 84 public:
 85 
 86   // Note: limit == 0 means unlimited
 87   // Reserve limit > 0 simulates a non-expandable VirtualSpaceList (like CompressedClassSpace)
 88   // Commit limit > 0 simulates a limit to max committable space (like MaxMetaspaceSize)
 89   MetaspaceTestContext(const char* name, size_t commit_limit = 0, size_t reserve_limit = 0);
 90   ~MetaspaceTestContext();
 91 
 92   // Create an arena, feeding off this area.
 93   MetaspaceTestArena* create_arena(Metaspace::MetaspaceType type);
 94 
 95   void purge_area();
 96 
 97   // Accessors
 98   const CommitLimiter& commit_limiter() const { return _commit_limiter; }
 99   const VirtualSpaceList& vslist() const      { return *(_context->vslist()); }
100   ChunkManager& cm()                          { return *(_context->cm()); }

101 
102   // Returns reserve- and commit limit we run the test with (in the real world,
103   // these would be equivalent to CompressedClassSpaceSize resp MaxMetaspaceSize)
104   size_t reserve_limit() const    { return _reserve_limit == 0 ? max_uintx : 0; }
105   size_t commit_limit() const     { return _commit_limit == 0 ? max_uintx : 0; }
106 
107   // Convenience function to retrieve total committed/used words
108   size_t used_words() const       { return _used_words_counter.get(); }
109   size_t committed_words() const  { return _commit_limiter.committed_words(); }
110 
111   DEBUG_ONLY(void verify() const;)
112 
113   void print_on(outputStream* st) const;
114 
115 };
116 
117 } // namespace metaspace
118 
119 #endif // SHARE_MEMORY_METASPACE_TESTHELPERS_HPP

 58     return _arena;
 59   }
 60 
 61   MetaspaceTestArena(Mutex* lock, MetaspaceArena* arena);
 62   ~MetaspaceTestArena();
 63 
 64   MetaWord* allocate(size_t word_size);
 65   void deallocate(MetaWord* p, size_t word_size);
 66 
 67 };
 68 
 69 // Wraps an instance of a MetaspaceContext together with some side objects for easy use in test beds (whitebox, gtests)
 70 class MetaspaceTestContext : public CHeapObj<mtInternal> {
 71 
 72   const char* const _name;
 73   const size_t _reserve_limit;
 74   const size_t _commit_limit;
 75 
 76   MetaspaceContext* _context;
 77   CommitLimiter _commit_limiter;

 78 
 79   // For non-expandable contexts we keep track of the space
 80   // and delete it at destruction time.
 81   ReservedSpace _rs;
 82 
 83 public:
 84 
 85   // Note: limit == 0 means unlimited
 86   // Reserve limit > 0 simulates a non-expandable VirtualSpaceList (like CompressedClassSpace)
 87   // Commit limit > 0 simulates a limit to max committable space (like MaxMetaspaceSize)
 88   MetaspaceTestContext(const char* name, size_t commit_limit = 0, size_t reserve_limit = 0);
 89   ~MetaspaceTestContext();
 90 
 91   // Create an arena, feeding off this area.
 92   MetaspaceTestArena* create_arena(Metaspace::MetaspaceType type);
 93 
 94   void purge_area();
 95 
 96   // Accessors
 97   const CommitLimiter& commit_limiter() const { return _commit_limiter; }
 98   const VirtualSpaceList& vslist() const      { return *(_context->vslist()); }
 99   ChunkManager& cm()                          { return *(_context->cm()); }
100   MetaspaceContext* context() const           { return _context; }
101 
102   // Returns reserve- and commit limit we run the test with (in the real world,
103   // these would be equivalent to CompressedClassSpaceSize resp MaxMetaspaceSize)
104   size_t reserve_limit() const    { return _reserve_limit == 0 ? max_uintx : 0; }
105   size_t commit_limit() const     { return _commit_limit == 0 ? max_uintx : 0; }
106 
107   size_t used_words() const;
108   size_t committed_words() const;
109   size_t reserved_words() const;
110 
111   DEBUG_ONLY(void verify() const;)
112 
113   void print_on(outputStream* st) const;
114 
115 };
116 
117 } // namespace metaspace
118 
119 #endif // SHARE_MEMORY_METASPACE_TESTHELPERS_HPP
< prev index next >