[jdk17u-dev] RFR: 8292989: Avoid dynamic memory in AsyncLogWriter
Xin Liu
xliu at openjdk.org
Tue Aug 1 20:11:56 UTC 2023
On Tue, 1 Aug 2023 19:33:39 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> This patch is *NOT* a clean backport. The logic part is exactly the same, but I have to adjust code in the following parts:
>> 1. change from KVHashtable to ResourceHashtable because we want to use resourceArea instead of C_HEAP.
>> 2. we added lambda-API iterator() to ResourceHashtable. Instead of backporting all patches from TIP, we just reuse the original iterator().
>>
>>
>> template<typename Function>
>> void iterate(Function function) const { // lambda enabled API
>>
>>
>> Testing:
>> jdk-test1 tests including gtest.
>> Manually check there's no malloc/free in runtime.
>
> src/hotspot/share/utilities/resourceHash.hpp line 187:
>
>> 185: template<class ITER>
>> 186: void iterate(ITER* iter) const {
>> 187: auto function = [&] (K& k, V& v) {
>
> Can we avoid doing this by making a named `struct` implementing `do_entry` for every use? I realize that would deviate the _uses_ from the upstream, but we would not be changing the shared code, which would be safer for generic code that does not use any of async logging *and* uses older toolchains.
>
> This hunk effectively backports https://bugs.openjdk.org/browse/JDK-8276789, which seems to imply the need to check this works well with different toolchains.
yes, I can rewrite lambdas using old-style functor.
to backport [JDK-8276789](https://bugs.openjdk.org/browse/JDK-8276789), we also need to backport bucket_at(), table()/table_size() beforehand. I take your advice. my approach skips more verification and it's not good. I will use functor.
-------------
PR Review Comment: https://git.openjdk.org/jdk17u-dev/pull/1630#discussion_r1281104422
More information about the jdk-updates-dev
mailing list