v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
startup-deserializer.cc
Go to the documentation of this file.
1// Copyright 2017 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/api/api.h"
13#include "src/logging/log.h"
14#include "src/objects/oddball.h"
15#include "src/roots/roots-inl.h"
16
17namespace v8 {
18namespace internal {
19
21 TRACE_EVENT0("v8", "V8.DeserializeIsolate");
22 RCS_SCOPE(isolate(), RuntimeCallCounterId::kDeserializeIsolate);
24 if (V8_UNLIKELY(v8_flags.profile_deserialization)) timer.Start();
25 NestedTimedHistogramScope histogram_timer(
26 isolate()->counters()->snapshot_deserialize_isolate());
27 HandleScope scope(isolate());
28
29 // No active threads.
30 DCHECK_NULL(isolate()->thread_manager()->FirstThreadStateInUse());
31 // No active handles.
32 DCHECK(isolate()->handle_scope_implementer()->blocks()->empty());
33 // Startup object cache is not yet populated.
34 DCHECK(isolate()->startup_object_cache()->empty());
35 // Builtins are not yet created.
36 DCHECK(!isolate()->builtins()->is_initialized());
37
38 {
40
41 isolate()->heap()->IterateSmiRoots(this);
43 this,
47
53 }
56 }
57
58 // Flush the instruction cache for the entire code-space. Must happen after
59 // builtins deserialization.
61 }
62
64 ReadOnlyRoots(isolate()).undefined_value());
65 // The allocation site list is build during root iteration, but if no sites
66 // were encountered then it needs to be initialized to undefined.
67 if (isolate()->heap()->allocation_sites_list() == Smi::zero()) {
69 ReadOnlyRoots(isolate()).undefined_value());
70 }
72 ReadOnlyRoots(isolate()).undefined_value());
74 ReadOnlyRoots(isolate()).undefined_value());
75
77
80
81 if (should_rehash()) {
82 // Hash seed was initialized in ReadOnlyDeserializer.
83 Rehash();
84 }
85
86 if (V8_UNLIKELY(v8_flags.profile_deserialization)) {
87 // ATTENTION: The Memory.json benchmark greps for this exact output. Do not
88 // change it without also updating Memory.json.
89 const int bytes = source()->length();
90 const double ms = timer.Elapsed().InMillisecondsF();
91 PrintF("[Deserializing isolate (%d bytes) took %0.3f ms]\n", bytes, ms);
92 }
93}
94
96 // Verify that any external reference entries that were deduplicated in the
97 // serializer are also deduplicated in this isolate.
99 while (true) {
100 uint32_t index = source()->GetUint30();
102 uint32_t encoded_index = source()->GetUint30();
103 CHECK_EQ(table->address(index), table->address(encoded_index));
104 }
105}
106
108 if (v8_flags.log_maps) LOG(isolate(), LogAllMaps());
109}
110
113 // The entire isolate is newly deserialized. Simply flush all code pages.
114 for (PageMetadata* p : *isolate()->heap()->code_space()) {
115 FlushInstructionCache(p->area_start(), p->area_end() - p->area_start());
116 }
117}
118
119} // namespace internal
120} // namespace v8
base::Vector< const DirectHandle< AccessorInfo > > accessor_infos() const
base::Vector< const DirectHandle< FunctionTemplateInfo > > function_template_infos() const
void set_native_contexts_list(Tagged< Object > object)
Definition heap.h:457
void set_allocation_sites_list(Tagged< UnionOf< Smi, Undefined, AllocationSiteWithWeakNext > > object)
Definition heap.h:466
void IterateWeakRoots(RootVisitor *v, base::EnumSet< SkipRoot > options)
Definition heap.cc:4532
void IterateSmiRoots(RootVisitor *v)
Definition heap.cc:4571
void set_dirty_js_finalization_registries_list_tail(Tagged< Object > object)
Definition heap.h:481
void IterateRoots(RootVisitor *v, base::EnumSet< SkipRoot > options, IterateRootsMode roots_mode=IterateRootsMode::kMainIsolate)
Definition heap.cc:4657
void set_dirty_js_finalization_registries_list(Tagged< Object > object)
Definition heap.h:475
ExternalReferenceTable * external_reference_table()
Definition isolate.h:1273
Builtins * builtins()
Definition isolate.h:1443
static void IterateStartupObjectCache(Isolate *isolate, RootVisitor *visitor)
void RestoreExternalReferenceRedirector(Isolate *isolate, Tagged< AccessorInfo > accessor_info)
static constexpr Tagged< Smi > zero()
Definition smi.h:99
#define LOG(isolate, Call)
Definition log.h:78
void PrintF(const char *format,...)
Definition utils.cc:39
void FlushInstructionCache(void *start, size_t size)
V8_EXPORT_PRIVATE FlagValues v8_flags
#define RCS_SCOPE(...)
#define DCHECK_NULL(val)
Definition logging.h:491
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
Definition logging.h:482
#define TRACE_EVENT0(category_group, name)
#define V8_UNLIKELY(condition)
Definition v8config.h:660