Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: src/snapshot/partial-serializer.cc

Issue 1992723002: [serializer] prepare attached references for general use. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/snapshot/partial-serializer.h ('k') | src/snapshot/serializer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/snapshot/partial-serializer.h" 5 #include "src/snapshot/partial-serializer.h"
6 6
7 #include "src/objects-inl.h" 7 #include "src/objects-inl.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 11
12 PartialSerializer::PartialSerializer(Isolate* isolate, 12 PartialSerializer::PartialSerializer(Isolate* isolate,
13 Serializer* startup_snapshot_serializer, 13 Serializer* startup_snapshot_serializer,
14 SnapshotByteSink* sink) 14 SnapshotByteSink* sink)
15 : Serializer(isolate, sink), 15 : Serializer(isolate, sink),
16 startup_serializer_(startup_snapshot_serializer), 16 startup_serializer_(startup_snapshot_serializer),
17 global_object_(NULL),
18 next_partial_cache_index_(0) { 17 next_partial_cache_index_(0) {
19 InitializeCodeAddressMap(); 18 InitializeCodeAddressMap();
20 } 19 }
21 20
22 PartialSerializer::~PartialSerializer() { 21 PartialSerializer::~PartialSerializer() {
23 OutputStatistics("PartialSerializer"); 22 OutputStatistics("PartialSerializer");
24 } 23 }
25 24
26 void PartialSerializer::Serialize(Object** o) { 25 void PartialSerializer::Serialize(Object** o) {
27 if ((*o)->IsContext()) { 26 if ((*o)->IsContext()) {
28 Context* context = Context::cast(*o); 27 Context* context = Context::cast(*o);
29 global_object_ = context->global_object(); 28 reference_map()->AddAttachedReference(context->global_proxy());
30 back_reference_map()->AddGlobalProxy(context->global_proxy());
31 // The bootstrap snapshot has a code-stub context. When serializing the 29 // The bootstrap snapshot has a code-stub context. When serializing the
32 // partial snapshot, it is chained into the weak context list on the isolate 30 // partial snapshot, it is chained into the weak context list on the isolate
33 // and it's next context pointer may point to the code-stub context. Clear 31 // and it's next context pointer may point to the code-stub context. Clear
34 // it before serializing, it will get re-added to the context list 32 // it before serializing, it will get re-added to the context list
35 // explicitly when it's loaded. 33 // explicitly when it's loaded.
36 if (context->IsNativeContext()) { 34 if (context->IsNativeContext()) {
37 context->set(Context::NEXT_CONTEXT_LINK, 35 context->set(Context::NEXT_CONTEXT_LINK,
38 isolate_->heap()->undefined_value()); 36 isolate_->heap()->undefined_value());
39 DCHECK(!context->global_object()->IsUndefined()); 37 DCHECK(!context->global_object()->IsUndefined());
40 } 38 }
(...skipping 26 matching lines...) Expand all
67 int cache_index = PartialSnapshotCacheIndex(obj); 65 int cache_index = PartialSnapshotCacheIndex(obj);
68 sink_->Put(kPartialSnapshotCache + how_to_code + where_to_point, 66 sink_->Put(kPartialSnapshotCache + how_to_code + where_to_point,
69 "PartialSnapshotCache"); 67 "PartialSnapshotCache");
70 sink_->PutInt(cache_index, "partial_snapshot_cache_index"); 68 sink_->PutInt(cache_index, "partial_snapshot_cache_index");
71 return; 69 return;
72 } 70 }
73 71
74 // Pointers from the partial snapshot to the objects in the startup snapshot 72 // Pointers from the partial snapshot to the objects in the startup snapshot
75 // should go through the root array or through the partial snapshot cache. 73 // should go through the root array or through the partial snapshot cache.
76 // If this is not the case you may have to add something to the root array. 74 // If this is not the case you may have to add something to the root array.
77 DCHECK(!startup_serializer_->back_reference_map()->Lookup(obj).is_valid()); 75 DCHECK(!startup_serializer_->reference_map()->Lookup(obj).is_valid());
78 // All the internalized strings that the partial snapshot needs should be 76 // All the internalized strings that the partial snapshot needs should be
79 // either in the root table or in the partial snapshot cache. 77 // either in the root table or in the partial snapshot cache.
80 DCHECK(!obj->IsInternalizedString()); 78 DCHECK(!obj->IsInternalizedString());
81 79
82 if (SerializeKnownObject(obj, how_to_code, where_to_point, skip)) return; 80 if (SerializeKnownObject(obj, how_to_code, where_to_point, skip)) return;
83 81
84 FlushSkip(skip); 82 FlushSkip(skip);
85 83
86 // Clear literal boilerplates. 84 // Clear literal boilerplates.
87 if (obj->IsJSFunction()) { 85 if (obj->IsJSFunction()) {
(...skipping 26 matching lines...) Expand all
114 // would cause dupes. 112 // would cause dupes.
115 DCHECK(!o->IsScript()); 113 DCHECK(!o->IsScript());
116 return o->IsName() || o->IsSharedFunctionInfo() || o->IsHeapNumber() || 114 return o->IsName() || o->IsSharedFunctionInfo() || o->IsHeapNumber() ||
117 o->IsCode() || o->IsScopeInfo() || o->IsAccessorInfo() || 115 o->IsCode() || o->IsScopeInfo() || o->IsAccessorInfo() ||
118 o->map() == 116 o->map() ==
119 startup_serializer_->isolate()->heap()->fixed_cow_array_map(); 117 startup_serializer_->isolate()->heap()->fixed_cow_array_map();
120 } 118 }
121 119
122 } // namespace internal 120 } // namespace internal
123 } // namespace v8 121 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/partial-serializer.h ('k') | src/snapshot/serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698