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

Side by Side Diff: runtime/vm/snapshot.h

Issue 12578009: - Canonicalize types, type_arguments only when the object is marked as being from the core librarie… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | runtime/vm/snapshot.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_SNAPSHOT_H_ 5 #ifndef VM_SNAPSHOT_H_
6 #define VM_SNAPSHOT_H_ 6 #define VM_SNAPSHOT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/bitfield.h" 10 #include "vm/bitfield.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 409 }
410 410
411 // Write out a buffer of bytes. 411 // Write out a buffer of bytes.
412 void WriteBytes(const uint8_t* addr, intptr_t len) { 412 void WriteBytes(const uint8_t* addr, intptr_t len) {
413 stream_.WriteBytes(addr, len); 413 stream_.WriteBytes(addr, len);
414 } 414 }
415 415
416 protected: 416 protected:
417 BaseWriter(uint8_t** buffer, 417 BaseWriter(uint8_t** buffer,
418 ReAlloc alloc, 418 ReAlloc alloc,
419 intptr_t increment_size) : stream_(buffer, alloc, increment_size) { 419 intptr_t initial_size) : stream_(buffer, alloc, initial_size) {
420 ASSERT(buffer != NULL); 420 ASSERT(buffer != NULL);
421 ASSERT(alloc != NULL); 421 ASSERT(alloc != NULL);
422 } 422 }
423 ~BaseWriter() { } 423 ~BaseWriter() { }
424 424
425 void ReserveHeader() { 425 void ReserveHeader() {
426 // Make room for recording snapshot buffer size. 426 // Make room for recording snapshot buffer size.
427 stream_.set_current(stream_.buffer() + Snapshot::kHeaderSize); 427 stream_.set_current(stream_.buffer() + Snapshot::kHeaderSize);
428 } 428 }
429 429
430 void FillHeader(Snapshot::Kind kind) { 430 void FillHeader(Snapshot::Kind kind) {
431 int32_t* data = reinterpret_cast<int32_t*>(stream_.buffer()); 431 int32_t* data = reinterpret_cast<int32_t*>(stream_.buffer());
432 data[Snapshot::kLengthIndex] = stream_.bytes_written(); 432 data[Snapshot::kLengthIndex] = stream_.bytes_written();
433 data[Snapshot::kSnapshotFlagIndex] = kind; 433 data[Snapshot::kSnapshotFlagIndex] = kind;
434 } 434 }
435 435
436 private: 436 private:
437 WriteStream stream_; 437 WriteStream stream_;
438 438
439 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseWriter); 439 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseWriter);
440 }; 440 };
441 441
442 442
443 class SnapshotWriter : public BaseWriter { 443 class SnapshotWriter : public BaseWriter {
444 protected: 444 protected:
445 SnapshotWriter(Snapshot::Kind kind, 445 SnapshotWriter(Snapshot::Kind kind,
446 uint8_t** buffer, 446 uint8_t** buffer,
447 ReAlloc alloc, 447 ReAlloc alloc,
448 intptr_t increment_size); 448 intptr_t initial_size);
449 449
450 public: 450 public:
451 // Snapshot kind. 451 // Snapshot kind.
452 Snapshot::Kind kind() const { return kind_; } 452 Snapshot::Kind kind() const { return kind_; }
453 453
454 // Serialize an object into the buffer. 454 // Serialize an object into the buffer.
455 void WriteObject(RawObject* raw); 455 void WriteObject(RawObject* raw);
456 456
457 uword GetObjectTags(RawObject* raw); 457 uword GetObjectTags(RawObject* raw);
458 458
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 friend class RawScript; 527 friend class RawScript;
528 friend class RawTokenStream; 528 friend class RawTokenStream;
529 friend class RawTypeArguments; 529 friend class RawTypeArguments;
530 friend class SnapshotWriterVisitor; 530 friend class SnapshotWriterVisitor;
531 DISALLOW_COPY_AND_ASSIGN(SnapshotWriter); 531 DISALLOW_COPY_AND_ASSIGN(SnapshotWriter);
532 }; 532 };
533 533
534 534
535 class FullSnapshotWriter : public SnapshotWriter { 535 class FullSnapshotWriter : public SnapshotWriter {
536 public: 536 public:
537 static const intptr_t kIncrementSize = 64 * KB; 537 static const intptr_t kInitialSize = 64 * KB;
538 FullSnapshotWriter(uint8_t** buffer, ReAlloc alloc) 538 FullSnapshotWriter(uint8_t** buffer, ReAlloc alloc)
539 : SnapshotWriter(Snapshot::kFull, buffer, alloc, kIncrementSize) { 539 : SnapshotWriter(Snapshot::kFull, buffer, alloc, kInitialSize) {
540 ASSERT(buffer != NULL); 540 ASSERT(buffer != NULL);
541 ASSERT(alloc != NULL); 541 ASSERT(alloc != NULL);
542 } 542 }
543 ~FullSnapshotWriter() { } 543 ~FullSnapshotWriter() { }
544 544
545 // Writes a full snapshot of the Isolate. 545 // Writes a full snapshot of the Isolate.
546 void WriteFullSnapshot(); 546 void WriteFullSnapshot();
547 547
548 private: 548 private:
549 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); 549 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter);
550 }; 550 };
551 551
552 552
553 class ScriptSnapshotWriter : public SnapshotWriter { 553 class ScriptSnapshotWriter : public SnapshotWriter {
554 public: 554 public:
555 static const intptr_t kIncrementSize = 64 * KB; 555 static const intptr_t kInitialSize = 64 * KB;
556 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc) 556 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc)
557 : SnapshotWriter(Snapshot::kScript, buffer, alloc, kIncrementSize) { 557 : SnapshotWriter(Snapshot::kScript, buffer, alloc, kInitialSize) {
558 ASSERT(buffer != NULL); 558 ASSERT(buffer != NULL);
559 ASSERT(alloc != NULL); 559 ASSERT(alloc != NULL);
560 } 560 }
561 ~ScriptSnapshotWriter() { } 561 ~ScriptSnapshotWriter() { }
562 562
563 // Writes a partial snapshot of the script. 563 // Writes a partial snapshot of the script.
564 void WriteScriptSnapshot(const Library& lib); 564 void WriteScriptSnapshot(const Library& lib);
565 565
566 private: 566 private:
567 DISALLOW_COPY_AND_ASSIGN(ScriptSnapshotWriter); 567 DISALLOW_COPY_AND_ASSIGN(ScriptSnapshotWriter);
568 }; 568 };
569 569
570 570
571 class MessageWriter : public SnapshotWriter { 571 class MessageWriter : public SnapshotWriter {
572 public: 572 public:
573 static const intptr_t kIncrementSize = 512; 573 static const intptr_t kInitialSize = 512;
574 MessageWriter(uint8_t** buffer, ReAlloc alloc) 574 MessageWriter(uint8_t** buffer, ReAlloc alloc)
575 : SnapshotWriter(Snapshot::kMessage, buffer, alloc, kIncrementSize) { 575 : SnapshotWriter(Snapshot::kMessage, buffer, alloc, kInitialSize) {
576 ASSERT(buffer != NULL); 576 ASSERT(buffer != NULL);
577 ASSERT(alloc != NULL); 577 ASSERT(alloc != NULL);
578 } 578 }
579 ~MessageWriter() { } 579 ~MessageWriter() { }
580 580
581 void WriteMessage(const Object& obj); 581 void WriteMessage(const Object& obj);
582 582
583 private: 583 private:
584 DISALLOW_COPY_AND_ASSIGN(MessageWriter); 584 DISALLOW_COPY_AND_ASSIGN(MessageWriter);
585 }; 585 };
(...skipping 18 matching lines...) Expand all
604 private: 604 private:
605 SnapshotWriter* writer_; 605 SnapshotWriter* writer_;
606 bool as_references_; 606 bool as_references_;
607 607
608 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 608 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
609 }; 609 };
610 610
611 } // namespace dart 611 } // namespace dart
612 612
613 #endif // VM_SNAPSHOT_H_ 613 #endif // VM_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698