1 /*
2 * Copyright (c) 2001, 2015, 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 *
79 }
80
81 // iteration
82 inline bool iterate(BitMapClosure* cl, MemRegion mr);
83
84 // Return the address corresponding to the next marked bit at or after
85 // "addr", and before "limit", if "limit" is non-NULL. If there is no
86 // such bit, returns "limit" if that is non-NULL, or else "endWord()".
87 HeapWord* getNextMarkedWordAddress(const HeapWord* addr,
88 const HeapWord* limit = NULL) const;
89
90 // conversion utilities
91 HeapWord* offsetToHeapWord(size_t offset) const {
92 return _bmStartWord + (offset << _shifter);
93 }
94 size_t heapWordToOffset(const HeapWord* addr) const {
95 return pointer_delta(addr, _bmStartWord) >> _shifter;
96 }
97
98 // The argument addr should be the start address of a valid object
99 HeapWord* nextObject(HeapWord* addr) {
100 oop obj = (oop) addr;
101 HeapWord* res = addr + obj->size();
102 assert(offsetToHeapWord(heapWordToOffset(res)) == res, "sanity");
103 return res;
104 }
105
106 void print_on_error(outputStream* st, const char* prefix) const;
107
108 // debugging
109 NOT_PRODUCT(bool covers(MemRegion rs) const;)
110 };
111
112 class CMBitMapMappingChangedListener : public G1MappingChangedListener {
113 private:
114 CMBitMap* _bm;
115 public:
116 CMBitMapMappingChangedListener() : _bm(NULL) {}
117
118 void set_bitmap(CMBitMap* bm) { _bm = bm; }
119
120 virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
121 };
122
123 class CMBitMap : public CMBitMapRO {
124 private:
610 // Clears marks for all objects in the given range, for the prev or
611 // next bitmaps. NB: the previous bitmap is usually
612 // read-only, so use this carefully!
613 void clearRangePrevBitmap(MemRegion mr);
614
615 // Notify data structures that a GC has started.
616 void note_start_of_gc() {
617 _markStack.note_start_of_gc();
618 }
619
620 // Notify data structures that a GC is finished.
621 void note_end_of_gc() {
622 _markStack.note_end_of_gc();
623 }
624
625 // Verify that there are no CSet oops on the stacks (taskqueues /
626 // global mark stack) and fingers (global / per-task).
627 // If marking is not in progress, it's a no-op.
628 void verify_no_cset_oops() PRODUCT_RETURN;
629
630 bool isPrevMarked(oop p) const {
631 assert(p != NULL && p->is_oop(), "expected an oop");
632 HeapWord* addr = (HeapWord*)p;
633 assert(addr >= _prevMarkBitMap->startWord() ||
634 addr < _prevMarkBitMap->endWord(), "in a region");
635
636 return _prevMarkBitMap->isMarked(addr);
637 }
638
639 inline bool do_yield_check(uint worker_i = 0);
640
641 // Called to abort the marking cycle after a Full GC takes place.
642 void abort();
643
644 bool has_aborted() { return _has_aborted; }
645
646 void print_summary_info();
647
648 void print_worker_threads_on(outputStream* st) const;
649
650 void print_on_error(outputStream* st) const;
651
652 // Liveness counting
653
654 // Utility routine to set an exclusive range of cards on the given
655 // card liveness bitmap
656 inline void set_card_bitmap_range(BitMap* card_bm,
657 BitMap::idx_t start_idx,
|
1 /*
2 * Copyright (c) 2001, 2016, 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 *
79 }
80
81 // iteration
82 inline bool iterate(BitMapClosure* cl, MemRegion mr);
83
84 // Return the address corresponding to the next marked bit at or after
85 // "addr", and before "limit", if "limit" is non-NULL. If there is no
86 // such bit, returns "limit" if that is non-NULL, or else "endWord()".
87 HeapWord* getNextMarkedWordAddress(const HeapWord* addr,
88 const HeapWord* limit = NULL) const;
89
90 // conversion utilities
91 HeapWord* offsetToHeapWord(size_t offset) const {
92 return _bmStartWord + (offset << _shifter);
93 }
94 size_t heapWordToOffset(const HeapWord* addr) const {
95 return pointer_delta(addr, _bmStartWord) >> _shifter;
96 }
97
98 // The argument addr should be the start address of a valid object
99 inline HeapWord* nextObject(HeapWord* addr);
100
101 void print_on_error(outputStream* st, const char* prefix) const;
102
103 // debugging
104 NOT_PRODUCT(bool covers(MemRegion rs) const;)
105 };
106
107 class CMBitMapMappingChangedListener : public G1MappingChangedListener {
108 private:
109 CMBitMap* _bm;
110 public:
111 CMBitMapMappingChangedListener() : _bm(NULL) {}
112
113 void set_bitmap(CMBitMap* bm) { _bm = bm; }
114
115 virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
116 };
117
118 class CMBitMap : public CMBitMapRO {
119 private:
605 // Clears marks for all objects in the given range, for the prev or
606 // next bitmaps. NB: the previous bitmap is usually
607 // read-only, so use this carefully!
608 void clearRangePrevBitmap(MemRegion mr);
609
610 // Notify data structures that a GC has started.
611 void note_start_of_gc() {
612 _markStack.note_start_of_gc();
613 }
614
615 // Notify data structures that a GC is finished.
616 void note_end_of_gc() {
617 _markStack.note_end_of_gc();
618 }
619
620 // Verify that there are no CSet oops on the stacks (taskqueues /
621 // global mark stack) and fingers (global / per-task).
622 // If marking is not in progress, it's a no-op.
623 void verify_no_cset_oops() PRODUCT_RETURN;
624
625 inline bool isPrevMarked(oop p) const;
626
627 inline bool do_yield_check(uint worker_i = 0);
628
629 // Called to abort the marking cycle after a Full GC takes place.
630 void abort();
631
632 bool has_aborted() { return _has_aborted; }
633
634 void print_summary_info();
635
636 void print_worker_threads_on(outputStream* st) const;
637
638 void print_on_error(outputStream* st) const;
639
640 // Liveness counting
641
642 // Utility routine to set an exclusive range of cards on the given
643 // card liveness bitmap
644 inline void set_card_bitmap_range(BitMap* card_bm,
645 BitMap::idx_t start_idx,
|