1 /* 2 * Copyright (c) 2018, Red Hat, Inc. and/or its affiliates. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_INLINE_HPP 25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_INLINE_HPP 26 27 #include "gc/shared/markBitMap.inline.hpp" 28 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp" 29 #include "gc/shenandoah/shenandoahHeap.inline.hpp" 30 #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" 31 #include "gc/shenandoah/shenandoahStringDedup.hpp" 32 #include "gc/shenandoah/shenandoahTraversalGC.hpp" 33 #include "gc/shenandoah/shenandoahTaskqueue.hpp" 34 #include "memory/iterator.inline.hpp" 35 #include "oops/oop.inline.hpp" 36 37 template <class T, bool STRING_DEDUP> 38 void ShenandoahTraversalGC::process_oop(T* p, Thread* thread, ShenandoahObjToScanQueue* queue, ShenandoahStrDedupQueue* dq) { 39 T o = oopDesc::load_heap_oop(p); 40 if (! oopDesc::is_null(o)) { 41 oop obj = oopDesc::decode_heap_oop_not_null(o); 42 if (_heap->in_collection_set(obj)) { 43 oop forw = ShenandoahBarrierSet::resolve_forwarded_not_null(obj); 44 if (oopDesc::unsafe_equals(obj, forw)) { 45 bool evacuated = false; 46 forw = _heap->evacuate_object(obj, thread, evacuated); 47 } 48 assert(! oopDesc::unsafe_equals(obj, forw) || _heap->cancelled_concgc(), "must be evacuated"); 49 // Update reference. 50 _heap->atomic_compare_exchange_oop(forw, p, obj); 51 obj = forw; 52 } 53 54 if (!_heap->is_marked_next(obj) && _heap->mark_next(obj)) { 55 bool succeeded = queue->push(ShenandoahMarkTask(obj)); 56 assert(succeeded, "must succeed to push to task queue"); 57 58 if (STRING_DEDUP && ShenandoahStringDedup::is_candidate(obj)) { 59 assert(ShenandoahStringDedup::is_enabled(), "Must be enabled"); 60 assert(dq != NULL, "Dedup queue not set"); 61 ShenandoahStringDedup::enqueue_candidate(obj, dq); 62 } 63 } 64 } 65 } 66 67 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_INLINE_HPP