From e87cd1788abad95b759fc139f30a56c31ed21b27 Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Tue, 21 Apr 2020 13:59:10 +0000 Subject: [PATCH] Revert "[snapshot] Extract more files" This reverts commit 5c4b80566f9bc42b00621becae115def3a0f2d6b. Reason for revert: https://ci.chromium.org/p/v8/builders/ci/V8%20Clusterfuzz%20Linux%20MSAN%20no%20origins/14661 Original change's description: > [snapshot] Extract more files > > This moves: > > - ExternalReferenceEncoder to codegen/external-reference-encoder.h > - SerializerDeserializer to snapshot/serializer-deserializer.h > - Checksum() to snapshot/snapshot-utils.h > > serializer-common.h and .cc are removed. > > Tbr: clemensb@chromium.org,ulan@chromium.org > Bug: v8:10416 > Change-Id: I36a242dcc1ad8833374aa567f73e0d4a75632c58 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2144118 > Commit-Queue: Jakob Gruber > Reviewed-by: Jakob Gruber > Reviewed-by: Ulan Degenbaev > Reviewed-by: Clemens Backes > Reviewed-by: Dan Elphick > Cr-Commit-Position: refs/heads/master@{#67281} TBR=ulan@chromium.org,jgruber@chromium.org,clemensb@chromium.org,delphick@chromium.org Change-Id: I718ca43a31d3ca937d700eab9bacc163e4598283 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:10416 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2157383 Reviewed-by: Sathya Gunasekaran Commit-Queue: Sathya Gunasekaran Cr-Commit-Position: refs/heads/master@{#67282} --- BUILD.gn | 8 +- src/codegen/assembler.cc | 1 + src/codegen/external-reference-encoder.h | 60 -------- src/codegen/reloc-info.cc | 2 +- src/codegen/turbo-assembler.cc | 2 +- src/diagnostics/disassembler.cc | 2 +- src/execution/isolate.cc | 1 - src/heap/heap.cc | 2 +- src/snapshot/DEPS | 2 +- src/snapshot/code-serializer.cc | 1 - src/snapshot/deserializer-allocator.h | 2 +- src/snapshot/deserializer.h | 2 +- src/snapshot/serializer-allocator.h | 2 +- .../serializer-common.cc} | 71 +++++++++- ...zer-deserializer.h => serializer-common.h} | 128 ++++++++++++------ src/snapshot/serializer-deserializer.cc | 61 --------- src/snapshot/serializer.h | 3 +- src/snapshot/snapshot-compression.cc | 2 - src/snapshot/snapshot-compression.h | 4 +- src/snapshot/snapshot-source-sink.h | 2 +- src/snapshot/snapshot-utils.cc | 24 ---- src/snapshot/snapshot-utils.h | 18 --- src/snapshot/snapshot.cc | 1 - src/wasm/wasm-serialization.cc | 1 + 24 files changed, 170 insertions(+), 232 deletions(-) delete mode 100644 src/codegen/external-reference-encoder.h rename src/{codegen/external-reference-encoder.cc => snapshot/serializer-common.cc} (55%) rename src/snapshot/{serializer-deserializer.h => serializer-common.h} (77%) delete mode 100644 src/snapshot/serializer-deserializer.cc delete mode 100644 src/snapshot/snapshot-utils.cc delete mode 100644 src/snapshot/snapshot-utils.h diff --git a/BUILD.gn b/BUILD.gn index ee069b7e1f..21e4bb7b13 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -2189,8 +2189,6 @@ v8_source_set("v8_base_without_compiler") { "src/codegen/constant-pool.h", "src/codegen/constants-arch.h", "src/codegen/cpu-features.h", - "src/codegen/external-reference-encoder.cc", - "src/codegen/external-reference-encoder.h", "src/codegen/external-reference-table.cc", "src/codegen/external-reference-table.h", "src/codegen/external-reference.cc", @@ -2958,8 +2956,8 @@ v8_source_set("v8_base_without_compiler") { "src/snapshot/roots-serializer.h", "src/snapshot/serializer-allocator.cc", "src/snapshot/serializer-allocator.h", - "src/snapshot/serializer-deserializer.cc", - "src/snapshot/serializer-deserializer.h", + "src/snapshot/serializer-common.cc", + "src/snapshot/serializer-common.h", "src/snapshot/serializer.cc", "src/snapshot/serializer.h", "src/snapshot/snapshot-compression.cc", @@ -2968,8 +2966,6 @@ v8_source_set("v8_base_without_compiler") { "src/snapshot/snapshot-data.h", "src/snapshot/snapshot-source-sink.cc", "src/snapshot/snapshot-source-sink.h", - "src/snapshot/snapshot-utils.cc", - "src/snapshot/snapshot-utils.h", "src/snapshot/snapshot.cc", "src/snapshot/snapshot.h", "src/snapshot/startup-deserializer.cc", diff --git a/src/codegen/assembler.cc b/src/codegen/assembler.cc index 3b27bf5db9..4bda1260a9 100644 --- a/src/codegen/assembler.cc +++ b/src/codegen/assembler.cc @@ -41,6 +41,7 @@ #include "src/execution/isolate.h" #include "src/heap/heap-inl.h" // For MemoryAllocator. TODO(jkummerow): Drop. #include "src/snapshot/embedded/embedded-data.h" +#include "src/snapshot/serializer-common.h" #include "src/snapshot/snapshot.h" #include "src/utils/ostreams.h" #include "src/utils/vector.h" diff --git a/src/codegen/external-reference-encoder.h b/src/codegen/external-reference-encoder.h deleted file mode 100644 index 7c41206f07..0000000000 --- a/src/codegen/external-reference-encoder.h +++ /dev/null @@ -1,60 +0,0 @@ -// 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. - -#ifndef V8_CODEGEN_EXTERNAL_REFERENCE_ENCODER_H_ -#define V8_CODEGEN_EXTERNAL_REFERENCE_ENCODER_H_ - -#include "src/base/bit-field.h" -#include "src/common/globals.h" -#include "src/utils/address-map.h" - -namespace v8 { -namespace internal { - -class Isolate; - -class ExternalReferenceEncoder { - public: - class Value { - public: - explicit Value(uint32_t raw) : value_(raw) {} - Value() : value_(0) {} - static uint32_t Encode(uint32_t index, bool is_from_api) { - return Index::encode(index) | IsFromAPI::encode(is_from_api); - } - - bool is_from_api() const { return IsFromAPI::decode(value_); } - uint32_t index() const { return Index::decode(value_); } - - private: - using Index = base::BitField; - using IsFromAPI = base::BitField; - uint32_t value_; - }; - - explicit ExternalReferenceEncoder(Isolate* isolate); -#ifdef DEBUG - ~ExternalReferenceEncoder(); -#endif // DEBUG - - Value Encode(Address key); - Maybe TryEncode(Address key); - - const char* NameOfAddress(Isolate* isolate, Address address) const; - - private: - AddressToIndexHashMap* map_; - -#ifdef DEBUG - std::vector count_; - const intptr_t* api_references_; -#endif // DEBUG - - DISALLOW_COPY_AND_ASSIGN(ExternalReferenceEncoder); -}; - -} // namespace internal -} // namespace v8 - -#endif // V8_CODEGEN_EXTERNAL_REFERENCE_ENCODER_H_ diff --git a/src/codegen/reloc-info.cc b/src/codegen/reloc-info.cc index 2e62c6f1f1..336be4e07b 100644 --- a/src/codegen/reloc-info.cc +++ b/src/codegen/reloc-info.cc @@ -6,12 +6,12 @@ #include "src/codegen/assembler-inl.h" #include "src/codegen/code-reference.h" -#include "src/codegen/external-reference-encoder.h" #include "src/deoptimizer/deoptimize-reason.h" #include "src/deoptimizer/deoptimizer.h" #include "src/heap/heap-write-barrier-inl.h" #include "src/objects/code-inl.h" #include "src/snapshot/embedded/embedded-data.h" +#include "src/snapshot/serializer-common.h" // For ExternalReferenceEncoder. namespace v8 { namespace internal { diff --git a/src/codegen/turbo-assembler.cc b/src/codegen/turbo-assembler.cc index 575529e399..f46ab0ade5 100644 --- a/src/codegen/turbo-assembler.cc +++ b/src/codegen/turbo-assembler.cc @@ -6,9 +6,9 @@ #include "src/builtins/builtins.h" #include "src/builtins/constants-table-builder.h" -#include "src/codegen/external-reference-encoder.h" #include "src/execution/isolate-data.h" #include "src/execution/isolate-inl.h" +#include "src/snapshot/serializer-common.h" namespace v8 { namespace internal { diff --git a/src/diagnostics/disassembler.cc b/src/diagnostics/disassembler.cc index 1bbdb558f1..5f977c36be 100644 --- a/src/diagnostics/disassembler.cc +++ b/src/diagnostics/disassembler.cc @@ -12,7 +12,6 @@ #include "src/codegen/assembler-inl.h" #include "src/codegen/code-comments.h" #include "src/codegen/code-reference.h" -#include "src/codegen/external-reference-encoder.h" #include "src/codegen/macro-assembler.h" #include "src/debug/debug.h" #include "src/deoptimizer/deoptimizer.h" @@ -21,6 +20,7 @@ #include "src/ic/ic.h" #include "src/objects/objects-inl.h" #include "src/snapshot/embedded/embedded-data.h" +#include "src/snapshot/serializer-common.h" #include "src/strings/string-stream.h" #include "src/utils/vector.h" #include "src/wasm/wasm-code-manager.h" diff --git a/src/execution/isolate.cc b/src/execution/isolate.cc index 45eb68311e..5b7ea2607f 100644 --- a/src/execution/isolate.cc +++ b/src/execution/isolate.cc @@ -80,7 +80,6 @@ #include "src/tasks/cancelable-task.h" #include "src/tracing/tracing-category-observer.h" #include "src/trap-handler/trap-handler.h" -#include "src/utils/address-map.h" #include "src/utils/ostreams.h" #include "src/utils/version.h" #include "src/wasm/wasm-code-manager.h" diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 006cfed8ba..db819953c1 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -71,7 +71,7 @@ #include "src/objects/slots-inl.h" #include "src/regexp/regexp.h" #include "src/snapshot/embedded/embedded-data.h" -#include "src/snapshot/serializer-deserializer.h" +#include "src/snapshot/serializer-common.h" #include "src/snapshot/snapshot.h" #include "src/strings/string-stream.h" #include "src/strings/unicode-decoder.h" diff --git a/src/snapshot/DEPS b/src/snapshot/DEPS index 6f92db18d4..93f17c9286 100644 --- a/src/snapshot/DEPS +++ b/src/snapshot/DEPS @@ -5,7 +5,7 @@ specific_include_rules = { "snapshot-compression.cc": [ "+third_party/zlib", ], - "snapshot-utils.cc": [ + "serializer-common.cc": [ "+third_party/zlib", ], } diff --git a/src/snapshot/code-serializer.cc b/src/snapshot/code-serializer.cc index bb6c58504c..d155313872 100644 --- a/src/snapshot/code-serializer.cc +++ b/src/snapshot/code-serializer.cc @@ -13,7 +13,6 @@ #include "src/objects/slots.h" #include "src/objects/visitors.h" #include "src/snapshot/object-deserializer.h" -#include "src/snapshot/snapshot-utils.h" #include "src/snapshot/snapshot.h" #include "src/utils/version.h" diff --git a/src/snapshot/deserializer-allocator.h b/src/snapshot/deserializer-allocator.h index 979e6ed2a8..b5140377b9 100644 --- a/src/snapshot/deserializer-allocator.h +++ b/src/snapshot/deserializer-allocator.h @@ -8,7 +8,7 @@ #include "src/common/globals.h" #include "src/heap/heap.h" #include "src/objects/heap-object.h" -#include "src/snapshot/references.h" +#include "src/snapshot/serializer-common.h" #include "src/snapshot/snapshot-data.h" namespace v8 { diff --git a/src/snapshot/deserializer.h b/src/snapshot/deserializer.h index 87d6adf477..c09c589633 100644 --- a/src/snapshot/deserializer.h +++ b/src/snapshot/deserializer.h @@ -16,7 +16,7 @@ #include "src/objects/map.h" #include "src/objects/string.h" #include "src/snapshot/deserializer-allocator.h" -#include "src/snapshot/serializer-deserializer.h" +#include "src/snapshot/serializer-common.h" #include "src/snapshot/snapshot-source-sink.h" namespace v8 { diff --git a/src/snapshot/serializer-allocator.h b/src/snapshot/serializer-allocator.h index 51264961cd..73dc8e6ed9 100644 --- a/src/snapshot/serializer-allocator.h +++ b/src/snapshot/serializer-allocator.h @@ -5,7 +5,7 @@ #ifndef V8_SNAPSHOT_SERIALIZER_ALLOCATOR_H_ #define V8_SNAPSHOT_SERIALIZER_ALLOCATOR_H_ -#include "src/snapshot/references.h" +#include "src/snapshot/serializer-common.h" #include "src/snapshot/snapshot-data.h" namespace v8 { diff --git a/src/codegen/external-reference-encoder.cc b/src/snapshot/serializer-common.cc similarity index 55% rename from src/codegen/external-reference-encoder.cc rename to src/snapshot/serializer-common.cc index 0dfe3e976a..fa2dc6ab25 100644 --- a/src/codegen/external-reference-encoder.cc +++ b/src/snapshot/serializer-common.cc @@ -1,11 +1,14 @@ -// Copyright 2020 the V8 project authors. All rights reserved. +// Copyright 2016 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/codegen/external-reference-encoder.h" +#include "src/snapshot/serializer-common.h" #include "src/codegen/external-reference-table.h" -#include "src/execution/isolate.h" +#include "src/objects/foreign-inl.h" +#include "src/objects/objects-inl.h" +#include "src/objects/slots.h" +#include "third_party/zlib/zlib.h" namespace v8 { namespace internal { @@ -42,8 +45,8 @@ ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) { } } -#ifdef DEBUG ExternalReferenceEncoder::~ExternalReferenceEncoder() { +#ifdef DEBUG if (!i::FLAG_external_reference_stats) return; if (api_references_ == nullptr) return; for (uint32_t i = 0; api_references_[i] != 0; ++i) { @@ -53,8 +56,8 @@ ExternalReferenceEncoder::~ExternalReferenceEncoder() { "index=%5d count=%5d %-60s\n", i, count_[i], ExternalReferenceTable::ResolveSymbol(reinterpret_cast(addr))); } -} #endif // DEBUG +} Maybe ExternalReferenceEncoder::TryEncode( Address address) { @@ -93,5 +96,63 @@ const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate, return isolate->external_reference_table()->name(value.index()); } +// The partial snapshot cache is terminated by undefined. We visit the +// partial snapshot... +// - during deserialization to populate it. +// - during normal GC to keep its content alive. +// - not during serialization. The partial serializer adds to it explicitly. +DISABLE_CFI_PERF +void SerializerDeserializer::Iterate(Isolate* isolate, RootVisitor* visitor) { + std::vector* cache = isolate->partial_snapshot_cache(); + for (size_t i = 0;; ++i) { + // Extend the array ready to get a value when deserializing. + if (cache->size() <= i) cache->push_back(Smi::zero()); + // During deserialization, the visitor populates the partial snapshot cache + // and eventually terminates the cache with undefined. + visitor->VisitRootPointer(Root::kPartialSnapshotCache, nullptr, + FullObjectSlot(&cache->at(i))); + if (cache->at(i).IsUndefined(isolate)) break; + } +} + +bool SerializerDeserializer::CanBeDeferred(HeapObject o) { + // ArrayBuffer instances are serialized by first re-assigning a index + // to the backing store field, then serializing the object, and then + // storing the actual backing store address again (and the same for the + // ArrayBufferExtension). If serialization of the object itself is deferred, + // the real backing store address is written into the snapshot, which cannot + // be processed when deserializing. + return !o.IsString() && !o.IsScript() && !o.IsJSTypedArray() && + !o.IsJSArrayBuffer(); +} + +void SerializerDeserializer::RestoreExternalReferenceRedirectors( + const std::vector& accessor_infos) { + // Restore wiped accessor infos. + for (AccessorInfo info : accessor_infos) { + Foreign::cast(info.js_getter()) + .set_foreign_address(info.redirected_getter()); + } +} + +void SerializerDeserializer::RestoreExternalReferenceRedirectors( + const std::vector& call_handler_infos) { + for (CallHandlerInfo info : call_handler_infos) { + Foreign::cast(info.js_callback()) + .set_foreign_address(info.redirected_callback()); + } +} + +uint32_t Checksum(Vector 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, NULL, 0); + return static_cast(adler32(0, payload.begin(), payload.length())); +} + } // namespace internal } // namespace v8 diff --git a/src/snapshot/serializer-deserializer.h b/src/snapshot/serializer-common.h similarity index 77% rename from src/snapshot/serializer-deserializer.h rename to src/snapshot/serializer-common.h index d639a271ff..3a678263a4 100644 --- a/src/snapshot/serializer-deserializer.h +++ b/src/snapshot/serializer-common.h @@ -1,12 +1,18 @@ -// Copyright 2020 the V8 project authors. All rights reserved. +// Copyright 2016 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. -#ifndef V8_SNAPSHOT_SERIALIZER_DESERIALIZER_H_ -#define V8_SNAPSHOT_SERIALIZER_DESERIALIZER_H_ +#ifndef V8_SNAPSHOT_SERIALIZER_COMMON_H_ +#define V8_SNAPSHOT_SERIALIZER_COMMON_H_ +#include "src/base/bits.h" +#include "src/base/memory.h" +#include "src/codegen/external-reference-table.h" +#include "src/common/globals.h" #include "src/objects/visitors.h" +#include "src/sanitizer/msan.h" #include "src/snapshot/references.h" +#include "src/utils/address-map.h" namespace v8 { namespace internal { @@ -14,6 +20,81 @@ namespace internal { class CallHandlerInfo; class Isolate; +class ExternalReferenceEncoder { + public: + class Value { + public: + explicit Value(uint32_t raw) : value_(raw) {} + Value() : value_(0) {} + static uint32_t Encode(uint32_t index, bool is_from_api) { + return Index::encode(index) | IsFromAPI::encode(is_from_api); + } + + bool is_from_api() const { return IsFromAPI::decode(value_); } + uint32_t index() const { return Index::decode(value_); } + + private: + using Index = base::BitField; + using IsFromAPI = base::BitField; + uint32_t value_; + }; + + explicit ExternalReferenceEncoder(Isolate* isolate); + ~ExternalReferenceEncoder(); // NOLINT (modernize-use-equals-default) + + Value Encode(Address key); + Maybe TryEncode(Address key); + + const char* NameOfAddress(Isolate* isolate, Address address) const; + + private: + AddressToIndexHashMap* map_; + +#ifdef DEBUG + std::vector count_; + const intptr_t* api_references_; +#endif // DEBUG + + DISALLOW_COPY_AND_ASSIGN(ExternalReferenceEncoder); +}; + +class HotObjectsList { + public: + HotObjectsList() : index_(0) {} + + void Add(HeapObject object) { + DCHECK(!AllowHeapAllocation::IsAllowed()); + circular_queue_[index_] = object; + index_ = (index_ + 1) & kSizeMask; + } + + HeapObject Get(int index) { + DCHECK(!AllowHeapAllocation::IsAllowed()); + DCHECK(!circular_queue_[index].is_null()); + return circular_queue_[index]; + } + + static const int kNotFound = -1; + + int Find(HeapObject object) { + DCHECK(!AllowHeapAllocation::IsAllowed()); + for (int i = 0; i < kSize; i++) { + if (circular_queue_[i] == object) return i; + } + return kNotFound; + } + + static const int kSize = 8; + + private: + static_assert(base::bits::IsPowerOfTwo(kSize), "kSize must be power of two"); + static const int kSizeMask = kSize - 1; + HeapObject circular_queue_[kSize]; + int index_; + + DISALLOW_COPY_AND_ASSIGN(HotObjectsList); +}; + // The Serializer/Deserializer class is a common superclass for Serializer and // Deserializer which is used to store common constants and methods used by // both. @@ -22,43 +103,6 @@ class SerializerDeserializer : public RootVisitor { static void Iterate(Isolate* isolate, RootVisitor* visitor); protected: - class HotObjectsList { - public: - HotObjectsList() = default; - - void Add(HeapObject object) { - DCHECK(!AllowHeapAllocation::IsAllowed()); - circular_queue_[index_] = object; - index_ = (index_ + 1) & kSizeMask; - } - - HeapObject Get(int index) { - DCHECK(!AllowHeapAllocation::IsAllowed()); - DCHECK(!circular_queue_[index].is_null()); - return circular_queue_[index]; - } - - static const int kNotFound = -1; - - int Find(HeapObject object) { - DCHECK(!AllowHeapAllocation::IsAllowed()); - for (int i = 0; i < kSize; i++) { - if (circular_queue_[i] == object) return i; - } - return kNotFound; - } - - static const int kSize = 8; - - private: - STATIC_ASSERT(base::bits::IsPowerOfTwo(kSize)); - static const int kSizeMask = kSize - 1; - HeapObject circular_queue_[kSize]; - int index_ = 0; - - DISALLOW_COPY_AND_ASSIGN(HotObjectsList); - }; - static bool CanBeDeferred(HeapObject o); void RestoreExternalReferenceRedirectors( @@ -249,7 +293,9 @@ class SerializerDeserializer : public RootVisitor { HotObjectsList hot_objects_; }; +V8_EXPORT_PRIVATE uint32_t Checksum(Vector payload); + } // namespace internal } // namespace v8 -#endif // V8_SNAPSHOT_SERIALIZER_DESERIALIZER_H_ +#endif // V8_SNAPSHOT_SERIALIZER_COMMON_H_ diff --git a/src/snapshot/serializer-deserializer.cc b/src/snapshot/serializer-deserializer.cc deleted file mode 100644 index 7e032da7ea..0000000000 --- a/src/snapshot/serializer-deserializer.cc +++ /dev/null @@ -1,61 +0,0 @@ -// 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/serializer-deserializer.h" - -#include "src/objects/foreign-inl.h" -#include "src/objects/objects-inl.h" - -namespace v8 { -namespace internal { - -// The partial snapshot cache is terminated by undefined. We visit the -// partial snapshot... -// - during deserialization to populate it. -// - during normal GC to keep its content alive. -// - not during serialization. The partial serializer adds to it explicitly. -DISABLE_CFI_PERF -void SerializerDeserializer::Iterate(Isolate* isolate, RootVisitor* visitor) { - std::vector* cache = isolate->partial_snapshot_cache(); - for (size_t i = 0;; ++i) { - // Extend the array ready to get a value when deserializing. - if (cache->size() <= i) cache->push_back(Smi::zero()); - // During deserialization, the visitor populates the partial snapshot cache - // and eventually terminates the cache with undefined. - visitor->VisitRootPointer(Root::kPartialSnapshotCache, nullptr, - FullObjectSlot(&cache->at(i))); - if (cache->at(i).IsUndefined(isolate)) break; - } -} - -bool SerializerDeserializer::CanBeDeferred(HeapObject o) { - // ArrayBuffer instances are serialized by first re-assigning a index - // to the backing store field, then serializing the object, and then - // storing the actual backing store address again (and the same for the - // ArrayBufferExtension). If serialization of the object itself is deferred, - // the real backing store address is written into the snapshot, which cannot - // be processed when deserializing. - return !o.IsString() && !o.IsScript() && !o.IsJSTypedArray() && - !o.IsJSArrayBuffer(); -} - -void SerializerDeserializer::RestoreExternalReferenceRedirectors( - const std::vector& accessor_infos) { - // Restore wiped accessor infos. - for (AccessorInfo info : accessor_infos) { - Foreign::cast(info.js_getter()) - .set_foreign_address(info.redirected_getter()); - } -} - -void SerializerDeserializer::RestoreExternalReferenceRedirectors( - const std::vector& call_handler_infos) { - for (CallHandlerInfo info : call_handler_infos) { - Foreign::cast(info.js_callback()) - .set_foreign_address(info.redirected_callback()); - } -} - -} // namespace internal -} // namespace v8 diff --git a/src/snapshot/serializer.h b/src/snapshot/serializer.h index 07fd1576e9..b5e20e2cba 100644 --- a/src/snapshot/serializer.h +++ b/src/snapshot/serializer.h @@ -7,13 +7,12 @@ #include -#include "src/codegen/external-reference-encoder.h" #include "src/execution/isolate.h" #include "src/logging/log.h" #include "src/objects/objects.h" #include "src/snapshot/embedded/embedded-data.h" #include "src/snapshot/serializer-allocator.h" -#include "src/snapshot/serializer-deserializer.h" +#include "src/snapshot/serializer-common.h" #include "src/snapshot/snapshot-source-sink.h" namespace v8 { diff --git a/src/snapshot/snapshot-compression.cc b/src/snapshot/snapshot-compression.cc index 09ac2eecda..dea16bfa34 100644 --- a/src/snapshot/snapshot-compression.cc +++ b/src/snapshot/snapshot-compression.cc @@ -4,9 +4,7 @@ #include "src/snapshot/snapshot-compression.h" -#include "src/base/platform/elapsed-timer.h" #include "src/utils/memcopy.h" -#include "src/utils/utils.h" #include "third_party/zlib/google/compression_utils_portable.h" namespace v8 { diff --git a/src/snapshot/snapshot-compression.h b/src/snapshot/snapshot-compression.h index fe637bd1a6..59c21feb74 100644 --- a/src/snapshot/snapshot-compression.h +++ b/src/snapshot/snapshot-compression.h @@ -5,7 +5,9 @@ #ifndef V8_SNAPSHOT_SNAPSHOT_COMPRESSION_H_ #define V8_SNAPSHOT_SNAPSHOT_COMPRESSION_H_ -#include "src/snapshot/snapshot-data.h" +#include "src/snapshot/serializer-common.h" +#include "src/snapshot/serializer.h" +#include "src/snapshot/snapshot.h" #include "src/utils/vector.h" namespace v8 { diff --git a/src/snapshot/snapshot-source-sink.h b/src/snapshot/snapshot-source-sink.h index eb4427a75f..1ff3ed42f1 100644 --- a/src/snapshot/snapshot-source-sink.h +++ b/src/snapshot/snapshot-source-sink.h @@ -8,7 +8,7 @@ #include #include "src/base/logging.h" -#include "src/snapshot/snapshot-utils.h" +#include "src/snapshot/serializer-common.h" #include "src/utils/utils.h" namespace v8 { diff --git a/src/snapshot/snapshot-utils.cc b/src/snapshot/snapshot-utils.cc deleted file mode 100644 index d489dcbac4..0000000000 --- a/src/snapshot/snapshot-utils.cc +++ /dev/null @@ -1,24 +0,0 @@ -// 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 "third_party/zlib/zlib.h" - -namespace v8 { -namespace internal { - -uint32_t Checksum(Vector 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, NULL, 0); - return static_cast(adler32(0, payload.begin(), payload.length())); -} - -} // namespace internal -} // namespace v8 diff --git a/src/snapshot/snapshot-utils.h b/src/snapshot/snapshot-utils.h deleted file mode 100644 index 045813b139..0000000000 --- a/src/snapshot/snapshot-utils.h +++ /dev/null @@ -1,18 +0,0 @@ -// 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. - -#ifndef V8_SNAPSHOT_SNAPSHOT_UTILS_H_ -#define V8_SNAPSHOT_SNAPSHOT_UTILS_H_ - -#include "src/utils/vector.h" - -namespace v8 { -namespace internal { - -V8_EXPORT_PRIVATE uint32_t Checksum(Vector payload); - -} // namespace internal -} // namespace v8 - -#endif // V8_SNAPSHOT_SNAPSHOT_UTILS_H_ diff --git a/src/snapshot/snapshot.cc b/src/snapshot/snapshot.cc index bb8e28773a..7c92b7a1b4 100644 --- a/src/snapshot/snapshot.cc +++ b/src/snapshot/snapshot.cc @@ -10,7 +10,6 @@ #include "src/logging/counters.h" #include "src/snapshot/partial-deserializer.h" #include "src/snapshot/read-only-deserializer.h" -#include "src/snapshot/snapshot-utils.h" #include "src/snapshot/startup-deserializer.h" #include "src/utils/memcopy.h" #include "src/utils/version.h" diff --git a/src/wasm/wasm-serialization.cc b/src/wasm/wasm-serialization.cc index b9ddd221a1..323e04251e 100644 --- a/src/wasm/wasm-serialization.cc +++ b/src/wasm/wasm-serialization.cc @@ -10,6 +10,7 @@ #include "src/objects/objects.h" #include "src/runtime/runtime.h" #include "src/snapshot/code-serializer.h" +#include "src/snapshot/serializer-common.h" #include "src/utils/ostreams.h" #include "src/utils/utils.h" #include "src/utils/version.h"