Undefined behaviour in hotspot
Christian Thalinger
christian.thalinger at oracle.com
Mon Apr 28 19:19:01 UTC 2014
On Apr 26, 2014, at 11:03 PM, Andrew Haley <aph at redhat.com> wrote:
> On 04/25/2014 03:10 AM, Christian Thalinger wrote:
>>
>> On Apr 24, 2014, at 10:33 AM, Christian Thalinger <christian.thalinger at oracle.com> wrote:
>>
>>>
>>> On Apr 21, 2014, at 10:41 PM, Volker Simonis <volker.simonis at gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I think the simplest and safest fix would be to make encoding() (and
>>>> all the corresponding functions) static functions which take a
>>>> Register as argument like:
>>>>
>>>> static int encoding(const RegisterImpl* r) { assert(is_valid(r),
>>>> "invalid register"); return (intptr_t)r; }
>>>>
>>>> This wouldn't waste any more memory and it would be fully C++
>>>> compliant at the price of a slightly more verbose usage:
>>>>
>>>> 2577 void Assembler::push(Register src) {
>>>> 2578 int encode = prefix_and_encode(RegisterImpl::encoding(src));
>>>> 2579
>>>>
>>>> And of course this would work with any compiler.
>>>>
>>>> What do you think?
>>>
>>> I’d rather make Register a real C++ class with an _encoding field.
>>> There are not that many registers used or allocated that it would
>>> make a big difference in memory usage.
>
> I don't think this is a good idea. Some ABIs pass structs in memory,
> even structs with a single word field. You'd be be pessimizing such
> systems, for no good reason AFAICS.
There was actually a reason why someone (Tom) chose to change the Register classes:
https://bugs.openjdk.java.net/browse/JDK-4642581
>
> Andrew.
More information about the hotspot-dev
mailing list