v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
shared-heap-deserializer.cc
Go to the documentation of this file.
1// Copyright 2021 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
7#include "src/heap/heap-inl.h"
8
9namespace v8 {
10namespace internal {
11
13 // Don't deserialize into isolates that don't own their string table. If there
14 // are client Isolates, the shared heap object cache should already be
15 // populated.
16 // TODO(372493838): The shared heap object cache can only contain strings.
17 // Update name to reflect this.
18 if (!isolate()->OwnsStringTables()) {
19 DCHECK(!isolate()->shared_heap_object_cache()->empty());
20 return;
21 }
22
23 DCHECK(isolate()->shared_heap_object_cache()->empty());
24 HandleScope scope(isolate());
25
29
30 if (should_rehash()) {
31 // The hash seed has already been initialized in ReadOnlyDeserializer, thus
32 // there is no need to call `isolate()->heap()->InitializeHashSeed();`.
33 Rehash();
34 }
35}
36
38 // See SharedHeapSerializer::SerializeStringTable.
39
40 DCHECK(isolate()->OwnsStringTables());
41
42 // Get the string table size.
43 const int length = source()->GetUint30();
44
45 // .. and the contents.
47 strings.reserve(length);
48 for (int i = 0; i < length; ++i) {
49 strings.emplace_back(Cast<String>(ReadObject()));
50 }
51
53 DCHECK_EQ(t->NumberOfElements(), 0);
54 t->InsertForIsolateDeserialization(
55 isolate(), base::VectorOf(strings.data(), strings.size()));
56 DCHECK_EQ(t->NumberOfElements(), length);
57}
58
59} // namespace internal
60} // namespace v8
DirectHandle< HeapObject > ReadObject()
StringTable * string_table() const
Definition isolate.h:781
static void IterateSharedHeapObjectCache(Isolate *isolate, RootVisitor *visitor)
constexpr Vector< T > VectorOf(T *start, size_t size)
Definition vector.h:360
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_EQ(v1, v2)
Definition logging.h:485