comparison src/share/vm/oops/oop.inline.hpp @ 167:feeb96a45707

6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC Summary: decouple set_klass() with zeroing the gap when compressed. Reviewed-by: kvn, ysr, jrose
author coleenp
date Wed, 28 May 2008 21:06:24 -0700
parents b7268662a986
children d1605aabd0a1 6aae2f9d0294
comparison
equal deleted inserted replaced
166:aaa1137c5ef4 167:feeb96a45707
34 } 34 }
35 35
36 inline klassOop oopDesc::klass() const { 36 inline klassOop oopDesc::klass() const {
37 if (UseCompressedOops) { 37 if (UseCompressedOops) {
38 return (klassOop)decode_heap_oop_not_null(_metadata._compressed_klass); 38 return (klassOop)decode_heap_oop_not_null(_metadata._compressed_klass);
39 // can be NULL in CMS, but isn't supported on CMS yet. 39 } else {
40 return _metadata._klass;
41 }
42 }
43
44 inline klassOop oopDesc::klass_or_null() const volatile {
45 // can be NULL in CMS
46 if (UseCompressedOops) {
47 return (klassOop)decode_heap_oop(_metadata._compressed_klass);
40 } else { 48 } else {
41 return _metadata._klass; 49 return _metadata._klass;
42 } 50 }
43 } 51 }
44 52
62 inline void oopDesc::set_klass(klassOop k) { 70 inline void oopDesc::set_klass(klassOop k) {
63 // since klasses are promoted no store check is needed 71 // since klasses are promoted no store check is needed
64 assert(Universe::is_bootstrapping() || k != NULL, "must be a real klassOop"); 72 assert(Universe::is_bootstrapping() || k != NULL, "must be a real klassOop");
65 assert(Universe::is_bootstrapping() || k->is_klass(), "not a klassOop"); 73 assert(Universe::is_bootstrapping() || k->is_klass(), "not a klassOop");
66 if (UseCompressedOops) { 74 if (UseCompressedOops) {
67 // zero the gap when the klass is set, by zeroing the pointer sized
68 // part of the union.
69 _metadata._klass = NULL;
70 oop_store_without_check(compressed_klass_addr(), (oop)k); 75 oop_store_without_check(compressed_klass_addr(), (oop)k);
71 } else { 76 } else {
72 oop_store_without_check(klass_addr(), (oop) k); 77 oop_store_without_check(klass_addr(), (oop) k);
78 }
79 }
80
81 inline int oopDesc::klass_gap() const {
82 return *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes());
83 }
84
85 inline void oopDesc::set_klass_gap(int v) {
86 if (UseCompressedOops) {
87 *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes()) = v;
73 } 88 }
74 } 89 }
75 90
76 inline void oopDesc::set_klass_to_list_ptr(oop k) { 91 inline void oopDesc::set_klass_to_list_ptr(oop k) {
77 // This is only to be used during GC, for from-space objects, so no 92 // This is only to be used during GC, for from-space objects, so no
503 if (!Universe::heap()->is_in_reserved(obj)) return false; 518 if (!Universe::heap()->is_in_reserved(obj)) return false;
504 // obj is aligned and accessible in heap 519 // obj is aligned and accessible in heap
505 // try to find metaclass cycle safely without seg faulting on bad input 520 // try to find metaclass cycle safely without seg faulting on bad input
506 // we should reach klassKlassObj by following klass link at most 3 times 521 // we should reach klassKlassObj by following klass link at most 3 times
507 for (int i = 0; i < 3; i++) { 522 for (int i = 0; i < 3; i++) {
508 obj = obj->klass(); 523 obj = obj->klass_or_null();
509 // klass should be aligned and in permspace 524 // klass should be aligned and in permspace
510 if (!check_obj_alignment(obj)) return false; 525 if (!check_obj_alignment(obj)) return false;
511 if (!Universe::heap()->is_in_permanent(obj)) return false; 526 if (!Universe::heap()->is_in_permanent(obj)) return false;
512 } 527 }
513 if (obj != Universe::klassKlassObj()) { 528 if (obj != Universe::klassKlassObj()) {