OLD | NEW |
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_DART_API_MESSAGE_H_ | 5 #ifndef VM_DART_API_MESSAGE_H_ |
6 #define VM_DART_API_MESSAGE_H_ | 6 #define VM_DART_API_MESSAGE_H_ |
7 | 7 |
8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
9 #include "vm/snapshot.h" | 9 #include "vm/snapshot.h" |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // Allocation of the structures for the decoded message happens | 75 // Allocation of the structures for the decoded message happens |
76 // either in the supplied zone or using the supplied allocation | 76 // either in the supplied zone or using the supplied allocation |
77 // function. | 77 // function. |
78 ReAlloc alloc_; | 78 ReAlloc alloc_; |
79 ApiGrowableArray<Dart_CObject*> backward_references_; | 79 ApiGrowableArray<Dart_CObject*> backward_references_; |
80 | 80 |
81 Dart_CObject type_arguments_marker; | 81 Dart_CObject type_arguments_marker; |
82 Dart_CObject dynamic_type_marker; | 82 Dart_CObject dynamic_type_marker; |
83 }; | 83 }; |
84 | 84 |
| 85 |
| 86 class ApiMessageWriter : public BaseWriter { |
| 87 public: |
| 88 ApiMessageWriter(uint8_t** buffer, ReAlloc alloc) |
| 89 : BaseWriter(buffer, alloc), object_id_(0) { |
| 90 ASSERT(kDartCObjectTypeMask >= Dart_CObject::kNumberOfTypes - 1); |
| 91 } |
| 92 ~ApiMessageWriter() { } |
| 93 |
| 94 // Writes a message of integers. |
| 95 void WriteMessage(intptr_t field_count, intptr_t *data); |
| 96 |
| 97 void WriteCMessage(Dart_CObject* object); |
| 98 |
| 99 void FinalizeBuffer() { |
| 100 BaseWriter::FinalizeBuffer(Snapshot::kMessage); |
| 101 } |
| 102 |
| 103 private: |
| 104 static const intptr_t kDartCObjectTypeBits = 4; |
| 105 static const intptr_t kDartCObjectTypeMask = (1 << kDartCObjectTypeBits) - 1; |
| 106 static const intptr_t kDartCObjectMarkMask = ~kDartCObjectTypeMask; |
| 107 static const intptr_t kDartCObjectMarkOffset = 1; |
| 108 |
| 109 void MarkCObject(Dart_CObject* object, intptr_t object_id); |
| 110 void UnmarkCObject(Dart_CObject* object); |
| 111 bool IsCObjectMarked(Dart_CObject* object); |
| 112 intptr_t GetMarkedCObjectMark(Dart_CObject* object); |
| 113 void UnmarkAllCObjects(Dart_CObject* object); |
| 114 |
| 115 void WriteSmi(int64_t value); |
| 116 void WriteMint(Dart_CObject* object, int64_t value); |
| 117 void WriteInt32(Dart_CObject* object); |
| 118 void WriteInt64(Dart_CObject* object); |
| 119 void WriteInlinedHeader(Dart_CObject* object); |
| 120 void WriteCObject(Dart_CObject* object); |
| 121 |
| 122 intptr_t object_id_; |
| 123 |
| 124 DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); |
| 125 }; |
| 126 |
85 } // namespace dart | 127 } // namespace dart |
86 | 128 |
87 #endif // VM_DART_API_MESSAGE_H_ | 129 #endif // VM_DART_API_MESSAGE_H_ |
OLD | NEW |