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/service_isolate.h" | 5 #include "vm/service_isolate.h" |
6 | 6 |
7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 Function& register_function_; | 212 Function& register_function_; |
213 Isolate* service_isolate_; | 213 Isolate* service_isolate_; |
214 }; | 214 }; |
215 | 215 |
216 | 216 |
217 | 217 |
218 class ServiceIsolateNatives : public AllStatic { | 218 class ServiceIsolateNatives : public AllStatic { |
219 public: | 219 public: |
220 static void SendIsolateServiceMessage(Dart_NativeArguments args) { | 220 static void SendIsolateServiceMessage(Dart_NativeArguments args) { |
221 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 221 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
222 Isolate* isolate = arguments->isolate(); | 222 Isolate* isolate = arguments->thread()->isolate(); |
223 StackZone stack_zone(isolate); | 223 StackZone stack_zone(isolate); |
224 Zone* zone = stack_zone.GetZone(); // Used by GET_NON_NULL_NATIVE_ARGUMENT. | 224 Zone* zone = stack_zone.GetZone(); // Used by GET_NON_NULL_NATIVE_ARGUMENT. |
225 HANDLESCOPE(isolate); | 225 HANDLESCOPE(isolate); |
226 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, sp, arguments->NativeArgAt(0)); | 226 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, sp, arguments->NativeArgAt(0)); |
227 GET_NON_NULL_NATIVE_ARGUMENT(Array, message, arguments->NativeArgAt(1)); | 227 GET_NON_NULL_NATIVE_ARGUMENT(Array, message, arguments->NativeArgAt(1)); |
228 | 228 |
229 // Set the type of the OOB message. | 229 // Set the type of the OOB message. |
230 message.SetAt(0, Smi::Handle(isolate, Smi::New(Message::kServiceOOBMsg))); | 230 message.SetAt(0, Smi::Handle(isolate, Smi::New(Message::kServiceOOBMsg))); |
231 | 231 |
232 // Serialize message. | 232 // Serialize message. |
233 uint8_t* data = NULL; | 233 uint8_t* data = NULL; |
234 MessageWriter writer(&data, &allocator, false); | 234 MessageWriter writer(&data, &allocator, false); |
235 writer.WriteMessage(message); | 235 writer.WriteMessage(message); |
236 | 236 |
237 // TODO(turnidge): Throw an exception when the return value is false? | 237 // TODO(turnidge): Throw an exception when the return value is false? |
238 bool result = PortMap::PostMessage( | 238 bool result = PortMap::PostMessage( |
239 new Message(sp.Id(), data, writer.BytesWritten(), | 239 new Message(sp.Id(), data, writer.BytesWritten(), |
240 Message::kOOBPriority)); | 240 Message::kOOBPriority)); |
241 arguments->SetReturn(Bool::Get(result)); | 241 arguments->SetReturn(Bool::Get(result)); |
242 } | 242 } |
243 | 243 |
244 static void SendRootServiceMessage(Dart_NativeArguments args) { | 244 static void SendRootServiceMessage(Dart_NativeArguments args) { |
245 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 245 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
246 Isolate* isolate = arguments->isolate(); | 246 Isolate* isolate = arguments->thread()->isolate(); |
247 StackZone stack_zone(isolate); | 247 StackZone stack_zone(isolate); |
248 Zone* zone = stack_zone.GetZone(); // Used by GET_NON_NULL_NATIVE_ARGUMENT. | 248 Zone* zone = stack_zone.GetZone(); // Used by GET_NON_NULL_NATIVE_ARGUMENT. |
249 HANDLESCOPE(isolate); | 249 HANDLESCOPE(isolate); |
250 GET_NON_NULL_NATIVE_ARGUMENT(Array, message, arguments->NativeArgAt(0)); | 250 GET_NON_NULL_NATIVE_ARGUMENT(Array, message, arguments->NativeArgAt(0)); |
251 Service::HandleRootMessage(message); | 251 Service::HandleRootMessage(message); |
252 } | 252 } |
253 | 253 |
254 static void OnStart(Dart_NativeArguments args) { | 254 static void OnStart(Dart_NativeArguments args) { |
255 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 255 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
256 Isolate* isolate = arguments->isolate(); | 256 Isolate* isolate = arguments->thread()->isolate(); |
257 StackZone zone(isolate); | 257 StackZone zone(isolate); |
258 HANDLESCOPE(isolate); | 258 HANDLESCOPE(isolate); |
259 { | 259 { |
260 if (FLAG_trace_service) { | 260 if (FLAG_trace_service) { |
261 OS::Print("vm-service: Booting dart:vmservice library.\n"); | 261 OS::Print("vm-service: Booting dart:vmservice library.\n"); |
262 } | 262 } |
263 // Boot the dart:vmservice library. | 263 // Boot the dart:vmservice library. |
264 Dart_EnterScope(); | 264 Dart_EnterScope(); |
265 Dart_Handle url_str = | 265 Dart_Handle url_str = |
266 Dart_NewStringFromCString(Symbols::Name(Symbols::kDartVMServiceId)); | 266 Dart_NewStringFromCString(Symbols::Name(Symbols::kDartVMServiceId)); |
(...skipping 13 matching lines...) Expand all Loading... |
280 OS::Print("vm-service: Registering running isolates.\n"); | 280 OS::Print("vm-service: Registering running isolates.\n"); |
281 } | 281 } |
282 // Register running isolates with service. | 282 // Register running isolates with service. |
283 RegisterRunningIsolatesVisitor register_isolates(isolate); | 283 RegisterRunningIsolatesVisitor register_isolates(isolate); |
284 Isolate::VisitIsolates(®ister_isolates); | 284 Isolate::VisitIsolates(®ister_isolates); |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
288 static void OnExit(Dart_NativeArguments args) { | 288 static void OnExit(Dart_NativeArguments args) { |
289 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 289 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
290 Isolate* isolate = arguments->isolate(); | 290 Isolate* isolate = arguments->thread()->isolate(); |
291 StackZone zone(isolate); | 291 StackZone zone(isolate); |
292 HANDLESCOPE(isolate); | 292 HANDLESCOPE(isolate); |
293 { | 293 { |
294 if (FLAG_trace_service) { | 294 if (FLAG_trace_service) { |
295 OS::Print("vm-service: processed exit message.\n"); | 295 OS::Print("vm-service: processed exit message.\n"); |
296 } | 296 } |
297 } | 297 } |
298 } | 298 } |
299 | 299 |
300 static void ListenStream(Dart_NativeArguments args) { | 300 static void ListenStream(Dart_NativeArguments args) { |
301 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 301 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
302 Isolate* isolate = arguments->isolate(); | 302 Isolate* isolate = arguments->thread()->isolate(); |
303 StackZone stack_zone(isolate); | 303 StackZone stack_zone(isolate); |
304 Zone* zone = stack_zone.GetZone(); // Used by GET_NON_NULL_NATIVE_ARGUMENT. | 304 Zone* zone = stack_zone.GetZone(); // Used by GET_NON_NULL_NATIVE_ARGUMENT. |
305 HANDLESCOPE(isolate); | 305 HANDLESCOPE(isolate); |
306 GET_NON_NULL_NATIVE_ARGUMENT(String, stream_id, arguments->NativeArgAt(0)); | 306 GET_NON_NULL_NATIVE_ARGUMENT(String, stream_id, arguments->NativeArgAt(0)); |
307 Service::ListenStream(stream_id.ToCString()); | 307 Service::ListenStream(stream_id.ToCString()); |
308 } | 308 } |
309 | 309 |
310 static void CancelStream(Dart_NativeArguments args) { | 310 static void CancelStream(Dart_NativeArguments args) { |
311 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 311 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
312 Isolate* isolate = arguments->isolate(); | 312 Isolate* isolate = arguments->thread()->isolate(); |
313 StackZone stack_zone(isolate); | 313 StackZone stack_zone(isolate); |
314 Zone* zone = stack_zone.GetZone(); // Used by GET_NON_NULL_NATIVE_ARGUMENT. | 314 Zone* zone = stack_zone.GetZone(); // Used by GET_NON_NULL_NATIVE_ARGUMENT. |
315 HANDLESCOPE(isolate); | 315 HANDLESCOPE(isolate); |
316 GET_NON_NULL_NATIVE_ARGUMENT(String, stream_id, arguments->NativeArgAt(0)); | 316 GET_NON_NULL_NATIVE_ARGUMENT(String, stream_id, arguments->NativeArgAt(0)); |
317 Service::CancelStream(stream_id.ToCString()); | 317 Service::CancelStream(stream_id.ToCString()); |
318 } | 318 } |
319 }; | 319 }; |
320 | 320 |
321 | 321 |
322 struct ServiceNativeEntry { | 322 struct ServiceNativeEntry { |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 return result; | 799 return result; |
800 } | 800 } |
801 Dart_Handle source = GetSource(url_string); | 801 Dart_Handle source = GetSource(url_string); |
802 if (Dart_IsError(source)) { | 802 if (Dart_IsError(source)) { |
803 return source; | 803 return source; |
804 } | 804 } |
805 return Dart_LoadSource(library, url, source, 0, 0); | 805 return Dart_LoadSource(library, url, source, 0, 0); |
806 } | 806 } |
807 | 807 |
808 } // namespace dart | 808 } // namespace dart |
OLD | NEW |