1 /*
2 * Copyright (c) 2015, 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_BROOKSPOINTER_INLINE_HPP
25 #define SHARE_VM_GC_SHENANDOAH_BROOKSPOINTER_INLINE_HPP
26
27 #include "gc_implementation/shenandoah/brooksPointer.hpp"
28 #include "gc_implementation/shenandoah/shenandoahAsserts.hpp"
29 #include "gc_implementation/shenandoah/shenandoahHeap.hpp"
30 #include "gc_implementation/shenandoah/shenandoahHeapRegion.hpp"
31 #include "gc_implementation/shenandoah/shenandoahLogging.hpp"
32 #include "runtime/atomic.hpp"
33
34 inline HeapWord** BrooksPointer::brooks_ptr_addr(oop obj) {
35 return (HeapWord**)((HeapWord*) obj + word_offset());
36 }
37
38 inline void BrooksPointer::initialize(oop obj) {
39 shenandoah_assert_in_heap(NULL, obj);
40 *brooks_ptr_addr(obj) = (HeapWord*) obj;
41 }
42
43 inline void BrooksPointer::set_raw(oop obj, HeapWord* update) {
44 shenandoah_assert_in_heap(NULL, obj);
45 *brooks_ptr_addr(obj) = update;
46 }
47
48 inline HeapWord* BrooksPointer::get_raw(oop obj) {
49 shenandoah_assert_in_heap(NULL, obj);
50 return *brooks_ptr_addr(obj);
51 }
52
53 inline HeapWord* BrooksPointer::get_raw_unchecked(oop obj) {
54 return *brooks_ptr_addr(obj);
55 }
56
57 inline oop BrooksPointer::forwardee(oop obj) {
58 shenandoah_assert_correct(NULL, obj);
59 return oop(*brooks_ptr_addr(obj));
60 }
61
62 inline oop BrooksPointer::try_update_forwardee(oop obj, oop update) {
63 oop result = (oop) Atomic::cmpxchg_ptr(update, brooks_ptr_addr(obj), obj);
64 shenandoah_assert_correct_except(NULL, obj, !oopDesc::unsafe_equals(result, obj));
65 return result;
66 }
67
68 #endif // SHARE_VM_GC_SHENANDOAH_BROOKSPOINTER_INLINE_HPP
|
1 /*
2 * Copyright (c) 2015, 2018, Red Hat, Inc. All rights reserved.
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_SHENANDOAHBROOKSPOINTER_INLINE_HPP
25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHBROOKSPOINTER_INLINE_HPP
26
27 #include "gc_implementation/shenandoah/shenandoahBrooksPointer.hpp"
28 #include "gc_implementation/shenandoah/shenandoahAsserts.hpp"
29 #include "gc_implementation/shenandoah/shenandoahHeap.hpp"
30 #include "gc_implementation/shenandoah/shenandoahHeapRegion.hpp"
31 #include "gc_implementation/shenandoah/shenandoahLogging.hpp"
32 #include "runtime/atomic.hpp"
33
34 inline HeapWord** ShenandoahBrooksPointer::brooks_ptr_addr(oop obj) {
35 return (HeapWord**)((HeapWord*) obj + word_offset());
36 }
37
38 inline void ShenandoahBrooksPointer::initialize(oop obj) {
39 shenandoah_assert_in_heap(NULL, obj);
40 *brooks_ptr_addr(obj) = (HeapWord*) obj;
41 }
42
43 inline void ShenandoahBrooksPointer::set_raw(oop obj, HeapWord* update) {
44 shenandoah_assert_in_heap(NULL, obj);
45 *brooks_ptr_addr(obj) = update;
46 }
47
48 inline HeapWord* ShenandoahBrooksPointer::get_raw(oop obj) {
49 shenandoah_assert_in_heap(NULL, obj);
50 return *brooks_ptr_addr(obj);
51 }
52
53 inline HeapWord* ShenandoahBrooksPointer::get_raw_unchecked(oop obj) {
54 return *brooks_ptr_addr(obj);
55 }
56
57 inline oop ShenandoahBrooksPointer::forwardee(oop obj) {
58 shenandoah_assert_correct(NULL, obj);
59 return oop(*brooks_ptr_addr(obj));
60 }
61
62 inline oop ShenandoahBrooksPointer::try_update_forwardee(oop obj, oop update) {
63 oop result = (oop) Atomic::cmpxchg_ptr(update, brooks_ptr_addr(obj), obj);
64 shenandoah_assert_correct_except(NULL, obj, !oopDesc::unsafe_equals(result, obj));
65 return result;
66 }
67
68 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHBROOKSPOINTER_INLINE_HPP
|