Mercurial > hg > graal-compiler
comparison src/share/vm/memory/space.hpp @ 20267:ff1e37e7eb83
8038405: Clean up some virtual fucntions in Space class hierarchy
Summary: Get rid of some duplicated implementations and change nonsense implementations to pure virtuals
Reviewed-by: stefank, jmasa
author | mgerdin |
---|---|
date | Wed, 12 Mar 2014 15:25:35 +0100 |
parents | 6c523f5d5440 |
children | 3f2894c5052e |
comparison
equal
deleted
inserted
replaced
20266:6c523f5d5440 | 20267:ff1e37e7eb83 |
---|---|
102 | 102 |
103 virtual HeapWord* saved_mark_word() const { return _saved_mark_word; } | 103 virtual HeapWord* saved_mark_word() const { return _saved_mark_word; } |
104 | 104 |
105 void set_saved_mark_word(HeapWord* p) { _saved_mark_word = p; } | 105 void set_saved_mark_word(HeapWord* p) { _saved_mark_word = p; } |
106 | 106 |
107 // Returns true if this object has been allocated since a | |
108 // generation's "save_marks" call. | |
109 virtual bool obj_allocated_since_save_marks(const oop obj) const { | |
110 return (HeapWord*)obj >= saved_mark_word(); | |
111 } | |
112 | |
107 MemRegionClosure* preconsumptionDirtyCardClosure() const { | 113 MemRegionClosure* preconsumptionDirtyCardClosure() const { |
108 return _preconsumptionDirtyCardClosure; | 114 return _preconsumptionDirtyCardClosure; |
109 } | 115 } |
110 void setPreconsumptionDirtyCardClosure(MemRegionClosure* cl) { | 116 void setPreconsumptionDirtyCardClosure(MemRegionClosure* cl) { |
111 _preconsumptionDirtyCardClosure = cl; | 117 _preconsumptionDirtyCardClosure = cl; |
112 } | 118 } |
113 | 119 |
114 // Returns a subregion of the space containing all the objects in | 120 // Returns a subregion of the space containing only the allocated objects in |
115 // the space. | 121 // the space. |
116 virtual MemRegion used_region() const { return MemRegion(bottom(), end()); } | 122 virtual MemRegion used_region() const = 0; |
117 | 123 |
118 // Returns a region that is guaranteed to contain (at least) all objects | 124 // Returns a region that is guaranteed to contain (at least) all objects |
119 // allocated at the time of the last call to "save_marks". If the space | 125 // allocated at the time of the last call to "save_marks". If the space |
120 // initializes its DirtyCardToOopClosure's specifying the "contig" option | 126 // initializes its DirtyCardToOopClosure's specifying the "contig" option |
121 // (that is, if the space is contiguous), then this region must contain only | 127 // (that is, if the space is contiguous), then this region must contain only |
122 // such objects: the memregion will be from the bottom of the region to the | 128 // such objects: the memregion will be from the bottom of the region to the |
123 // saved mark. Otherwise, the "obj_allocated_since_save_marks" method of | 129 // saved mark. Otherwise, the "obj_allocated_since_save_marks" method of |
124 // the space must distiguish between objects in the region allocated before | 130 // the space must distiguish between objects in the region allocated before |
125 // and after the call to save marks. | 131 // and after the call to save marks. |
126 virtual MemRegion used_region_at_save_marks() const { | 132 MemRegion used_region_at_save_marks() const { |
127 return MemRegion(bottom(), saved_mark_word()); | 133 return MemRegion(bottom(), saved_mark_word()); |
128 } | 134 } |
129 | 135 |
130 // Initialization. | 136 // Initialization. |
131 // "initialize" should be called once on a space, before it is used for | 137 // "initialize" should be called once on a space, before it is used for |
154 // given address as part of an allocated object. For | 160 // given address as part of an allocated object. For |
155 // ceratin kinds of spaces, this might be a potentially | 161 // ceratin kinds of spaces, this might be a potentially |
156 // expensive operation. To prevent performance problems | 162 // expensive operation. To prevent performance problems |
157 // on account of its inadvertent use in product jvm's, | 163 // on account of its inadvertent use in product jvm's, |
158 // we restrict its use to assertion checks only. | 164 // we restrict its use to assertion checks only. |
159 virtual bool is_in(const void* p) const = 0; | 165 bool is_in(const void* p) const { |
166 return used_region().contains(p); | |
167 } | |
160 | 168 |
161 // Returns true iff the given reserved memory of the space contains the | 169 // Returns true iff the given reserved memory of the space contains the |
162 // given address. | 170 // given address. |
163 bool is_in_reserved(const void* p) const { return _bottom <= p && p < _end; } | 171 bool is_in_reserved(const void* p) const { return _bottom <= p && p < _end; } |
164 | 172 |
225 // mutually exclusive access to the space. | 233 // mutually exclusive access to the space. |
226 virtual HeapWord* allocate(size_t word_size) = 0; | 234 virtual HeapWord* allocate(size_t word_size) = 0; |
227 | 235 |
228 // Allocation (return NULL if full). Enforces mutual exclusion internally. | 236 // Allocation (return NULL if full). Enforces mutual exclusion internally. |
229 virtual HeapWord* par_allocate(size_t word_size) = 0; | 237 virtual HeapWord* par_allocate(size_t word_size) = 0; |
230 | |
231 // Returns true if this object has been allocated since a | |
232 // generation's "save_marks" call. | |
233 virtual bool obj_allocated_since_save_marks(const oop obj) const = 0; | |
234 | 238 |
235 // Mark-sweep-compact support: all spaces can update pointers to objects | 239 // Mark-sweep-compact support: all spaces can update pointers to objects |
236 // moving as a part of compaction. | 240 // moving as a part of compaction. |
237 virtual void adjust_pointers(); | 241 virtual void adjust_pointers(); |
238 | 242 |
361 _compaction_top = value; | 365 _compaction_top = value; |
362 } | 366 } |
363 | 367 |
364 // Perform operations on the space needed after a compaction | 368 // Perform operations on the space needed after a compaction |
365 // has been performed. | 369 // has been performed. |
366 virtual void reset_after_compaction() {} | 370 virtual void reset_after_compaction() = 0; |
367 | 371 |
368 // Returns the next space (in the current generation) to be compacted in | 372 // Returns the next space (in the current generation) to be compacted in |
369 // the global compaction order. Also is used to select the next | 373 // the global compaction order. Also is used to select the next |
370 // space into which to compact. | 374 // space into which to compact. |
371 | 375 |
426 // Used during compaction. | 430 // Used during compaction. |
427 HeapWord* _first_dead; | 431 HeapWord* _first_dead; |
428 HeapWord* _end_of_live; | 432 HeapWord* _end_of_live; |
429 | 433 |
430 // Minimum size of a free block. | 434 // Minimum size of a free block. |
431 virtual size_t minimum_free_block_size() const = 0; | 435 virtual size_t minimum_free_block_size() const { return 0; } |
432 | 436 |
433 // This the function is invoked when an allocation of an object covering | 437 // This the function is invoked when an allocation of an object covering |
434 // "start" to "end occurs crosses the threshold; returns the next | 438 // "start" to "end occurs crosses the threshold; returns the next |
435 // threshold. (The default implementation does nothing.) | 439 // threshold. (The default implementation does nothing.) |
436 virtual HeapWord* cross_threshold(HeapWord* start, HeapWord* the_end) { | 440 virtual HeapWord* cross_threshold(HeapWord* start, HeapWord* the_end) { |
476 | 480 |
477 // Accessors | 481 // Accessors |
478 HeapWord* top() const { return _top; } | 482 HeapWord* top() const { return _top; } |
479 void set_top(HeapWord* value) { _top = value; } | 483 void set_top(HeapWord* value) { _top = value; } |
480 | 484 |
481 virtual void set_saved_mark() { _saved_mark_word = top(); } | 485 void set_saved_mark() { _saved_mark_word = top(); } |
482 void reset_saved_mark() { _saved_mark_word = bottom(); } | 486 void reset_saved_mark() { _saved_mark_word = bottom(); } |
483 | 487 |
484 WaterMark bottom_mark() { return WaterMark(this, bottom()); } | 488 WaterMark bottom_mark() { return WaterMark(this, bottom()); } |
485 WaterMark top_mark() { return WaterMark(this, top()); } | 489 WaterMark top_mark() { return WaterMark(this, top()); } |
486 WaterMark saved_mark() { return WaterMark(this, saved_mark_word()); } | 490 WaterMark saved_mark() { return WaterMark(this, saved_mark_word()); } |
511 // Size computations: sizes in bytes. | 515 // Size computations: sizes in bytes. |
512 size_t capacity() const { return byte_size(bottom(), end()); } | 516 size_t capacity() const { return byte_size(bottom(), end()); } |
513 size_t used() const { return byte_size(bottom(), top()); } | 517 size_t used() const { return byte_size(bottom(), top()); } |
514 size_t free() const { return byte_size(top(), end()); } | 518 size_t free() const { return byte_size(top(), end()); } |
515 | 519 |
516 // Override from space. | |
517 bool is_in(const void* p) const; | |
518 | |
519 virtual bool is_free_block(const HeapWord* p) const; | 520 virtual bool is_free_block(const HeapWord* p) const; |
520 | 521 |
521 // In a contiguous space we have a more obvious bound on what parts | 522 // In a contiguous space we have a more obvious bound on what parts |
522 // contain objects. | 523 // contain objects. |
523 MemRegion used_region() const { return MemRegion(bottom(), top()); } | 524 MemRegion used_region() const { return MemRegion(bottom(), top()); } |
524 | 525 |
525 MemRegion used_region_at_save_marks() const { | |
526 return MemRegion(bottom(), saved_mark_word()); | |
527 } | |
528 | |
529 // Allocation (return NULL if full) | 526 // Allocation (return NULL if full) |
530 virtual HeapWord* allocate(size_t word_size); | 527 virtual HeapWord* allocate(size_t word_size); |
531 virtual HeapWord* par_allocate(size_t word_size); | 528 virtual HeapWord* par_allocate(size_t word_size); |
532 | |
533 virtual bool obj_allocated_since_save_marks(const oop obj) const { | |
534 return (HeapWord*)obj >= saved_mark_word(); | |
535 } | |
536 | 529 |
537 // Iteration | 530 // Iteration |
538 void oop_iterate(ExtendedOopClosure* cl); | 531 void oop_iterate(ExtendedOopClosure* cl); |
539 void object_iterate(ObjectClosure* blk); | 532 void object_iterate(ObjectClosure* blk); |
540 // For contiguous spaces this method will iterate safely over objects | 533 // For contiguous spaces this method will iterate safely over objects |
576 assert(compaction_top() >= bottom() && compaction_top() <= end(), "should point inside space"); | 569 assert(compaction_top() >= bottom() && compaction_top() <= end(), "should point inside space"); |
577 set_top(compaction_top()); | 570 set_top(compaction_top()); |
578 // set new iteration safe limit | 571 // set new iteration safe limit |
579 set_concurrent_iteration_safe_limit(compaction_top()); | 572 set_concurrent_iteration_safe_limit(compaction_top()); |
580 } | 573 } |
581 virtual size_t minimum_free_block_size() const { return 0; } | |
582 | 574 |
583 // Override. | 575 // Override. |
584 DirtyCardToOopClosure* new_dcto_cl(ExtendedOopClosure* cl, | 576 DirtyCardToOopClosure* new_dcto_cl(ExtendedOopClosure* cl, |
585 CardTableModRefBS::PrecisionStyle precision, | 577 CardTableModRefBS::PrecisionStyle precision, |
586 HeapWord* boundary = NULL); | 578 HeapWord* boundary = NULL); |