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 "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
8 #include "vm/dart.h" | 8 #include "vm/dart.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 utf8_package_root = zone->Alloc<char>(len + 1); | 260 utf8_package_root = zone->Alloc<char>(len + 1); |
261 package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len); | 261 package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len); |
262 utf8_package_root[len] = '\0'; | 262 utf8_package_root[len] = '\0'; |
263 } | 263 } |
264 | 264 |
265 return Spawn(isolate, new IsolateSpawnState( | 265 return Spawn(isolate, new IsolateSpawnState( |
266 port.Id(), canonical_uri, utf8_package_root, args, message)); | 266 port.Id(), canonical_uri, utf8_package_root, args, message)); |
267 } | 267 } |
268 | 268 |
269 | 269 |
| 270 DEFINE_NATIVE_ENTRY(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) { |
| 271 const Array& result = Array::Handle(Array::New(3)); |
| 272 result.SetAt(0, SendPort::Handle(SendPort::New(isolate->main_port()))); |
| 273 result.SetAt(1, Capability::Handle( |
| 274 Capability::New(isolate->pause_capability()))); |
| 275 result.SetAt(2, Capability::Handle( |
| 276 Capability::New(isolate->terminate_capability()))); |
| 277 return result.raw(); |
| 278 } |
| 279 |
| 280 |
270 DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) { | 281 DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) { |
271 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); | 282 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
272 GET_NON_NULL_NATIVE_ARGUMENT(Array, msg, arguments->NativeArgAt(1)); | 283 GET_NON_NULL_NATIVE_ARGUMENT(Array, msg, arguments->NativeArgAt(1)); |
273 | 284 |
274 // Make sure to route this request to the isolate library OOB mesage handler. | 285 // Make sure to route this request to the isolate library OOB mesage handler. |
275 msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg))); | 286 msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg))); |
276 | 287 |
277 uint8_t* data = NULL; | 288 uint8_t* data = NULL; |
278 MessageWriter writer(&data, &allocator); | 289 MessageWriter writer(&data, &allocator); |
279 writer.WriteMessage(msg); | 290 writer.WriteMessage(msg); |
280 | 291 |
281 PortMap::PostMessage(new Message(port.Id(), | 292 PortMap::PostMessage(new Message(port.Id(), |
282 data, writer.BytesWritten(), | 293 data, writer.BytesWritten(), |
283 Message::kOOBPriority)); | 294 Message::kOOBPriority)); |
284 return Object::null(); | 295 return Object::null(); |
285 } | 296 } |
286 | 297 |
287 } // namespace dart | 298 } // namespace dart |
OLD | NEW |