1 /* |
1 /* |
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
33 #include "memory/generation.hpp" |
33 #include "memory/generation.hpp" |
34 #include "memory/sharedHeap.hpp" |
34 #include "memory/sharedHeap.hpp" |
35 #include "memory/space.hpp" |
35 #include "memory/space.hpp" |
36 |
36 |
37 inline OopsInGenClosure::OopsInGenClosure(Generation* gen) : |
37 inline OopsInGenClosure::OopsInGenClosure(Generation* gen) : |
38 OopClosure(gen->ref_processor()), _orig_gen(gen), _rs(NULL) { |
38 ExtendedOopClosure(gen->ref_processor()), _orig_gen(gen), _rs(NULL) { |
39 set_generation(gen); |
39 set_generation(gen); |
40 } |
40 } |
41 |
41 |
42 inline void OopsInGenClosure::set_generation(Generation* gen) { |
42 inline void OopsInGenClosure::set_generation(Generation* gen) { |
43 _gen = gen; |
43 _gen = gen; |
70 if ((HeapWord*)obj < gen_boundary()) { |
70 if ((HeapWord*)obj < gen_boundary()) { |
71 rs()->write_ref_field_gc_par(p, obj); |
71 rs()->write_ref_field_gc_par(p, obj); |
72 } |
72 } |
73 } |
73 } |
74 |
74 |
|
75 inline void OopsInKlassOrGenClosure::do_klass_barrier() { |
|
76 assert(_scanned_klass != NULL, "Must be"); |
|
77 _scanned_klass->record_modified_oops(); |
|
78 } |
|
79 |
75 // NOTE! Any changes made here should also be made |
80 // NOTE! Any changes made here should also be made |
76 // in FastScanClosure::do_oop_work() |
81 // in FastScanClosure::do_oop_work() |
77 template <class T> inline void ScanClosure::do_oop_work(T* p) { |
82 template <class T> inline void ScanClosure::do_oop_work(T* p) { |
78 T heap_oop = oopDesc::load_heap_oop(p); |
83 T heap_oop = oopDesc::load_heap_oop(p); |
79 // Should we copy the obj? |
84 // Should we copy the obj? |
83 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?"); |
88 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?"); |
84 oop new_obj = obj->is_forwarded() ? obj->forwardee() |
89 oop new_obj = obj->is_forwarded() ? obj->forwardee() |
85 : _g->copy_to_survivor_space(obj); |
90 : _g->copy_to_survivor_space(obj); |
86 oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
91 oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
87 } |
92 } |
88 if (_gc_barrier) { |
93 |
|
94 if (is_scanning_a_klass()) { |
|
95 do_klass_barrier(); |
|
96 } else if (_gc_barrier) { |
89 // Now call parent closure |
97 // Now call parent closure |
90 do_barrier(p); |
98 do_barrier(p); |
91 } |
99 } |
92 } |
100 } |
93 } |
101 } |
105 if ((HeapWord*)obj < _boundary) { |
113 if ((HeapWord*)obj < _boundary) { |
106 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?"); |
114 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?"); |
107 oop new_obj = obj->is_forwarded() ? obj->forwardee() |
115 oop new_obj = obj->is_forwarded() ? obj->forwardee() |
108 : _g->copy_to_survivor_space(obj); |
116 : _g->copy_to_survivor_space(obj); |
109 oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
117 oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
110 if (_gc_barrier) { |
118 if (is_scanning_a_klass()) { |
|
119 do_klass_barrier(); |
|
120 } else if (_gc_barrier) { |
111 // Now call parent closure |
121 // Now call parent closure |
112 do_barrier(p); |
122 do_barrier(p); |
113 } |
123 } |
114 } |
124 } |
115 } |
125 } |