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

Side by Side Diff: src/serialize.h

Issue 342054: Introduce a switch for the new snapshot code and switch... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 1 month 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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 SnapshotByteSource(const byte* array, int length) 356 SnapshotByteSource(const byte* array, int length)
357 : data_(array), length_(length), position_(0) { } 357 : data_(array), length_(length), position_(0) { }
358 358
359 bool HasMore() { return position_ < length_; } 359 bool HasMore() { return position_ < length_; }
360 360
361 int Get() { 361 int Get() {
362 ASSERT(position_ < length_); 362 ASSERT(position_ < length_);
363 return data_[position_++]; 363 return data_[position_++];
364 } 364 }
365 365
366 void CopyRaw(byte* to, int number_of_bytes) {
367 memcpy(to, data_ + position_, number_of_bytes);
368 position_ += number_of_bytes;
369 }
370
366 int GetInt() { 371 int GetInt() {
367 // A little unwind to catch the really small ints. 372 // A little unwind to catch the really small ints.
368 int snapshot_byte = Get(); 373 int snapshot_byte = Get();
369 if ((snapshot_byte & 0x80) == 0) { 374 if ((snapshot_byte & 0x80) == 0) {
370 return snapshot_byte; 375 return snapshot_byte;
371 } 376 }
372 uintptr_t accumulator = (snapshot_byte & 0x7f) << 7; 377 uintptr_t accumulator = (snapshot_byte & 0x7f) << 7;
373 while (true) { 378 while (true) {
374 snapshot_byte = Get(); 379 snapshot_byte = Get();
375 if ((snapshot_byte & 0x80) == 0) { 380 if ((snapshot_byte & 0x80) == 0) {
(...skipping 22 matching lines...) Expand all
398 class SerDes: public GenericDeserializer { 403 class SerDes: public GenericDeserializer {
399 protected: 404 protected:
400 enum DataType { 405 enum DataType {
401 SMI_SERIALIZATION, 406 SMI_SERIALIZATION,
402 RAW_DATA_SERIALIZATION, 407 RAW_DATA_SERIALIZATION,
403 OBJECT_SERIALIZATION, 408 OBJECT_SERIALIZATION,
404 CODE_OBJECT_SERIALIZATION, 409 CODE_OBJECT_SERIALIZATION,
405 BACKREF_SERIALIZATION, 410 BACKREF_SERIALIZATION,
406 CODE_BACKREF_SERIALIZATION, 411 CODE_BACKREF_SERIALIZATION,
407 EXTERNAL_REFERENCE_SERIALIZATION, 412 EXTERNAL_REFERENCE_SERIALIZATION,
413 EXTERNAL_BRANCH_TARGET_SERIALIZATION,
408 SYNCHRONIZE 414 SYNCHRONIZE
409 }; 415 };
410 // Our Smi encoding is much more efficient for small positive integers than it 416 // Our Smi encoding is much more efficient for small positive integers than it
411 // is for negative numbers so we add a bias before encoding and subtract it 417 // is for negative numbers so we add a bias before encoding and subtract it
412 // after encoding so that popular small negative Smis are efficiently encoded. 418 // after encoding so that popular small negative Smis are efficiently encoded.
413 static const int kSmiBias = 16; 419 static const int kSmiBias = 16;
414 static const int kLargeData = LAST_SPACE; 420 static const int kLargeData = LAST_SPACE;
415 static const int kLargeCode = kLargeData + 1; 421 static const int kLargeCode = kLargeData + 1;
416 static const int kLargeFixedArray = kLargeCode + 1; 422 static const int kLargeFixedArray = kLargeCode + 1;
417 static const int kNumberOfSpaces = kLargeFixedArray + 1; 423 static const int kNumberOfSpaces = kLargeFixedArray + 1;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 ReferenceRepresentation representation) 520 ReferenceRepresentation representation)
515 : serializer_(serializer), 521 : serializer_(serializer),
516 object_(HeapObject::cast(o)), 522 object_(HeapObject::cast(o)),
517 sink_(sink), 523 sink_(sink),
518 reference_representation_(representation), 524 reference_representation_(representation),
519 bytes_processed_so_far_(0) { } 525 bytes_processed_so_far_(0) { }
520 void Serialize(); 526 void Serialize();
521 void VisitPointers(Object** start, Object** end); 527 void VisitPointers(Object** start, Object** end);
522 void VisitExternalReferences(Address* start, Address* end); 528 void VisitExternalReferences(Address* start, Address* end);
523 void VisitCodeTarget(RelocInfo* target); 529 void VisitCodeTarget(RelocInfo* target);
530 void VisitRuntimeEntry(RelocInfo* reloc);
524 531
525 private: 532 private:
526 void OutputRawData(Address up_to); 533 void OutputRawData(Address up_to);
527 534
528 Serializer2* serializer_; 535 Serializer2* serializer_;
529 HeapObject* object_; 536 HeapObject* object_;
530 SnapshotByteSink* sink_; 537 SnapshotByteSink* sink_;
531 ReferenceRepresentation reference_representation_; 538 ReferenceRepresentation reference_representation_;
532 int bytes_processed_so_far_; 539 int bytes_processed_so_far_;
533 }; 540 };
(...skipping 29 matching lines...) Expand all
563 570
564 friend class ObjectSerializer; 571 friend class ObjectSerializer;
565 friend class Deserializer2; 572 friend class Deserializer2;
566 573
567 DISALLOW_COPY_AND_ASSIGN(Serializer2); 574 DISALLOW_COPY_AND_ASSIGN(Serializer2);
568 }; 575 };
569 576
570 } } // namespace v8::internal 577 } } // namespace v8::internal
571 578
572 #endif // V8_SERIALIZE_H_ 579 #endif // V8_SERIALIZE_H_
OLDNEW
« src/mksnapshot.cc ('K') | « src/mksnapshot.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698