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

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

Issue 2090563002: [serializer] encode recent long-encoded root list items as hot objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 4 years, 5 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/deserializer.cc ('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 #include "src/snapshot/startup-serializer.h" 6 #include "src/snapshot/startup-serializer.h"
7 7
8 #include "src/objects-inl.h" 8 #include "src/objects-inl.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 WhereToPoint where_to_point, int skip) { 44 WhereToPoint where_to_point, int skip) {
45 if (obj->IsMap()) { 45 if (obj->IsMap()) {
46 // The code-caches link to context-specific code objects, which 46 // The code-caches link to context-specific code objects, which
47 // the startup and context serializes cannot currently handle. 47 // the startup and context serializes cannot currently handle.
48 DCHECK(Map::cast(obj)->code_cache() == obj->GetHeap()->empty_fixed_array()); 48 DCHECK(Map::cast(obj)->code_cache() == obj->GetHeap()->empty_fixed_array());
49 } 49 }
50 50
51 // Replace typed arrays by undefined. 51 // Replace typed arrays by undefined.
52 if (obj->IsJSTypedArray()) obj = isolate_->heap()->undefined_value(); 52 if (obj->IsJSTypedArray()) obj = isolate_->heap()->undefined_value();
53 53
54 if (SerializeHotObject(obj, how_to_code, where_to_point, skip)) return;
55
54 int root_index = root_index_map_.Lookup(obj); 56 int root_index = root_index_map_.Lookup(obj);
55 if (root_index != RootIndexMap::kInvalidRootIndex) { 57 if (root_index != RootIndexMap::kInvalidRootIndex) {
56 PutRoot(root_index, obj, how_to_code, where_to_point, skip); 58 PutRoot(root_index, obj, how_to_code, where_to_point, skip);
57 return; 59 return;
58 } 60 }
59 61
62 if (SerializeBackReference(obj, how_to_code, where_to_point, skip)) return;
63
60 if (ShouldBeInThePartialSnapshotCache(obj)) { 64 if (ShouldBeInThePartialSnapshotCache(obj)) {
61 FlushSkip(skip); 65 FlushSkip(skip);
62 66
63 int cache_index = startup_serializer_->PartialSnapshotCacheIndex(obj); 67 int cache_index = startup_serializer_->PartialSnapshotCacheIndex(obj);
64 sink_.Put(kPartialSnapshotCache + how_to_code + where_to_point, 68 sink_.Put(kPartialSnapshotCache + how_to_code + where_to_point,
65 "PartialSnapshotCache"); 69 "PartialSnapshotCache");
66 sink_.PutInt(cache_index, "partial_snapshot_cache_index"); 70 sink_.PutInt(cache_index, "partial_snapshot_cache_index");
67 return; 71 return;
68 } 72 }
69 73
70 // Pointers from the partial snapshot to the objects in the startup snapshot 74 // Pointers from the partial snapshot to the objects in the startup snapshot
71 // should go through the root array or through the partial snapshot cache. 75 // should go through the root array or through the partial snapshot cache.
72 // If this is not the case you may have to add something to the root array. 76 // If this is not the case you may have to add something to the root array.
73 DCHECK(!startup_serializer_->reference_map()->Lookup(obj).is_valid()); 77 DCHECK(!startup_serializer_->reference_map()->Lookup(obj).is_valid());
74 // All the internalized strings that the partial snapshot needs should be 78 // All the internalized strings that the partial snapshot needs should be
75 // either in the root table or in the partial snapshot cache. 79 // either in the root table or in the partial snapshot cache.
76 DCHECK(!obj->IsInternalizedString()); 80 DCHECK(!obj->IsInternalizedString());
77 // Function and object templates are not context specific. 81 // Function and object templates are not context specific.
78 DCHECK(!obj->IsTemplateInfo()); 82 DCHECK(!obj->IsTemplateInfo());
79 83
80 if (SerializeKnownObject(obj, how_to_code, where_to_point, skip)) return;
81
82 FlushSkip(skip); 84 FlushSkip(skip);
83 85
84 // Clear literal boilerplates. 86 // Clear literal boilerplates.
85 if (obj->IsJSFunction()) { 87 if (obj->IsJSFunction()) {
86 LiteralsArray* literals = JSFunction::cast(obj)->literals(); 88 JSFunction* function = JSFunction::cast(obj);
89 LiteralsArray* literals = function->literals();
87 for (int i = 0; i < literals->literals_count(); i++) { 90 for (int i = 0; i < literals->literals_count(); i++) {
88 literals->set_literal_undefined(i); 91 literals->set_literal_undefined(i);
89 } 92 }
93 function->ClearTypeFeedbackInfo();
90 } 94 }
91 95
92 // Object has not yet been serialized. Serialize it here. 96 // Object has not yet been serialized. Serialize it here.
93 ObjectSerializer serializer(this, obj, &sink_, how_to_code, where_to_point); 97 ObjectSerializer serializer(this, obj, &sink_, how_to_code, where_to_point);
94 serializer.Serialize(); 98 serializer.Serialize();
95 } 99 }
96 100
97 bool PartialSerializer::ShouldBeInThePartialSnapshotCache(HeapObject* o) { 101 bool PartialSerializer::ShouldBeInThePartialSnapshotCache(HeapObject* o) {
98 // Scripts should be referred only through shared function infos. We can't 102 // Scripts should be referred only through shared function infos. We can't
99 // allow them to be part of the partial snapshot because they contain a 103 // allow them to be part of the partial snapshot because they contain a
100 // unique ID, and deserializing several partial snapshots containing script 104 // unique ID, and deserializing several partial snapshots containing script
101 // would cause dupes. 105 // would cause dupes.
102 DCHECK(!o->IsScript()); 106 DCHECK(!o->IsScript());
103 return o->IsName() || o->IsSharedFunctionInfo() || o->IsHeapNumber() || 107 return o->IsName() || o->IsSharedFunctionInfo() || o->IsHeapNumber() ||
104 o->IsCode() || o->IsScopeInfo() || o->IsAccessorInfo() || 108 o->IsCode() || o->IsScopeInfo() || o->IsAccessorInfo() ||
105 o->map() == 109 o->map() ==
106 startup_serializer_->isolate()->heap()->fixed_cow_array_map(); 110 startup_serializer_->isolate()->heap()->fixed_cow_array_map();
107 } 111 }
108 112
109 } // namespace internal 113 } // namespace internal
110 } // namespace v8 114 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/deserializer.cc ('k') | src/snapshot/serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698