| 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 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 // Use this C structure for reading internal objects in the serialized | 13 // Use this C structure for reading internal objects in the serialized |
| 14 // data. These are objects that we need to process in order to | 14 // data. These are objects that we need to process in order to |
| 15 // generate the Dart_CObject graph but that we don't want to expose in | 15 // generate the Dart_CObject graph but that we don't want to expose in |
| 16 // that graph. | 16 // that graph. |
| 17 // TODO(sjesse): Remove this when message serialization format is | |
| 18 // updated. | |
| 19 struct Dart_CObject_Internal : public Dart_CObject { | 17 struct Dart_CObject_Internal : public Dart_CObject { |
| 20 enum Type { | 18 enum Type { |
| 21 kTypeArguments = Dart_CObject::kNumberOfTypes, | 19 kTypeArguments = Dart_CObject::kNumberOfTypes, |
| 22 kDynamicType, | 20 kDynamicType, |
| 21 kClass, |
| 22 kView, |
| 23 kUninitialized, |
| 23 }; | 24 }; |
| 25 struct Dart_CObject_Internal* cls; |
| 26 union { |
| 27 struct { |
| 28 struct _Dart_CObject* library_url; |
| 29 struct _Dart_CObject* class_name; |
| 30 } as_class; |
| 31 struct { |
| 32 struct _Dart_CObject* buffer; |
| 33 int offset_in_bytes; |
| 34 int length; |
| 35 } as_view; |
| 36 } internal; |
| 24 }; | 37 }; |
| 25 | 38 |
| 26 | 39 |
| 27 // Reads a message snapshot into a C structure. | 40 // Reads a message snapshot into a C structure. |
| 28 class ApiMessageReader : public BaseReader { | 41 class ApiMessageReader : public BaseReader { |
| 29 public: | 42 public: |
| 30 // The allocator passed is used to allocate memory for the C structure used | 43 // The allocator passed is used to allocate memory for the C structure used |
| 31 // to represent the message snapshot. This allocator must keep track of the | 44 // to represent the message snapshot. This allocator must keep track of the |
| 32 // memory allocated as there is no way to run through the resulting C | 45 // memory allocated as there is no way to run through the resulting C |
| 33 // structure and free the individual pieces. Using a zone based allocator is | 46 // structure and free the individual pieces. Using a zone based allocator is |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Allocates a Dart_CObject object for bigint data. | 85 // Allocates a Dart_CObject object for bigint data. |
| 73 Dart_CObject* AllocateDartCObjectBigint(intptr_t length); | 86 Dart_CObject* AllocateDartCObjectBigint(intptr_t length); |
| 74 // Allocates a Dart_CObject object for a double. | 87 // Allocates a Dart_CObject object for a double. |
| 75 Dart_CObject* AllocateDartCObjectDouble(double value); | 88 Dart_CObject* AllocateDartCObjectDouble(double value); |
| 76 // Allocates a Dart_CObject object for string data. | 89 // Allocates a Dart_CObject object for string data. |
| 77 Dart_CObject* AllocateDartCObjectString(intptr_t length); | 90 Dart_CObject* AllocateDartCObjectString(intptr_t length); |
| 78 // Allocates a C Dart_CObject object for byte data. | 91 // Allocates a C Dart_CObject object for byte data. |
| 79 Dart_CObject* AllocateDartCObjectUint8Array(intptr_t length); | 92 Dart_CObject* AllocateDartCObjectUint8Array(intptr_t length); |
| 80 // Allocates a C array of Dart_CObject objects. | 93 // Allocates a C array of Dart_CObject objects. |
| 81 Dart_CObject* AllocateDartCObjectArray(intptr_t length); | 94 Dart_CObject* AllocateDartCObjectArray(intptr_t length); |
| 95 // Allocates a Dart_CObject_Internal object with the specified type. |
| 96 Dart_CObject_Internal* AllocateDartCObjectInternal( |
| 97 Dart_CObject_Internal::Type type); |
| 98 // Allocates a Dart_CObject_Internal object for a class object. |
| 99 Dart_CObject_Internal* AllocateDartCObjectClass(); |
| 82 // Allocates a backwards reference node. | 100 // Allocates a backwards reference node. |
| 83 BackRefNode* AllocateBackRefNode(Dart_CObject* ref, DeserializeState state); | 101 BackRefNode* AllocateBackRefNode(Dart_CObject* ref, DeserializeState state); |
| 84 | 102 |
| 85 void Init(); | 103 void Init(); |
| 86 | 104 |
| 87 intptr_t LookupInternalClass(intptr_t class_header); | 105 intptr_t LookupInternalClass(intptr_t class_header); |
| 88 Dart_CObject* ReadVMIsolateObject(intptr_t value); | 106 Dart_CObject* ReadVMIsolateObject(intptr_t value); |
| 89 Dart_CObject* ReadInternalVMObject(intptr_t class_id, intptr_t object_id); | 107 Dart_CObject* ReadInternalVMObject(intptr_t class_id, intptr_t object_id); |
| 90 Dart_CObject* ReadInlinedObject(intptr_t object_id); | 108 Dart_CObject* ReadInlinedObject(intptr_t object_id); |
| 91 Dart_CObject* ReadObjectImpl(); | 109 Dart_CObject* ReadObjectImpl(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 Dart_CObject** forward_list_; | 182 Dart_CObject** forward_list_; |
| 165 intptr_t forward_list_length_; | 183 intptr_t forward_list_length_; |
| 166 intptr_t forward_id_; | 184 intptr_t forward_id_; |
| 167 | 185 |
| 168 DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); | 186 DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); |
| 169 }; | 187 }; |
| 170 | 188 |
| 171 } // namespace dart | 189 } // namespace dart |
| 172 | 190 |
| 173 #endif // VM_DART_API_MESSAGE_H_ | 191 #endif // VM_DART_API_MESSAGE_H_ |
| OLD | NEW |