1 /*
2 * Copyright (c) 1997, 2009, 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 class ReferenceProcessor;
26 class DataLayout;
27
28 // MarkSweep takes care of global mark-compact garbage collection for a
29 // GenCollectedHeap using a four-phase pointer forwarding algorithm. All
30 // generations are assumed to support marking; those that can also support
31 // compaction.
32 //
33 // Class unloading will only occur when a full gc is invoked.
34
35 // If VALIDATE_MARK_SWEEP is defined, the -XX:+ValidateMarkSweep flag will
36 // be operational, and will provide slow but comprehensive self-checks within
37 // the GC. This is not enabled by default in product or release builds,
38 // since the extra call to track_adjusted_pointer() in _adjust_pointer()
39 // would be too much overhead, and would disturb performance measurement.
40 // However, debug builds are sometimes way too slow to run GC tests!
41 #ifdef ASSERT
42 #define VALIDATE_MARK_SWEEP 1
43 #endif
44 #ifdef VALIDATE_MARK_SWEEP
231
232 class PreservedMark VALUE_OBJ_CLASS_SPEC {
233 private:
234 oop _obj;
235 markOop _mark;
236
237 public:
238 void init(oop obj, markOop mark) {
239 _obj = obj;
240 _mark = mark;
241 }
242
243 void adjust_pointer() {
244 MarkSweep::adjust_pointer(&_obj);
245 }
246
247 void restore() {
248 _obj->set_mark(_mark);
249 }
250 };
|
1 /*
2 * Copyright (c) 1997, 2010, 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_VM_GC_IMPLEMENTATION_SHARED_MARKSWEEP_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_MARKSWEEP_HPP
27
28 #include "gc_interface/collectedHeap.hpp"
29 #include "memory/universe.hpp"
30 #include "oops/markOop.hpp"
31 #include "oops/oop.hpp"
32 #include "runtime/timer.hpp"
33 #include "utilities/growableArray.hpp"
34 #include "utilities/stack.hpp"
35 #include "utilities/taskqueue.hpp"
36
37 class ReferenceProcessor;
38 class DataLayout;
39
40 // MarkSweep takes care of global mark-compact garbage collection for a
41 // GenCollectedHeap using a four-phase pointer forwarding algorithm. All
42 // generations are assumed to support marking; those that can also support
43 // compaction.
44 //
45 // Class unloading will only occur when a full gc is invoked.
46
47 // If VALIDATE_MARK_SWEEP is defined, the -XX:+ValidateMarkSweep flag will
48 // be operational, and will provide slow but comprehensive self-checks within
49 // the GC. This is not enabled by default in product or release builds,
50 // since the extra call to track_adjusted_pointer() in _adjust_pointer()
51 // would be too much overhead, and would disturb performance measurement.
52 // However, debug builds are sometimes way too slow to run GC tests!
53 #ifdef ASSERT
54 #define VALIDATE_MARK_SWEEP 1
55 #endif
56 #ifdef VALIDATE_MARK_SWEEP
243
244 class PreservedMark VALUE_OBJ_CLASS_SPEC {
245 private:
246 oop _obj;
247 markOop _mark;
248
249 public:
250 void init(oop obj, markOop mark) {
251 _obj = obj;
252 _mark = mark;
253 }
254
255 void adjust_pointer() {
256 MarkSweep::adjust_pointer(&_obj);
257 }
258
259 void restore() {
260 _obj->set_mark(_mark);
261 }
262 };
263
264 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_MARKSWEEP_HPP
|