RFR: 8229258: Make markOopDesc AllStatic
Kim Barrett
kim.barrett at oracle.com
Thu Aug 8 17:20:31 UTC 2019
> On Aug 8, 2019, at 7:01 AM, Stefan Karlsson <stefan.karlsson at oracle.com> wrote:
> class oopDesc {
> volatile markWord _mark;
> }
> ...
> _mark = prototype(); <-- complains here that the assignment operator discards volatile qualifier
>
> I'm unsure what performance effects it will have if I provide a hand-written assignment operator, since the class will not be a trivial class anymore. Because of that, I backed away from such a change.
[Not a review, just a comment about the above.]
There are some other places where that problem arises in our code base.
They’ve been dealt with by casting away the volatile, e.g. here would be
// discard volatile post-assignment read.
(void)const_cast<markWord&>(_mark = prototype());
To find some other examples (with some false positives):
egrep “const_cast<[^>]+&>”
taskqueue has several, with others scattered here and there. There
are enough of them (more than I expected, over a dozen), and they are
long and ugly and obscure enough, that maybe there should be a helper
function for this. I think something like (completely untested)
template<typename T>
ALWAYSINLINE void discard_volatile(T volatile& x) {
static_cast<void>(const_cast<T&>(x));
}
More information about the hotspot-dev
mailing list