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

Side by Side Diff: src/snapshot/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: Created 4 years, 6 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/serializer.h ('k') | src/snapshot/startup-serializer.cc » ('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/serializer.h" 5 #include "src/snapshot/serializer.h"
6 6
7 #include "src/macro-assembler.h" 7 #include "src/macro-assembler.h"
8 #include "src/snapshot/natives.h" 8 #include "src/snapshot/natives.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 reference.large_object_index() < seen_large_objects_index_; 133 reference.large_object_index() < seen_large_objects_index_;
134 } else if (chunk_index == completed_chunks_[space].length()) { 134 } else if (chunk_index == completed_chunks_[space].length()) {
135 return reference.chunk_offset() < pending_chunk_[space]; 135 return reference.chunk_offset() < pending_chunk_[space];
136 } else { 136 } else {
137 return chunk_index < completed_chunks_[space].length() && 137 return chunk_index < completed_chunks_[space].length() &&
138 reference.chunk_offset() < completed_chunks_[space][chunk_index]; 138 reference.chunk_offset() < completed_chunks_[space][chunk_index];
139 } 139 }
140 } 140 }
141 #endif // DEBUG 141 #endif // DEBUG
142 142
143 bool Serializer::SerializeKnownObject(HeapObject* obj, HowToCode how_to_code, 143 bool Serializer::SerializeHotObject(HeapObject* obj, HowToCode how_to_code,
144 WhereToPoint where_to_point, int skip) { 144 WhereToPoint where_to_point, int skip) {
145 if (how_to_code == kPlain && where_to_point == kStartOfObject) { 145 if (how_to_code == kPlain && where_to_point == kStartOfObject) {
vogelheim 2016/06/23 13:39:14 [Feel free to ignore, since this is not even about
Yang 2016/06/24 06:00:58 Done.
146 // Encode a reference to a hot object by its index in the working set. 146 // Encode a reference to a hot object by its index in the working set.
147 int index = hot_objects_.Find(obj); 147 int index = hot_objects_.Find(obj);
148 if (index != HotObjectsList::kNotFound) { 148 if (index != HotObjectsList::kNotFound) {
149 DCHECK(index >= 0 && index < kNumberOfHotObjects); 149 DCHECK(index >= 0 && index < kNumberOfHotObjects);
150 if (FLAG_trace_serializer) { 150 if (FLAG_trace_serializer) {
151 PrintF(" Encoding hot object %d:", index); 151 PrintF(" Encoding hot object %d:", index);
152 obj->ShortPrint(); 152 obj->ShortPrint();
153 PrintF("\n"); 153 PrintF("\n");
154 } 154 }
155 if (skip != 0) { 155 if (skip != 0) {
156 sink_.Put(kHotObjectWithSkip + index, "HotObjectWithSkip"); 156 sink_.Put(kHotObjectWithSkip + index, "HotObjectWithSkip");
157 sink_.PutInt(skip, "HotObjectSkipDistance"); 157 sink_.PutInt(skip, "HotObjectSkipDistance");
158 } else { 158 } else {
159 sink_.Put(kHotObject + index, "HotObject"); 159 sink_.Put(kHotObject + index, "HotObject");
160 } 160 }
161 return true; 161 return true;
162 } 162 }
163 } 163 }
164 return false;
165 }
166
167 bool Serializer::SerializeBackReference(HeapObject* obj, HowToCode how_to_code,
168 WhereToPoint where_to_point, int skip) {
164 SerializerReference reference = reference_map_.Lookup(obj); 169 SerializerReference reference = reference_map_.Lookup(obj);
165 if (reference.is_valid()) { 170 if (reference.is_valid()) {
166 // Encode the location of an already deserialized object in order to write 171 // Encode the location of an already deserialized object in order to write
167 // its location into a later object. We can encode the location as an 172 // its location into a later object. We can encode the location as an
168 // offset fromthe start of the deserialized objects or as an offset 173 // offset fromthe start of the deserialized objects or as an offset
169 // backwards from thecurrent allocation pointer. 174 // backwards from thecurrent allocation pointer.
170 if (reference.is_attached_reference()) { 175 if (reference.is_attached_reference()) {
171 FlushSkip(skip); 176 FlushSkip(skip);
172 if (FLAG_trace_serializer) { 177 if (FLAG_trace_serializer) {
173 PrintF(" Encoding attached reference %d\n", 178 PrintF(" Encoding attached reference %d\n",
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (skip == 0) { 219 if (skip == 0) {
215 sink_.Put(kRootArrayConstants + root_index, "RootConstant"); 220 sink_.Put(kRootArrayConstants + root_index, "RootConstant");
216 } else { 221 } else {
217 sink_.Put(kRootArrayConstantsWithSkip + root_index, "RootConstant"); 222 sink_.Put(kRootArrayConstantsWithSkip + root_index, "RootConstant");
218 sink_.PutInt(skip, "SkipInPutRoot"); 223 sink_.PutInt(skip, "SkipInPutRoot");
219 } 224 }
220 } else { 225 } else {
221 FlushSkip(skip); 226 FlushSkip(skip);
222 sink_.Put(kRootArray + how_to_code + where_to_point, "RootSerialization"); 227 sink_.Put(kRootArray + how_to_code + where_to_point, "RootSerialization");
223 sink_.PutInt(root_index, "root_index"); 228 sink_.PutInt(root_index, "root_index");
229 hot_objects_.Add(object);
224 } 230 }
225 } 231 }
226 232
227 void Serializer::PutSmi(Smi* smi) { 233 void Serializer::PutSmi(Smi* smi) {
228 sink_.Put(kOnePointerRawData, "Smi"); 234 sink_.Put(kOnePointerRawData, "Smi");
229 byte* bytes = reinterpret_cast<byte*>(&smi); 235 byte* bytes = reinterpret_cast<byte*>(&smi);
230 for (int i = 0; i < kPointerSize; i++) sink_.Put(bytes[i], "Byte"); 236 for (int i = 0; i < kPointerSize; i++) sink_.Put(bytes[i], "Byte");
231 } 237 }
232 238
233 void Serializer::PutBackReference(HeapObject* object, 239 void Serializer::PutBackReference(HeapObject* object,
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 if (to_skip != 0 && return_skip == kIgnoringReturn) { 780 if (to_skip != 0 && return_skip == kIgnoringReturn) {
775 sink_->Put(kSkip, "Skip"); 781 sink_->Put(kSkip, "Skip");
776 sink_->PutInt(to_skip, "SkipDistance"); 782 sink_->PutInt(to_skip, "SkipDistance");
777 to_skip = 0; 783 to_skip = 0;
778 } 784 }
779 return to_skip; 785 return to_skip;
780 } 786 }
781 787
782 } // namespace internal 788 } // namespace internal
783 } // namespace v8 789 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/serializer.h ('k') | src/snapshot/startup-serializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698