OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 #include "vm/dart_api_impl.h" | 6 #include "vm/dart_api_impl.h" |
7 #include "vm/datastream.h" | 7 #include "vm/datastream.h" |
8 #include "vm/exceptions.h" | 8 #include "vm/exceptions.h" |
9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
11 #include "vm/message.h" | 11 #include "vm/message.h" |
12 #include "vm/message_handler.h" | 12 #include "vm/message_handler.h" |
13 #include "vm/native_entry.h" | 13 #include "vm/native_entry.h" |
14 #include "vm/object.h" | 14 #include "vm/object.h" |
15 #include "vm/port.h" | 15 #include "vm/port.h" |
| 16 #include "vm/service_event.h" |
16 #include "vm/service_isolate.h" | 17 #include "vm/service_isolate.h" |
17 #include "vm/symbols.h" | 18 #include "vm/symbols.h" |
18 | 19 |
19 namespace dart { | 20 namespace dart { |
20 | 21 |
21 DECLARE_FLAG(bool, trace_service); | 22 DECLARE_FLAG(bool, trace_service); |
22 | 23 |
23 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 24 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
24 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 25 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
25 return reinterpret_cast<uint8_t*>(new_ptr); | 26 return reinterpret_cast<uint8_t*>(new_ptr); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 thread->zone(), dart_contents)); | 444 thread->zone(), dart_contents)); |
444 idx += 2; | 445 idx += 2; |
445 } | 446 } |
446 | 447 |
447 return result_list.raw(); | 448 return result_list.raw(); |
448 #else | 449 #else |
449 return Object::null(); | 450 return Object::null(); |
450 #endif | 451 #endif |
451 } | 452 } |
452 | 453 |
| 454 |
| 455 |
| 456 DEFINE_NATIVE_ENTRY(VMService_spawnUriNotify, 2) { |
| 457 GET_NON_NULL_NATIVE_ARGUMENT(Instance, result, arguments->NativeArgAt(0)); |
| 458 GET_NON_NULL_NATIVE_ARGUMENT(String, token, arguments->NativeArgAt(1)); |
| 459 |
| 460 if (result.IsSendPort()) { |
| 461 Dart_Port id = SendPort::Cast(result).Id(); |
| 462 Isolate* isolate = PortMap::GetIsolate(id); |
| 463 if (isolate != NULL) { |
| 464 ServiceEvent spawn_event(isolate, ServiceEvent::kIsolateSpawn); |
| 465 spawn_event.set_spawn_token(&token); |
| 466 Service::HandleEvent(&spawn_event); |
| 467 } else { |
| 468 // There is no isolate at the control port anymore. Must have |
| 469 // died already. |
| 470 ServiceEvent spawn_event(NULL, ServiceEvent::kIsolateSpawn); |
| 471 const String& error = String::Handle(String::New( |
| 472 "spawned isolate exited before notification completed")); |
| 473 spawn_event.set_spawn_token(&token); |
| 474 spawn_event.set_spawn_error(&error); |
| 475 Service::HandleEvent(&spawn_event); |
| 476 } |
| 477 } else { |
| 478 // The isolate failed to spawn. |
| 479 ASSERT(result.IsString()); |
| 480 ServiceEvent spawn_event(NULL, ServiceEvent::kIsolateSpawn); |
| 481 spawn_event.set_spawn_token(&token); |
| 482 spawn_event.set_spawn_error(&String::Cast(result)); |
| 483 Service::HandleEvent(&spawn_event); |
| 484 } |
| 485 |
| 486 return Object::null(); |
| 487 } |
| 488 |
453 } // namespace dart | 489 } // namespace dart |
OLD | NEW |