typed arrays: swizzle with compiler intrinsics
authorDean McNamee <dean@gmail.com>
Sat, 5 Jan 2013 21:06:35 +0000 (22:06 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Wed, 9 Jan 2013 16:44:25 +0000 (17:44 +0100)
commit46a489be73fd87fa3e17dd929c53d9e90860f80a
tree36b8a4ebcee36d9feef32f650b82600f74c1539e
parent7d66a9d06048601121220084f7f6d5672866d2ec
typed arrays: swizzle with compiler intrinsics

Implement swizzling with compiler intrinsics and be aware of the native
endianness to correctly swap on big endian machines.

This introduces a template function to swap the bytes of a value,
and macros for the low level swap (taking advantage of gcc and msvc
intrinsics). This produces code like the following (comments are mine):

gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

setValue<double>:
  movd  %xmm0, %rax         ; fp reg -> gen reg
  bswapq  %rax              ; 64-bit byte swap
  movd  %rax, %xmm0         ; gen reg -> fp reg
  movq  %xmm0, (%r15,%r12)  ; store
src/v8_typed_array.cc
src/v8_typed_array_bswap.h [new file with mode: 0644]