RFR: 8296453: Simplify resource_area uses in ClassPathDirEntry::open_stream [v2]

Xin Liu xliu at openjdk.org
Thu Nov 10 08:41:36 UTC 2022


On Tue, 8 Nov 2022 05:49:02 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Xin Liu has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>> 
>>  - Add API FREE_RESOURCE_ARRAY_IN_THREAD.
>>    
>>    Remove the assert at the begining because it is redundant.
>>    We also replace ResourceArea allocation/free with their IN_THREAD variants.
>>  - Merge branch 'master' into JDK-8296453
>>  - 8296453: Simplify resource_area uses in ClassPathDirEntry::open_stream
>
> src/hotspot/share/classfile/classLoader.cpp line 267:
> 
>> 265:           ClassLoader::perf_sys_classfile_bytes_read()->inc(num_read);
>> 266:         }
>> 267:         FREE_RESOURCE_ARRAY(char, path, path_len);
> 
> I see your argument about this being basically a no-op, but we also lose the guard against access-after-free (ZapResourceArea). At a minimum I'd add a comment "// No need to free path here" else someone will think it is an oversight.

`ZapResourceArea` is only enabled when ASSERT is defined, so I bring back FREE_RESOURCE_ARRAY_IN_THREAD under ASSERT. We won't call Afree() in release build.

-------------

PR: https://git.openjdk.org/jdk/pull/11024


More information about the hotspot-runtime-dev mailing list