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

Side by Side Diff: src/serialize.h

Issue 565047: * Add the partial context snapshot to the VM executable if... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 f(14, 32) \ 166 f(14, 32) \
167 f(15, 36) 167 f(15, 36)
168 168
169 // The Serializer/Deserializer class is a common superclass for Serializer and 169 // The Serializer/Deserializer class is a common superclass for Serializer and
170 // Deserializer which is used to store common constants and methods used by 170 // Deserializer which is used to store common constants and methods used by
171 // both. 171 // both.
172 class SerializerDeserializer: public ObjectVisitor { 172 class SerializerDeserializer: public ObjectVisitor {
173 public: 173 public:
174 static void Iterate(ObjectVisitor* visitor); 174 static void Iterate(ObjectVisitor* visitor);
175 static void SetSnapshotCacheSize(int size); 175 static void SetSnapshotCacheSize(int size);
176 #ifdef DEBUG
177 static void StartTracing() { tracing_ = true; }
178 static void StopTracing() { tracing_ = false; }
179 static void Trace(const char *msg, int arg) { if (tracing_) printf("%s %d\n", msg, arg); }
180 static void Trace(const char *msg, const char* arg) { if (tracing_) printf("%s %s\n", msg, arg); }
181 static void Trace(const char *msg, const char* arg1, int arg2) { if (tracing_) printf("%s %s %d\n", msg, arg1, arg2); }
182 static bool tracing() { return tracing_; }
183 #else
184 static void StartTracing() { }
185 static void StopTracing() { }
186 static void Trace(const char *msg, int arg) { }
187 static void Trace(const char *msg, const char* arg) { }
188 static void Trace(const char *msg, const char* arg1, int arg2) { }
189 static bool tracing() { return false; }
190 #endif
191 176
192 protected: 177 protected:
193 enum DataType { 178 enum DataType {
194 RAW_DATA_SERIALIZATION = 0, 179 RAW_DATA_SERIALIZATION = 0,
195 // And 15 common raw lengths. 180 // And 15 common raw lengths.
196 OBJECT_SERIALIZATION = 16, 181 OBJECT_SERIALIZATION = 16,
197 // One variant per space. 182 // One variant per space.
198 CODE_OBJECT_SERIALIZATION = 25, 183 CODE_OBJECT_SERIALIZATION = 25,
199 // One per space (only code spaces in use). 184 // One per space (only code spaces in use).
200 EXTERNAL_REFERENCE_SERIALIZATION = 34, 185 EXTERNAL_REFERENCE_SERIALIZATION = 34,
(...skipping 25 matching lines...) Expand all
226 static const int kSpaceMask = 15; 211 static const int kSpaceMask = 15;
227 212
228 static inline bool SpaceIsLarge(int space) { return space >= kLargeData; } 213 static inline bool SpaceIsLarge(int space) { return space >= kLargeData; }
229 static inline bool SpaceIsPaged(int space) { 214 static inline bool SpaceIsPaged(int space) {
230 return space >= FIRST_PAGED_SPACE && space <= LAST_PAGED_SPACE; 215 return space >= FIRST_PAGED_SPACE && space <= LAST_PAGED_SPACE;
231 } 216 }
232 217
233 static int partial_snapshot_cache_length_; 218 static int partial_snapshot_cache_length_;
234 static const int kPartialSnapshotCacheCapacity = 1300; 219 static const int kPartialSnapshotCacheCapacity = 1300;
235 static Object* partial_snapshot_cache_[]; 220 static Object* partial_snapshot_cache_[];
236 static bool tracing_;
237 }; 221 };
238 222
239 223
240 int SnapshotByteSource::GetInt() { 224 int SnapshotByteSource::GetInt() {
241 // A little unwind to catch the really small ints. 225 // A little unwind to catch the really small ints.
242 int snapshot_byte = Get(); 226 int snapshot_byte = Get();
243 if ((snapshot_byte & 0x80) == 0) { 227 if ((snapshot_byte & 0x80) == 0) {
244 SerializerDeserializer::Trace("Tag IntLastPart", snapshot_byte);
245 return snapshot_byte; 228 return snapshot_byte;
246 } 229 }
247 SerializerDeserializer::Trace("Tag IntPart", snapshot_byte);
248 int accumulator = (snapshot_byte & 0x7f) << 7; 230 int accumulator = (snapshot_byte & 0x7f) << 7;
249 while (true) { 231 while (true) {
250 snapshot_byte = Get(); 232 snapshot_byte = Get();
251 if ((snapshot_byte & 0x80) == 0) { 233 if ((snapshot_byte & 0x80) == 0) {
252 SerializerDeserializer::Trace("Tag IntLastPart", snapshot_byte);
253 return accumulator | snapshot_byte; 234 return accumulator | snapshot_byte;
254 } 235 }
255 SerializerDeserializer::Trace("Tag IntPart", snapshot_byte);
256 accumulator = (accumulator | (snapshot_byte & 0x7f)) << 7; 236 accumulator = (accumulator | (snapshot_byte & 0x7f)) << 7;
257 } 237 }
258 UNREACHABLE(); 238 UNREACHABLE();
259 return accumulator; 239 return accumulator;
260 } 240 }
261 241
262 242
263 void SnapshotByteSource::CopyRaw(byte* to, int number_of_bytes) { 243 void SnapshotByteSource::CopyRaw(byte* to, int number_of_bytes) {
264 if (SerializerDeserializer::tracing()) {
265 for (int i = 0; i < number_of_bytes; i++) {
266 SerializerDeserializer::Trace("Tag Byte", data_[position_ + i]);
267 }
268 }
269 memcpy(to, data_ + position_, number_of_bytes); 244 memcpy(to, data_ + position_, number_of_bytes);
270 position_ += number_of_bytes; 245 position_ += number_of_bytes;
271 } 246 }
272 247
273 248
274 // A Deserializer reads a snapshot and reconstructs the Object graph it defines. 249 // A Deserializer reads a snapshot and reconstructs the Object graph it defines.
275 class Deserializer: public SerializerDeserializer { 250 class Deserializer: public SerializerDeserializer {
276 public: 251 public:
277 // Create a deserializer from a snapshot byte source. 252 // Create a deserializer from a snapshot byte source.
278 explicit Deserializer(SnapshotByteSource* source); 253 explicit Deserializer(SnapshotByteSource* source);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 virtual int RootIndex(HeapObject* o) { return kInvalidRootIndex; } 532 virtual int RootIndex(HeapObject* o) { return kInvalidRootIndex; }
558 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { 533 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) {
559 return false; 534 return false;
560 } 535 }
561 }; 536 };
562 537
563 538
564 } } // namespace v8::internal 539 } } // namespace v8::internal
565 540
566 #endif // V8_SERIALIZE_H_ 541 #endif // V8_SERIALIZE_H_
OLDNEW
« src/api.cc ('K') | « src/mksnapshot.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698