Bug 188716

Summary: [WTF] Add WTF::unalignedLoad and WTF::unalignedStore
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: New BugsAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, Hironori.Fujii, mark.lam, saam, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch darin: review+

Yusuke Suzuki
Reported 2018-08-17 19:04:26 PDT
[WTF] Add WTF::unalignedLoad and WTF::unalignedStore
Attachments
Patch (10.39 KB, patch)
2018-08-17 19:10 PDT, Yusuke Suzuki
no flags
Patch (12.75 KB, patch)
2018-08-17 19:18 PDT, Yusuke Suzuki
no flags
Patch (17.97 KB, patch)
2018-08-19 01:21 PDT, Yusuke Suzuki
darin: review+
Yusuke Suzuki
Comment 1 2018-08-17 19:10:40 PDT
Yusuke Suzuki
Comment 2 2018-08-17 19:18:59 PDT
Yusuke Suzuki
Comment 3 2018-08-19 01:21:51 PDT
Darin Adler
Comment 4 2018-08-19 12:24:36 PDT
Comment on attachment 347455 [details] Patch How close does this put us to removing reinterpret_cast_ptr?
Yusuke Suzuki
Comment 5 2018-08-19 15:42:00 PDT
(In reply to Darin Adler from comment #4) > Comment on attachment 347455 [details] > Patch > > How close does this put us to removing reinterpret_cast_ptr? Nice catch. Currently, `reinterpret_cast_ptr<T>(ptr)` is used only when we ensure that the casted `ptr` has the expected alignment by `T`. It would be optimized way with CPUs without unaligned accesses support. But since the major CPUs like ARM64, X86, and X86_64 support unaligned accesses, always using `WTF::unalignedXXX` would be feasible. We should investigate each site of `reinterpret_cast_ptr` carefully to decide whether we can replace it with unalignedXXX helpers!
Yusuke Suzuki
Comment 6 2018-08-19 15:50:11 PDT
Fujii Hironori
Comment 7 2018-08-20 06:58:37 PDT
I'm surprised. There are so many unaligned access. I thought unaligned memory access is slow. See https://github.com/spotify/linux/blob/master/Documentation/unaligned-memory-access.txt Are they really unaligned memory access? Or, actually aligned?
Radar WebKit Bug Importer
Comment 8 2018-08-20 16:52:06 PDT
Yusuke Suzuki
Comment 9 2018-08-20 20:38:26 PDT
(In reply to Fujii Hironori from comment #7) > I'm surprised. There are so many unaligned access. > I thought unaligned memory access is slow. > See > https://github.com/spotify/linux/blob/master/Documentation/unaligned-memory- > access.txt > > Are they really unaligned memory access? Or, actually aligned? Unaligned accesses reported by UBSan. They are typically filling/extracting an value into/from X86 machine code stream.
Note You need to log in before you can comment on or make changes to this bug.