8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_OOPS_OOP_INLINE_HPP
26 #define SHARE_VM_OOPS_OOP_INLINE_HPP
27
28 #include "gc/shared/ageTable.hpp"
29 #include "gc/shared/barrierSet.inline.hpp"
30 #include "gc/shared/cardTableModRefBS.hpp"
31 #include "gc/shared/collectedHeap.inline.hpp"
32 #include "gc/shared/genCollectedHeap.hpp"
33 #include "gc/shared/generation.hpp"
34 #include "oops/arrayKlass.hpp"
35 #include "oops/arrayOop.hpp"
36 #include "oops/klass.inline.hpp"
37 #include "oops/markOop.inline.hpp"
38 #include "oops/oop.hpp"
39 #include "runtime/atomic.inline.hpp"
40 #include "runtime/orderAccess.inline.hpp"
41 #include "runtime/os.hpp"
42 #include "utilities/macros.hpp"
43
44 // Implementation of all inlined member functions defined in oop.hpp
45 // We need a separate file to avoid circular references
46
47 inline void oopDesc::release_set_mark(markOop m) {
522 if (prebarrier) {
523 update_barrier_set_pre((narrowOop*)dest, exchange_value);
524 }
525 // encode exchange and compare value from oop to T
526 narrowOop val = encode_heap_oop(exchange_value);
527 narrowOop cmp = encode_heap_oop(compare_value);
528
529 narrowOop old = (narrowOop) Atomic::cmpxchg(val, (narrowOop*)dest, cmp);
530 // decode old from T to oop
531 return decode_heap_oop(old);
532 } else {
533 if (prebarrier) {
534 update_barrier_set_pre((oop*)dest, exchange_value);
535 }
536 return (oop)Atomic::cmpxchg_ptr(exchange_value, (oop*)dest, compare_value);
537 }
538 }
539
540 // Used only for markSweep, scavenging
541 inline bool oopDesc::is_gc_marked() const {
542 return mark()->is_marked();
543 }
544
545 inline bool oopDesc::is_locked() const {
546 return mark()->is_locked();
547 }
548
549 inline bool oopDesc::is_unlocked() const {
550 return mark()->is_unlocked();
551 }
552
553 inline bool oopDesc::has_bias_pattern() const {
554 return mark()->has_bias_pattern();
555 }
556
557
558 // used only for asserts
559 inline bool oopDesc::is_oop(bool ignore_mark_word) const {
560 oop obj = (oop) this;
561 if (!check_obj_alignment(obj)) return false;
683 } else {
684 set_mark(mark()->incr_age());
685 }
686 }
687
688
689 inline intptr_t oopDesc::identity_hash() {
690 // Fast case; if the object is unlocked and the hash value is set, no locking is needed
691 // Note: The mark must be read into local variable to avoid concurrent updates.
692 markOop mrk = mark();
693 if (mrk->is_unlocked() && !mrk->has_no_hash()) {
694 return mrk->hash();
695 } else if (mrk->is_marked()) {
696 return mrk->hash();
697 } else {
698 return slow_identity_hash();
699 }
700 }
701
702 inline void oopDesc::ms_follow_contents() {
703 klass()->oop_ms_follow_contents(this);
704 }
705
706 inline int oopDesc::ms_adjust_pointers() {
707 debug_only(int check_size = size());
708 int s = klass()->oop_ms_adjust_pointers(this);
709 assert(s == check_size, "should be the same");
710 return s;
711 }
712
713 #if INCLUDE_ALL_GCS
714 inline void oopDesc::pc_follow_contents(ParCompactionManager* cm) {
715 klass()->oop_pc_follow_contents(this, cm);
716 }
717
718 inline void oopDesc::pc_update_contents() {
719 Klass* k = klass();
720 if (!k->oop_is_typeArray()) {
721 // It might contain oops beyond the header, so take the virtual call.
722 k->oop_pc_update_pointers(this);
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_OOPS_OOP_INLINE_HPP
26 #define SHARE_VM_OOPS_OOP_INLINE_HPP
27
28 #include "gc/serial/markSweep.inline.hpp"
29 #include "gc/shared/ageTable.hpp"
30 #include "gc/shared/barrierSet.inline.hpp"
31 #include "gc/shared/cardTableModRefBS.hpp"
32 #include "gc/shared/collectedHeap.inline.hpp"
33 #include "gc/shared/genCollectedHeap.hpp"
34 #include "gc/shared/generation.hpp"
35 #include "oops/arrayKlass.hpp"
36 #include "oops/arrayOop.hpp"
37 #include "oops/klass.inline.hpp"
38 #include "oops/markOop.inline.hpp"
39 #include "oops/oop.hpp"
40 #include "runtime/atomic.inline.hpp"
41 #include "runtime/orderAccess.inline.hpp"
42 #include "runtime/os.hpp"
43 #include "utilities/macros.hpp"
44
45 // Implementation of all inlined member functions defined in oop.hpp
46 // We need a separate file to avoid circular references
47
48 inline void oopDesc::release_set_mark(markOop m) {
523 if (prebarrier) {
524 update_barrier_set_pre((narrowOop*)dest, exchange_value);
525 }
526 // encode exchange and compare value from oop to T
527 narrowOop val = encode_heap_oop(exchange_value);
528 narrowOop cmp = encode_heap_oop(compare_value);
529
530 narrowOop old = (narrowOop) Atomic::cmpxchg(val, (narrowOop*)dest, cmp);
531 // decode old from T to oop
532 return decode_heap_oop(old);
533 } else {
534 if (prebarrier) {
535 update_barrier_set_pre((oop*)dest, exchange_value);
536 }
537 return (oop)Atomic::cmpxchg_ptr(exchange_value, (oop*)dest, compare_value);
538 }
539 }
540
541 // Used only for markSweep, scavenging
542 inline bool oopDesc::is_gc_marked() const {
543 assert(!CMSParallelFullGC, "CMSParallelFullGC should call parallel version.");
544 return mark()->is_marked();
545 }
546
547 inline bool oopDesc::is_locked() const {
548 return mark()->is_locked();
549 }
550
551 inline bool oopDesc::is_unlocked() const {
552 return mark()->is_unlocked();
553 }
554
555 inline bool oopDesc::has_bias_pattern() const {
556 return mark()->has_bias_pattern();
557 }
558
559
560 // used only for asserts
561 inline bool oopDesc::is_oop(bool ignore_mark_word) const {
562 oop obj = (oop) this;
563 if (!check_obj_alignment(obj)) return false;
685 } else {
686 set_mark(mark()->incr_age());
687 }
688 }
689
690
691 inline intptr_t oopDesc::identity_hash() {
692 // Fast case; if the object is unlocked and the hash value is set, no locking is needed
693 // Note: The mark must be read into local variable to avoid concurrent updates.
694 markOop mrk = mark();
695 if (mrk->is_unlocked() && !mrk->has_no_hash()) {
696 return mrk->hash();
697 } else if (mrk->is_marked()) {
698 return mrk->hash();
699 } else {
700 return slow_identity_hash();
701 }
702 }
703
704 inline void oopDesc::ms_follow_contents() {
705 #ifdef ASSERT
706 if (!CMSParallelFullGC) {
707 assert (is_gc_marked(), "should be marked");
708 } else {
709 assert(MarkSweep::is_object_marked(this), "should be marked");
710 }
711 #endif
712 klass()->oop_ms_follow_contents(this);
713 }
714
715 inline int oopDesc::ms_adjust_pointers() {
716 debug_only(int check_size = size());
717 int s = klass()->oop_ms_adjust_pointers(this);
718 assert(s == check_size, "should be the same");
719 return s;
720 }
721
722 #if INCLUDE_ALL_GCS
723 inline void oopDesc::pc_follow_contents(ParCompactionManager* cm) {
724 klass()->oop_pc_follow_contents(this, cm);
725 }
726
727 inline void oopDesc::pc_update_contents() {
728 Klass* k = klass();
729 if (!k->oop_is_typeArray()) {
730 // It might contain oops beyond the header, so take the virtual call.
731 k->oop_pc_update_pointers(this);
|