RFR: 8153658: Redundant memory copy in LogStreamNoResourceMark
Kim Barrett
kim.barrett at oracle.com
Thu Apr 7 05:23:52 UTC 2016
> On Apr 7, 2016, at 1:17 AM, Kim Barrett <kim.barrett at oracle.com> wrote:
>
>> On Apr 6, 2016, at 1:30 PM, Stefan Karlsson <stefan.karlsson at oracle.com> wrote:
>>
>> Hi all,
>>
>> Please review this patch to remove a redundant memory copy in the UL log stream classes.
>>
>> http://cr.openjdk.java.net/~stefank/8153658/webrev.01
>> https://bugs.openjdk.java.net/browse/JDK-8153658
>>
>> LogStreamNoResourceMark copies the resource allocated string buffer into a new resource allocated string buffer before copying the data to UL.
>>
>> Moreover, this also causes problem when implementing a log stream class using CHeap memory instead of Resource memory. Even though the first allocation is done from CHeap the second copy comes from Resource memory.
>
> ------------------------------------------------------------------------------
> src/share/vm/logging/logStream.inline.hpp
> 36 _current_line.write("\0", 1);
>
> I think this write isn't needed. stringStream purportedly ensures the
> internal buffer is NUL terminated, according to a comment in
> stringStream::write. And the code seems to do that. Hm, except maybe
> at construction time? That seems like a bug. And I think bad things
> might happen if a stringStream is constructed with initial_size or
> fixed_buffer_size of zero, which would also be a bug.
>
> ------------------------------------------------------------------------------
I forgot to say, the rest of the change looks fine, subject to possible bugs in stringStream.
More information about the hotspot-dev
mailing list