1 /*
  2  * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_GC_SHARED_SPACE_HPP
 26 #define SHARE_GC_SHARED_SPACE_HPP
 27 
 28 #include "gc/shared/blockOffsetTable.hpp"
 29 #include "gc/shared/cardTable.hpp"
 30 #include "gc/shared/workerThread.hpp"
 31 #include "memory/allocation.hpp"
 32 #include "memory/iterator.hpp"
 33 #include "memory/memRegion.hpp"
 34 #include "oops/markWord.hpp"
 35 #include "runtime/mutexLocker.hpp"
 36 #include "utilities/align.hpp"
 37 #include "utilities/macros.hpp"
 38 
 39 // A space is an abstraction for the "storage units" backing
 40 // up the generation abstraction. It includes specific
 41 // implementations for keeping track of free and used space,
 42 // for iterating over objects and free blocks, etc.
 43 
 44 // Forward decls.
 45 class Space;
 46 class BlockOffsetArray;
 47 class BlockOffsetArrayContigSpace;
 48 class Generation;
 49 class CompactibleSpace;
 50 class BlockOffsetTable;
 51 class CardTableRS;
 52 class DirtyCardToOopClosure;
 53 class SlidingForwarding;
 54 
 55 // A Space describes a heap area. Class Space is an abstract
 56 // base class.
 57 //
 58 // Space supports allocation, size computation and GC support is provided.
 59 //
 60 // Invariant: bottom() and end() are on page_size boundaries and
 61 // bottom() <= top() <= end()
 62 // top() is inclusive and end() is exclusive.
 63 
 64 class Space: public CHeapObj<mtGC> {
 65   friend class VMStructs;
 66  protected:
 67   HeapWord* _bottom;
 68   HeapWord* _end;
 69 
 70   // Used in support of save_marks()
 71   HeapWord* _saved_mark_word;
 72 
 73   Space():
 74     _bottom(NULL), _end(NULL) { }
 75 
 76  public:
 77   // Accessors
 78   HeapWord* bottom() const         { return _bottom; }
 79   HeapWord* end() const            { return _end;    }
 80   virtual void set_bottom(HeapWord* value) { _bottom = value; }
 81   virtual void set_end(HeapWord* value)    { _end = value; }
 82 
 83   virtual HeapWord* saved_mark_word() const  { return _saved_mark_word; }
 84 
 85   void set_saved_mark_word(HeapWord* p) { _saved_mark_word = p; }
 86 
 87   // Returns true if this object has been allocated since a
 88   // generation's "save_marks" call.
 89   virtual bool obj_allocated_since_save_marks(const oop obj) const {
 90     return cast_from_oop<HeapWord*>(obj) >= saved_mark_word();
 91   }
 92 
 93   // Returns a subregion of the space containing only the allocated objects in
 94   // the space.
 95   virtual MemRegion used_region() const = 0;
 96 
 97   // Returns a region that is guaranteed to contain (at least) all objects
 98   // allocated at the time of the last call to "save_marks".  If the space
 99   // initializes its DirtyCardToOopClosure's specifying the "contig" option
100   // (that is, if the space is contiguous), then this region must contain only
101   // such objects: the memregion will be from the bottom of the region to the
102   // saved mark.  Otherwise, the "obj_allocated_since_save_marks" method of
103   // the space must distinguish between objects in the region allocated before
104   // and after the call to save marks.
105   MemRegion used_region_at_save_marks() const {
106     return MemRegion(bottom(), saved_mark_word());
107   }
108 
109   // Initialization.
110   // "initialize" should be called once on a space, before it is used for
111   // any purpose.  The "mr" arguments gives the bounds of the space, and
112   // the "clear_space" argument should be true unless the memory in "mr" is
113   // known to be zeroed.
114   virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
115 
116   // The "clear" method must be called on a region that may have
117   // had allocation performed in it, but is now to be considered empty.
118   virtual void clear(bool mangle_space);
119 
120   // For detecting GC bugs.  Should only be called at GC boundaries, since
121   // some unused space may be used as scratch space during GC's.
122   // We also call this when expanding a space to satisfy an allocation
123   // request. See bug #4668531
124   virtual void mangle_unused_area() = 0;
125   virtual void mangle_unused_area_complete() = 0;
126 
127   // Testers
128   bool is_empty() const              { return used() == 0; }
129   bool not_empty() const             { return used() > 0; }
130 
131   // Returns true iff the given the space contains the
132   // given address as part of an allocated object. For
133   // certain kinds of spaces, this might be a potentially
134   // expensive operation. To prevent performance problems
135   // on account of its inadvertent use in product jvm's,
136   // we restrict its use to assertion checks only.
137   bool is_in(const void* p) const {
138     return used_region().contains(p);
139   }
140   bool is_in(oop obj) const {
141     return is_in((void*)obj);
142   }
143 
144   // Returns true iff the given reserved memory of the space contains the
145   // given address.
146   bool is_in_reserved(const void* p) const { return _bottom <= p && p < _end; }
147 
148   // Returns true iff the given block is not allocated.
149   virtual bool is_free_block(const HeapWord* p) const = 0;
150 
151   // Test whether p is double-aligned
152   static bool is_aligned(void* p) {
153     return ::is_aligned(p, sizeof(double));
154   }
155 
156   // Size computations.  Sizes are in bytes.
157   size_t capacity()     const { return byte_size(bottom(), end()); }
158   virtual size_t used() const = 0;
159   virtual size_t free() const = 0;
160 
161   // Iterate over all the ref-containing fields of all objects in the
162   // space, calling "cl.do_oop" on each.  Fields in objects allocated by
163   // applications of the closure are not included in the iteration.
164   virtual void oop_iterate(OopIterateClosure* cl);
165 
166   // Iterate over all objects in the space, calling "cl.do_object" on
167   // each.  Objects allocated by applications of the closure are not
168   // included in the iteration.
169   virtual void object_iterate(ObjectClosure* blk) = 0;
170 
171   // Create and return a new dirty card to oop closure. Can be
172   // overridden to return the appropriate type of closure
173   // depending on the type of space in which the closure will
174   // operate. ResourceArea allocated.
175   virtual DirtyCardToOopClosure* new_dcto_cl(OopIterateClosure* cl,
176                                              CardTable::PrecisionStyle precision,
177                                              HeapWord* boundary);
178 
179   // If "p" is in the space, returns the address of the start of the
180   // "block" that contains "p".  We say "block" instead of "object" since
181   // some heaps may not pack objects densely; a chunk may either be an
182   // object or a non-object.  If "p" is not in the space, return NULL.
183   virtual HeapWord* block_start_const(const void* p) const = 0;
184 
185   // The non-const version may have benevolent side effects on the data
186   // structure supporting these calls, possibly speeding up future calls.
187   // The default implementation, however, is simply to call the const
188   // version.
189   virtual HeapWord* block_start(const void* p);
190 
191   // Requires "addr" to be the start of a chunk, and returns its size.
192   // "addr + size" is required to be the start of a new chunk, or the end
193   // of the active area of the heap.
194   virtual size_t block_size(const HeapWord* addr) const = 0;
195 
196   // Requires "addr" to be the start of a block, and returns "TRUE" iff
197   // the block is an object.
198   virtual bool block_is_obj(const HeapWord* addr) const = 0;
199 
200   // Requires "addr" to be the start of a block, and returns "TRUE" iff
201   // the block is an object and the object is alive.
202   virtual bool obj_is_alive(const HeapWord* addr) const;
203 
204   // Allocation (return NULL if full).  Assumes the caller has established
205   // mutually exclusive access to the space.
206   virtual HeapWord* allocate(size_t word_size) = 0;
207 
208   // Allocation (return NULL if full).  Enforces mutual exclusion internally.
209   virtual HeapWord* par_allocate(size_t word_size) = 0;
210 
211 #if INCLUDE_SERIALGC
212   // Mark-sweep-compact support: all spaces can update pointers to objects
213   // moving as a part of compaction.
214   virtual void adjust_pointers() = 0;
215 #endif
216 
217   virtual void print() const;
218   virtual void print_on(outputStream* st) const;
219   virtual void print_short() const;
220   virtual void print_short_on(outputStream* st) const;
221 
222 
223   // IF "this" is a ContiguousSpace, return it, else return NULL.
224   virtual ContiguousSpace* toContiguousSpace() {
225     return NULL;
226   }
227 
228   // Debugging
229   virtual void verify() const = 0;
230 };
231 
232 // A MemRegionClosure (ResourceObj) whose "do_MemRegion" function applies an
233 // OopClosure to (the addresses of) all the ref-containing fields that could
234 // be modified by virtue of the given MemRegion being dirty. (Note that
235 // because of the imprecise nature of the write barrier, this may iterate
236 // over oops beyond the region.)
237 // This base type for dirty card to oop closures handles memory regions
238 // in non-contiguous spaces with no boundaries, and should be sub-classed
239 // to support other space types. See ContiguousDCTOC for a sub-class
240 // that works with ContiguousSpaces.
241 
242 class DirtyCardToOopClosure: public MemRegionClosureRO {
243 protected:
244   OopIterateClosure* _cl;
245   Space* _sp;
246   CardTable::PrecisionStyle _precision;
247   HeapWord* _boundary;          // If non-NULL, process only non-NULL oops
248                                 // pointing below boundary.
249   HeapWord* _min_done;          // ObjHeadPreciseArray precision requires
250                                 // a downwards traversal; this is the
251                                 // lowest location already done (or,
252                                 // alternatively, the lowest address that
253                                 // shouldn't be done again.  NULL means infinity.)
254   NOT_PRODUCT(HeapWord* _last_bottom;)
255   NOT_PRODUCT(HeapWord* _last_explicit_min_done;)
256 
257   // Get the actual top of the area on which the closure will
258   // operate, given where the top is assumed to be (the end of the
259   // memory region passed to do_MemRegion) and where the object
260   // at the top is assumed to start. For example, an object may
261   // start at the top but actually extend past the assumed top,
262   // in which case the top becomes the end of the object.
263   virtual HeapWord* get_actual_top(HeapWord* top, HeapWord* top_obj);
264 
265   // Walk the given memory region from bottom to (actual) top
266   // looking for objects and applying the oop closure (_cl) to
267   // them. The base implementation of this treats the area as
268   // blocks, where a block may or may not be an object. Sub-
269   // classes should override this to provide more accurate
270   // or possibly more efficient walking.
271   virtual void walk_mem_region(MemRegion mr, HeapWord* bottom, HeapWord* top);
272 
273 public:
274   DirtyCardToOopClosure(Space* sp, OopIterateClosure* cl,
275                         CardTable::PrecisionStyle precision,
276                         HeapWord* boundary) :
277     _cl(cl), _sp(sp), _precision(precision), _boundary(boundary),
278     _min_done(NULL) {
279     NOT_PRODUCT(_last_bottom = NULL);
280     NOT_PRODUCT(_last_explicit_min_done = NULL);
281   }
282 
283   void do_MemRegion(MemRegion mr);
284 
285   void set_min_done(HeapWord* min_done) {
286     _min_done = min_done;
287     NOT_PRODUCT(_last_explicit_min_done = _min_done);
288   }
289 #ifndef PRODUCT
290   void set_last_bottom(HeapWord* last_bottom) {
291     _last_bottom = last_bottom;
292   }
293 #endif
294 };
295 
296 // A structure to represent a point at which objects are being copied
297 // during compaction.
298 class CompactPoint : public StackObj {
299 public:
300   Generation* gen;
301   CompactibleSpace* space;
302 
303   CompactPoint(Generation* g = NULL) :
304     gen(g), space(NULL) {}
305 };
306 
307 // A space that supports compaction operations.  This is usually, but not
308 // necessarily, a space that is normally contiguous.  But, for example, a
309 // free-list-based space whose normal collection is a mark-sweep without
310 // compaction could still support compaction in full GC's.
311 class CompactibleSpace: public Space {
312   friend class VMStructs;
313 private:
314   HeapWord* _compaction_top;
315   CompactibleSpace* _next_compaction_space;
316 
317   template <class SpaceType>
318   static inline void verify_up_to_first_dead(SpaceType* space) NOT_DEBUG_RETURN;
319 
320   template <class SpaceType>
321   static inline void clear_empty_region(SpaceType* space);
322 
323 public:
324   CompactibleSpace() :
325    _compaction_top(NULL), _next_compaction_space(NULL) {}
326 
327   virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
328   virtual void clear(bool mangle_space);
329 
330   // Used temporarily during a compaction phase to hold the value
331   // top should have when compaction is complete.
332   HeapWord* compaction_top() const { return _compaction_top;    }
333 
334   void set_compaction_top(HeapWord* value) {
335     assert(value == NULL || (value >= bottom() && value <= end()),
336       "should point inside space");
337     _compaction_top = value;
338   }
339 
340   // Perform operations on the space needed after a compaction
341   // has been performed.
342   virtual void reset_after_compaction() = 0;
343 
344   // Returns the next space (in the current generation) to be compacted in
345   // the global compaction order.  Also is used to select the next
346   // space into which to compact.
347 
348   virtual CompactibleSpace* next_compaction_space() const {
349     return _next_compaction_space;
350   }
351 
352   void set_next_compaction_space(CompactibleSpace* csp) {
353     _next_compaction_space = csp;
354   }
355 
356 #if INCLUDE_SERIALGC
357   // MarkSweep support phase2
358 
359   // Start the process of compaction of the current space: compute
360   // post-compaction addresses, and insert forwarding pointers.  The fields
361   // "cp->gen" and "cp->compaction_space" are the generation and space into
362   // which we are currently compacting.  This call updates "cp" as necessary,
363   // and leaves the "compaction_top" of the final value of
364   // "cp->compaction_space" up-to-date.  Offset tables may be updated in
365   // this phase as if the final copy had occurred; if so, "cp->threshold"
366   // indicates when the next such action should be taken.
367   virtual void prepare_for_compaction(CompactPoint* cp) = 0;
368   // MarkSweep support phase3
369   virtual void adjust_pointers();
370   // MarkSweep support phase4
371   virtual void compact();
372 #endif // INCLUDE_SERIALGC
373 
374   // The maximum percentage of objects that can be dead in the compacted
375   // live part of a compacted space ("deadwood" support.)
376   virtual size_t allowed_dead_ratio() const { return 0; };
377 
378   // Some contiguous spaces may maintain some data structures that should
379   // be updated whenever an allocation crosses a boundary.  This function
380   // initializes these data structures for further updates.
381   virtual void initialize_threshold() { }
382 
383   // "q" is an object of the given "size" that should be forwarded;
384   // "cp" names the generation ("gen") and containing "this" (which must
385   // also equal "cp->space").  "compact_top" is where in "this" the
386   // next object should be forwarded to.  If there is room in "this" for
387   // the object, insert an appropriate forwarding pointer in "q".
388   // If not, go to the next compaction space (there must
389   // be one, since compaction must succeed -- we go to the first space of
390   // the previous generation if necessary, updating "cp"), reset compact_top
391   // and then forward.  In either case, returns the new value of "compact_top".
392   // Invokes the "alloc_block" function of the then-current compaction
393   // space.
394   virtual HeapWord* forward(oop q, size_t size, CompactPoint* cp,
395                     HeapWord* compact_top, SlidingForwarding* const forwarding);
396 
397   // Return a size with adjustments as required of the space.
398   virtual size_t adjust_object_size_v(size_t size) const { return size; }
399 
400   void set_first_dead(HeapWord* value) { _first_dead = value; }
401   void set_end_of_live(HeapWord* value) { _end_of_live = value; }
402 
403 protected:
404   // Used during compaction.
405   HeapWord* _first_dead;
406   HeapWord* _end_of_live;
407 
408   // This the function to invoke when an allocation of an object covering
409   // "start" to "end" occurs to update other internal data structures.
410   virtual void alloc_block(HeapWord* start, HeapWord* the_end) { }
411 };
412 
413 class GenSpaceMangler;
414 
415 // A space in which the free area is contiguous.  It therefore supports
416 // faster allocation, and compaction.
417 class ContiguousSpace: public CompactibleSpace {
418   friend class VMStructs;
419 
420  protected:
421   HeapWord* _top;
422   // A helper for mangling the unused area of the space in debug builds.
423   GenSpaceMangler* _mangler;
424 
425   GenSpaceMangler* mangler() { return _mangler; }
426 
427   // Allocation helpers (return NULL if full).
428   inline HeapWord* allocate_impl(size_t word_size);
429   inline HeapWord* par_allocate_impl(size_t word_size);
430 
431  public:
432   ContiguousSpace();
433   ~ContiguousSpace();
434 
435   virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
436   virtual void clear(bool mangle_space);
437 
438   // Accessors
439   HeapWord* top() const            { return _top;    }
440   void set_top(HeapWord* value)    { _top = value; }
441 
442   void set_saved_mark()            { _saved_mark_word = top();    }
443   void reset_saved_mark()          { _saved_mark_word = bottom(); }
444 
445   bool saved_mark_at_top() const { return saved_mark_word() == top(); }
446 
447   // In debug mode mangle (write it with a particular bit
448   // pattern) the unused part of a space.
449 
450   // Used to save the an address in a space for later use during mangling.
451   void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN;
452   // Used to save the space's current top for later use during mangling.
453   void set_top_for_allocations() PRODUCT_RETURN;
454 
455   // Mangle regions in the space from the current top up to the
456   // previously mangled part of the space.
457   void mangle_unused_area() PRODUCT_RETURN;
458   // Mangle [top, end)
459   void mangle_unused_area_complete() PRODUCT_RETURN;
460 
461   // Do some sparse checking on the area that should have been mangled.
462   void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
463   // Check the complete area that should have been mangled.
464   // This code may be NULL depending on the macro DEBUG_MANGLING.
465   void check_mangled_unused_area_complete() PRODUCT_RETURN;
466 
467   // Size computations: sizes in bytes.
468   size_t capacity() const        { return byte_size(bottom(), end()); }
469   size_t used() const            { return byte_size(bottom(), top()); }
470   size_t free() const            { return byte_size(top(),    end()); }
471 
472   virtual bool is_free_block(const HeapWord* p) const;
473 
474   // In a contiguous space we have a more obvious bound on what parts
475   // contain objects.
476   MemRegion used_region() const { return MemRegion(bottom(), top()); }
477 
478   // Allocation (return NULL if full)
479   virtual HeapWord* allocate(size_t word_size);
480   virtual HeapWord* par_allocate(size_t word_size);
481 
482   // Iteration
483   void oop_iterate(OopIterateClosure* cl);
484   void object_iterate(ObjectClosure* blk);
485 
486   // Compaction support
487   virtual void reset_after_compaction() {
488     assert(compaction_top() >= bottom() && compaction_top() <= end(), "should point inside space");
489     set_top(compaction_top());
490   }
491 
492   // Override.
493   DirtyCardToOopClosure* new_dcto_cl(OopIterateClosure* cl,
494                                      CardTable::PrecisionStyle precision,
495                                      HeapWord* boundary);
496 
497   // Apply "blk->do_oop" to the addresses of all reference fields in objects
498   // starting with the _saved_mark_word, which was noted during a generation's
499   // save_marks and is required to denote the head of an object.
500   // Fields in objects allocated by applications of the closure
501   // *are* included in the iteration.
502   // Updates _saved_mark_word to point to just after the last object
503   // iterated over.
504   template <typename OopClosureType>
505   void oop_since_save_marks_iterate(OopClosureType* blk);
506 
507   // Same as object_iterate, but starting from "mark", which is required
508   // to denote the start of an object.  Objects allocated by
509   // applications of the closure *are* included in the iteration.
510   virtual void object_iterate_from(HeapWord* mark, ObjectClosure* blk);
511 
512   // Very inefficient implementation.
513   virtual HeapWord* block_start_const(const void* p) const;
514   size_t block_size(const HeapWord* p) const;
515   // If a block is in the allocated area, it is an object.
516   bool block_is_obj(const HeapWord* p) const { return p < top(); }
517 
518   // Addresses for inlined allocation
519   HeapWord** top_addr() { return &_top; }
520   HeapWord** end_addr() { return &_end; }
521 
522 #if INCLUDE_SERIALGC
523   // Overrides for more efficient compaction support.
524   void prepare_for_compaction(CompactPoint* cp);
525 #endif
526 
527   virtual void print_on(outputStream* st) const;
528 
529   // Checked dynamic downcasts.
530   virtual ContiguousSpace* toContiguousSpace() {
531     return this;
532   }
533 
534   // Debugging
535   virtual void verify() const;
536 
537   // Used to increase collection frequency.  "factor" of 0 means entire
538   // space.
539   void allocate_temporary_filler(int factor);
540 };
541 
542 
543 // A dirty card to oop closure that does filtering.
544 // It knows how to filter out objects that are outside of the _boundary.
545 class FilteringDCTOC : public DirtyCardToOopClosure {
546 protected:
547   // Override.
548   void walk_mem_region(MemRegion mr,
549                        HeapWord* bottom, HeapWord* top);
550 
551   // Walk the given memory region, from bottom to top, applying
552   // the given oop closure to (possibly) all objects found. The
553   // given oop closure may or may not be the same as the oop
554   // closure with which this closure was created, as it may
555   // be a filtering closure which makes use of the _boundary.
556   // We offer two signatures, so the FilteringClosure static type is
557   // apparent.
558   virtual void walk_mem_region_with_cl(MemRegion mr,
559                                        HeapWord* bottom, HeapWord* top,
560                                        OopIterateClosure* cl) = 0;
561   virtual void walk_mem_region_with_cl(MemRegion mr,
562                                        HeapWord* bottom, HeapWord* top,
563                                        FilteringClosure* cl) = 0;
564 
565 public:
566   FilteringDCTOC(Space* sp, OopIterateClosure* cl,
567                   CardTable::PrecisionStyle precision,
568                   HeapWord* boundary) :
569     DirtyCardToOopClosure(sp, cl, precision, boundary) {}
570 };
571 
572 // A dirty card to oop closure for contiguous spaces
573 // (ContiguousSpace and sub-classes).
574 // It is a FilteringClosure, as defined above, and it knows:
575 //
576 // 1. That the actual top of any area in a memory region
577 //    contained by the space is bounded by the end of the contiguous
578 //    region of the space.
579 // 2. That the space is really made up of objects and not just
580 //    blocks.
581 
582 class ContiguousSpaceDCTOC : public FilteringDCTOC {
583 protected:
584   // Overrides.
585   HeapWord* get_actual_top(HeapWord* top, HeapWord* top_obj);
586 
587   virtual void walk_mem_region_with_cl(MemRegion mr,
588                                        HeapWord* bottom, HeapWord* top,
589                                        OopIterateClosure* cl);
590   virtual void walk_mem_region_with_cl(MemRegion mr,
591                                        HeapWord* bottom, HeapWord* top,
592                                        FilteringClosure* cl);
593 
594 public:
595   ContiguousSpaceDCTOC(ContiguousSpace* sp, OopIterateClosure* cl,
596                        CardTable::PrecisionStyle precision,
597                        HeapWord* boundary) :
598     FilteringDCTOC(sp, cl, precision, boundary)
599   {}
600 };
601 
602 // A ContigSpace that Supports an efficient "block_start" operation via
603 // a BlockOffsetArray (whose BlockOffsetSharedArray may be shared with
604 // other spaces.)  This is the abstract base class for old generation
605 // (tenured) spaces.
606 
607 class OffsetTableContigSpace: public ContiguousSpace {
608   friend class VMStructs;
609  protected:
610   BlockOffsetArrayContigSpace _offsets;
611   Mutex _par_alloc_lock;
612 
613  public:
614   // Constructor
615   OffsetTableContigSpace(BlockOffsetSharedArray* sharedOffsetArray,
616                          MemRegion mr);
617 
618   void set_bottom(HeapWord* value);
619   void set_end(HeapWord* value);
620 
621   void clear(bool mangle_space);
622 
623   inline HeapWord* block_start_const(const void* p) const;
624 
625   // Add offset table update.
626   virtual inline HeapWord* allocate(size_t word_size);
627   inline HeapWord* par_allocate(size_t word_size);
628 
629   // MarkSweep support phase3
630   virtual void initialize_threshold();
631   virtual void alloc_block(HeapWord* start, HeapWord* end);
632 
633   virtual void print_on(outputStream* st) const;
634 
635   // Debugging
636   void verify() const;
637 };
638 
639 
640 // Class TenuredSpace is used by TenuredGeneration
641 
642 class TenuredSpace: public OffsetTableContigSpace {
643   friend class VMStructs;
644  protected:
645   // Mark sweep support
646   size_t allowed_dead_ratio() const;
647  public:
648   // Constructor
649   TenuredSpace(BlockOffsetSharedArray* sharedOffsetArray,
650                MemRegion mr) :
651     OffsetTableContigSpace(sharedOffsetArray, mr) {}
652 };
653 #endif // SHARE_GC_SHARED_SPACE_HPP