On 2014/02/18 21:14:25, jochen wrote:
On 2014/02/18 18:26:05, Rodolph Perfetta (ARM) wrote:
> It is not safe, and I am surprised at the speedup, the compiler should be
able
> to generate very similar code with the memcpy version. At least C compilers
do.
> Have you tried replacing the mempcy by __builtin_memcpy, it may give a hint
to
> the compiler.

Can you explain why this is not safe?

Using reinterpret_cast violates type aliasing rules. In C(++), if you write to an object of type X, then read it as type Y, the results are undefined. Usually, things work anyway, but sometimes (with new compiler optimisations) things stop working. That doesn't mean that you can't use reinterpret_cast, because it is
possible to use it safely, but I don't think it's possible here.

For simple, fixed-sized casts, the compiler will optimise away the memcpy and
the conversion will be free.

I doubt that the compiler can optimize the memcpy calls away. We profiled a
release build of d8, and more than 10% of the total runtime are spend in
memcpy.

Neither of these memcpy calls are simple, so the compiler probably can't
optimise them away.

> another idea in debug would be to compile the simulator itself in release
mode:
> there are a fair amount of asserts in the decoder and skipping those should
> help.

We could do that as an additional build variant, but I'm wary of disabling the assertions for a full debug build. I'm aware that the A64 port has a lot more assertions than the ARM port (and probably the others too) so we might be able
to make some compromise, perhaps with another build variant that disables
known-slow assertions at build time.

The numbers Ulan gave are on a release build.

> On 2014/02/18 17:35:18, ulan wrote:
> > PTAL. Is this safe to replace memcpy? This speeds up the simulator by
~20%:
> >
> > Richards: 51.5 (before)
> > Richards: 63.9 (after)



https://codereview.chromium.org/169223004/

--
--
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/groups/opt_out.

Reply via email to