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

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

Issue 9104041: Added API Dart_PostCMessage for posting a Dart_CMessage structure (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from asiva@ Created 8 years, 10 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
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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 }; 417 };
418 }; 418 };
419 419
420 420
421 // Reads a message snapshot into C structure. 421 // Reads a message snapshot into C structure.
422 class CMessageReader : public BaseReader { 422 class CMessageReader : public BaseReader {
423 public: 423 public:
424 CMessageReader(const uint8_t* buffer, intptr_t length, ReAlloc alloc); 424 CMessageReader(const uint8_t* buffer, intptr_t length, ReAlloc alloc);
425 ~CMessageReader() { } 425 ~CMessageReader() { }
426 426
427 Dart_CMessage* ReadMessage(); 427 Dart_CObject* ReadMessage();
428 428
429 private: 429 private:
430 // Allocates a Dart_CObject object on the C heap. 430 // Allocates a Dart_CObject object on the C heap.
431 Dart_CObject* AllocateDartCObject(); 431 Dart_CObject* AllocateDartCObject();
432 // Allocates a Dart_CObject object with the specified type on the C heap. 432 // Allocates a Dart_CObject object with the specified type on the C heap.
433 Dart_CObject* AllocateDartCObject(Dart_CObject::Type type); 433 Dart_CObject* AllocateDartCObject(Dart_CObject::Type type);
434 // Allocates a Dart_CObject object for the null object on the C heap. 434 // Allocates a Dart_CObject object for the null object on the C heap.
435 Dart_CObject* AllocateDartCObjectNull(); 435 Dart_CObject* AllocateDartCObjectNull();
436 // Allocates a Dart_CObject object for a boolean object on the C heap. 436 // Allocates a Dart_CObject object for a boolean object on the C heap.
437 Dart_CObject* AllocateDartCObjectBool(bool value); 437 Dart_CObject* AllocateDartCObjectBool(bool value);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 524
525 private: 525 private:
526 WriteStream stream_; 526 WriteStream stream_;
527 527
528 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseWriter); 528 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseWriter);
529 }; 529 };
530 530
531 531
532 class MessageWriter : public BaseWriter { 532 class MessageWriter : public BaseWriter {
533 public: 533 public:
534 MessageWriter(uint8_t** buffer, ReAlloc alloc) : BaseWriter(buffer, alloc) { 534 MessageWriter(uint8_t** buffer, ReAlloc alloc)
535 : BaseWriter(buffer, alloc), object_id_(0) {
536 ASSERT(kDartCObjectTypeMask >= Dart_CObject::kNumberOfTypes);
535 } 537 }
536 ~MessageWriter() { } 538 ~MessageWriter() { }
537 539
538 // Writes a message of integers. 540 // Writes a message of integers.
539 void WriteMessage(intptr_t field_count, intptr_t *data); 541 void WriteMessage(intptr_t field_count, intptr_t *data);
540 542
543 void WriteCMessage(Dart_CObject* object);
544
541 void FinalizeBuffer() { 545 void FinalizeBuffer() {
542 BaseWriter::FinalizeBuffer(Snapshot::kMessage); 546 BaseWriter::FinalizeBuffer(Snapshot::kMessage);
543 } 547 }
544 548
545 private: 549 private:
550 static const intptr_t kDartCObjectTypeBits = 3;
551 static const intptr_t kDartCObjectTypeMask = (1 << kDartCObjectTypeBits) - 1;
552 static const intptr_t kDartCObjectMarkMask = ~kDartCObjectTypeMask;
553 static const intptr_t kDartCObjectMarkOffset = 1;
554
555 void MarkCObject(Dart_CObject* object, intptr_t object_id);
556 void UnmarkCObject(Dart_CObject* object);
557 bool IsCObjectMarked(Dart_CObject* object);
558 intptr_t GetMarkedCObjectMark(Dart_CObject* object);
559 void UnmarkAllCObjects(Dart_CObject* object);
560
561 void WriteSmi(int32_t value);
562 void WriteInlinedHeader(Dart_CObject* object);
563 void WriteCObject(Dart_CObject* object);
564
565 intptr_t object_id_;
566
546 DISALLOW_COPY_AND_ASSIGN(MessageWriter); 567 DISALLOW_COPY_AND_ASSIGN(MessageWriter);
547 }; 568 };
548 569
549 570
550 class SnapshotWriter : public BaseWriter { 571 class SnapshotWriter : public BaseWriter {
551 public: 572 public:
552 SnapshotWriter(Snapshot::Kind kind, uint8_t** buffer, ReAlloc alloc) 573 SnapshotWriter(Snapshot::Kind kind, uint8_t** buffer, ReAlloc alloc)
553 : BaseWriter(buffer, alloc), 574 : BaseWriter(buffer, alloc),
554 kind_(kind), 575 kind_(kind),
555 object_store_(Isolate::Current()->object_store()), 576 object_store_(Isolate::Current()->object_store()),
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 655
635 private: 656 private:
636 SnapshotWriter* writer_; 657 SnapshotWriter* writer_;
637 658
638 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 659 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
639 }; 660 };
640 661
641 } // namespace dart 662 } // namespace dart
642 663
643 #endif // VM_SNAPSHOT_H_ 664 #endif // VM_SNAPSHOT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698