Skip to content

Commit 0817750

Browse files
committed
8366794: [lworld] "assert(!is_null(v)) failed: narrow klass value can never be zero" with -Xint and COH
Reviewed-by: fparain
1 parent 9014ec2 commit 0817750

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/hotspot/share/oops/flatArrayKlass.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,13 @@ jint FlatArrayKlass::array_layout_helper(InlineKlass* vk, LayoutKind lk) {
169169
}
170170

171171
size_t FlatArrayKlass::oop_size(oop obj) const {
172-
assert(obj->klass()->is_flatArray_klass(),"must be an flat array");
172+
// In this assert, we cannot safely access the Klass* with compact headers,
173+
// because size_given_klass() calls oop_size() on objects that might be
174+
// concurrently forwarded, which would overwrite the Klass*.
175+
// Also, why we need to pass this layout_helper() to flatArrayOop::object_size.
176+
assert(UseCompactObjectHeaders || obj->is_flatArray(),"must be an flat array");
173177
flatArrayOop array = flatArrayOop(obj);
174-
return array->object_size();
178+
return array->object_size(layout_helper());
175179
}
176180

177181
// For now return the maximum number of array elements that will not exceed:

src/hotspot/share/oops/flatArrayOop.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class flatArrayOopDesc : public objArrayOopDesc {
5959
return align_object_size((intptr_t)size_in_words);
6060
}
6161

62-
int object_size() const;
62+
int object_size(int lh) const;
6363

6464
};
6565

src/hotspot/share/oops/flatArrayOop.inline.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ inline void* flatArrayOopDesc::value_at_addr(int index, jint lh) const {
4242
return (void*) addr;
4343
}
4444

45-
inline int flatArrayOopDesc::object_size() const {
46-
return object_size(klass()->layout_helper(), length());
45+
inline int flatArrayOopDesc::object_size(int lh) const {
46+
return object_size(lh, length());
4747
}
4848

4949
inline oop flatArrayOopDesc::obj_at(int index) const {

src/hotspot/share/oops/objArrayKlass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ size_t ObjArrayKlass::oop_size(oop obj) const {
149149
// concurrently forwarded, which would overwrite the Klass*.
150150
assert(UseCompactObjectHeaders || obj->is_objArray(), "must be object array");
151151
// return objArrayOop(obj)->object_size();
152-
return obj->is_flatArray() ? flatArrayOop(obj)->object_size() : refArrayOop(obj)->object_size();
152+
return obj->is_flatArray() ? flatArrayOop(obj)->object_size(layout_helper()) : refArrayOop(obj)->object_size();
153153
}
154154

155155
ArrayDescription ObjArrayKlass::array_layout_selection(Klass* element, ArrayProperties properties) {

0 commit comments

Comments
 (0)