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 | 6 |
7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
8 #include "vm/exceptions.h" | 8 #include "vm/exceptions.h" |
9 #include "vm/message.h" | 9 #include "vm/message.h" |
10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
11 #include "vm/object.h" | 11 #include "vm/object.h" |
12 #include "vm/port.h" | 12 #include "vm/port.h" |
13 #include "vm/service_isolate.h" | 13 #include "vm/service_isolate.h" |
14 #include "vm/symbols.h" | 14 #include "vm/symbols.h" |
15 | 15 |
16 namespace dart { | 16 namespace dart { |
17 | 17 |
18 DECLARE_FLAG(bool, trace_service); | 18 DECLARE_FLAG(bool, trace_service); |
19 | 19 |
20 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 20 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
21 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 21 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
22 return reinterpret_cast<uint8_t*>(new_ptr); | 22 return reinterpret_cast<uint8_t*>(new_ptr); |
23 } | 23 } |
24 | 24 |
25 | 25 |
26 class RegisterRunningIsolatesVisitor : public IsolateVisitor { | 26 class RegisterRunningIsolatesVisitor : public IsolateVisitor { |
27 public: | 27 public: |
28 explicit RegisterRunningIsolatesVisitor(Isolate* service_isolate) | 28 explicit RegisterRunningIsolatesVisitor(Thread* thread) |
29 : IsolateVisitor(), | 29 : IsolateVisitor(), |
30 register_function_(Function::Handle(service_isolate)), | 30 register_function_(Function::Handle(thread->zone())), |
31 service_isolate_(service_isolate) { | 31 service_isolate_(thread->isolate()) { |
32 ASSERT(ServiceIsolate::IsServiceIsolate(Isolate::Current())); | 32 ASSERT(ServiceIsolate::IsServiceIsolate(Isolate::Current())); |
33 // Get library. | 33 // Get library. |
34 const String& library_url = Symbols::DartVMService(); | 34 const String& library_url = Symbols::DartVMService(); |
35 ASSERT(!library_url.IsNull()); | 35 ASSERT(!library_url.IsNull()); |
36 const Library& library = | 36 const Library& library = |
37 Library::Handle(Library::LookupLibrary(library_url)); | 37 Library::Handle(Library::LookupLibrary(library_url)); |
38 ASSERT(!library.IsNull()); | 38 ASSERT(!library.IsNull()); |
39 // Get function. | 39 // Get function. |
40 const String& function_name = | 40 const String& function_name = |
41 String::Handle(String::New("_registerIsolate")); | 41 String::Handle(String::New("_registerIsolate")); |
(...skipping 14 matching lines...) Expand all Loading... |
56 const Integer& port_int = Integer::Handle(Integer::New(port_id)); | 56 const Integer& port_int = Integer::Handle(Integer::New(port_id)); |
57 ASSERT(!port_int.IsNull()); | 57 ASSERT(!port_int.IsNull()); |
58 const SendPort& send_port = SendPort::Handle(SendPort::New(port_id)); | 58 const SendPort& send_port = SendPort::Handle(SendPort::New(port_id)); |
59 const String& name = String::Handle(String::New(isolate->name())); | 59 const String& name = String::Handle(String::New(isolate->name())); |
60 ASSERT(!name.IsNull()); | 60 ASSERT(!name.IsNull()); |
61 const Array& args = Array::Handle(Array::New(3)); | 61 const Array& args = Array::Handle(Array::New(3)); |
62 ASSERT(!args.IsNull()); | 62 ASSERT(!args.IsNull()); |
63 args.SetAt(0, port_int); | 63 args.SetAt(0, port_int); |
64 args.SetAt(1, send_port); | 64 args.SetAt(1, send_port); |
65 args.SetAt(2, name); | 65 args.SetAt(2, name); |
66 Object& r = Object::Handle(service_isolate_); | 66 Object& r = Object::Handle(service_isolate_->current_zone()); |
67 r = DartEntry::InvokeFunction(register_function_, args); | 67 r = DartEntry::InvokeFunction(register_function_, args); |
68 if (FLAG_trace_service) { | 68 if (FLAG_trace_service) { |
69 OS::Print("vm-service: Isolate %s %" Pd64 " registered.\n", | 69 OS::Print("vm-service: Isolate %s %" Pd64 " registered.\n", |
70 name.ToCString(), | 70 name.ToCString(), |
71 port_id); | 71 port_id); |
72 } | 72 } |
73 ASSERT(!r.IsError()); | 73 ASSERT(!r.IsError()); |
74 } | 74 } |
75 | 75 |
76 private: | 76 private: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 | 109 |
110 DEFINE_NATIVE_ENTRY(VMService_OnStart, 0) { | 110 DEFINE_NATIVE_ENTRY(VMService_OnStart, 0) { |
111 if (FLAG_trace_service) { | 111 if (FLAG_trace_service) { |
112 OS::Print("vm-service: Booting dart:vmservice library.\n"); | 112 OS::Print("vm-service: Booting dart:vmservice library.\n"); |
113 } | 113 } |
114 // Boot the dart:vmservice library. | 114 // Boot the dart:vmservice library. |
115 ServiceIsolate::BootVmServiceLibrary(); | 115 ServiceIsolate::BootVmServiceLibrary(); |
116 | 116 |
117 // Register running isolates with service. | 117 // Register running isolates with service. |
118 RegisterRunningIsolatesVisitor register_isolates(isolate); | 118 RegisterRunningIsolatesVisitor register_isolates(thread); |
119 if (FLAG_trace_service) { | 119 if (FLAG_trace_service) { |
120 OS::Print("vm-service: Registering running isolates.\n"); | 120 OS::Print("vm-service: Registering running isolates.\n"); |
121 } | 121 } |
122 Isolate::VisitIsolates(®ister_isolates); | 122 Isolate::VisitIsolates(®ister_isolates); |
123 | 123 |
124 return Object::null(); | 124 return Object::null(); |
125 } | 125 } |
126 | 126 |
127 | 127 |
128 DEFINE_NATIVE_ENTRY(VMService_OnExit, 0) { | 128 DEFINE_NATIVE_ENTRY(VMService_OnExit, 0) { |
(...skipping 11 matching lines...) Expand all Loading... |
140 } | 140 } |
141 | 141 |
142 | 142 |
143 DEFINE_NATIVE_ENTRY(VMService_CancelStream, 1) { | 143 DEFINE_NATIVE_ENTRY(VMService_CancelStream, 1) { |
144 GET_NON_NULL_NATIVE_ARGUMENT(String, stream_id, arguments->NativeArgAt(0)); | 144 GET_NON_NULL_NATIVE_ARGUMENT(String, stream_id, arguments->NativeArgAt(0)); |
145 Service::CancelStream(stream_id.ToCString()); | 145 Service::CancelStream(stream_id.ToCString()); |
146 return Object::null(); | 146 return Object::null(); |
147 } | 147 } |
148 | 148 |
149 } // namespace dart | 149 } // namespace dart |
OLD | NEW |