RFR: 8271569: Rename cdsoffsets.cpp to cdsConstants.cpp
Stefan Karlsson
stefank at openjdk.java.net
Mon Sep 13 13:41:34 UTC 2021
On Mon, 13 Sep 2021 12:42:27 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> The array size is known at compile time --- it is not dynamic but we do not need to manually count the size of the array this way. If define a size for the array, we need to count the number of items in the array to define the array size. We may add more items to the array --- just add items and don't need change anything else. Since total array memory size and array component size are known at compile time, so compiler will not generate code to calculate the size. How about this?
>> const int size = (int)(sizeof(cds_offsets)/sizeof(cds_offsets[0]));
>> for (int i = 0; i < size; i++) {
>> ...
>> }
>
> I always thought that was a hack way of determining an array size, not an approved method. :(
>
> Don't worry just leave it as-is.
We have functionality for this in globalDefinitions.hpp:
#define ARRAY_SIZE(array) sizeof(array_size_impl(array))
-------------
PR: https://git.openjdk.java.net/jdk/pull/5450
More information about the hotspot-runtime-dev
mailing list