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