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
5
#include "
src/snapshot/snapshot-utils.h
"
6
7
#include "
src/base/sanitizer/msan.h
"
8
9
#ifdef V8_USE_ZLIB
10
#include "third_party/zlib/zlib.h"
11
#endif
12
13
namespace
v8
{
14
namespace
internal
{
15
16
uint32_t
Checksum
(
base::Vector<const uint8_t>
payload) {
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
data
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
v8::base::Vector
Definition
zone-list.h:15
v8::base::Vector::length
int length() const
Definition
vector.h:64
v8::base::Vector::begin
constexpr T * begin() const
Definition
vector.h:96
msan.h
MSAN_MEMORY_IS_INITIALIZED
#define MSAN_MEMORY_IS_INITIALIZED(start, size)
Definition
msan.h:37
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8::internal::Checksum
uint32_t Checksum(base::Vector< const uint8_t > payload)
Definition
snapshot-utils.cc:16
v8
Definition
api-arguments-inl.h:19
snapshot-utils.h
src
snapshot
snapshot-utils.cc
Generated on Sun Apr 6 2025 21:08:57 for v8 by
1.12.0