71
72 private:
73 void check(ShenandoahAsserts::SafeLevel level, oop obj, bool test, const char* label) {
74 if (!test) {
75 ShenandoahAsserts::print_failure(level, obj, _interior_loc, _loc, _phase, label, __FILE__, __LINE__);
76 }
77 }
78
79 template <class T>
80 void do_oop_work(T* p) {
81 T o = RawAccess<>::oop_load(p);
82 if (!CompressedOops::is_null(o)) {
83 oop obj = CompressedOops::decode_not_null(o);
84
85 // Single threaded verification can use faster non-atomic stack and bitmap
86 // methods.
87 //
88 // For performance reasons, only fully verify non-marked field values.
89 // We are here when the host object for *p is already marked.
90
91 if (_map->par_mark(obj)) {
92 verify_oop_at(p, obj);
93 _stack->push(ShenandoahVerifierTask(obj));
94 }
95 }
96 }
97
98 void verify_oop(oop obj) {
99 // Perform consistency checks with gradually decreasing safety level. This guarantees
100 // that failure report would not try to touch something that was not yet verified to be
101 // safe to process.
102
103 check(ShenandoahAsserts::_safe_unknown, obj, _heap->is_in(obj),
104 "oop must be in heap");
105 check(ShenandoahAsserts::_safe_unknown, obj, is_object_aligned(obj),
106 "oop must be aligned");
107
108 ShenandoahHeapRegion *obj_reg = _heap->heap_region_containing(obj);
109 Klass* obj_klass = obj->klass_or_null();
110
111 // Verify that obj is not in dead space:
112 {
113 // Do this before touching obj->size()
114 check(ShenandoahAsserts::_safe_unknown, obj, obj_klass != NULL,
115 "Object klass pointer should not be NULL");
116 check(ShenandoahAsserts::_safe_unknown, obj, Metaspace::contains(obj_klass),
117 "Object klass pointer must go to metaspace");
118
119 HeapWord *obj_addr = cast_from_oop<HeapWord*>(obj);
120 check(ShenandoahAsserts::_safe_unknown, obj, obj_addr < obj_reg->top(),
121 "Object start should be within the region");
122
123 if (!obj_reg->is_humongous()) {
124 check(ShenandoahAsserts::_safe_unknown, obj, (obj_addr + obj->size()) <= obj_reg->top(),
125 "Object end should be within the region");
126 } else {
127 size_t humongous_start = obj_reg->region_number();
128 size_t humongous_end = humongous_start + (obj->size() >> ShenandoahHeapRegion::region_size_words_shift());
129 for (size_t idx = humongous_start + 1; idx < humongous_end; idx++) {
130 check(ShenandoahAsserts::_safe_unknown, obj, _heap->get_region(idx)->is_humongous_continuation(),
131 "Humongous object is in continuation that fits it");
132 }
133 }
134
135 // ------------ obj is safe at this point --------------
136
137 check(ShenandoahAsserts::_safe_oop, obj, obj_reg->is_active(),
138 "Object should be in active region");
139
163 check(ShenandoahAsserts::_safe_oop, obj, !CompressedOops::is_null(fwd),
164 "Forwardee is set");
165 check(ShenandoahAsserts::_safe_oop, obj, is_object_aligned(fwd),
166 "Forwardee must be aligned");
167
168 // Do this before touching fwd->size()
169 Klass* fwd_klass = fwd->klass_or_null();
170 check(ShenandoahAsserts::_safe_oop, obj, fwd_klass != NULL,
171 "Forwardee klass pointer should not be NULL");
172 check(ShenandoahAsserts::_safe_oop, obj, Metaspace::contains(fwd_klass),
173 "Forwardee klass pointer must go to metaspace");
174 check(ShenandoahAsserts::_safe_oop, obj, obj_klass == fwd_klass,
175 "Forwardee klass pointer must go to metaspace");
176
177 fwd_reg = _heap->heap_region_containing(fwd);
178
179 // Verify that forwardee is not in the dead space:
180 check(ShenandoahAsserts::_safe_oop, obj, !fwd_reg->is_humongous(),
181 "Should have no humongous forwardees");
182
183 HeapWord *fwd_addr = cast_from_oop<HeapWord *>(fwd);
184 check(ShenandoahAsserts::_safe_oop, obj, fwd_addr < fwd_reg->top(),
185 "Forwardee start should be within the region");
186 check(ShenandoahAsserts::_safe_oop, obj, (fwd_addr + fwd->size()) <= fwd_reg->top(),
187 "Forwardee end should be within the region");
188
189 oop fwd2 = (oop) ShenandoahForwarding::get_forwardee_raw_unchecked(fwd);
190 check(ShenandoahAsserts::_safe_oop, obj, (fwd == fwd2),
191 "Double forwarding");
192 } else {
193 fwd_reg = obj_reg;
194 }
195
196 // ------------ obj and fwd are safe at this point --------------
197
198 switch (_options._verify_marked) {
199 case ShenandoahVerifier::_verify_marked_disable:
200 // skip
201 break;
202 case ShenandoahVerifier::_verify_marked_incomplete:
203 check(ShenandoahAsserts::_safe_all, obj, _heap->marking_context()->is_marked(obj),
|
71
72 private:
73 void check(ShenandoahAsserts::SafeLevel level, oop obj, bool test, const char* label) {
74 if (!test) {
75 ShenandoahAsserts::print_failure(level, obj, _interior_loc, _loc, _phase, label, __FILE__, __LINE__);
76 }
77 }
78
79 template <class T>
80 void do_oop_work(T* p) {
81 T o = RawAccess<>::oop_load(p);
82 if (!CompressedOops::is_null(o)) {
83 oop obj = CompressedOops::decode_not_null(o);
84
85 // Single threaded verification can use faster non-atomic stack and bitmap
86 // methods.
87 //
88 // For performance reasons, only fully verify non-marked field values.
89 // We are here when the host object for *p is already marked.
90
91 HeapWord* addr = (HeapWord*) obj;
92 if (_map->par_mark(addr)) {
93 verify_oop_at(p, obj);
94 _stack->push(ShenandoahVerifierTask(obj));
95 }
96 }
97 }
98
99 void verify_oop(oop obj) {
100 // Perform consistency checks with gradually decreasing safety level. This guarantees
101 // that failure report would not try to touch something that was not yet verified to be
102 // safe to process.
103
104 check(ShenandoahAsserts::_safe_unknown, obj, _heap->is_in(obj),
105 "oop must be in heap");
106 check(ShenandoahAsserts::_safe_unknown, obj, is_object_aligned(obj),
107 "oop must be aligned");
108
109 ShenandoahHeapRegion *obj_reg = _heap->heap_region_containing(obj);
110 Klass* obj_klass = obj->klass_or_null();
111
112 // Verify that obj is not in dead space:
113 {
114 // Do this before touching obj->size()
115 check(ShenandoahAsserts::_safe_unknown, obj, obj_klass != NULL,
116 "Object klass pointer should not be NULL");
117 check(ShenandoahAsserts::_safe_unknown, obj, Metaspace::contains(obj_klass),
118 "Object klass pointer must go to metaspace");
119
120 HeapWord *obj_addr = (HeapWord *) obj;
121 check(ShenandoahAsserts::_safe_unknown, obj, obj_addr < obj_reg->top(),
122 "Object start should be within the region");
123
124 if (!obj_reg->is_humongous()) {
125 check(ShenandoahAsserts::_safe_unknown, obj, (obj_addr + obj->size()) <= obj_reg->top(),
126 "Object end should be within the region");
127 } else {
128 size_t humongous_start = obj_reg->region_number();
129 size_t humongous_end = humongous_start + (obj->size() >> ShenandoahHeapRegion::region_size_words_shift());
130 for (size_t idx = humongous_start + 1; idx < humongous_end; idx++) {
131 check(ShenandoahAsserts::_safe_unknown, obj, _heap->get_region(idx)->is_humongous_continuation(),
132 "Humongous object is in continuation that fits it");
133 }
134 }
135
136 // ------------ obj is safe at this point --------------
137
138 check(ShenandoahAsserts::_safe_oop, obj, obj_reg->is_active(),
139 "Object should be in active region");
140
164 check(ShenandoahAsserts::_safe_oop, obj, !CompressedOops::is_null(fwd),
165 "Forwardee is set");
166 check(ShenandoahAsserts::_safe_oop, obj, is_object_aligned(fwd),
167 "Forwardee must be aligned");
168
169 // Do this before touching fwd->size()
170 Klass* fwd_klass = fwd->klass_or_null();
171 check(ShenandoahAsserts::_safe_oop, obj, fwd_klass != NULL,
172 "Forwardee klass pointer should not be NULL");
173 check(ShenandoahAsserts::_safe_oop, obj, Metaspace::contains(fwd_klass),
174 "Forwardee klass pointer must go to metaspace");
175 check(ShenandoahAsserts::_safe_oop, obj, obj_klass == fwd_klass,
176 "Forwardee klass pointer must go to metaspace");
177
178 fwd_reg = _heap->heap_region_containing(fwd);
179
180 // Verify that forwardee is not in the dead space:
181 check(ShenandoahAsserts::_safe_oop, obj, !fwd_reg->is_humongous(),
182 "Should have no humongous forwardees");
183
184 HeapWord *fwd_addr = (HeapWord *) fwd;
185 check(ShenandoahAsserts::_safe_oop, obj, fwd_addr < fwd_reg->top(),
186 "Forwardee start should be within the region");
187 check(ShenandoahAsserts::_safe_oop, obj, (fwd_addr + fwd->size()) <= fwd_reg->top(),
188 "Forwardee end should be within the region");
189
190 oop fwd2 = (oop) ShenandoahForwarding::get_forwardee_raw_unchecked(fwd);
191 check(ShenandoahAsserts::_safe_oop, obj, (fwd == fwd2),
192 "Double forwarding");
193 } else {
194 fwd_reg = obj_reg;
195 }
196
197 // ------------ obj and fwd are safe at this point --------------
198
199 switch (_options._verify_marked) {
200 case ShenandoahVerifier::_verify_marked_disable:
201 // skip
202 break;
203 case ShenandoahVerifier::_verify_marked_incomplete:
204 check(ShenandoahAsserts::_safe_all, obj, _heap->marking_context()->is_marked(obj),
|