RFR: 8239001: Hotspot build broken on linux-sparc after 8238281
Kim Barrett
kim.barrett at oracle.com
Sat Feb 15 21:30:54 UTC 2020
> On Feb 15, 2020, at 1:06 PM, John Paul Adrian Glaubitz <glaubitz at physik.fu-berlin.de> wrote:
>
> On 2/13/20 8:35 PM, Kim Barrett wrote:
>> I don't think this is the right way to address this problem.
>>
>> I think the JDK-8238281 change to offset_of and the associated
>> addition of -Wno-invalid-offsetof to the build configuration was a
>> mistake, and should be reverted. Those changes seem unrelated to the
>> purpose of JDK-8238281, which was to raise the minimum acceptable gcc
>> version.
>
> Alternatively, this works as well:
>
> glaubitz at gcc202:~/jdk-hg$ hg diff
> diff -r 274a0bcce99d src/hotspot/cpu/sparc/macroAssembler_sparc.hpp
> --- a/src/hotspot/cpu/sparc/macroAssembler_sparc.hpp Sat Feb 15 17:35:57 2020 +0800
> +++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.hpp Sat Feb 15 21:05:10 2020 +0300
> @@ -485,12 +485,12 @@
>
> void print(outputStream* s);
>
> - static int i_offset(int j) { return offset_of(RegistersForDebugging, i[j]); }
> - static int l_offset(int j) { return offset_of(RegistersForDebugging, l[j]); }
> - static int o_offset(int j) { return offset_of(RegistersForDebugging, o[j]); }
> - static int g_offset(int j) { return offset_of(RegistersForDebugging, g[j]); }
> - static int f_offset(int j) { return offset_of(RegistersForDebugging, f[j]); }
> - static int d_offset(int j) { return offset_of(RegistersForDebugging, d[j / 2]); }
> + static int i_offset(int j) { return offset_of(RegistersForDebugging, i) + j * sizeof(((RegistersForDebugging*)16)->i[0]); }
> + static int l_offset(int j) { return offset_of(RegistersForDebugging, l) + j * sizeof(((RegistersForDebugging*)16)->l[0]); }
> + static int o_offset(int j) { return offset_of(RegistersForDebugging, o) + j * sizeof(((RegistersForDebugging*)16)->o[0]); }
> + static int g_offset(int j) { return offset_of(RegistersForDebugging, g) + j * sizeof(((RegistersForDebugging*)16)->g[0]); }
> + static int f_offset(int j) { return offset_of(RegistersForDebugging, f) + j * sizeof(((RegistersForDebugging*)16)->f[0]); }
> + static int d_offset(int j) { return offset_of(RegistersForDebugging, d) + (j / 2) * sizeof(((RegistersForDebugging*)16)->d[0]); }
>
> // gen asm code to save regs
> static void save_registers(MacroAssembler* a);
>
> What about this approach?
>
> Alternatively, with C++11, this should work as well:
>
> #include <utility>
>
> static int i_offset(int j) { return offset_of(RegistersForDebugging, i) + j * sizeof(std::declval<RegistersForDebugging>().i[0]); }
>
> Comments?
I prefer the approach using a non-ODR-used dummy to the approach of
casting of some random number to an address. Non-ODR-used
declarations are well supported by the standard (C++03 3.2) and widely
used; that's the basis for the "sizeof trick" metaprogramming idiom,
for example. Using std::declval is morally equivalent, but we haven't
turned on C++11 yet.
More information about the build-dev
mailing list