Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: runtime/vm/dart_api_message.cc

Issue 43483004: Remove the reply port form the native isolate handler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated to new isolate API Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/native_message_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bigint_operations.h" 5 #include "vm/bigint_operations.h"
6 #include "vm/dart_api_message.h" 6 #include "vm/dart_api_message.h"
7 #include "vm/object.h" 7 #include "vm/object.h"
8 #include "vm/snapshot_ids.h" 8 #include "vm/snapshot_ids.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/unicode.h" 10 #include "vm/unicode.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 DeserializeState state) { 214 DeserializeState state) {
215 BackRefNode* value = 215 BackRefNode* value =
216 reinterpret_cast<BackRefNode*>(alloc_(NULL, 0, sizeof(BackRefNode))); 216 reinterpret_cast<BackRefNode*>(alloc_(NULL, 0, sizeof(BackRefNode)));
217 value->set_reference(reference); 217 value->set_reference(reference);
218 value->set_state(state); 218 value->set_state(state);
219 return value; 219 return value;
220 } 220 }
221 221
222 222
223 static Dart_TypedData_Type GetTypedDataTypeFromView( 223 static Dart_TypedData_Type GetTypedDataTypeFromView(
224 Dart_CObject_Internal* object) { 224 Dart_CObject_Internal* object,
225 char* class_name) {
225 struct { 226 struct {
226 const char* name; 227 const char* name;
227 Dart_TypedData_Type type; 228 Dart_TypedData_Type type;
228 } view_class_names[] = { 229 } view_class_names[] = {
229 { "_Int8ArrayView", Dart_TypedData_kInt8 }, 230 { "_Int8ArrayView", Dart_TypedData_kInt8 },
230 { "_Uint8ArrayView", Dart_TypedData_kUint8 }, 231 { "_Uint8ArrayView", Dart_TypedData_kUint8 },
231 { "_Uint8ClampedArrayView", Dart_TypedData_kUint8Clamped }, 232 { "_Uint8ClampedArrayView", Dart_TypedData_kUint8Clamped },
232 { "_Int16ArrayView", Dart_TypedData_kInt16 }, 233 { "_Int16ArrayView", Dart_TypedData_kInt16 },
233 { "_Uint16ArrayView", Dart_TypedData_kUint16 }, 234 { "_Uint16ArrayView", Dart_TypedData_kUint16 },
234 { "_Int32ArrayView", Dart_TypedData_kInt32 }, 235 { "_Int32ArrayView", Dart_TypedData_kInt32 },
235 { "_Uint32ArrayView", Dart_TypedData_kUint32 }, 236 { "_Uint32ArrayView", Dart_TypedData_kUint32 },
236 { "_Int64ArrayView", Dart_TypedData_kInt64 }, 237 { "_Int64ArrayView", Dart_TypedData_kInt64 },
237 { "_Uint64ArrayView", Dart_TypedData_kUint64 }, 238 { "_Uint64ArrayView", Dart_TypedData_kUint64 },
238 { "_ByteDataView", Dart_TypedData_kUint8 }, 239 { "_ByteDataView", Dart_TypedData_kUint8 },
239 { "_Float32ArrayView", Dart_TypedData_kFloat32 }, 240 { "_Float32ArrayView", Dart_TypedData_kFloat32 },
240 { "_Float64ArrayView", Dart_TypedData_kFloat64 }, 241 { "_Float64ArrayView", Dart_TypedData_kFloat64 },
241 { NULL, Dart_TypedData_kInvalid }, 242 { NULL, Dart_TypedData_kInvalid },
242 }; 243 };
243 244
244 char* library_url =
245 object->cls->internal.as_class.library_url->value.as_string;
246 char* class_name =
247 object->cls->internal.as_class.class_name->value.as_string;
248 if (strcmp("dart:typed_data", library_url) != 0) {
249 return Dart_TypedData_kInvalid;
250 }
251 int i = 0; 245 int i = 0;
252 while (view_class_names[i].name != NULL) { 246 while (view_class_names[i].name != NULL) {
253 if (strncmp(view_class_names[i].name, 247 if (strncmp(view_class_names[i].name,
254 class_name, 248 class_name,
255 strlen(view_class_names[i].name)) == 0) { 249 strlen(view_class_names[i].name)) == 0) {
256 return view_class_names[i].type; 250 return view_class_names[i].type;
257 } 251 }
258 i++; 252 i++;
259 } 253 }
260 return Dart_TypedData_kInvalid; 254 return Dart_TypedData_kInvalid;
(...skipping 18 matching lines...) Expand all
279 AddBackRef(object_id, object, kIsDeserialized); 273 AddBackRef(object_id, object, kIsDeserialized);
280 // Read class of object. 274 // Read class of object.
281 object->cls = reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl()); 275 object->cls = reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl());
282 ASSERT(object->cls->type == 276 ASSERT(object->cls->type ==
283 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kClass)); 277 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kClass));
284 } 278 }
285 ASSERT(object->type == 279 ASSERT(object->type ==
286 static_cast<Dart_CObject_Type>( 280 static_cast<Dart_CObject_Type>(
287 Dart_CObject_Internal::kUninitialized)); 281 Dart_CObject_Internal::kUninitialized));
288 282
283 char* library_uri =
284 object->cls->internal.as_class.library_url->value.as_string;
285 char* class_name =
286 object->cls->internal.as_class.class_name->value.as_string;
287
289 // Handle typed data views. 288 // Handle typed data views.
290 Dart_TypedData_Type type = GetTypedDataTypeFromView(object); 289 if (strcmp("dart:typed_data", library_uri) == 0) {
291 if (type != Dart_TypedData_kInvalid) { 290 Dart_TypedData_Type type = GetTypedDataTypeFromView(object, class_name);
292 object->type = 291 if (type != Dart_TypedData_kInvalid) {
293 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kView); 292 object->type =
293 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kView);
294 ReadObjectImpl(); // Skip type arguments.
295 object->internal.as_view.buffer = ReadObjectImpl();
296 object->internal.as_view.offset_in_bytes = ReadSmiValue();
297 object->internal.as_view.length = ReadSmiValue();
298 ReadObjectImpl(); // Skip last field.
299
300 // The buffer is fully read now as typed data objects are
301 // serialized in-line.
302 Dart_CObject* buffer = object->internal.as_view.buffer;
303 ASSERT(buffer->type == Dart_CObject_kTypedData);
304
305 // Now turn the view into a byte array.
306 object->type = Dart_CObject_kTypedData;
307 object->value.as_typed_data.type = type;
308 object->value.as_typed_data.length =
309 object->internal.as_view.length *
310 GetTypedDataSizeInBytes(type);
311 object->value.as_typed_data.values =
312 buffer->value.as_typed_data.values +
313 object->internal.as_view.offset_in_bytes;
314 } else {
315 // TODO(sgjesse): Handle other instances. Currently this will
316 // skew the reading as the fields of the instance is not read.
317 }
318 } else if (strcmp("dart:isolate", library_uri) == 0 &&
319 strncmp("_SendPortImpl@", class_name, 14) == 0) {
294 ReadObjectImpl(); // Skip type arguments. 320 ReadObjectImpl(); // Skip type arguments.
295 object->internal.as_view.buffer = ReadObjectImpl(); 321 // Read the port id.
296 object->internal.as_view.offset_in_bytes = ReadSmiValue(); 322 Dart_CObject* port = ReadObjectImpl();
297 object->internal.as_view.length = ReadSmiValue(); 323 if (port->type == Dart_CObject_kInt32) {
324 object->type = Dart_CObject_kSendPort;
325 object->value.as_send_port = port->value.as_int32;
326 } else if (port->type == Dart_CObject_kInt64) {
327 object->type = Dart_CObject_kSendPort;
328 object->value.as_send_port = port->value.as_int64;
329 }
298 ReadObjectImpl(); // Skip last field. 330 ReadObjectImpl(); // Skip last field.
299
300 // The buffer is fully read now as typed data objects are
301 // serialized in-line.
302 Dart_CObject* buffer = object->internal.as_view.buffer;
303 ASSERT(buffer->type == Dart_CObject_kTypedData);
304
305 // Now turn the view into a byte array.
306 object->type = Dart_CObject_kTypedData;
307 object->value.as_typed_data.type = type;
308 object->value.as_typed_data.length =
309 object->internal.as_view.length *
310 GetTypedDataSizeInBytes(type);
311 object->value.as_typed_data.values =
312 buffer->value.as_typed_data.values +
313 object->internal.as_view.offset_in_bytes;
314 } else { 331 } else {
315 // TODO(sgjesse): Handle other instances. Currently this will 332 // TODO(sgjesse): Handle other instances. Currently this will
316 // skew the reading as the fields of the instance is not read. 333 // skew the reading as the fields of the instance is not read.
317 } 334 }
318 return object; 335 return object;
319 } 336 }
320 337
321 ASSERT((class_header & kSmiTagMask) != 0); 338 ASSERT((class_header & kSmiTagMask) != 0);
322 class_id = LookupInternalClass(class_header); 339 class_id = LookupInternalClass(class_header);
323 if ((class_id == kArrayCid) || (class_id == kImmutableArrayCid)) { 340 if ((class_id == kArrayCid) || (class_id == kImmutableArrayCid)) {
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 if (!success) { 1168 if (!success) {
1152 UnmarkAllCObjects(object); 1169 UnmarkAllCObjects(object);
1153 return false; 1170 return false;
1154 } 1171 }
1155 } 1172 }
1156 UnmarkAllCObjects(object); 1173 UnmarkAllCObjects(object);
1157 return true; 1174 return true;
1158 } 1175 }
1159 1176
1160 } // namespace dart 1177 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/native_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698