| 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 state->isolate()->set_spawn_data(reinterpret_cast<uword>(state)); | 391 state->isolate()->set_spawn_data(reinterpret_cast<uword>(state)); |
| 392 state->isolate()->message_handler()->Run( | 392 state->isolate()->message_handler()->Run( |
| 393 Dart::thread_pool(), RunIsolate, ShutdownIsolate, | 393 Dart::thread_pool(), RunIsolate, ShutdownIsolate, |
| 394 reinterpret_cast<uword>(state->isolate())); | 394 reinterpret_cast<uword>(state->isolate())); |
| 395 | 395 |
| 396 return port.raw(); | 396 return port.raw(); |
| 397 } | 397 } |
| 398 | 398 |
| 399 | 399 |
| 400 DEFINE_NATIVE_ENTRY(isolate_spawnFunction, 1) { | 400 DEFINE_NATIVE_ENTRY(isolate_spawnFunction, 1) { |
| 401 GET_NATIVE_ARGUMENT(Closure, closure, arguments->At(0)); | 401 GET_NATIVE_ARGUMENT(Instance, closure, arguments->At(0)); |
| 402 const Function& func = Function::Handle(closure.function()); | 402 bool throw_exception = false; |
| 403 const Class& cls = Class::Handle(func.Owner()); | 403 Function& func = Function::Handle(); |
| 404 if (!func.IsClosureFunction() || !func.is_static() || !cls.IsTopLevel()) { | 404 if (closure.IsClosure()) { |
| 405 func ^= Closure::function(closure); |
| 406 const Class& cls = Class::Handle(func.Owner()); |
| 407 if (!func.IsClosureFunction() || !func.is_static() || !cls.IsTopLevel()) { |
| 408 throw_exception = true; |
| 409 } |
| 410 } else { |
| 411 throw_exception = true; |
| 412 } |
| 413 if (throw_exception) { |
| 405 const String& msg = String::Handle(String::New( | 414 const String& msg = String::Handle(String::New( |
| 406 "spawnFunction expects to be passed a closure to a top-level static " | 415 "spawnFunction expects to be passed a closure to a top-level static " |
| 407 "function")); | 416 "function")); |
| 408 ThrowIllegalArgException(msg); | 417 ThrowIllegalArgException(msg); |
| 409 } | 418 } |
| 410 | 419 |
| 411 #if defined(DEBUG) | 420 #if defined(DEBUG) |
| 412 const Context& ctx = Context::Handle(closure.context()); | 421 const Context& ctx = Context::Handle(Closure::context(closure)); |
| 413 ASSERT(ctx.num_variables() == 0); | 422 ASSERT(ctx.num_variables() == 0); |
| 414 #endif | 423 #endif |
| 415 | 424 |
| 416 return Spawn(arguments, new SpawnState(func)); | 425 return Spawn(arguments, new SpawnState(func)); |
| 417 } | 426 } |
| 418 | 427 |
| 419 | 428 |
| 420 DEFINE_NATIVE_ENTRY(isolate_spawnUri, 1) { | 429 DEFINE_NATIVE_ENTRY(isolate_spawnUri, 1) { |
| 421 GET_NATIVE_ARGUMENT(String, uri, arguments->At(0)); | 430 GET_NATIVE_ARGUMENT(String, uri, arguments->At(0)); |
| 422 | 431 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 438 | 447 |
| 439 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { | 448 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { |
| 440 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); | 449 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); |
| 441 if (port.IsError()) { | 450 if (port.IsError()) { |
| 442 Exceptions::PropagateError(Error::Cast(port)); | 451 Exceptions::PropagateError(Error::Cast(port)); |
| 443 } | 452 } |
| 444 return port.raw(); | 453 return port.raw(); |
| 445 } | 454 } |
| 446 | 455 |
| 447 } // namespace dart | 456 } // namespace dart |
| OLD | NEW |