1 /* |
1 /* |
2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2007, 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. |
35 // weak references are sometimes scanned twice; must check |
35 // weak references are sometimes scanned twice; must check |
36 // that to-space doesn't already contain this object |
36 // that to-space doesn't already contain this object |
37 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) { |
37 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) { |
38 // we need to ensure that it is copied (see comment in |
38 // we need to ensure that it is copied (see comment in |
39 // ParScanClosure::do_oop_work). |
39 // ParScanClosure::do_oop_work). |
40 klassOop objK = obj->klass(); |
40 Klass* objK = obj->klass(); |
41 markOop m = obj->mark(); |
41 markOop m = obj->mark(); |
42 oop new_obj; |
42 oop new_obj; |
43 if (m->is_marked()) { // Contains forwarding pointer. |
43 if (m->is_marked()) { // Contains forwarding pointer. |
44 new_obj = ParNewGeneration::real_forwardee(obj); |
44 new_obj = ParNewGeneration::real_forwardee(obj); |
45 } else { |
45 } else { |
46 size_t obj_sz = obj->size_given_klass(objK->klass_part()); |
46 size_t obj_sz = obj->size_given_klass(objK); |
47 new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state, |
47 new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state, |
48 obj, obj_sz, m); |
48 obj, obj_sz, m); |
49 } |
49 } |
50 oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
50 oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
51 } |
51 } |
98 // We read the klass and mark in this order, so that we can reliably |
98 // We read the klass and mark in this order, so that we can reliably |
99 // get the size of the object: if the mark we read is not a |
99 // get the size of the object: if the mark we read is not a |
100 // forwarding pointer, then the klass is valid: the klass is only |
100 // forwarding pointer, then the klass is valid: the klass is only |
101 // overwritten with an overflow next pointer after the object is |
101 // overwritten with an overflow next pointer after the object is |
102 // forwarded. |
102 // forwarded. |
103 klassOop objK = obj->klass(); |
103 Klass* objK = obj->klass(); |
104 markOop m = obj->mark(); |
104 markOop m = obj->mark(); |
105 oop new_obj; |
105 oop new_obj; |
106 if (m->is_marked()) { // Contains forwarding pointer. |
106 if (m->is_marked()) { // Contains forwarding pointer. |
107 new_obj = ParNewGeneration::real_forwardee(obj); |
107 new_obj = ParNewGeneration::real_forwardee(obj); |
108 oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
108 oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
|
109 #ifndef PRODUCT |
|
110 if (TraceScavenge) { |
|
111 gclog_or_tty->print_cr("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", |
|
112 "forwarded ", |
|
113 new_obj->klass()->internal_name(), p, obj, new_obj, new_obj->size()); |
|
114 } |
|
115 #endif |
|
116 |
109 } else { |
117 } else { |
110 size_t obj_sz = obj->size_given_klass(objK->klass_part()); |
118 size_t obj_sz = obj->size_given_klass(objK); |
111 new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m); |
119 new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m); |
112 oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
120 oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
113 if (root_scan) { |
121 if (root_scan) { |
114 // This may have pushed an object. If we have a root |
122 // This may have pushed an object. If we have a root |
115 // category with a lot of roots, can't let the queue get too |
123 // category with a lot of roots, can't let the queue get too |
116 // full: |
124 // full: |
117 (void)_par_scan_state->trim_queues(10 * ParallelGCThreads); |
125 (void)_par_scan_state->trim_queues(10 * ParallelGCThreads); |
118 } |
126 } |
119 } |
127 } |
120 if (gc_barrier) { |
128 if (is_scanning_a_klass()) { |
|
129 do_klass_barrier(); |
|
130 } else if (gc_barrier) { |
121 // Now call parent closure |
131 // Now call parent closure |
122 par_do_barrier(p); |
132 par_do_barrier(p); |
123 } |
133 } |
124 } |
134 } |
125 } |
135 } |