JDK-8229258 : Rework markOop and markOopDesc into a simpler mark word value carrier
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 14
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-08-07
  • Updated: 2024-02-06
  • Resolved: 2019-08-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 14
14 b11Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
I want to change/rename markOop and markOopDesc

Today markOopDescs inherits from oopDesc even though they are not oopDescs (Java objects):
 `class markOopDesc : public oopDesc {`

This is very confusing to new-comers (and probably to old-timers as well).

A simple fix would be to break the inheritance and do the following rename:
markOopDesc -> MarkWord
markOop -> markWord

However, there are more dubious code in this area. markOopDescs are created and used like this:

```
class oopDesc {
...
  volatile markOop _mark;
...
markOop  oopDesc::mark_raw()  const { return _mark; }
...
// Usage
obj->mark_raw()->is_marked()
...
// Implementation
  bool is_marked()   const {
    return (mask_bits(value(), lock_mask_in_place) == marked_value);
  }
...
// Implementation
  bool is_being_inflated() const { return (value() == 0); }
...
// Implementation of markOopDesc::value()
  uintptr_t value() const { return (uintptr_t) this; }
```

Remember, _mark is an arbitrary bit pattern describing the object. We treat it as if it were a pointer to a markOopDesc object, but it's not pointing to such an object. While using that (weird) pointer we call value() and extract it's bit pattern to be used for further bit pattern checking functions. AFAICT, this is also undefined behavior. At least is_being_inflated() const is effectively 'return (uintptr_t) this == NULL'. This UB was recently discussed here:
 https://mail.openjdk.java.net/pipermail/hotspot-dev/2019-July/038704.html
 https://mail.openjdk.java.net/pipermail/hotspot-dev/2019-July/038712.html

Revoked: "I propose that we change MarkWord (markOopDesc) to be an AllStatic class instead and get rid of this (ab)use of the markWord (markOop) pointer."
Revised: "I propose that we change markWord (markOopDesc) to contain an uintptr_t _value member and stop using the bit pattern of the this pointer"
Comments
A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk11u/pull/23 Date: 2021-12-19 02:55:01 +0000
09-02-2022

URL: https://hg.openjdk.java.net/jdk/jdk/rev/90ead0febf56 User: stefank Date: 2019-08-16 11:02:59 +0000
16-08-2019