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

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

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