[lilliput-jdk17u:lilliput] RFR: 8308956: [Lilliput/JDK17] Fix some object initialization paths

Aleksey Shipilev shade at openjdk.org
Sat May 27 10:06:49 UTC 2023


On Fri, 26 May 2023 14:37:46 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> In some object initialization paths I got the conditions wrong, especial wrt to biased-locking. Let's fix them.
>> 
>> Testing:
>>  - [x] tier1
>>  - [x] tier2
>
> src/hotspot/share/cds/heapShared.cpp line 429:
> 
>> 427:   {
>> 428:     // This is copied from MemAllocator::finish
>> 429:     if (UseBiasedLocking || UseCompactObjectHeaders) {
> 
> This misses klass store on `UseBiasedLocking` path.

Also, we should be doing `oopDesc::release_set_mark` if there is no klass-release on some path?

> src/hotspot/share/gc/shared/memAllocator.cpp line 388:
> 
>> 386:   assert(mem != NULL, "NULL object pointer");
>> 387:   if (UseBiasedLocking) {
>> 388:     oopDesc::set_mark(mem, _klass->prototype_header());
> 
> Not enough, I think, because there is a `oopDesc::set_mark` in the block below that would overwrite it.

I think this one would be cleaner:


if (UseCompactObjectHeaders) {
  oopDesc::release_set_mark(mem, _klass->prototype_header());
} else {
  if (UseBiasedLocking) {
    oopDesc::set_mark(mem, _klass->prototype_header());
  } else {
    // May be bootstrapping
    oopDesc::set_mark(mem, markWord::prototype());
  }
  // Need a release store to ensure array/class length, mark word, and
  // object zeroing are visible before setting the klass non-NULL, for
  // concurrent collectors.
  if (!UseCompactObjectHeaders) {
    oopDesc::release_set_klass(mem, _klass);
  }
}

-------------

PR Review Comment: https://git.openjdk.org/lilliput-jdk17u/pull/28#discussion_r1206888142
PR Review Comment: https://git.openjdk.org/lilliput-jdk17u/pull/28#discussion_r1206895479


More information about the lilliput-dev mailing list