1 /* 2 * Copyright (c) 2017, 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_SHENANDOAHPARTIALGC_INLINE_HPP 25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHPARTIALGC_INLINE_HPP 26 27 #include "gc/shenandoah/shenandoahAsserts.hpp" 28 #include "gc/shenandoah/shenandoahPartialGC.hpp" 29 30 template <class T, bool UPDATE_MATRIX> 31 void ShenandoahPartialGC::process_oop(T* p, Thread* thread, ShenandoahObjToScanQueue* queue) { 32 T o = RawAccess<>::oop_load(p); 33 if (!CompressedOops::is_null(o)) { 34 oop obj = CompressedOops::decode_not_null(o); 35 if (_heap->in_collection_set(obj)) { 36 oop forw = ShenandoahBarrierSet::resolve_forwarded_not_null(obj); 37 if (oopDesc::unsafe_equals(obj, forw)) { 38 bool evacuated = false; 39 forw = _heap->evacuate_object(obj, thread, evacuated); 40 41 // Only the thread that succeeded evacuating this object pushes it to its work queue. 42 if (evacuated) { 43 assert(oopDesc::is_oop(forw), "sanity"); 44 bool succeeded = queue->push(ShenandoahMarkTask(forw)); 45 assert(succeeded, "must succeed to push to task queue"); 46 } 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 // TODO: No need to update matrix if other thread beat us. 52 obj = forw; // For matrix update below. 53 } 54 if (UPDATE_MATRIX) { 55 shenandoah_assert_not_forwarded_except(p, obj, _heap->cancelled_concgc()); 56 _matrix->set_connected(p, obj); 57 } 58 } 59 } 60 61 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHPARTIALGC_INLINE_HPP