RFR: 8214377: ZGC: Don't use memset to initialize array of ZForwardingTableEntry
Per Liden
per.liden at oracle.com
Tue Dec 4 18:23:47 UTC 2018
Hi Kim,
On 2018-12-04 17:15, Kim Barrett wrote:
>> On Nov 29, 2018, at 7:49 AM, Per Liden <per.liden at oracle.com> wrote:
>>
>> Use placement new instead of memset() to avoid compiler warning/error when using GCC 8 with -Werror=class-memaccess (memset to initialize non-trivial object).
>>
>> To avoid any undefined behavior I also added a loop to destruct the objects properly, but this loop will be compiled down to nothing.
>
> Just an FYI here; I see this change has been pushed.
>
> FYI: Calling the destructor is only required if it has side effects
> that the program depends on. See C++14 3.8/4. Of course, it is okay to
> call it anyway, and I agree that currently it will optimize away.
Oh, I actually thought the aliasing rules (which we don't depend on, but
anyway) stipulated that I had to call it, even when it's a no-op. But
apparently not, good to know.
>
> Also, the for-loop of placement new calls might in this case be
> optimized by the compiler into memset.
That was not the case here unfortunately, despite everything (except the
loop count) being visible to the compiler.
Thanks for the feedback!
/Per
>
>> I ran SPECjbb2015 to see if the execution time for "Prepare Relocation Set" was noticeably affected by this change (assuming memset does a batter job than then loop), but I can't see any real difference. I'll run a few more iterations over night just to make sure.
>>
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8214377
>> Webrev: http://cr.openjdk.java.net/~pliden/8214377/webrev.0
>>
>> /Per
>
>
More information about the hotspot-gc-dev
mailing list