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

Side by Side Diff: src/serialize.h

Issue 759823006: Ensure double alignment when deserializing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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/objects-inl.h ('k') | src/serialize.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #ifndef V8_SERIALIZE_H_ 5 #ifndef V8_SERIALIZE_H_
6 #define V8_SERIALIZE_H_ 6 #define V8_SERIALIZE_H_
7 7
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/hashmap.h" 9 #include "src/hashmap.h"
10 #include "src/heap-profiler.h" 10 #include "src/heap-profiler.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 static int nop() { return kNop; } 295 static int nop() { return kNop; }
296 296
297 // No reservation for large object space necessary. 297 // No reservation for large object space necessary.
298 static const int kNumberOfPreallocatedSpaces = LO_SPACE; 298 static const int kNumberOfPreallocatedSpaces = LO_SPACE;
299 static const int kNumberOfSpaces = LAST_SPACE + 1; 299 static const int kNumberOfSpaces = LAST_SPACE + 1;
300 300
301 protected: 301 protected:
302 // Where the pointed-to object can be found: 302 // Where the pointed-to object can be found:
303 enum Where { 303 enum Where {
304 kNewObject = 0, // Object is next in snapshot. 304 kNewObject = 0, // Object is next in snapshot.
305 // 1-7 One per space. 305 // 1-7 One per space.
306 kRootArray = 0x9, // Object is found in root array. 306 kRootArray = 0x9, // Object is found in root array.
307 kPartialSnapshotCache = 0xa, // Object is in the cache. 307 kPartialSnapshotCache = 0xa, // Object is in the cache.
308 kExternalReference = 0xb, // Pointer to an external reference. 308 kExternalReference = 0xb, // Pointer to an external reference.
309 kSkip = 0xc, // Skip n bytes. 309 kSkip = 0xc, // Skip n bytes.
310 kBuiltin = 0xd, // Builtin code object. 310 kBuiltin = 0xd, // Builtin code object.
311 kAttachedReference = 0xe, // Object is described in an attached list. 311 kAttachedReference = 0xe, // Object is described in an attached list.
312 kNop = 0xf, // Does nothing, used to pad. 312 // 0xf Used by misc. See below.
313 kBackref = 0x10, // Object is described relative to end. 313 kBackref = 0x10, // Object is described relative to end.
314 // 0x11-0x17 One per space. 314 // 0x11-0x17 One per space.
315 kBackrefWithSkip = 0x18, // Object is described relative to end. 315 kBackrefWithSkip = 0x18, // Object is described relative to end.
316 // 0x19-0x1f One per space. 316 // 0x19-0x1f One per space.
317 // 0x20-0x3f Used by misc. tags below. 317 // 0x20-0x3f Used by misc. See below.
318 kPointedToMask = 0x3f 318 kPointedToMask = 0x3f
319 }; 319 };
320 320
321 // How to code the pointer to the object. 321 // How to code the pointer to the object.
322 enum HowToCode { 322 enum HowToCode {
323 kPlain = 0, // Straight pointer. 323 kPlain = 0, // Straight pointer.
324 // What this means depends on the architecture: 324 // What this means depends on the architecture:
325 kFromCode = 0x40, // A pointer inlined in code. 325 kFromCode = 0x40, // A pointer inlined in code.
326 kHowToCodeMask = 0x40 326 kHowToCodeMask = 0x40
327 }; 327 };
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 DCHECK(byte_code >= kConstantRepeat && byte_code <= 0x7f); 368 DCHECK(byte_code >= kConstantRepeat && byte_code <= 0x7f);
369 return byte_code - 0x72; 369 return byte_code - 0x72;
370 } 370 }
371 static const int kRootArrayConstants = 0xa0; 371 static const int kRootArrayConstants = 0xa0;
372 // 0xa0-0xbf Things from the first 32 elements of the root array. 372 // 0xa0-0xbf Things from the first 32 elements of the root array.
373 static const int kRootArrayNumberOfConstantEncodings = 0x20; 373 static const int kRootArrayNumberOfConstantEncodings = 0x20;
374 static int RootArrayConstantFromByteCode(int byte_code) { 374 static int RootArrayConstantFromByteCode(int byte_code) {
375 return byte_code & 0x1f; 375 return byte_code & 0x1f;
376 } 376 }
377 377
378 static const int kNop = 0xf; // Do nothing, used for padding.
379
378 static const int kAnyOldSpace = -1; 380 static const int kAnyOldSpace = -1;
379 381
380 // A bitmask for getting the space out of an instruction. 382 // A bitmask for getting the space out of an instruction.
381 static const int kSpaceMask = 7; 383 static const int kSpaceMask = 7;
382 STATIC_ASSERT(kNumberOfSpaces <= kSpaceMask + 1); 384 STATIC_ASSERT(kNumberOfSpaces <= kSpaceMask + 1);
385
386 // Sentinel after a new object to indicate that double alignment is needed.
387 static const int kDoubleAlignmentSentinel = 0;
383 }; 388 };
384 389
385 390
386 // A Deserializer reads a snapshot and reconstructs the Object graph it defines. 391 // A Deserializer reads a snapshot and reconstructs the Object graph it defines.
387 class Deserializer: public SerializerDeserializer { 392 class Deserializer: public SerializerDeserializer {
388 public: 393 public:
389 // Create a deserializer from a snapshot byte source. 394 // Create a deserializer from a snapshot byte source.
390 explicit Deserializer(SnapshotByteSource* source); 395 explicit Deserializer(SnapshotByteSource* source);
391 396
392 virtual ~Deserializer(); 397 virtual ~Deserializer();
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 // Following the header, we store, in sequential order 866 // Following the header, we store, in sequential order
862 // - code stub keys 867 // - code stub keys
863 // - serialization payload 868 // - serialization payload
864 869
865 ScriptData* script_data_; 870 ScriptData* script_data_;
866 bool owns_script_data_; 871 bool owns_script_data_;
867 }; 872 };
868 } } // namespace v8::internal 873 } } // namespace v8::internal
869 874
870 #endif // V8_SERIALIZE_H_ 875 #endif // V8_SERIALIZE_H_
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698