mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibCrypto: Start sometimes hardware-accelerating crc32
Takes % time Build/lagom/gunzip -c \ /Users/thakis/Downloads/trace_bug.json.gz > /dev/null from 4s to 3.9s on my MBP.
This commit is contained in:
parent
ee6843a13c
commit
0452a8ed4b
Notes:
sideshowbarker
2024-07-17 04:34:25 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/0452a8ed4b Pull-request: https://github.com/SerenityOS/serenity/pull/18041
1 changed files with 18 additions and 0 deletions
|
@ -11,6 +11,22 @@
|
|||
|
||||
namespace Crypto::Checksum {
|
||||
|
||||
#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
|
||||
|
||||
void CRC32::update(ReadonlyBytes data)
|
||||
{
|
||||
// FIXME: Does this require runtime checking on rpi?
|
||||
// (Maybe the instruction is present on the rpi4 but not on the rpi3?)
|
||||
|
||||
// FIXME: Use __builtin_arm_crc32d() for aligned middle part.
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
m_state = __builtin_arm_crc32b(m_state, data.at(i));
|
||||
};
|
||||
|
||||
// FIXME: On Intel, use _mm_crc32_u8 / _mm_crc32_u64 if available (SSE 4.2).
|
||||
|
||||
#else
|
||||
|
||||
static constexpr auto generate_table()
|
||||
{
|
||||
Array<u32, 256> data {};
|
||||
|
@ -39,6 +55,8 @@ void CRC32::update(ReadonlyBytes data)
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
u32 CRC32::digest()
|
||||
{
|
||||
return ~m_state;
|
||||
|
|
Loading…
Reference in a new issue