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

Side by Side Diff: src/snapshot/serialize.h

Issue 1179873003: Serializer: support all alignment kinds. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix assertion conditional Created 5 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/heap/objects-visiting-inl.h ('k') | src/snapshot/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_SNAPSHOT_SERIALIZE_H_ 5 #ifndef V8_SNAPSHOT_SERIALIZE_H_
6 #define V8_SNAPSHOT_SERIALIZE_H_ 6 #define V8_SNAPSHOT_SERIALIZE_H_
7 7
8 #include "src/hashmap.h" 8 #include "src/hashmap.h"
9 #include "src/heap-profiler.h" 9 #include "src/heap-profiler.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 // changed. If that happens, update the bytecode ranges in the comments below. 317 // changed. If that happens, update the bytecode ranges in the comments below.
318 STATIC_ASSERT(5 == kNumberOfSpaces); 318 STATIC_ASSERT(5 == kNumberOfSpaces);
319 enum Where { 319 enum Where {
320 // 0x00..0x04 Allocate new object, in specified space. 320 // 0x00..0x04 Allocate new object, in specified space.
321 kNewObject = 0, 321 kNewObject = 0,
322 // 0x05 Unused (including 0x25, 0x45, 0x65). 322 // 0x05 Unused (including 0x25, 0x45, 0x65).
323 // 0x06 Unused (including 0x26, 0x46, 0x66). 323 // 0x06 Unused (including 0x26, 0x46, 0x66).
324 // 0x07 Unused (including 0x27, 0x47, 0x67). 324 // 0x07 Unused (including 0x27, 0x47, 0x67).
325 // 0x08..0x0c Reference to previous object from space. 325 // 0x08..0x0c Reference to previous object from space.
326 kBackref = 0x08, 326 kBackref = 0x08,
327 // 0x0d Unused (including 0x2d, 0x4d, 0x6d).
327 // 0x0e Unused (including 0x2e, 0x4e, 0x6e). 328 // 0x0e Unused (including 0x2e, 0x4e, 0x6e).
328 // 0x0f Unused (including 0x2f, 0x4f, 0x6f). 329 // 0x0f Unused (including 0x2f, 0x4f, 0x6f).
329 // 0x10..0x14 Reference to previous object from space after skip. 330 // 0x10..0x14 Reference to previous object from space after skip.
330 kBackrefWithSkip = 0x10, 331 kBackrefWithSkip = 0x10,
332 // 0x15 Unused (including 0x35, 0x55, 0x75).
331 // 0x16 Unused (including 0x36, 0x56, 0x76). 333 // 0x16 Unused (including 0x36, 0x56, 0x76).
332 // 0x17 Unused (including 0x37, 0x57, 0x77). 334 // 0x17 Misc (including 0x37, 0x57, 0x77).
333 // 0x18 Root array item. 335 // 0x18 Root array item.
334 kRootArray = 0x18, 336 kRootArray = 0x18,
335 // 0x19 Object in the partial snapshot cache. 337 // 0x19 Object in the partial snapshot cache.
336 kPartialSnapshotCache = 0x19, 338 kPartialSnapshotCache = 0x19,
337 // 0x1a External reference referenced by id. 339 // 0x1a External reference referenced by id.
338 kExternalReference = 0x1a, 340 kExternalReference = 0x1a,
339 // 0x1b Object provided in the attached list. 341 // 0x1b Object provided in the attached list.
340 kAttachedReference = 0x1b, 342 kAttachedReference = 0x1b,
341 // 0x1c Builtin code referenced by index. 343 // 0x1c Builtin code referenced by index.
342 kBuiltin = 0x1c 344 kBuiltin = 0x1c
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 static const int kNop = 0x3d; 379 static const int kNop = 0x3d;
378 // Move to next reserved chunk. 380 // Move to next reserved chunk.
379 static const int kNextChunk = 0x3e; 381 static const int kNextChunk = 0x3e;
380 // Deferring object content. 382 // Deferring object content.
381 static const int kDeferred = 0x3f; 383 static const int kDeferred = 0x3f;
382 // A tag emitted at strategic points in the snapshot to delineate sections. 384 // A tag emitted at strategic points in the snapshot to delineate sections.
383 // If the deserializer does not find these at the expected moments then it 385 // If the deserializer does not find these at the expected moments then it
384 // is an indication that the snapshot and the VM do not fit together. 386 // is an indication that the snapshot and the VM do not fit together.
385 // Examine the build process for architecture, version or configuration 387 // Examine the build process for architecture, version or configuration
386 // mismatches. 388 // mismatches.
387 static const int kSynchronize = 0x5d; 389 static const int kSynchronize = 0x17;
388 // Used for the source code of the natives, which is in the executable, but 390 // Used for the source code of the natives, which is in the executable, but
389 // is referred to from external strings in the snapshot. 391 // is referred to from external strings in the snapshot.
390 static const int kNativesStringResource = 0x5e; 392 static const int kNativesStringResource = 0x37;
391 // Raw data of variable length. 393 // Raw data of variable length.
392 static const int kVariableRawData = 0x7d; 394 static const int kVariableRawData = 0x57;
393 // Repeats of variable length. 395 // Repeats of variable length.
394 static const int kVariableRepeat = 0x7e; 396 static const int kVariableRepeat = 0x77;
397 // Alignment prefixes 0x7d..0x7f
398 static const int kAlignmentPrefix = 0x7d;
399
400 // 0x5d..0x5f unused
395 401
396 // ---------- byte code range 0x80..0xff ---------- 402 // ---------- byte code range 0x80..0xff ----------
397 // First 32 root array items. 403 // First 32 root array items.
398 static const int kNumberOfRootArrayConstants = 0x20; 404 static const int kNumberOfRootArrayConstants = 0x20;
399 // 0x80..0x9f 405 // 0x80..0x9f
400 static const int kRootArrayConstants = 0x80; 406 static const int kRootArrayConstants = 0x80;
401 // 0xa0..0xbf 407 // 0xa0..0xbf
402 static const int kRootArrayConstantsWithSkip = 0xa0; 408 static const int kRootArrayConstantsWithSkip = 0xa0;
403 static const int kRootArrayConstantsMask = 0x1f; 409 static const int kRootArrayConstantsMask = 0x1f;
404 410
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 class Deserializer: public SerializerDeserializer { 514 class Deserializer: public SerializerDeserializer {
509 public: 515 public:
510 // Create a deserializer from a snapshot byte source. 516 // Create a deserializer from a snapshot byte source.
511 template <class Data> 517 template <class Data>
512 explicit Deserializer(Data* data) 518 explicit Deserializer(Data* data)
513 : isolate_(NULL), 519 : isolate_(NULL),
514 source_(data->Payload()), 520 source_(data->Payload()),
515 magic_number_(data->GetMagicNumber()), 521 magic_number_(data->GetMagicNumber()),
516 external_reference_table_(NULL), 522 external_reference_table_(NULL),
517 deserialized_large_objects_(0), 523 deserialized_large_objects_(0),
518 deserializing_user_code_(false) { 524 deserializing_user_code_(false),
525 next_alignment_(kWordAligned) {
519 DecodeReservation(data->Reservations()); 526 DecodeReservation(data->Reservations());
520 } 527 }
521 528
522 virtual ~Deserializer(); 529 virtual ~Deserializer();
523 530
524 // Deserialize the snapshot into an empty heap. 531 // Deserialize the snapshot into an empty heap.
525 void Deserialize(Isolate* isolate); 532 void Deserialize(Isolate* isolate);
526 533
527 // Deserialize a single object and the objects reachable from it. 534 // Deserialize a single object and the objects reachable from it.
528 MaybeHandle<Object> DeserializePartial( 535 MaybeHandle<Object> DeserializePartial(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 uint32_t current_chunk_[kNumberOfPreallocatedSpaces]; 602 uint32_t current_chunk_[kNumberOfPreallocatedSpaces];
596 Address high_water_[kNumberOfPreallocatedSpaces]; 603 Address high_water_[kNumberOfPreallocatedSpaces];
597 604
598 ExternalReferenceTable* external_reference_table_; 605 ExternalReferenceTable* external_reference_table_;
599 606
600 List<HeapObject*> deserialized_large_objects_; 607 List<HeapObject*> deserialized_large_objects_;
601 List<Code*> new_code_objects_; 608 List<Code*> new_code_objects_;
602 609
603 bool deserializing_user_code_; 610 bool deserializing_user_code_;
604 611
612 AllocationAlignment next_alignment_;
613
605 DISALLOW_COPY_AND_ASSIGN(Deserializer); 614 DISALLOW_COPY_AND_ASSIGN(Deserializer);
606 }; 615 };
607 616
608 617
609 class CodeAddressMap; 618 class CodeAddressMap;
610 619
611 // There can be only one serializer per V8 process. 620 // There can be only one serializer per V8 process.
612 class Serializer : public SerializerDeserializer { 621 class Serializer : public SerializerDeserializer {
613 public: 622 public:
614 Serializer(Isolate* isolate, SnapshotByteSink* sink); 623 Serializer(Isolate* isolate, SnapshotByteSink* sink);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 }; 708 };
700 709
701 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, 710 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code,
702 WhereToPoint where_to_point, int skip) = 0; 711 WhereToPoint where_to_point, int skip) = 0;
703 712
704 void PutRoot(int index, HeapObject* object, HowToCode how, WhereToPoint where, 713 void PutRoot(int index, HeapObject* object, HowToCode how, WhereToPoint where,
705 int skip); 714 int skip);
706 715
707 void PutBackReference(HeapObject* object, BackReference reference); 716 void PutBackReference(HeapObject* object, BackReference reference);
708 717
718 // Emit alignment prefix if necessary, return required padding space in bytes.
719 int PutAlignmentPrefix(HeapObject* object);
720
709 // Returns true if the object was successfully serialized. 721 // Returns true if the object was successfully serialized.
710 bool SerializeKnownObject(HeapObject* obj, HowToCode how_to_code, 722 bool SerializeKnownObject(HeapObject* obj, HowToCode how_to_code,
711 WhereToPoint where_to_point, int skip); 723 WhereToPoint where_to_point, int skip);
712 724
713 inline void FlushSkip(int skip) { 725 inline void FlushSkip(int skip) {
714 if (skip != 0) { 726 if (skip != 0) {
715 sink_->Put(kSkip, "SkipFromSerializeObject"); 727 sink_->Put(kSkip, "SkipFromSerializeObject");
716 sink_->PutInt(skip, "SkipDistanceFromSerializeObject"); 728 sink_->PutInt(skip, "SkipDistanceFromSerializeObject");
717 } 729 }
718 } 730 }
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 kNumInternalizedStringsOffset + kInt32Size; 1042 kNumInternalizedStringsOffset + kInt32Size;
1031 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; 1043 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size;
1032 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; 1044 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size;
1033 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; 1045 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size;
1034 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; 1046 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size;
1035 static const int kHeaderSize = kChecksum2Offset + kInt32Size; 1047 static const int kHeaderSize = kChecksum2Offset + kInt32Size;
1036 }; 1048 };
1037 } } // namespace v8::internal 1049 } } // namespace v8::internal
1038 1050
1039 #endif // V8_SNAPSHOT_SERIALIZE_H_ 1051 #endif // V8_SNAPSHOT_SERIALIZE_H_
OLDNEW
« no previous file with comments | « src/heap/objects-visiting-inl.h ('k') | src/snapshot/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698