| 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 "include/dart_native_api.h" | 5 #include "include/dart_native_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "vm/bootstrap_natives.h" | 7 #include "vm/bootstrap_natives.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/dart.h" | 9 #include "vm/dart.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| 11 #include "vm/dart_api_message.h" | 11 #include "vm/dart_api_message.h" |
| 12 #include "vm/dart_entry.h" | 12 #include "vm/dart_entry.h" |
| 13 #include "vm/exceptions.h" | 13 #include "vm/exceptions.h" |
| 14 #include "vm/lockers.h" | 14 #include "vm/lockers.h" |
| 15 #include "vm/longjump.h" | 15 #include "vm/longjump.h" |
| 16 #include "vm/message_handler.h" | 16 #include "vm/message_handler.h" |
| 17 #include "vm/object.h" | 17 #include "vm/object.h" |
| 18 #include "vm/object_store.h" | 18 #include "vm/object_store.h" |
| 19 #include "vm/port.h" | 19 #include "vm/port.h" |
| 20 #include "vm/resolver.h" | 20 #include "vm/resolver.h" |
| 21 #include "vm/service.h" | 21 #include "vm/service.h" |
| 22 #include "vm/snapshot.h" | 22 #include "vm/snapshot.h" |
| 23 #include "vm/symbols.h" | 23 #include "vm/symbols.h" |
| 24 #include "vm/unicode.h" | 24 #include "vm/unicode.h" |
| 25 | 25 |
| 26 namespace dart { | 26 namespace dart { |
| 27 | 27 |
| 28 DEFINE_FLAG(bool, i_like_slow_isolate_spawn, false, | 28 DEFINE_FLAG(bool, |
| 29 i_like_slow_isolate_spawn, |
| 30 false, |
| 29 "Block the parent thread when loading spawned isolates."); | 31 "Block the parent thread when loading spawned isolates."); |
| 30 | 32 |
| 31 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 33 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
| 32 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 34 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
| 33 return reinterpret_cast<uint8_t*>(new_ptr); | 35 return reinterpret_cast<uint8_t*>(new_ptr); |
| 34 } | 36 } |
| 35 | 37 |
| 36 | 38 |
| 37 DEFINE_NATIVE_ENTRY(CapabilityImpl_factory, 1) { | 39 DEFINE_NATIVE_ENTRY(CapabilityImpl_factory, 1) { |
| 38 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); | 40 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 53 int64_t id = cap.Id(); | 55 int64_t id = cap.Id(); |
| 54 int32_t hi = static_cast<int32_t>(id >> 32); | 56 int32_t hi = static_cast<int32_t>(id >> 32); |
| 55 int32_t lo = static_cast<int32_t>(id); | 57 int32_t lo = static_cast<int32_t>(id); |
| 56 int32_t hash = (hi ^ lo) & kSmiMax; | 58 int32_t hash = (hi ^ lo) & kSmiMax; |
| 57 return Smi::New(hash); | 59 return Smi::New(hash); |
| 58 } | 60 } |
| 59 | 61 |
| 60 | 62 |
| 61 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_factory, 1) { | 63 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_factory, 1) { |
| 62 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); | 64 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); |
| 63 Dart_Port port_id = | 65 Dart_Port port_id = PortMap::CreatePort(isolate->message_handler()); |
| 64 PortMap::CreatePort(isolate->message_handler()); | |
| 65 return ReceivePort::New(port_id, false /* not control port */); | 66 return ReceivePort::New(port_id, false /* not control port */); |
| 66 } | 67 } |
| 67 | 68 |
| 68 | 69 |
| 69 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_get_id, 1) { | 70 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_get_id, 1) { |
| 70 GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0)); | 71 GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0)); |
| 71 return Integer::NewFromUint64(port.Id()); | 72 return Integer::NewFromUint64(port.Id()); |
| 72 } | 73 } |
| 73 | 74 |
| 74 | 75 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 104 | 105 |
| 105 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 2) { | 106 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 2) { |
| 106 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); | 107 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
| 107 // TODO(iposva): Allow for arbitrary messages to be sent. | 108 // TODO(iposva): Allow for arbitrary messages to be sent. |
| 108 GET_NON_NULL_NATIVE_ARGUMENT(Instance, obj, arguments->NativeArgAt(1)); | 109 GET_NON_NULL_NATIVE_ARGUMENT(Instance, obj, arguments->NativeArgAt(1)); |
| 109 | 110 |
| 110 const Dart_Port destination_port_id = port.Id(); | 111 const Dart_Port destination_port_id = port.Id(); |
| 111 const bool can_send_any_object = isolate->origin_id() == port.origin_id(); | 112 const bool can_send_any_object = isolate->origin_id() == port.origin_id(); |
| 112 | 113 |
| 113 if (ApiObjectConverter::CanConvert(obj.raw())) { | 114 if (ApiObjectConverter::CanConvert(obj.raw())) { |
| 114 PortMap::PostMessage(new Message( | 115 PortMap::PostMessage( |
| 115 destination_port_id, obj.raw(), Message::kNormalPriority)); | 116 new Message(destination_port_id, obj.raw(), Message::kNormalPriority)); |
| 116 } else { | 117 } else { |
| 117 uint8_t* data = NULL; | 118 uint8_t* data = NULL; |
| 118 MessageWriter writer(&data, &allocator, can_send_any_object); | 119 MessageWriter writer(&data, &allocator, can_send_any_object); |
| 119 writer.WriteMessage(obj); | 120 writer.WriteMessage(obj); |
| 120 | 121 |
| 121 // TODO(turnidge): Throw an exception when the return value is false? | 122 // TODO(turnidge): Throw an exception when the return value is false? |
| 122 PortMap::PostMessage(new Message(destination_port_id, | 123 PortMap::PostMessage(new Message(destination_port_id, data, |
| 123 data, writer.BytesWritten(), | 124 writer.BytesWritten(), |
| 124 Message::kNormalPriority)); | 125 Message::kNormalPriority)); |
| 125 } | 126 } |
| 126 return Object::null(); | 127 return Object::null(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 | 130 |
| 130 static void ThrowIsolateSpawnException(const String& message) { | 131 static void ThrowIsolateSpawnException(const String& message) { |
| 131 const Array& args = Array::Handle(Array::New(1)); | 132 const Array& args = Array::Handle(Array::New(1)); |
| 132 args.SetAt(0, message); | 133 args.SetAt(0, message); |
| 133 Exceptions::ThrowByType(Exceptions::kIsolateSpawn, args); | 134 Exceptions::ThrowByType(Exceptions::kIsolateSpawn, args); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 147 ReportError( | 148 ReportError( |
| 148 "Isolate spawn is not supported by this Dart implementation\n"); | 149 "Isolate spawn is not supported by this Dart implementation\n"); |
| 149 delete state_; | 150 delete state_; |
| 150 state_ = NULL; | 151 state_ = NULL; |
| 151 return; | 152 return; |
| 152 } | 153 } |
| 153 | 154 |
| 154 // Make a copy of the state's isolate flags and hand it to the callback. | 155 // Make a copy of the state's isolate flags and hand it to the callback. |
| 155 Dart_IsolateFlags api_flags = *(state_->isolate_flags()); | 156 Dart_IsolateFlags api_flags = *(state_->isolate_flags()); |
| 156 | 157 |
| 157 Isolate* isolate = reinterpret_cast<Isolate*>( | 158 Isolate* isolate = reinterpret_cast<Isolate*>((callback)( |
| 158 (callback)(state_->script_url(), | 159 state_->script_url(), state_->function_name(), state_->package_root(), |
| 159 state_->function_name(), | 160 state_->package_config(), &api_flags, state_->init_data(), &error)); |
| 160 state_->package_root(), | |
| 161 state_->package_config(), | |
| 162 &api_flags, | |
| 163 state_->init_data(), | |
| 164 &error)); | |
| 165 state_->DecrementSpawnCount(); | 161 state_->DecrementSpawnCount(); |
| 166 if (isolate == NULL) { | 162 if (isolate == NULL) { |
| 167 ReportError(error); | 163 ReportError(error); |
| 168 delete state_; | 164 delete state_; |
| 169 state_ = NULL; | 165 state_ = NULL; |
| 170 free(error); | 166 free(error); |
| 171 return; | 167 return; |
| 172 } | 168 } |
| 173 | 169 |
| 174 if (state_->origin_id() != ILLEGAL_PORT) { | 170 if (state_->origin_id() != ILLEGAL_PORT) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 234 |
| 239 const char* utf8_package_root = | 235 const char* utf8_package_root = |
| 240 packageRoot.IsNull() ? NULL : String2UTF8(packageRoot); | 236 packageRoot.IsNull() ? NULL : String2UTF8(packageRoot); |
| 241 const char* utf8_package_config = | 237 const char* utf8_package_config = |
| 242 packageConfig.IsNull() ? NULL : String2UTF8(packageConfig); | 238 packageConfig.IsNull() ? NULL : String2UTF8(packageConfig); |
| 243 | 239 |
| 244 bool fatal_errors = fatalErrors.IsNull() ? true : fatalErrors.value(); | 240 bool fatal_errors = fatalErrors.IsNull() ? true : fatalErrors.value(); |
| 245 Dart_Port on_exit_port = onExit.IsNull() ? ILLEGAL_PORT : onExit.Id(); | 241 Dart_Port on_exit_port = onExit.IsNull() ? ILLEGAL_PORT : onExit.Id(); |
| 246 Dart_Port on_error_port = onError.IsNull() ? ILLEGAL_PORT : onError.Id(); | 242 Dart_Port on_error_port = onError.IsNull() ? ILLEGAL_PORT : onError.Id(); |
| 247 | 243 |
| 248 IsolateSpawnState* state = | 244 IsolateSpawnState* state = new IsolateSpawnState( |
| 249 new IsolateSpawnState(port.Id(), | 245 port.Id(), isolate->origin_id(), isolate->init_callback_data(), |
| 250 isolate->origin_id(), | 246 String2UTF8(script_uri), func, message, |
| 251 isolate->init_callback_data(), | 247 isolate->spawn_count_monitor(), isolate->spawn_count(), |
| 252 String2UTF8(script_uri), | 248 utf8_package_root, utf8_package_config, paused.value(), fatal_errors, |
| 253 func, | 249 on_exit_port, on_error_port); |
| 254 message, | |
| 255 isolate->spawn_count_monitor(), | |
| 256 isolate->spawn_count(), | |
| 257 utf8_package_root, | |
| 258 utf8_package_config, | |
| 259 paused.value(), | |
| 260 fatal_errors, | |
| 261 on_exit_port, | |
| 262 on_error_port); | |
| 263 ThreadPool::Task* spawn_task = new SpawnIsolateTask(state); | 250 ThreadPool::Task* spawn_task = new SpawnIsolateTask(state); |
| 264 | 251 |
| 265 isolate->IncrementSpawnCount(); | 252 isolate->IncrementSpawnCount(); |
| 266 if (FLAG_i_like_slow_isolate_spawn) { | 253 if (FLAG_i_like_slow_isolate_spawn) { |
| 267 // We block the parent isolate while the child isolate loads. | 254 // We block the parent isolate while the child isolate loads. |
| 268 Isolate* saved = Isolate::Current(); | 255 Isolate* saved = Isolate::Current(); |
| 269 Thread::ExitIsolate(); | 256 Thread::ExitIsolate(); |
| 270 spawn_task->Run(); | 257 spawn_task->Run(); |
| 271 delete spawn_task; | 258 delete spawn_task; |
| 272 spawn_task = NULL; | 259 spawn_task = NULL; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 293 const Library& library, | 280 const Library& library, |
| 294 const String& uri, | 281 const String& uri, |
| 295 char** error) { | 282 char** error) { |
| 296 const char* result = NULL; | 283 const char* result = NULL; |
| 297 Zone* zone = thread->zone(); | 284 Zone* zone = thread->zone(); |
| 298 Isolate* isolate = thread->isolate(); | 285 Isolate* isolate = thread->isolate(); |
| 299 Dart_LibraryTagHandler handler = isolate->library_tag_handler(); | 286 Dart_LibraryTagHandler handler = isolate->library_tag_handler(); |
| 300 if (handler != NULL) { | 287 if (handler != NULL) { |
| 301 TransitionVMToNative transition(thread); | 288 TransitionVMToNative transition(thread); |
| 302 Dart_EnterScope(); | 289 Dart_EnterScope(); |
| 303 Dart_Handle handle = handler(Dart_kCanonicalizeUrl, | 290 Dart_Handle handle = |
| 304 Api::NewHandle(thread, library.raw()), | 291 handler(Dart_kCanonicalizeUrl, Api::NewHandle(thread, library.raw()), |
| 305 Api::NewHandle(thread, uri.raw())); | 292 Api::NewHandle(thread, uri.raw())); |
| 306 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); | 293 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); |
| 307 if (obj.IsString()) { | 294 if (obj.IsString()) { |
| 308 result = String2UTF8(String::Cast(obj)); | 295 result = String2UTF8(String::Cast(obj)); |
| 309 } else if (obj.IsError()) { | 296 } else if (obj.IsError()) { |
| 310 Error& error_obj = Error::Handle(); | 297 Error& error_obj = Error::Handle(); |
| 311 error_obj ^= obj.raw(); | 298 error_obj ^= obj.raw(); |
| 312 *error = zone->PrintToString("Unable to canonicalize uri '%s': %s", | 299 *error = zone->PrintToString("Unable to canonicalize uri '%s': %s", |
| 313 uri.ToCString(), error_obj.ToErrorCString()); | 300 uri.ToCString(), error_obj.ToErrorCString()); |
| 314 } else { | 301 } else { |
| 315 *error = zone->PrintToString("Unable to canonicalize uri '%s': " | 302 *error = zone->PrintToString( |
| 316 "library tag handler returned wrong type", | 303 "Unable to canonicalize uri '%s': " |
| 317 uri.ToCString()); | 304 "library tag handler returned wrong type", |
| 305 uri.ToCString()); |
| 318 } | 306 } |
| 319 Dart_ExitScope(); | 307 Dart_ExitScope(); |
| 320 } else { | 308 } else { |
| 321 *error = zone->PrintToString( | 309 *error = zone->PrintToString( |
| 322 "Unable to canonicalize uri '%s': no library tag handler found.", | 310 "Unable to canonicalize uri '%s': no library tag handler found.", |
| 323 uri.ToCString()); | 311 uri.ToCString()); |
| 324 } | 312 } |
| 325 return result; | 313 return result; |
| 326 } | 314 } |
| 327 | 315 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 341 GET_NATIVE_ARGUMENT(Bool, checked, arguments->NativeArgAt(8)); | 329 GET_NATIVE_ARGUMENT(Bool, checked, arguments->NativeArgAt(8)); |
| 342 | 330 |
| 343 GET_NATIVE_ARGUMENT(Array, environment, arguments->NativeArgAt(9)); | 331 GET_NATIVE_ARGUMENT(Array, environment, arguments->NativeArgAt(9)); |
| 344 | 332 |
| 345 GET_NATIVE_ARGUMENT(String, packageRoot, arguments->NativeArgAt(10)); | 333 GET_NATIVE_ARGUMENT(String, packageRoot, arguments->NativeArgAt(10)); |
| 346 GET_NATIVE_ARGUMENT(String, packageConfig, arguments->NativeArgAt(11)); | 334 GET_NATIVE_ARGUMENT(String, packageConfig, arguments->NativeArgAt(11)); |
| 347 | 335 |
| 348 if (Snapshot::IncludesCode(Dart::snapshot_kind())) { | 336 if (Snapshot::IncludesCode(Dart::snapshot_kind())) { |
| 349 const Array& args = Array::Handle(Array::New(1)); | 337 const Array& args = Array::Handle(Array::New(1)); |
| 350 args.SetAt(0, String::Handle(String::New( | 338 args.SetAt(0, String::Handle(String::New( |
| 351 "Isolate.spawnUri not supported under precompilation"))); | 339 "Isolate.spawnUri not supported under precompilation"))); |
| 352 Exceptions::ThrowByType(Exceptions::kUnsupported, args); | 340 Exceptions::ThrowByType(Exceptions::kUnsupported, args); |
| 353 UNREACHABLE(); | 341 UNREACHABLE(); |
| 354 } | 342 } |
| 355 | 343 |
| 356 // Canonicalize the uri with respect to the current isolate. | 344 // Canonicalize the uri with respect to the current isolate. |
| 357 const Library& root_lib = | 345 const Library& root_lib = |
| 358 Library::Handle(isolate->object_store()->root_library()); | 346 Library::Handle(isolate->object_store()->root_library()); |
| 359 char* error = NULL; | 347 char* error = NULL; |
| 360 const char* canonical_uri = CanonicalizeUri(thread, root_lib, uri, &error); | 348 const char* canonical_uri = CanonicalizeUri(thread, root_lib, uri, &error); |
| 361 if (canonical_uri == NULL) { | 349 if (canonical_uri == NULL) { |
| 362 const String& msg = String::Handle(String::New(error)); | 350 const String& msg = String::Handle(String::New(error)); |
| 363 ThrowIsolateSpawnException(msg); | 351 ThrowIsolateSpawnException(msg); |
| 364 } | 352 } |
| 365 | 353 |
| 366 const char* utf8_package_root = | 354 const char* utf8_package_root = |
| 367 packageRoot.IsNull() ? NULL : String2UTF8(packageRoot); | 355 packageRoot.IsNull() ? NULL : String2UTF8(packageRoot); |
| 368 const char* utf8_package_config = | 356 const char* utf8_package_config = |
| 369 packageConfig.IsNull() ? NULL : String2UTF8(packageConfig); | 357 packageConfig.IsNull() ? NULL : String2UTF8(packageConfig); |
| 370 | 358 |
| 371 bool fatal_errors = fatalErrors.IsNull() ? true : fatalErrors.value(); | 359 bool fatal_errors = fatalErrors.IsNull() ? true : fatalErrors.value(); |
| 372 Dart_Port on_exit_port = onExit.IsNull() ? ILLEGAL_PORT : onExit.Id(); | 360 Dart_Port on_exit_port = onExit.IsNull() ? ILLEGAL_PORT : onExit.Id(); |
| 373 Dart_Port on_error_port = onError.IsNull() ? ILLEGAL_PORT : onError.Id(); | 361 Dart_Port on_error_port = onError.IsNull() ? ILLEGAL_PORT : onError.Id(); |
| 374 | 362 |
| 375 IsolateSpawnState* state = | 363 IsolateSpawnState* state = new IsolateSpawnState( |
| 376 new IsolateSpawnState( | 364 port.Id(), isolate->init_callback_data(), canonical_uri, |
| 377 port.Id(), | 365 utf8_package_root, utf8_package_config, args, message, |
| 378 isolate->init_callback_data(), | 366 isolate->spawn_count_monitor(), isolate->spawn_count(), paused.value(), |
| 379 canonical_uri, | 367 fatal_errors, on_exit_port, on_error_port); |
| 380 utf8_package_root, | |
| 381 utf8_package_config, | |
| 382 args, | |
| 383 message, | |
| 384 isolate->spawn_count_monitor(), | |
| 385 isolate->spawn_count(), | |
| 386 paused.value(), | |
| 387 fatal_errors, | |
| 388 on_exit_port, | |
| 389 on_error_port); | |
| 390 | 368 |
| 391 // If we were passed a value then override the default flags state for | 369 // If we were passed a value then override the default flags state for |
| 392 // checked mode. | 370 // checked mode. |
| 393 if (!checked.IsNull()) { | 371 if (!checked.IsNull()) { |
| 394 bool val = checked.value(); | 372 bool val = checked.value(); |
| 395 Dart_IsolateFlags* flags = state->isolate_flags(); | 373 Dart_IsolateFlags* flags = state->isolate_flags(); |
| 396 flags->enable_asserts = val; | 374 flags->enable_asserts = val; |
| 397 flags->enable_type_checks = val; | 375 flags->enable_type_checks = val; |
| 398 } | 376 } |
| 399 | 377 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 416 delete spawn_task; | 394 delete spawn_task; |
| 417 spawn_task = NULL; | 395 spawn_task = NULL; |
| 418 } | 396 } |
| 419 return Object::null(); | 397 return Object::null(); |
| 420 } | 398 } |
| 421 | 399 |
| 422 | 400 |
| 423 DEFINE_NATIVE_ENTRY(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) { | 401 DEFINE_NATIVE_ENTRY(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) { |
| 424 const Array& result = Array::Handle(Array::New(3)); | 402 const Array& result = Array::Handle(Array::New(3)); |
| 425 result.SetAt(0, SendPort::Handle(SendPort::New(isolate->main_port()))); | 403 result.SetAt(0, SendPort::Handle(SendPort::New(isolate->main_port()))); |
| 426 result.SetAt(1, Capability::Handle( | 404 result.SetAt( |
| 427 Capability::New(isolate->pause_capability()))); | 405 1, Capability::Handle(Capability::New(isolate->pause_capability()))); |
| 428 result.SetAt(2, Capability::Handle( | 406 result.SetAt( |
| 429 Capability::New(isolate->terminate_capability()))); | 407 2, Capability::Handle(Capability::New(isolate->terminate_capability()))); |
| 430 return result.raw(); | 408 return result.raw(); |
| 431 } | 409 } |
| 432 | 410 |
| 433 | 411 |
| 434 DEFINE_NATIVE_ENTRY(Isolate_getCurrentRootUriStr, 0) { | 412 DEFINE_NATIVE_ENTRY(Isolate_getCurrentRootUriStr, 0) { |
| 435 const Library& root_lib = Library::Handle(zone, | 413 const Library& root_lib = |
| 436 isolate->object_store()->root_library()); | 414 Library::Handle(zone, isolate->object_store()->root_library()); |
| 437 return root_lib.url(); | 415 return root_lib.url(); |
| 438 } | 416 } |
| 439 | 417 |
| 440 | 418 |
| 441 DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) { | 419 DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) { |
| 442 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); | 420 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
| 443 GET_NON_NULL_NATIVE_ARGUMENT(Array, msg, arguments->NativeArgAt(1)); | 421 GET_NON_NULL_NATIVE_ARGUMENT(Array, msg, arguments->NativeArgAt(1)); |
| 444 | 422 |
| 445 // Make sure to route this request to the isolate library OOB mesage handler. | 423 // Make sure to route this request to the isolate library OOB mesage handler. |
| 446 msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg))); | 424 msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg))); |
| 447 | 425 |
| 448 uint8_t* data = NULL; | 426 uint8_t* data = NULL; |
| 449 MessageWriter writer(&data, &allocator, false); | 427 MessageWriter writer(&data, &allocator, false); |
| 450 writer.WriteMessage(msg); | 428 writer.WriteMessage(msg); |
| 451 | 429 |
| 452 PortMap::PostMessage(new Message(port.Id(), | 430 PortMap::PostMessage(new Message(port.Id(), data, writer.BytesWritten(), |
| 453 data, writer.BytesWritten(), | |
| 454 Message::kOOBPriority)); | 431 Message::kOOBPriority)); |
| 455 return Object::null(); | 432 return Object::null(); |
| 456 } | 433 } |
| 457 | 434 |
| 458 } // namespace dart | 435 } // namespace dart |
| OLD | NEW |