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