| 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 23 matching lines...) Expand all Loading... |
| 34 int offset_in_bytes; | 34 int offset_in_bytes; |
| 35 int length; | 35 int length; |
| 36 } as_view; | 36 } as_view; |
| 37 } internal; | 37 } internal; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 | 40 |
| 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 ApiMessageReader object must be enclosed by an ApiNativeScope. |
| 45 // to represent the message snapshot. This allocator must keep track of the | 45 // Allocation of all C Heap objects is done in the zone associated with |
| 46 // memory allocated as there is no way to run through the resulting C | 46 // the enclosing ApiNativeScope. |
| 47 // structure and free the individual pieces. Using a zone based allocator is | 47 ApiMessageReader(const uint8_t* buffer, intptr_t length); |
| 48 // recommended. | |
| 49 ApiMessageReader(const uint8_t* buffer, | |
| 50 intptr_t length, | |
| 51 ReAlloc alloc); | |
| 52 ~ApiMessageReader() { } | 48 ~ApiMessageReader() { } |
| 53 | 49 |
| 54 Dart_CObject* ReadMessage(); | 50 Dart_CObject* ReadMessage(); |
| 55 | 51 |
| 56 private: | 52 private: |
| 57 class BackRefNode { | 53 class BackRefNode { |
| 58 public: | 54 public: |
| 59 BackRefNode(Dart_CObject* reference, DeserializeState state) | 55 BackRefNode(Dart_CObject* reference, DeserializeState state) |
| 60 : reference_(reference), state_(state) {} | 56 : reference_(reference), state_(state) {} |
| 61 Dart_CObject* reference() const { return reference_; } | 57 Dart_CObject* reference() const { return reference_; } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 128 } |
| 133 | 129 |
| 134 RawObject* VmIsolateSnapshotObject(intptr_t index) const { | 130 RawObject* VmIsolateSnapshotObject(intptr_t index) const { |
| 135 return Object::vm_isolate_snapshot_object_table().At(index); | 131 return Object::vm_isolate_snapshot_object_table().At(index); |
| 136 } | 132 } |
| 137 | 133 |
| 138 Dart_CObject* CreateDartCObjectString(RawObject* raw); | 134 Dart_CObject* CreateDartCObjectString(RawObject* raw); |
| 139 Dart_CObject* GetCanonicalMintObject(Dart_CObject_Type type, | 135 Dart_CObject* GetCanonicalMintObject(Dart_CObject_Type type, |
| 140 int64_t value64); | 136 int64_t value64); |
| 141 | 137 |
| 142 // Allocation of the structures for the decoded message happens | 138 uint8_t* allocator(intptr_t size) { |
| 143 // either in the supplied zone or using the supplied allocation | 139 return zone_->Realloc<uint8_t>(NULL, 0, size); |
| 144 // function. | 140 } |
| 145 ReAlloc alloc_; | 141 |
| 142 Zone* zone_; // Zone in which C heap objects are allocated. |
| 146 ApiGrowableArray<BackRefNode*> backward_references_; | 143 ApiGrowableArray<BackRefNode*> backward_references_; |
| 147 ApiGrowableArray<Dart_CObject*> vm_isolate_references_; | 144 ApiGrowableArray<Dart_CObject*> vm_isolate_references_; |
| 148 Dart_CObject** vm_symbol_references_; | 145 Dart_CObject** vm_symbol_references_; |
| 149 | 146 |
| 150 Dart_CObject type_arguments_marker; | 147 Dart_CObject type_arguments_marker; |
| 151 Dart_CObject dynamic_type_marker; | 148 Dart_CObject dynamic_type_marker; |
| 152 static _Dart_CObject* singleton_uint32_typed_data_; | 149 static _Dart_CObject* singleton_uint32_typed_data_; |
| 153 }; | 150 }; |
| 154 | 151 |
| 155 | 152 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 Dart_CObject** forward_list_; | 197 Dart_CObject** forward_list_; |
| 201 intptr_t forward_list_length_; | 198 intptr_t forward_list_length_; |
| 202 intptr_t forward_id_; | 199 intptr_t forward_id_; |
| 203 | 200 |
| 204 DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); | 201 DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); |
| 205 }; | 202 }; |
| 206 | 203 |
| 207 } // namespace dart | 204 } // namespace dart |
| 208 | 205 |
| 209 #endif // VM_DART_API_MESSAGE_H_ | 206 #endif // VM_DART_API_MESSAGE_H_ |
| OLD | NEW |