On 13/03/14 13:01, Sven Panne wrote:
> On Thu, Mar 13, 2014 at 1:41 PM, Jacob Bramley <[email protected]
> <mailto:[email protected]>> wrote:
>
>     I have had to debug things caused by strict aliasing problems in the
>     past, and it wasn't easy to track down the cause. Nonetheless, the
>     problems are rare in practice, as you say.
>
>
> Same experience here, but why do you think it is safe for the ARM
> emulator and not for the A64 emulator?

The short answer is that I don't. This comes from VIXL, which was
developed independently from the V8 port, and only supports A64.

> If one is really, really scared
> about the aliasing rules, I think some casting via char* (which aliases
> everything) and/or some inline asm can do the trick, too.

Inline asm could certainly do the trick, though it would be a bit ugly
and a simple implementation would probably be slightly less efficient
than an optimised-away memcpy. You might be able to use a constraint
trick to do it for free, but it would be really ugly.

Casting through char* probably won't help; char* itself can alias
anything, but it can't pass that property on through a second cast.

> But if we do
> this, we should do this consistently on all simulators, and it will be
> ugly (because the underlying design is ugly).

Agreed.

>     Also, some of the memcpy uses in the CL are completely optimised away.
>     In those cases, there's no good reason to use a reinterpret_cast so they
>     should probably stay.
>
>
> For something as performance-sensitive as a simulator, I think some
> hacks are worth the trouble. The CL shaves away more than 1min of
> developer time per quickcheck run and more than half an hour on the bots.

Yep, fair enough, though I think we have more to investigate here
because Rodolph didn't see any benefit when he tried it.

>     > The *right* way of doing this is either throwing away the useless
>     > distinction
>     > between Instr and Instruction or make Instruction carry an Instr
>     as a member
>     > field, but this would probably be a bigger change. If somebody has
>     time
>     > left it
>     > can be done, but in the meantime let's speed up our daily work.
>
>
> Hmmm, no reply to the *real* fix...? ;-)

I just didn't have anything else to add; it's the right thing to do, but
it would take more time. We have some assumptions in places that
sizeof(Instruction) == 1, but we could work around that.

This design also probably doesn't work well with variable-width
instructions. That won't bother the existing simulator back-ends, but it
would affect Thumb(-2), for example.


-- IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered 
in England & Wales, Company No:  2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, 
Registered in England & Wales, Company No:  2548782

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to