RFR: 8317132: Prepare HotSpot for permissive- [v9]
Kim Barrett
kbarrett at openjdk.org
Tue Oct 31 07:35:34 UTC 2023
On Tue, 3 Oct 2023 07:45:42 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Is Thomas around? Would like to get his opinion of what to do with this particular snippet
>
> I know he was away until October but not exactly when in October.
Ick! I hadn't followed https://github.com/openjdk/jdk/pull/15096 closely, so
hadn't noticed the discussion there. Not sure why this is using a literal 0
rather than `(T) '\n'` as in that PR?
So the literal "0" (or previously, NUL char constant) is either an integral
zero or a null pointer constant (because one of the types used for T is
HMODULE). imprint_sentinal uses `(T)'X'`. (Double ick! The value is either an
integral constant or a HMODULE with a weird value.)
An approach to being type safe/consistent would be to provide a traits utility
for specifying the terminator and the sentinal on a type-specific basis. Don't
know if that's worth doing in this PR. We've been living (dangerously?) with
the existing mechanism for a long time.
Something like
template<typename T>
struct SimpleBufferSpecialValues;
template<>
struct SimpleBufferSpecialValues<char> {
char terminator() const { return '\0'; }
char sentinal() const { return '\X'; }
};
template<>
struct SimpleBufferSpecialValues<HMODULE> {
HMODULE terminator() const { return nullptr; }
HMODULE sentinal() const {
// Untested, might be completely wrong.
alignas(HMODULE) static const char sentinal_data[1];
return reinterpret_cast<HMODULE>(&sentinal_data);
}
};
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15955#discussion_r1377160121
More information about the build-dev
mailing list