RFR (XS) 8238909: x86_32 fails gtest:power_of_2
Stefan Karlsson
stefan.karlsson at oracle.com
Wed Feb 12 18:54:09 UTC 2020
On 2020-02-12 19:45, Aleksey Shipilev wrote:
> Bug:
> https://bugs.openjdk.java.net/browse/JDK-8238909
>
> Fix:
> https://cr.openjdk.java.net/~shade/8238909/webrev.01/
>
> The problem here is is_power_of_2(intptr_t), which truncates int64_t on x86_32, and replies "false"
> on large power-of-two values. is_power_of_2_long(jlong) is awkward, but alternatives seem worse:
> *) "LP64_ONLY(is_power_of_2(value)) NOT_LP64(is_power_of_2_long(value))" looks worse;
> *) Overloading is_power_of_2(int64_t) quickly runs afoul of ambiguities on the platforms I tried;
> *) Specializing the whole thing for 8-byte types seems to invite even more template madness;
FWIW, we have a template version in align.hpp:
// Temporary declaration until this file has been restructured.
template <typename T>
bool is_power_of_2_t(T x) {
return (x != T(0)) && ((x & (x - 1)) == T(0));
}
Would that version work in this situation?
StefanK
>
> Testing: affected test on {x86_64, x86_32}; jdk-submit
>
More information about the hotspot-dev
mailing list