[snapshot] Use adler32 to create the embedded blob checksum

The snapshot's Checksum function internally uses adler32, which
appears to be significantly faster than base::hash_range and almost as
fast as doing nothing at all.

Test times, measured with

$ time tools/run-tests.py --outdir out/release-with-dchecks/
--exit-after-n-failures=1 --quickcheck

base::hash_range: 1m35s
adler32: 1m15s
nop: 1m13s

Bug: chromium:1047818
Change-Id: I8def62f6276a3d06d06911abf5368f59331245ea
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2187492
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67649}
This commit is contained in:
Jakob Gruber 2020-05-07 13:44:28 +02:00 committed by Commit Bot
parent 13968f9e76
commit ec01074831

View File

@ -7,6 +7,7 @@
#include "src/codegen/assembler-inl.h"
#include "src/codegen/callable.h"
#include "src/objects/objects-inl.h"
#include "src/snapshot/snapshot-utils.h"
#include "src/snapshot/snapshot.h"
namespace v8 {
@ -306,7 +307,10 @@ Address EmbeddedData::InstructionEndOfBytecodeHandlers() const {
size_t EmbeddedData::CreateEmbeddedBlobHash() const {
STATIC_ASSERT(EmbeddedBlobHashOffset() == 0);
STATIC_ASSERT(EmbeddedBlobHashSize() == kSizetSize);
return base::hash_range(data_ + EmbeddedBlobHashSize(), data_ + size_);
// Hash the entire blob except the hash field itself.
Vector<const byte> payload(data_ + EmbeddedBlobHashSize(),
size_ - EmbeddedBlobHashSize());
return Checksum(payload);
}
void EmbeddedData::PrintStatistics() const {