v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
snapshot-utils.cc
Go to the documentation of this file.
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
8
9#ifdef V8_USE_ZLIB
10#include "third_party/zlib/zlib.h"
11#endif
12
13namespace v8 {
14namespace internal {
15
17#ifdef MEMORY_SANITIZER
18 // Computing the checksum includes padding bytes for objects like strings.
19 // Mark every object as initialized in the code serializer.
20 MSAN_MEMORY_IS_INITIALIZED(payload.begin(), payload.length());
21#endif // MEMORY_SANITIZER
22
23#ifdef V8_USE_ZLIB
24 // Priming the adler32 call so it can see what CPU features are available.
25 adler32(0, nullptr, 0);
26 return static_cast<uint32_t>(adler32(0, payload.begin(), payload.length()));
27#else
28 // Simple Fletcher-32.
29 uint32_t sum1 = 0, sum2 = 0;
30 for (auto data : payload) {
31 sum1 = (sum1 + data) % 65535;
32 sum2 = (sum2 + sum1) % 65535;
33 }
34 return (sum2 << 16 | sum1);
35#endif
36}
37
38} // namespace internal
39} // namespace v8
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
int length() const
Definition vector.h:64
constexpr T * begin() const
Definition vector.h:96
#define MSAN_MEMORY_IS_INITIALIZED(start, size)
Definition msan.h:37
uint32_t Checksum(base::Vector< const uint8_t > payload)