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 #include "vm/dart_api_message.h" | 5 #include "vm/dart_api_message.h" |
6 #include "vm/object.h" | 6 #include "vm/object.h" |
7 #include "vm/snapshot_ids.h" | 7 #include "vm/snapshot_ids.h" |
8 #include "vm/symbols.h" | 8 #include "vm/symbols.h" |
9 #include "vm/unicode.h" | 9 #include "vm/unicode.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 static const int kNumInitialReferences = 4; | 13 static const int kNumInitialReferences = 4; |
14 | 14 |
15 ApiMessageReader::ApiMessageReader(const uint8_t* buffer, intptr_t length) | 15 ApiMessageReader::ApiMessageReader(const uint8_t* buffer, intptr_t length) |
16 : BaseReader(buffer, length), | 16 : BaseReader(buffer, length), |
17 zone_(NULL), | 17 zone_(NULL), |
18 backward_references_(kNumInitialReferences), | 18 backward_references_(kNumInitialReferences), |
19 vm_isolate_references_(kNumInitialReferences), | 19 vm_isolate_references_(kNumInitialReferences), |
20 vm_symbol_references_(NULL) { | 20 vm_symbol_references_(NULL) {} |
21 } | |
22 | 21 |
23 | 22 |
24 ApiMessageReader::ApiMessageReader(Message* msg) | 23 ApiMessageReader::ApiMessageReader(Message* msg) |
25 : BaseReader(msg->IsRaw() ? reinterpret_cast<uint8_t*>(msg->raw_obj()) | 24 : BaseReader(msg->IsRaw() ? reinterpret_cast<uint8_t*>(msg->raw_obj()) |
26 : msg->data(), | 25 : msg->data(), |
27 msg->len()), | 26 msg->len()), |
28 zone_(NULL), | 27 zone_(NULL), |
29 backward_references_(kNumInitialReferences), | 28 backward_references_(kNumInitialReferences), |
30 vm_isolate_references_(kNumInitialReferences), | 29 vm_isolate_references_(kNumInitialReferences), |
31 vm_symbol_references_(NULL) { | 30 vm_symbol_references_(NULL) {} |
32 } | |
33 | 31 |
34 | 32 |
35 void ApiMessageReader::Init() { | 33 void ApiMessageReader::Init() { |
36 // We need to have an enclosing ApiNativeScope. | 34 // We need to have an enclosing ApiNativeScope. |
37 ASSERT(ApiNativeScope::Current() != NULL); | 35 ASSERT(ApiNativeScope::Current() != NULL); |
38 zone_ = ApiNativeScope::Current()->zone(); | 36 zone_ = ApiNativeScope::Current()->zone(); |
39 ASSERT(zone_ != NULL); | 37 ASSERT(zone_ != NULL); |
40 | 38 |
41 // Initialize marker objects used to handle Lists. | 39 // Initialize marker objects used to handle Lists. |
42 // TODO(sjesse): Remove this when message serialization format is | 40 // TODO(sjesse): Remove this when message serialization format is |
(...skipping 10 matching lines...) Expand all Loading... |
53 Dart_CObject* ApiMessageReader::ReadMessage() { | 51 Dart_CObject* ApiMessageReader::ReadMessage() { |
54 Init(); | 52 Init(); |
55 if (PendingBytes() > 0) { | 53 if (PendingBytes() > 0) { |
56 // Read the object out of the message. | 54 // Read the object out of the message. |
57 return ReadObject(); | 55 return ReadObject(); |
58 } else { | 56 } else { |
59 const RawObject* raw_obj = | 57 const RawObject* raw_obj = |
60 reinterpret_cast<const RawObject*>(CurrentBufferAddress()); | 58 reinterpret_cast<const RawObject*>(CurrentBufferAddress()); |
61 ASSERT(ApiObjectConverter::CanConvert(raw_obj)); | 59 ASSERT(ApiObjectConverter::CanConvert(raw_obj)); |
62 Dart_CObject* cobj = | 60 Dart_CObject* cobj = |
63 reinterpret_cast<Dart_CObject*>(allocator(sizeof(Dart_CObject))); | 61 reinterpret_cast<Dart_CObject*>(allocator(sizeof(Dart_CObject))); |
64 ApiObjectConverter::Convert(raw_obj, cobj); | 62 ApiObjectConverter::Convert(raw_obj, cobj); |
65 return cobj; | 63 return cobj; |
66 } | 64 } |
67 } | 65 } |
68 | 66 |
69 | 67 |
70 intptr_t ApiMessageReader::LookupInternalClass(intptr_t class_header) { | 68 intptr_t ApiMessageReader::LookupInternalClass(intptr_t class_header) { |
71 if (IsVMIsolateObject(class_header)) { | 69 if (IsVMIsolateObject(class_header)) { |
72 return GetVMIsolateObjectId(class_header); | 70 return GetVMIsolateObjectId(class_header); |
73 } | 71 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 Dart_CObject* value = AllocateDartCObject(Dart_CObject_kDouble); | 134 Dart_CObject* value = AllocateDartCObject(Dart_CObject_kDouble); |
137 value->value.as_double = val; | 135 value->value.as_double = val; |
138 return value; | 136 return value; |
139 } | 137 } |
140 | 138 |
141 | 139 |
142 Dart_CObject* ApiMessageReader::AllocateDartCObjectString(intptr_t length) { | 140 Dart_CObject* ApiMessageReader::AllocateDartCObjectString(intptr_t length) { |
143 // Allocate a Dart_CObject structure followed by an array of chars | 141 // Allocate a Dart_CObject structure followed by an array of chars |
144 // for the string content. The pointer to the string content is set | 142 // for the string content. The pointer to the string content is set |
145 // up to this area. | 143 // up to this area. |
146 Dart_CObject* value = | 144 Dart_CObject* value = reinterpret_cast<Dart_CObject*>( |
147 reinterpret_cast<Dart_CObject*>( | 145 allocator(sizeof(Dart_CObject) + length + 1)); |
148 allocator(sizeof(Dart_CObject) + length + 1)); | |
149 ASSERT(value != NULL); | 146 ASSERT(value != NULL); |
150 value->value.as_string = reinterpret_cast<char*>(value) + sizeof(*value); | 147 value->value.as_string = reinterpret_cast<char*>(value) + sizeof(*value); |
151 value->type = Dart_CObject_kString; | 148 value->type = Dart_CObject_kString; |
152 return value; | 149 return value; |
153 } | 150 } |
154 | 151 |
155 | 152 |
156 static int GetTypedDataSizeInBytes(Dart_TypedData_Type type) { | 153 static int GetTypedDataSizeInBytes(Dart_TypedData_Type type) { |
157 switch (type) { | 154 switch (type) { |
158 case Dart_TypedData_kInt8: | 155 case Dart_TypedData_kInt8: |
(...skipping 13 matching lines...) Expand all Loading... |
172 return 8; | 169 return 8; |
173 default: | 170 default: |
174 break; | 171 break; |
175 } | 172 } |
176 UNREACHABLE(); | 173 UNREACHABLE(); |
177 return -1; | 174 return -1; |
178 } | 175 } |
179 | 176 |
180 | 177 |
181 Dart_CObject* ApiMessageReader::AllocateDartCObjectTypedData( | 178 Dart_CObject* ApiMessageReader::AllocateDartCObjectTypedData( |
182 Dart_TypedData_Type type, intptr_t length) { | 179 Dart_TypedData_Type type, |
| 180 intptr_t length) { |
183 // Allocate a Dart_CObject structure followed by an array of bytes | 181 // Allocate a Dart_CObject structure followed by an array of bytes |
184 // for the byte array content. The pointer to the byte array content | 182 // for the byte array content. The pointer to the byte array content |
185 // is set up to this area. | 183 // is set up to this area. |
186 intptr_t length_in_bytes = GetTypedDataSizeInBytes(type) * length; | 184 intptr_t length_in_bytes = GetTypedDataSizeInBytes(type) * length; |
187 Dart_CObject* value = | 185 Dart_CObject* value = reinterpret_cast<Dart_CObject*>( |
188 reinterpret_cast<Dart_CObject*>( | 186 allocator(sizeof(Dart_CObject) + length_in_bytes)); |
189 allocator(sizeof(Dart_CObject) + length_in_bytes)); | |
190 ASSERT(value != NULL); | 187 ASSERT(value != NULL); |
191 value->type = Dart_CObject_kTypedData; | 188 value->type = Dart_CObject_kTypedData; |
192 value->value.as_typed_data.type = type; | 189 value->value.as_typed_data.type = type; |
193 value->value.as_typed_data.length = length_in_bytes; | 190 value->value.as_typed_data.length = length_in_bytes; |
194 if (length > 0) { | 191 if (length > 0) { |
195 value->value.as_typed_data.values = | 192 value->value.as_typed_data.values = |
196 reinterpret_cast<uint8_t*>(value) + sizeof(*value); | 193 reinterpret_cast<uint8_t*>(value) + sizeof(*value); |
197 } else { | 194 } else { |
198 value->value.as_typed_data.values = NULL; | 195 value->value.as_typed_data.values = NULL; |
199 } | 196 } |
200 return value; | 197 return value; |
201 } | 198 } |
202 | 199 |
203 | 200 |
204 Dart_CObject* ApiMessageReader::AllocateDartCObjectArray(intptr_t length) { | 201 Dart_CObject* ApiMessageReader::AllocateDartCObjectArray(intptr_t length) { |
205 // Allocate a Dart_CObject structure followed by an array of | 202 // Allocate a Dart_CObject structure followed by an array of |
206 // pointers to Dart_CObject structures. The pointer to the array | 203 // pointers to Dart_CObject structures. The pointer to the array |
207 // content is set up to this area. | 204 // content is set up to this area. |
208 Dart_CObject* value = | 205 Dart_CObject* value = reinterpret_cast<Dart_CObject*>( |
209 reinterpret_cast<Dart_CObject*>( | 206 allocator(sizeof(Dart_CObject) + length * sizeof(value))); |
210 allocator(sizeof(Dart_CObject) + length * sizeof(value))); | |
211 ASSERT(value != NULL); | 207 ASSERT(value != NULL); |
212 value->type = Dart_CObject_kArray; | 208 value->type = Dart_CObject_kArray; |
213 value->value.as_array.length = length; | 209 value->value.as_array.length = length; |
214 if (length > 0) { | 210 if (length > 0) { |
215 value->value.as_array.values = reinterpret_cast<Dart_CObject**>(value + 1); | 211 value->value.as_array.values = reinterpret_cast<Dart_CObject**>(value + 1); |
216 } else { | 212 } else { |
217 value->value.as_array.values = NULL; | 213 value->value.as_array.values = NULL; |
218 } | 214 } |
219 return value; | 215 return value; |
220 } | 216 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 250 |
255 default: | 251 default: |
256 UNREACHABLE(); | 252 UNREACHABLE(); |
257 return NULL; | 253 return NULL; |
258 } | 254 } |
259 } | 255 } |
260 | 256 |
261 | 257 |
262 Dart_CObject_Internal* ApiMessageReader::AllocateDartCObjectInternal( | 258 Dart_CObject_Internal* ApiMessageReader::AllocateDartCObjectInternal( |
263 Dart_CObject_Internal::Type type) { | 259 Dart_CObject_Internal::Type type) { |
264 Dart_CObject_Internal* value = | 260 Dart_CObject_Internal* value = reinterpret_cast<Dart_CObject_Internal*>( |
265 reinterpret_cast<Dart_CObject_Internal*>( | 261 allocator(sizeof(Dart_CObject_Internal))); |
266 allocator(sizeof(Dart_CObject_Internal))); | |
267 ASSERT(value != NULL); | 262 ASSERT(value != NULL); |
268 value->type = static_cast<Dart_CObject_Type>(type); | 263 value->type = static_cast<Dart_CObject_Type>(type); |
269 return value; | 264 return value; |
270 } | 265 } |
271 | 266 |
272 | 267 |
273 Dart_CObject_Internal* ApiMessageReader::AllocateDartCObjectClass() { | 268 Dart_CObject_Internal* ApiMessageReader::AllocateDartCObjectClass() { |
274 return AllocateDartCObjectInternal(Dart_CObject_Internal::kClass); | 269 return AllocateDartCObjectInternal(Dart_CObject_Internal::kClass); |
275 } | 270 } |
276 | 271 |
277 | 272 |
278 ApiMessageReader::BackRefNode* ApiMessageReader::AllocateBackRefNode( | 273 ApiMessageReader::BackRefNode* ApiMessageReader::AllocateBackRefNode( |
279 Dart_CObject* reference, | 274 Dart_CObject* reference, |
280 DeserializeState state) { | 275 DeserializeState state) { |
281 BackRefNode* value = | 276 BackRefNode* value = |
282 reinterpret_cast<BackRefNode*>(allocator(sizeof(BackRefNode))); | 277 reinterpret_cast<BackRefNode*>(allocator(sizeof(BackRefNode))); |
283 value->set_reference(reference); | 278 value->set_reference(reference); |
284 value->set_state(state); | 279 value->set_state(state); |
285 return value; | 280 return value; |
286 } | 281 } |
287 | 282 |
288 | 283 |
289 static Dart_TypedData_Type GetTypedDataTypeFromView( | 284 static Dart_TypedData_Type GetTypedDataTypeFromView( |
290 Dart_CObject_Internal* object, | 285 Dart_CObject_Internal* object, |
291 char* class_name) { | 286 char* class_name) { |
292 struct { | 287 struct { |
293 const char* name; | 288 const char* name; |
294 Dart_TypedData_Type type; | 289 Dart_TypedData_Type type; |
295 } view_class_names[] = { | 290 } view_class_names[] = { |
296 { "_Int8ArrayView", Dart_TypedData_kInt8 }, | 291 {"_Int8ArrayView", Dart_TypedData_kInt8}, |
297 { "_Uint8ArrayView", Dart_TypedData_kUint8 }, | 292 {"_Uint8ArrayView", Dart_TypedData_kUint8}, |
298 { "_Uint8ClampedArrayView", Dart_TypedData_kUint8Clamped }, | 293 {"_Uint8ClampedArrayView", Dart_TypedData_kUint8Clamped}, |
299 { "_Int16ArrayView", Dart_TypedData_kInt16 }, | 294 {"_Int16ArrayView", Dart_TypedData_kInt16}, |
300 { "_Uint16ArrayView", Dart_TypedData_kUint16 }, | 295 {"_Uint16ArrayView", Dart_TypedData_kUint16}, |
301 { "_Int32ArrayView", Dart_TypedData_kInt32 }, | 296 {"_Int32ArrayView", Dart_TypedData_kInt32}, |
302 { "_Uint32ArrayView", Dart_TypedData_kUint32 }, | 297 {"_Uint32ArrayView", Dart_TypedData_kUint32}, |
303 { "_Int64ArrayView", Dart_TypedData_kInt64 }, | 298 {"_Int64ArrayView", Dart_TypedData_kInt64}, |
304 { "_Uint64ArrayView", Dart_TypedData_kUint64 }, | 299 {"_Uint64ArrayView", Dart_TypedData_kUint64}, |
305 { "_ByteDataView", Dart_TypedData_kUint8 }, | 300 {"_ByteDataView", Dart_TypedData_kUint8}, |
306 { "_Float32ArrayView", Dart_TypedData_kFloat32 }, | 301 {"_Float32ArrayView", Dart_TypedData_kFloat32}, |
307 { "_Float64ArrayView", Dart_TypedData_kFloat64 }, | 302 {"_Float64ArrayView", Dart_TypedData_kFloat64}, |
308 { NULL, Dart_TypedData_kInvalid }, | 303 {NULL, Dart_TypedData_kInvalid}, |
309 }; | 304 }; |
310 | 305 |
311 int i = 0; | 306 int i = 0; |
312 while (view_class_names[i].name != NULL) { | 307 while (view_class_names[i].name != NULL) { |
313 if (strncmp(view_class_names[i].name, | 308 if (strncmp(view_class_names[i].name, class_name, |
314 class_name, | |
315 strlen(view_class_names[i].name)) == 0) { | 309 strlen(view_class_names[i].name)) == 0) { |
316 return view_class_names[i].type; | 310 return view_class_names[i].type; |
317 } | 311 } |
318 i++; | 312 i++; |
319 } | 313 } |
320 return Dart_TypedData_kInvalid; | 314 return Dart_TypedData_kInvalid; |
321 } | 315 } |
322 | 316 |
323 | 317 |
324 Dart_CObject* ApiMessageReader::ReadInlinedObject(intptr_t object_id) { | 318 Dart_CObject* ApiMessageReader::ReadInlinedObject(intptr_t object_id) { |
(...skipping 10 matching lines...) Expand all Loading... |
335 reinterpret_cast<Dart_CObject_Internal*>(GetBackRef(object_id)); | 329 reinterpret_cast<Dart_CObject_Internal*>(GetBackRef(object_id)); |
336 if (object == NULL) { | 330 if (object == NULL) { |
337 object = | 331 object = |
338 AllocateDartCObjectInternal(Dart_CObject_Internal::kUninitialized); | 332 AllocateDartCObjectInternal(Dart_CObject_Internal::kUninitialized); |
339 AddBackRef(object_id, object, kIsDeserialized); | 333 AddBackRef(object_id, object, kIsDeserialized); |
340 // Read class of object. | 334 // Read class of object. |
341 object->cls = reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl()); | 335 object->cls = reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl()); |
342 ASSERT(object->cls->type == | 336 ASSERT(object->cls->type == |
343 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kClass)); | 337 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kClass)); |
344 } | 338 } |
345 ASSERT(object->type == | 339 ASSERT(object->type == static_cast<Dart_CObject_Type>( |
346 static_cast<Dart_CObject_Type>( | 340 Dart_CObject_Internal::kUninitialized)); |
347 Dart_CObject_Internal::kUninitialized)); | |
348 | 341 |
349 char* library_uri = | 342 char* library_uri = |
350 object->cls->internal.as_class.library_url->value.as_string; | 343 object->cls->internal.as_class.library_url->value.as_string; |
351 char* class_name = | 344 char* class_name = |
352 object->cls->internal.as_class.class_name->value.as_string; | 345 object->cls->internal.as_class.class_name->value.as_string; |
353 | 346 |
354 // Handle typed data views. | 347 // Handle typed data views. |
355 if (strcmp("dart:typed_data", library_uri) == 0) { | 348 if (strcmp("dart:typed_data", library_uri) == 0) { |
356 Dart_TypedData_Type type = GetTypedDataTypeFromView(object, class_name); | 349 Dart_TypedData_Type type = GetTypedDataTypeFromView(object, class_name); |
357 if (type != Dart_TypedData_kInvalid) { | 350 if (type != Dart_TypedData_kInvalid) { |
358 object->type = | 351 object->type = |
359 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kView); | 352 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kView); |
360 Dart_CObject_Internal* cls = | 353 Dart_CObject_Internal* cls = |
361 reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl()); | 354 reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl()); |
362 ASSERT(cls == object->cls); | 355 ASSERT(cls == object->cls); |
363 object->internal.as_view.buffer = ReadObjectImpl(); | 356 object->internal.as_view.buffer = ReadObjectImpl(); |
364 object->internal.as_view.offset_in_bytes = ReadSmiValue(); | 357 object->internal.as_view.offset_in_bytes = ReadSmiValue(); |
365 object->internal.as_view.length = ReadSmiValue(); | 358 object->internal.as_view.length = ReadSmiValue(); |
366 | 359 |
367 // The buffer is fully read now as typed data objects are | 360 // The buffer is fully read now as typed data objects are |
368 // serialized in-line. | 361 // serialized in-line. |
369 Dart_CObject* buffer = object->internal.as_view.buffer; | 362 Dart_CObject* buffer = object->internal.as_view.buffer; |
370 ASSERT(buffer->type == Dart_CObject_kTypedData); | 363 ASSERT(buffer->type == Dart_CObject_kTypedData); |
371 | 364 |
372 // Now turn the view into a byte array. | 365 // Now turn the view into a byte array. |
373 object->type = Dart_CObject_kTypedData; | 366 object->type = Dart_CObject_kTypedData; |
374 object->value.as_typed_data.type = type; | 367 object->value.as_typed_data.type = type; |
375 object->value.as_typed_data.length = | 368 object->value.as_typed_data.length = |
376 object->internal.as_view.length * | 369 object->internal.as_view.length * GetTypedDataSizeInBytes(type); |
377 GetTypedDataSizeInBytes(type); | |
378 object->value.as_typed_data.values = | 370 object->value.as_typed_data.values = |
379 buffer->value.as_typed_data.values + | 371 buffer->value.as_typed_data.values + |
380 object->internal.as_view.offset_in_bytes; | 372 object->internal.as_view.offset_in_bytes; |
381 } else { | 373 } else { |
382 // TODO(sgjesse): Handle other instances. Currently this will | 374 // TODO(sgjesse): Handle other instances. Currently this will |
383 // skew the reading as the fields of the instance is not read. | 375 // skew the reading as the fields of the instance is not read. |
384 } | 376 } |
385 } else { | 377 } else { |
386 // TODO(sgjesse): Handle other instances. Currently this will | 378 // TODO(sgjesse): Handle other instances. Currently this will |
387 // skew the reading as the fields of the instance is not read. | 379 // skew the reading as the fields of the instance is not read. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 intptr_t symbol_id = object_id - kMaxPredefinedObjectIds; | 413 intptr_t symbol_id = object_id - kMaxPredefinedObjectIds; |
422 Dart_CObject* object; | 414 Dart_CObject* object; |
423 if (vm_symbol_references_ != NULL && | 415 if (vm_symbol_references_ != NULL && |
424 (object = vm_symbol_references_[symbol_id]) != NULL) { | 416 (object = vm_symbol_references_[symbol_id]) != NULL) { |
425 return object; | 417 return object; |
426 } | 418 } |
427 | 419 |
428 if (vm_symbol_references_ == NULL) { | 420 if (vm_symbol_references_ == NULL) { |
429 intptr_t size = | 421 intptr_t size = |
430 (sizeof(*vm_symbol_references_) * Symbols::kMaxPredefinedId); | 422 (sizeof(*vm_symbol_references_) * Symbols::kMaxPredefinedId); |
431 vm_symbol_references_ = | 423 vm_symbol_references_ = reinterpret_cast<Dart_CObject**>(allocator(size)); |
432 reinterpret_cast<Dart_CObject**>(allocator(size)); | |
433 memset(vm_symbol_references_, 0, size); | 424 memset(vm_symbol_references_, 0, size); |
434 } | 425 } |
435 | 426 |
436 object = CreateDartCObjectString(Symbols::GetPredefinedSymbol(object_id)); | 427 object = CreateDartCObjectString(Symbols::GetPredefinedSymbol(object_id)); |
437 ASSERT(vm_symbol_references_[symbol_id] == NULL); | 428 ASSERT(vm_symbol_references_[symbol_id] == NULL); |
438 vm_symbol_references_[symbol_id] = object; | 429 vm_symbol_references_[symbol_id] = object; |
439 return object; | 430 return object; |
440 } | 431 } |
441 | 432 |
442 | 433 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 AddBackRef(object_id, object, kIsDeserialized); | 612 AddBackRef(object_id, object, kIsDeserialized); |
622 Dart_CObject* neg_obj = ReadObjectImpl(); | 613 Dart_CObject* neg_obj = ReadObjectImpl(); |
623 ASSERT(neg_obj->type == Dart_CObject_kBool); | 614 ASSERT(neg_obj->type == Dart_CObject_kBool); |
624 const bool neg = neg_obj->value.as_bool; | 615 const bool neg = neg_obj->value.as_bool; |
625 Dart_CObject* used_obj = ReadObjectImpl(); | 616 Dart_CObject* used_obj = ReadObjectImpl(); |
626 ASSERT(used_obj->type == Dart_CObject_kInt32); | 617 ASSERT(used_obj->type == Dart_CObject_kInt32); |
627 const intptr_t used = used_obj->value.as_int32; | 618 const intptr_t used = used_obj->value.as_int32; |
628 Dart_CObject* digits = ReadObjectImpl(); | 619 Dart_CObject* digits = ReadObjectImpl(); |
629 ASSERT(digits->type == Dart_CObject_kTypedData); | 620 ASSERT(digits->type == Dart_CObject_kTypedData); |
630 ASSERT(digits->value.as_typed_data.type == Dart_TypedData_kUint32); | 621 ASSERT(digits->value.as_typed_data.type == Dart_TypedData_kUint32); |
631 ASSERT(digits->value.as_typed_data.length >= 4*used); | 622 ASSERT(digits->value.as_typed_data.length >= 4 * used); |
632 // Update the bigint object. | 623 // Update the bigint object. |
633 object->value.as_bigint.neg = neg; | 624 object->value.as_bigint.neg = neg; |
634 object->value.as_bigint.used = used; | 625 object->value.as_bigint.used = used; |
635 object->value.as_bigint.digits = digits; | 626 object->value.as_bigint.digits = digits; |
636 return object; | 627 return object; |
637 } | 628 } |
638 case kDoubleCid: { | 629 case kDoubleCid: { |
639 // Doubles are handled specially when being sent as part of message | 630 // Doubles are handled specially when being sent as part of message |
640 // snapshots. | 631 // snapshots. |
641 UNREACHABLE(); | 632 UNREACHABLE(); |
642 } | 633 } |
643 case kOneByteStringCid: { | 634 case kOneByteStringCid: { |
644 intptr_t len = ReadSmiValue(); | 635 intptr_t len = ReadSmiValue(); |
645 uint8_t *latin1 = | 636 uint8_t* latin1 = |
646 reinterpret_cast<uint8_t*>(allocator(len * sizeof(uint8_t))); | 637 reinterpret_cast<uint8_t*>(allocator(len * sizeof(uint8_t))); |
647 intptr_t utf8_len = 0; | 638 intptr_t utf8_len = 0; |
648 for (intptr_t i = 0; i < len; i++) { | 639 for (intptr_t i = 0; i < len; i++) { |
649 latin1[i] = Read<uint8_t>(); | 640 latin1[i] = Read<uint8_t>(); |
650 utf8_len += Utf8::Length(latin1[i]); | 641 utf8_len += Utf8::Length(latin1[i]); |
651 } | 642 } |
652 Dart_CObject* object = AllocateDartCObjectString(utf8_len); | 643 Dart_CObject* object = AllocateDartCObjectString(utf8_len); |
653 AddBackRef(object_id, object, kIsDeserialized); | 644 AddBackRef(object_id, object, kIsDeserialized); |
654 char* p = object->value.as_string; | 645 char* p = object->value.as_string; |
655 for (intptr_t i = 0; i < len; i++) { | 646 for (intptr_t i = 0; i < len; i++) { |
656 p += Utf8::Encode(latin1[i], p); | 647 p += Utf8::Encode(latin1[i], p); |
657 } | 648 } |
658 *p = '\0'; | 649 *p = '\0'; |
659 ASSERT(p == (object->value.as_string + utf8_len)); | 650 ASSERT(p == (object->value.as_string + utf8_len)); |
660 return object; | 651 return object; |
661 } | 652 } |
662 case kTwoByteStringCid: { | 653 case kTwoByteStringCid: { |
663 intptr_t len = ReadSmiValue(); | 654 intptr_t len = ReadSmiValue(); |
664 uint16_t *utf16 = reinterpret_cast<uint16_t*>( | 655 uint16_t* utf16 = |
665 allocator(len * sizeof(uint16_t))); | 656 reinterpret_cast<uint16_t*>(allocator(len * sizeof(uint16_t))); |
666 intptr_t utf8_len = 0; | 657 intptr_t utf8_len = 0; |
667 // Read all the UTF-16 code units. | 658 // Read all the UTF-16 code units. |
668 for (intptr_t i = 0; i < len; i++) { | 659 for (intptr_t i = 0; i < len; i++) { |
669 utf16[i] = Read<uint16_t>(); | 660 utf16[i] = Read<uint16_t>(); |
670 } | 661 } |
671 // Calculate the UTF-8 length and check if the string can be | 662 // Calculate the UTF-8 length and check if the string can be |
672 // UTF-8 encoded. | 663 // UTF-8 encoded. |
673 bool valid = true; | 664 bool valid = true; |
674 intptr_t i = 0; | 665 intptr_t i = 0; |
675 while (i < len && valid) { | 666 while (i < len && valid) { |
(...skipping 26 matching lines...) Expand all Loading... |
702 } | 693 } |
703 case kCapabilityCid: { | 694 case kCapabilityCid: { |
704 int64_t id = Read<int64_t>(); | 695 int64_t id = Read<int64_t>(); |
705 Dart_CObject* object = AllocateDartCObject(Dart_CObject_kCapability); | 696 Dart_CObject* object = AllocateDartCObject(Dart_CObject_kCapability); |
706 object->value.as_capability.id = id; | 697 object->value.as_capability.id = id; |
707 AddBackRef(object_id, object, kIsDeserialized); | 698 AddBackRef(object_id, object, kIsDeserialized); |
708 return object; | 699 return object; |
709 } | 700 } |
710 | 701 |
711 #define READ_TYPED_DATA_HEADER(type) \ | 702 #define READ_TYPED_DATA_HEADER(type) \ |
712 intptr_t len = ReadSmiValue(); \ | 703 intptr_t len = ReadSmiValue(); \ |
713 Dart_CObject* object = \ | 704 Dart_CObject* object = \ |
714 AllocateDartCObjectTypedData(Dart_TypedData_k##type, len); \ | 705 AllocateDartCObjectTypedData(Dart_TypedData_k##type, len); \ |
715 AddBackRef(object_id, object, kIsDeserialized); \ | 706 AddBackRef(object_id, object, kIsDeserialized); |
716 | 707 |
717 | 708 |
718 #define READ_TYPED_DATA(type, ctype) \ | 709 #define READ_TYPED_DATA(type, ctype) \ |
719 { \ | 710 { \ |
720 READ_TYPED_DATA_HEADER(type); \ | 711 READ_TYPED_DATA_HEADER(type); \ |
721 if (len > 0) { \ | 712 if (len > 0) { \ |
722 ctype* p = \ | 713 ctype* p = reinterpret_cast<ctype*>(object->value.as_typed_data.values); \ |
723 reinterpret_cast<ctype*>(object->value.as_typed_data.values); \ | 714 for (intptr_t i = 0; i < len; i++) { \ |
724 for (intptr_t i = 0; i < len; i++) { \ | 715 p[i] = Read<ctype>(); \ |
725 p[i] = Read<ctype>(); \ | |
726 } \ | |
727 } \ | 716 } \ |
728 return object; \ | |
729 } \ | 717 } \ |
| 718 return object; \ |
| 719 } |
730 | 720 |
731 case kTypedDataInt8ArrayCid: | 721 case kTypedDataInt8ArrayCid: |
732 case kExternalTypedDataInt8ArrayCid: { | 722 case kExternalTypedDataInt8ArrayCid: { |
733 READ_TYPED_DATA_HEADER(Int8); | 723 READ_TYPED_DATA_HEADER(Int8); |
734 if (len > 0) { | 724 if (len > 0) { |
735 uint8_t* p = | 725 uint8_t* p = |
736 reinterpret_cast<uint8_t*>(object->value.as_typed_data.values); | 726 reinterpret_cast<uint8_t*>(object->value.as_typed_data.values); |
737 ReadBytes(p, len); | 727 ReadBytes(p, len); |
738 } | 728 } |
739 return object; | 729 return object; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 default: | 812 default: |
823 // Everything else not supported. | 813 // Everything else not supported. |
824 Dart_CObject* value = AllocateDartCObjectUnsupported(); | 814 Dart_CObject* value = AllocateDartCObjectUnsupported(); |
825 AddBackRef(object_id, value, kIsDeserialized); | 815 AddBackRef(object_id, value, kIsDeserialized); |
826 return value; | 816 return value; |
827 } | 817 } |
828 } | 818 } |
829 | 819 |
830 | 820 |
831 Dart_CObject* ApiMessageReader::ReadIndexedObject(intptr_t object_id) { | 821 Dart_CObject* ApiMessageReader::ReadIndexedObject(intptr_t object_id) { |
832 if (object_id == kDynamicType || | 822 if (object_id == kDynamicType || object_id == kDoubleType || |
833 object_id == kDoubleType || | 823 object_id == kIntType || object_id == kBoolType || |
834 object_id == kIntType || | |
835 object_id == kBoolType || | |
836 object_id == kStringType) { | 824 object_id == kStringType) { |
837 // Always return dynamic type (this is only a marker). | 825 // Always return dynamic type (this is only a marker). |
838 return &dynamic_type_marker; | 826 return &dynamic_type_marker; |
839 } | 827 } |
840 intptr_t index = object_id - kMaxPredefinedObjectIds; | 828 intptr_t index = object_id - kMaxPredefinedObjectIds; |
841 ASSERT((0 <= index) && (index < backward_references_.length())); | 829 ASSERT((0 <= index) && (index < backward_references_.length())); |
842 ASSERT(backward_references_[index]->reference() != NULL); | 830 ASSERT(backward_references_[index]->reference() != NULL); |
843 return backward_references_[index]->reference(); | 831 return backward_references_[index]->reference(); |
844 } | 832 } |
845 | 833 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 Dart_CObject* ApiMessageReader::GetBackRef(intptr_t id) { | 886 Dart_CObject* ApiMessageReader::GetBackRef(intptr_t id) { |
899 ASSERT(id >= kMaxPredefinedObjectIds); | 887 ASSERT(id >= kMaxPredefinedObjectIds); |
900 intptr_t index = (id - kMaxPredefinedObjectIds); | 888 intptr_t index = (id - kMaxPredefinedObjectIds); |
901 if (index < backward_references_.length()) { | 889 if (index < backward_references_.length()) { |
902 return backward_references_[index]->reference(); | 890 return backward_references_[index]->reference(); |
903 } | 891 } |
904 return NULL; | 892 return NULL; |
905 } | 893 } |
906 | 894 |
907 | 895 |
908 void ApiMessageWriter::WriteMessage(intptr_t field_count, intptr_t *data) { | 896 void ApiMessageWriter::WriteMessage(intptr_t field_count, intptr_t* data) { |
909 // Write out the serialization header value for this object. | 897 // Write out the serialization header value for this object. |
910 WriteInlinedObjectHeader(kMaxPredefinedObjectIds); | 898 WriteInlinedObjectHeader(kMaxPredefinedObjectIds); |
911 | 899 |
912 // Write out the class and tags information. | 900 // Write out the class and tags information. |
913 WriteIndexedObject(kArrayCid); | 901 WriteIndexedObject(kArrayCid); |
914 WriteTags(0); | 902 WriteTags(0); |
915 | 903 |
916 // Write out the length field. | 904 // Write out the length field. |
917 Write<RawObject*>(Smi::New(field_count)); | 905 Write<RawObject*>(Smi::New(field_count)); |
918 | 906 |
(...skipping 13 matching lines...) Expand all Loading... |
932 // an offset for making marking of object id 0 possible. | 920 // an offset for making marking of object id 0 possible. |
933 ASSERT(!IsCObjectMarked(object)); | 921 ASSERT(!IsCObjectMarked(object)); |
934 intptr_t mark_value = object_id + kDartCObjectMarkOffset; | 922 intptr_t mark_value = object_id + kDartCObjectMarkOffset; |
935 object->type = static_cast<Dart_CObject_Type>( | 923 object->type = static_cast<Dart_CObject_Type>( |
936 ((mark_value) << kDartCObjectTypeBits) | object->type); | 924 ((mark_value) << kDartCObjectTypeBits) | object->type); |
937 } | 925 } |
938 | 926 |
939 | 927 |
940 void ApiMessageWriter::UnmarkCObject(Dart_CObject* object) { | 928 void ApiMessageWriter::UnmarkCObject(Dart_CObject* object) { |
941 ASSERT(IsCObjectMarked(object)); | 929 ASSERT(IsCObjectMarked(object)); |
942 object->type = static_cast<Dart_CObject_Type>( | 930 object->type = |
943 object->type & kDartCObjectTypeMask); | 931 static_cast<Dart_CObject_Type>(object->type & kDartCObjectTypeMask); |
944 } | 932 } |
945 | 933 |
946 | 934 |
947 bool ApiMessageWriter::IsCObjectMarked(Dart_CObject* object) { | 935 bool ApiMessageWriter::IsCObjectMarked(Dart_CObject* object) { |
948 return (object->type & kDartCObjectMarkMask) != 0; | 936 return (object->type & kDartCObjectMarkMask) != 0; |
949 } | 937 } |
950 | 938 |
951 | 939 |
952 intptr_t ApiMessageWriter::GetMarkedCObjectMark(Dart_CObject* object) { | 940 intptr_t ApiMessageWriter::GetMarkedCObjectMark(Dart_CObject* object) { |
953 ASSERT(IsCObjectMarked(object)); | 941 ASSERT(IsCObjectMarked(object)); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 bool ApiMessageWriter::WriteCObject(Dart_CObject* object) { | 1034 bool ApiMessageWriter::WriteCObject(Dart_CObject* object) { |
1047 if (IsCObjectMarked(object)) { | 1035 if (IsCObjectMarked(object)) { |
1048 intptr_t object_id = GetMarkedCObjectMark(object); | 1036 intptr_t object_id = GetMarkedCObjectMark(object); |
1049 WriteIndexedObject(kMaxPredefinedObjectIds + object_id); | 1037 WriteIndexedObject(kMaxPredefinedObjectIds + object_id); |
1050 return true; | 1038 return true; |
1051 } | 1039 } |
1052 | 1040 |
1053 Dart_CObject_Type type = object->type; | 1041 Dart_CObject_Type type = object->type; |
1054 if (type == Dart_CObject_kArray) { | 1042 if (type == Dart_CObject_kArray) { |
1055 const intptr_t array_length = object->value.as_array.length; | 1043 const intptr_t array_length = object->value.as_array.length; |
1056 if (array_length < 0 || | 1044 if (array_length < 0 || array_length > Array::kMaxElements) { |
1057 array_length > Array::kMaxElements) { | |
1058 return false; | 1045 return false; |
1059 } | 1046 } |
1060 | 1047 |
1061 // Write out the serialization header value for this object. | 1048 // Write out the serialization header value for this object. |
1062 WriteInlinedHeader(object); | 1049 WriteInlinedHeader(object); |
1063 // Write out the class and tags information. | 1050 // Write out the class and tags information. |
1064 WriteIndexedObject(kArrayCid); | 1051 WriteIndexedObject(kArrayCid); |
1065 WriteTags(0); | 1052 WriteTags(0); |
1066 // Write out the length information. | 1053 // Write out the length information. |
1067 WriteSmi(array_length); | 1054 WriteSmi(array_length); |
(...skipping 13 matching lines...) Expand all Loading... |
1081 bool ApiMessageWriter::WriteCObjectRef(Dart_CObject* object) { | 1068 bool ApiMessageWriter::WriteCObjectRef(Dart_CObject* object) { |
1082 if (IsCObjectMarked(object)) { | 1069 if (IsCObjectMarked(object)) { |
1083 intptr_t object_id = GetMarkedCObjectMark(object); | 1070 intptr_t object_id = GetMarkedCObjectMark(object); |
1084 WriteIndexedObject(kMaxPredefinedObjectIds + object_id); | 1071 WriteIndexedObject(kMaxPredefinedObjectIds + object_id); |
1085 return true; | 1072 return true; |
1086 } | 1073 } |
1087 | 1074 |
1088 Dart_CObject_Type type = object->type; | 1075 Dart_CObject_Type type = object->type; |
1089 if (type == Dart_CObject_kArray) { | 1076 if (type == Dart_CObject_kArray) { |
1090 const intptr_t array_length = object->value.as_array.length; | 1077 const intptr_t array_length = object->value.as_array.length; |
1091 if (array_length < 0 || | 1078 if (array_length < 0 || array_length > Array::kMaxElements) { |
1092 array_length > Array::kMaxElements) { | |
1093 return false; | 1079 return false; |
1094 } | 1080 } |
1095 // Write out the serialization header value for this object. | 1081 // Write out the serialization header value for this object. |
1096 WriteInlinedHeader(object); | 1082 WriteInlinedHeader(object); |
1097 // Write out the class information. | 1083 // Write out the class information. |
1098 WriteIndexedObject(kArrayCid); | 1084 WriteIndexedObject(kArrayCid); |
1099 WriteTags(0); | 1085 WriteTags(0); |
1100 // Write out the length information. | 1086 // Write out the length information. |
1101 WriteSmi(array_length); | 1087 WriteSmi(array_length); |
1102 // Add object to forward list so that this object is serialized later. | 1088 // Add object to forward list so that this object is serialized later. |
1103 AddToForwardList(object); | 1089 AddToForwardList(object); |
1104 return true; | 1090 return true; |
1105 } | 1091 } |
1106 return WriteCObjectInlined(object, type); | 1092 return WriteCObjectInlined(object, type); |
1107 } | 1093 } |
1108 | 1094 |
1109 | 1095 |
1110 bool ApiMessageWriter::WriteForwardedCObject(Dart_CObject* object) { | 1096 bool ApiMessageWriter::WriteForwardedCObject(Dart_CObject* object) { |
1111 ASSERT(IsCObjectMarked(object)); | 1097 ASSERT(IsCObjectMarked(object)); |
1112 Dart_CObject_Type type = | 1098 Dart_CObject_Type type = |
1113 static_cast<Dart_CObject_Type>(object->type & kDartCObjectTypeMask); | 1099 static_cast<Dart_CObject_Type>(object->type & kDartCObjectTypeMask); |
1114 ASSERT(type == Dart_CObject_kArray); | 1100 ASSERT(type == Dart_CObject_kArray); |
1115 const intptr_t array_length = object->value.as_array.length; | 1101 const intptr_t array_length = object->value.as_array.length; |
1116 if (array_length < 0 || | 1102 if (array_length < 0 || array_length > Array::kMaxElements) { |
1117 array_length > Array::kMaxElements) { | |
1118 return false; | 1103 return false; |
1119 } | 1104 } |
1120 | 1105 |
1121 // Write out the serialization header value for this object. | 1106 // Write out the serialization header value for this object. |
1122 intptr_t object_id = GetMarkedCObjectMark(object); | 1107 intptr_t object_id = GetMarkedCObjectMark(object); |
1123 WriteInlinedObjectHeader(kMaxPredefinedObjectIds + object_id); | 1108 WriteInlinedObjectHeader(kMaxPredefinedObjectIds + object_id); |
1124 // Write out the class and tags information. | 1109 // Write out the class and tags information. |
1125 WriteIndexedObject(kArrayCid); | 1110 WriteIndexedObject(kArrayCid); |
1126 WriteTags(0); | 1111 WriteTags(0); |
1127 // Write out the length information. | 1112 // Write out the length information. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 WriteInlinedHeader(object); | 1181 WriteInlinedHeader(object); |
1197 // Write out the class and tags information. | 1182 // Write out the class and tags information. |
1198 WriteIndexedObject(type == Utf8::kLatin1 ? kOneByteStringCid | 1183 WriteIndexedObject(type == Utf8::kLatin1 ? kOneByteStringCid |
1199 : kTwoByteStringCid); | 1184 : kTwoByteStringCid); |
1200 WriteTags(0); | 1185 WriteTags(0); |
1201 // Write string length and content. | 1186 // Write string length and content. |
1202 WriteSmi(len); | 1187 WriteSmi(len); |
1203 if (type == Utf8::kLatin1) { | 1188 if (type == Utf8::kLatin1) { |
1204 uint8_t* latin1_str = | 1189 uint8_t* latin1_str = |
1205 reinterpret_cast<uint8_t*>(::malloc(len * sizeof(uint8_t))); | 1190 reinterpret_cast<uint8_t*>(::malloc(len * sizeof(uint8_t))); |
1206 bool success = Utf8::DecodeToLatin1(utf8_str, | 1191 bool success = |
1207 utf8_len, | 1192 Utf8::DecodeToLatin1(utf8_str, utf8_len, latin1_str, len); |
1208 latin1_str, | |
1209 len); | |
1210 ASSERT(success); | 1193 ASSERT(success); |
1211 for (intptr_t i = 0; i < len; i++) { | 1194 for (intptr_t i = 0; i < len; i++) { |
1212 Write<uint8_t>(latin1_str[i]); | 1195 Write<uint8_t>(latin1_str[i]); |
1213 } | 1196 } |
1214 ::free(latin1_str); | 1197 ::free(latin1_str); |
1215 } else { | 1198 } else { |
1216 uint16_t* utf16_str = | 1199 uint16_t* utf16_str = |
1217 reinterpret_cast<uint16_t*>(::malloc(len * sizeof(uint16_t))); | 1200 reinterpret_cast<uint16_t*>(::malloc(len * sizeof(uint16_t))); |
1218 bool success = Utf8::DecodeToUTF16(utf8_str, utf8_len, utf16_str, len); | 1201 bool success = Utf8::DecodeToUTF16(utf8_str, utf8_len, utf16_str, len); |
1219 ASSERT(success); | 1202 ASSERT(success); |
(...skipping 18 matching lines...) Expand all Loading... |
1238 break; | 1221 break; |
1239 case Dart_TypedData_kUint32: | 1222 case Dart_TypedData_kUint32: |
1240 class_id = kTypedDataUint32ArrayCid; | 1223 class_id = kTypedDataUint32ArrayCid; |
1241 break; | 1224 break; |
1242 default: | 1225 default: |
1243 class_id = kTypedDataUint8ArrayCid; | 1226 class_id = kTypedDataUint8ArrayCid; |
1244 UNIMPLEMENTED(); | 1227 UNIMPLEMENTED(); |
1245 } | 1228 } |
1246 | 1229 |
1247 intptr_t len = object->value.as_typed_data.length; | 1230 intptr_t len = object->value.as_typed_data.length; |
1248 if (len < 0 || | 1231 if (len < 0 || len > TypedData::MaxElements(class_id)) { |
1249 len > TypedData::MaxElements(class_id)) { | |
1250 return false; | 1232 return false; |
1251 } | 1233 } |
1252 | 1234 |
1253 WriteIndexedObject(class_id); | 1235 WriteIndexedObject(class_id); |
1254 WriteTags(0); | 1236 WriteTags(0); |
1255 WriteSmi(len); | 1237 WriteSmi(len); |
1256 switch (class_id) { | 1238 switch (class_id) { |
1257 case kTypedDataInt8ArrayCid: | 1239 case kTypedDataInt8ArrayCid: |
1258 case kTypedDataUint8ArrayCid: { | 1240 case kTypedDataUint8ArrayCid: { |
1259 uint8_t* bytes = object->value.as_typed_data.values; | 1241 uint8_t* bytes = object->value.as_typed_data.values; |
(...skipping 21 matching lines...) Expand all Loading... |
1281 // sure that messages containing pointers can never be posted | 1263 // sure that messages containing pointers can never be posted |
1282 // to other processes. | 1264 // to other processes. |
1283 | 1265 |
1284 // Write out serialization header value for this object. | 1266 // Write out serialization header value for this object. |
1285 WriteInlinedHeader(object); | 1267 WriteInlinedHeader(object); |
1286 // Write out the class and tag information. | 1268 // Write out the class and tag information. |
1287 WriteIndexedObject(kExternalTypedDataUint8ArrayCid); | 1269 WriteIndexedObject(kExternalTypedDataUint8ArrayCid); |
1288 WriteTags(0); | 1270 WriteTags(0); |
1289 intptr_t length = object->value.as_external_typed_data.length; | 1271 intptr_t length = object->value.as_external_typed_data.length; |
1290 if (length < 0 || | 1272 if (length < 0 || |
1291 length > ExternalTypedData::MaxElements( | 1273 length > |
1292 kExternalTypedDataUint8ArrayCid)) { | 1274 ExternalTypedData::MaxElements(kExternalTypedDataUint8ArrayCid)) { |
1293 return false; | 1275 return false; |
1294 } | 1276 } |
1295 uint8_t* data = object->value.as_external_typed_data.data; | 1277 uint8_t* data = object->value.as_external_typed_data.data; |
1296 void* peer = object->value.as_external_typed_data.peer; | 1278 void* peer = object->value.as_external_typed_data.peer; |
1297 Dart_WeakPersistentHandleFinalizer callback = | 1279 Dart_WeakPersistentHandleFinalizer callback = |
1298 object->value.as_external_typed_data.callback; | 1280 object->value.as_external_typed_data.callback; |
1299 WriteSmi(length); | 1281 WriteSmi(length); |
1300 WriteRawPointerValue(reinterpret_cast<intptr_t>(data)); | 1282 WriteRawPointerValue(reinterpret_cast<intptr_t>(data)); |
1301 WriteRawPointerValue(reinterpret_cast<intptr_t>(peer)); | 1283 WriteRawPointerValue(reinterpret_cast<intptr_t>(peer)); |
1302 WriteRawPointerValue(reinterpret_cast<intptr_t>(callback)); | 1284 WriteRawPointerValue(reinterpret_cast<intptr_t>(callback)); |
(...skipping 28 matching lines...) Expand all Loading... |
1331 if (!success) { | 1313 if (!success) { |
1332 UnmarkAllCObjects(object); | 1314 UnmarkAllCObjects(object); |
1333 return false; | 1315 return false; |
1334 } | 1316 } |
1335 } | 1317 } |
1336 UnmarkAllCObjects(object); | 1318 UnmarkAllCObjects(object); |
1337 return true; | 1319 return true; |
1338 } | 1320 } |
1339 | 1321 |
1340 } // namespace dart | 1322 } // namespace dart |
OLD | NEW |