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