blob: df53dfe751e6be4e96aef452571532b1f2f7a09f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/snapshot/snapshot-utils.h"
#include "src/base/sanitizer/msan.h"
#include "third_party/zlib/zlib.h"
namespace v8 {
namespace internal {
uint32_t Checksum(Vector<const byte> payload) {
#ifdef MEMORY_SANITIZER
// Computing the checksum includes padding bytes for objects like strings.
// Mark every object as initialized in the code serializer.
MSAN_MEMORY_IS_INITIALIZED(payload.begin(), payload.length());
#endif // MEMORY_SANITIZER
// Priming the adler32 call so it can see what CPU features are available.
adler32(0, nullptr, 0);
return static_cast<uint32_t>(adler32(0, payload.begin(), payload.length()));
}
} // namespace internal
} // namespace v8
|