mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8158854: Ensure release_store is paired with load_acquire in lock-free code
Reviewed-by: shade, dcubed, zgu
This commit is contained in:
parent
56ff858c45
commit
6db26ca5bf
10 changed files with 87 additions and 23 deletions
|
@ -1041,7 +1041,8 @@ Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) {
|
|||
}
|
||||
|
||||
Klass* InstanceKlass::array_klass_impl(instanceKlassHandle this_k, bool or_null, int n, TRAPS) {
|
||||
if (this_k->array_klasses() == NULL) {
|
||||
// Need load-acquire for lock-free read
|
||||
if (this_k->array_klasses_acquire() == NULL) {
|
||||
if (or_null) return NULL;
|
||||
|
||||
ResourceMark rm;
|
||||
|
@ -1054,7 +1055,8 @@ Klass* InstanceKlass::array_klass_impl(instanceKlassHandle this_k, bool or_null,
|
|||
// Check if update has already taken place
|
||||
if (this_k->array_klasses() == NULL) {
|
||||
Klass* k = ObjArrayKlass::allocate_objArray_klass(this_k->class_loader_data(), 1, this_k, CHECK_NULL);
|
||||
this_k->set_array_klasses(k);
|
||||
// use 'release' to pair with lock-free load
|
||||
this_k->release_set_array_klasses(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue