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/sanitizer/msan.h" 8 #include "third_party/zlib/zlib.h" 9 10 namespace v8 { 11 namespace internal { 12 Checksum(Vector<const byte> payload)13uint32_t Checksum(Vector<const byte> payload) { 14 #ifdef MEMORY_SANITIZER 15 // Computing the checksum includes padding bytes for objects like strings. 16 // Mark every object as initialized in the code serializer. 17 MSAN_MEMORY_IS_INITIALIZED(payload.begin(), payload.length()); 18 #endif // MEMORY_SANITIZER 19 // Priming the adler32 call so it can see what CPU features are available. 20 adler32(0, nullptr, 0); 21 return static_cast<uint32_t>(adler32(0, payload.begin(), payload.length())); 22 } 23 24 } // namespace internal 25 } // namespace v8 26