| 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" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 static const char* String2UTF8(const String& str) { | 205 static const char* String2UTF8(const String& str) { |
| 206 intptr_t len = Utf8::Length(str); | 206 intptr_t len = Utf8::Length(str); |
| 207 char* result = new char[len + 1]; | 207 char* result = new char[len + 1]; |
| 208 str.ToUTF8(reinterpret_cast<uint8_t*>(result), len); | 208 str.ToUTF8(reinterpret_cast<uint8_t*>(result), len); |
| 209 result[len] = 0; | 209 result[len] = 0; |
| 210 | 210 |
| 211 return result; | 211 return result; |
| 212 } | 212 } |
| 213 | 213 |
| 214 | 214 |
| 215 DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 9) { | 215 DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 10) { |
| 216 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); | 216 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
| 217 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(1)); | 217 GET_NON_NULL_NATIVE_ARGUMENT(String, script_uri, arguments->NativeArgAt(1)); |
| 218 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(2)); | 218 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(2)); |
| 219 GET_NON_NULL_NATIVE_ARGUMENT(Bool, paused, arguments->NativeArgAt(3)); | 219 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(3)); |
| 220 GET_NATIVE_ARGUMENT(Bool, fatalErrors, arguments->NativeArgAt(4)); | 220 GET_NON_NULL_NATIVE_ARGUMENT(Bool, paused, arguments->NativeArgAt(4)); |
| 221 GET_NATIVE_ARGUMENT(SendPort, onExit, arguments->NativeArgAt(5)); | 221 GET_NATIVE_ARGUMENT(Bool, fatalErrors, arguments->NativeArgAt(5)); |
| 222 GET_NATIVE_ARGUMENT(SendPort, onError, arguments->NativeArgAt(6)); | 222 GET_NATIVE_ARGUMENT(SendPort, onExit, arguments->NativeArgAt(6)); |
| 223 GET_NATIVE_ARGUMENT(String, packageRoot, arguments->NativeArgAt(7)); | 223 GET_NATIVE_ARGUMENT(SendPort, onError, arguments->NativeArgAt(7)); |
| 224 GET_NATIVE_ARGUMENT(String, packageConfig, arguments->NativeArgAt(8)); | 224 GET_NATIVE_ARGUMENT(String, packageRoot, arguments->NativeArgAt(8)); |
| 225 GET_NATIVE_ARGUMENT(String, packageConfig, arguments->NativeArgAt(9)); |
| 225 | 226 |
| 226 if (closure.IsClosure()) { | 227 if (closure.IsClosure()) { |
| 227 Function& func = Function::Handle(); | 228 Function& func = Function::Handle(); |
| 228 func = Closure::function(closure); | 229 func = Closure::function(closure); |
| 229 if (func.IsImplicitClosureFunction() && func.is_static()) { | 230 if (func.IsImplicitClosureFunction() && func.is_static()) { |
| 230 #if defined(DEBUG) | 231 #if defined(DEBUG) |
| 231 Context& ctx = Context::Handle(); | 232 Context& ctx = Context::Handle(); |
| 232 ctx = Closure::context(closure); | 233 ctx = Closure::context(closure); |
| 233 ASSERT(ctx.num_variables() == 0); | 234 ASSERT(ctx.num_variables() == 0); |
| 234 #endif | 235 #endif |
| 235 // Get the parent function so that we get the right function name. | 236 // Get the parent function so that we get the right function name. |
| 236 func = func.parent_function(); | 237 func = func.parent_function(); |
| 237 | 238 |
| 238 // Get the script URI so that we know what script to load. | |
| 239 const Library& root_lib = Library::Handle(zone, | |
| 240 isolate->object_store()->root_library()); | |
| 241 const String& script_uri = String::Handle(zone, root_lib.url()); | |
| 242 | |
| 243 const char* utf8_package_root = | 239 const char* utf8_package_root = |
| 244 packageRoot.IsNull() ? NULL : String2UTF8(packageRoot); | 240 packageRoot.IsNull() ? NULL : String2UTF8(packageRoot); |
| 245 const char* utf8_package_config = | 241 const char* utf8_package_config = |
| 246 packageConfig.IsNull() ? NULL : String2UTF8(packageConfig); | 242 packageConfig.IsNull() ? NULL : String2UTF8(packageConfig); |
| 247 | 243 |
| 248 bool fatal_errors = fatalErrors.IsNull() ? true : fatalErrors.value(); | 244 bool fatal_errors = fatalErrors.IsNull() ? true : fatalErrors.value(); |
| 249 Dart_Port on_exit_port = onExit.IsNull() ? ILLEGAL_PORT : onExit.Id(); | 245 Dart_Port on_exit_port = onExit.IsNull() ? ILLEGAL_PORT : onExit.Id(); |
| 250 Dart_Port on_error_port = onError.IsNull() ? ILLEGAL_PORT : onError.Id(); | 246 Dart_Port on_error_port = onError.IsNull() ? ILLEGAL_PORT : onError.Id(); |
| 251 | 247 |
| 252 IsolateSpawnState* state = | 248 IsolateSpawnState* state = |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 MessageWriter writer(&data, &allocator, false); | 445 MessageWriter writer(&data, &allocator, false); |
| 450 writer.WriteMessage(msg); | 446 writer.WriteMessage(msg); |
| 451 | 447 |
| 452 PortMap::PostMessage(new Message(port.Id(), | 448 PortMap::PostMessage(new Message(port.Id(), |
| 453 data, writer.BytesWritten(), | 449 data, writer.BytesWritten(), |
| 454 Message::kOOBPriority)); | 450 Message::kOOBPriority)); |
| 455 return Object::null(); | 451 return Object::null(); |
| 456 } | 452 } |
| 457 | 453 |
| 458 } // namespace dart | 454 } // namespace dart |
| OLD | NEW |