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 "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
10 #include "vm/snapshot.h" | 10 #include "vm/snapshot.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // Reads a message snapshot into a C structure. | 41 // Reads a message snapshot into a C structure. |
42 class ApiMessageReader : public BaseReader { | 42 class ApiMessageReader : public BaseReader { |
43 public: | 43 public: |
44 // The allocator passed is used to allocate memory for the C structure used | 44 // The allocator passed is used to allocate memory for the C structure used |
45 // to represent the message snapshot. This allocator must keep track of the | 45 // to represent the message snapshot. This allocator must keep track of the |
46 // memory allocated as there is no way to run through the resulting C | 46 // memory allocated as there is no way to run through the resulting C |
47 // structure and free the individual pieces. Using a zone based allocator is | 47 // structure and free the individual pieces. Using a zone based allocator is |
48 // recommended. | 48 // recommended. |
49 ApiMessageReader(const uint8_t* buffer, | 49 ApiMessageReader(const uint8_t* buffer, |
50 intptr_t length, | 50 intptr_t length, |
51 ReAlloc alloc, | 51 ReAlloc alloc); |
52 bool use_vm_isolate_snapshot = true); | |
53 ~ApiMessageReader() { } | 52 ~ApiMessageReader() { } |
54 | 53 |
55 Dart_CObject* ReadMessage(); | 54 Dart_CObject* ReadMessage(); |
56 | 55 |
57 private: | 56 private: |
58 class BackRefNode { | 57 class BackRefNode { |
59 public: | 58 public: |
60 BackRefNode(Dart_CObject* reference, DeserializeState state) | 59 BackRefNode(Dart_CObject* reference, DeserializeState state) |
61 : reference_(reference), state_(state) {} | 60 : reference_(reference), state_(state) {} |
62 Dart_CObject* reference() const { return reference_; } | 61 Dart_CObject* reference() const { return reference_; } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 Dart_CObject* GetCanonicalMintObject(Dart_CObject_Type type, | 139 Dart_CObject* GetCanonicalMintObject(Dart_CObject_Type type, |
141 int64_t value64); | 140 int64_t value64); |
142 | 141 |
143 // Allocation of the structures for the decoded message happens | 142 // Allocation of the structures for the decoded message happens |
144 // either in the supplied zone or using the supplied allocation | 143 // either in the supplied zone or using the supplied allocation |
145 // function. | 144 // function. |
146 ReAlloc alloc_; | 145 ReAlloc alloc_; |
147 ApiGrowableArray<BackRefNode*> backward_references_; | 146 ApiGrowableArray<BackRefNode*> backward_references_; |
148 ApiGrowableArray<Dart_CObject*> vm_isolate_references_; | 147 ApiGrowableArray<Dart_CObject*> vm_isolate_references_; |
149 Dart_CObject** vm_symbol_references_; | 148 Dart_CObject** vm_symbol_references_; |
150 intptr_t max_vm_isolate_object_id_; | |
151 | 149 |
152 Dart_CObject type_arguments_marker; | 150 Dart_CObject type_arguments_marker; |
153 Dart_CObject dynamic_type_marker; | 151 Dart_CObject dynamic_type_marker; |
154 static _Dart_CObject* singleton_uint32_typed_data_; | 152 static _Dart_CObject* singleton_uint32_typed_data_; |
155 }; | 153 }; |
156 | 154 |
157 | 155 |
158 class ApiMessageWriter : public BaseWriter { | 156 class ApiMessageWriter : public BaseWriter { |
159 public: | 157 public: |
160 static const intptr_t kInitialSize = 512; | 158 static const intptr_t kInitialSize = 512; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 void WriteInlinedHeader(Dart_CObject* object); | 193 void WriteInlinedHeader(Dart_CObject* object); |
196 bool WriteCObject(Dart_CObject* object); | 194 bool WriteCObject(Dart_CObject* object); |
197 bool WriteCObjectRef(Dart_CObject* object); | 195 bool WriteCObjectRef(Dart_CObject* object); |
198 bool WriteForwardedCObject(Dart_CObject* object); | 196 bool WriteForwardedCObject(Dart_CObject* object); |
199 bool WriteCObjectInlined(Dart_CObject* object, Dart_CObject_Type type); | 197 bool WriteCObjectInlined(Dart_CObject* object, Dart_CObject_Type type); |
200 | 198 |
201 intptr_t object_id_; | 199 intptr_t object_id_; |
202 Dart_CObject** forward_list_; | 200 Dart_CObject** forward_list_; |
203 intptr_t forward_list_length_; | 201 intptr_t forward_list_length_; |
204 intptr_t forward_id_; | 202 intptr_t forward_id_; |
205 intptr_t max_vm_isolate_object_id_; | |
206 | 203 |
207 DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); | 204 DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); |
208 }; | 205 }; |
209 | 206 |
210 } // namespace dart | 207 } // namespace dart |
211 | 208 |
212 #endif // VM_DART_API_MESSAGE_H_ | 209 #endif // VM_DART_API_MESSAGE_H_ |
OLD | NEW |