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():
415 // Some contiguous spaces may maintain some data structures that should
416 // be updated whenever an allocation crosses a boundary. This function
417 // returns the first such boundary.
418 // (The default implementation returns the end of the space, so the
419 // boundary is never crossed.)
420 virtual HeapWord* initialize_threshold() { return end(); }
421
422 // "q" is an object of the given "size" that should be forwarded;
423 // "cp" names the generation ("gen") and containing "this" (which must
424 // also equal "cp->space"). "compact_top" is where in "this" the
425 // next object should be forwarded to. If there is room in "this" for
426 // the object, insert an appropriate forwarding pointer in "q".
427 // If not, go to the next compaction space (there must
428 // be one, since compaction must succeed -- we go to the first space of
429 // the previous generation if necessary, updating "cp"), reset compact_top
430 // and then forward. In either case, returns the new value of "compact_top".
431 // If the forwarding crosses "cp->threshold", invokes the "cross_threshold"
432 // function of the then-current compaction space, and updates "cp->threshold
433 // accordingly".
434 virtual HeapWord* forward(oop q, size_t size, CompactPoint* cp,
435 HeapWord* compact_top);
436
437 // Return a size with adjustments as required of the space.
438 virtual size_t adjust_object_size_v(size_t size) const { return size; }
439
440 void set_first_dead(HeapWord* value) { _first_dead = value; }
441 void set_end_of_live(HeapWord* value) { _end_of_live = value; }
442
443 protected:
444 // Used during compaction.
445 HeapWord* _first_dead;
446 HeapWord* _end_of_live;
447
448 // This the function is invoked when an allocation of an object covering
449 // "start" to "end occurs crosses the threshold; returns the next
450 // threshold. (The default implementation does nothing.)
451 virtual HeapWord* cross_threshold(HeapWord* start, HeapWord* the_end) {
452 return end();
453 }
454
455 // Below are template functions for scan_and_* algorithms (avoiding virtual calls).
|
33 #include "memory/memRegion.hpp"
34 #include "oops/markWord.hpp"
35 #include "runtime/mutexLocker.hpp"
36 #include "utilities/align.hpp"
37 #include "utilities/macros.hpp"
38
39 // A space is an abstraction for the "storage units" backing
40 // up the generation abstraction. It includes specific
41 // implementations for keeping track of free and used space,
42 // for iterating over objects and free blocks, etc.
43
44 // Forward decls.
45 class Space;
46 class BlockOffsetArray;
47 class BlockOffsetArrayContigSpace;
48 class Generation;
49 class CompactibleSpace;
50 class BlockOffsetTable;
51 class CardTableRS;
52 class DirtyCardToOopClosure;
53 class SlidingForwarding;
54
55 // A Space describes a heap area. Class Space is an abstract
56 // base class.
57 //
58 // Space supports allocation, size computation and GC support is provided.
59 //
60 // Invariant: bottom() and end() are on page_size boundaries and
61 // bottom() <= top() <= end()
62 // top() is inclusive and end() is exclusive.
63
64 class Space: public CHeapObj<mtGC> {
65 friend class VMStructs;
66 protected:
67 HeapWord* _bottom;
68 HeapWord* _end;
69
70 // Used in support of save_marks()
71 HeapWord* _saved_mark_word;
72
73 Space():
416 // Some contiguous spaces may maintain some data structures that should
417 // be updated whenever an allocation crosses a boundary. This function
418 // returns the first such boundary.
419 // (The default implementation returns the end of the space, so the
420 // boundary is never crossed.)
421 virtual HeapWord* initialize_threshold() { return end(); }
422
423 // "q" is an object of the given "size" that should be forwarded;
424 // "cp" names the generation ("gen") and containing "this" (which must
425 // also equal "cp->space"). "compact_top" is where in "this" the
426 // next object should be forwarded to. If there is room in "this" for
427 // the object, insert an appropriate forwarding pointer in "q".
428 // If not, go to the next compaction space (there must
429 // be one, since compaction must succeed -- we go to the first space of
430 // the previous generation if necessary, updating "cp"), reset compact_top
431 // and then forward. In either case, returns the new value of "compact_top".
432 // If the forwarding crosses "cp->threshold", invokes the "cross_threshold"
433 // function of the then-current compaction space, and updates "cp->threshold
434 // accordingly".
435 virtual HeapWord* forward(oop q, size_t size, CompactPoint* cp,
436 HeapWord* compact_top, SlidingForwarding* const forwarding);
437
438 // Return a size with adjustments as required of the space.
439 virtual size_t adjust_object_size_v(size_t size) const { return size; }
440
441 void set_first_dead(HeapWord* value) { _first_dead = value; }
442 void set_end_of_live(HeapWord* value) { _end_of_live = value; }
443
444 protected:
445 // Used during compaction.
446 HeapWord* _first_dead;
447 HeapWord* _end_of_live;
448
449 // This the function is invoked when an allocation of an object covering
450 // "start" to "end occurs crosses the threshold; returns the next
451 // threshold. (The default implementation does nothing.)
452 virtual HeapWord* cross_threshold(HeapWord* start, HeapWord* the_end) {
453 return end();
454 }
455
456 // Below are template functions for scan_and_* algorithms (avoiding virtual calls).
|