| 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" |
| 11 #include "vm/exceptions.h" | 11 #include "vm/exceptions.h" |
| 12 #include "vm/longjump.h" | 12 #include "vm/longjump.h" |
| 13 #include "vm/message_handler.h" | 13 #include "vm/message_handler.h" |
| 14 #include "vm/object.h" | 14 #include "vm/object.h" |
| 15 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
| 16 #include "vm/port.h" | 16 #include "vm/port.h" |
| 17 #include "vm/resolver.h" | 17 #include "vm/resolver.h" |
| 18 #include "vm/snapshot.h" | 18 #include "vm/snapshot.h" |
| 19 #include "vm/symbols.h" | 19 #include "vm/symbols.h" |
| 20 #include "vm/thread.h" | 20 #include "vm/thread.h" |
| 21 | 21 |
| 22 namespace dart { | 22 namespace dart { |
| 23 | 23 |
| 24 class IsolateStartData { | |
| 25 public: | |
| 26 IsolateStartData(char* library_url, | |
| 27 char* class_name, | |
| 28 intptr_t port_id) | |
| 29 : library_url_(library_url), | |
| 30 class_name_(class_name), | |
| 31 port_id_(port_id) {} | |
| 32 | |
| 33 char* library_url_; | |
| 34 char* class_name_; | |
| 35 intptr_t port_id_; | |
| 36 }; | |
| 37 | |
| 38 | |
| 39 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 24 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
| 40 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 25 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
| 41 return reinterpret_cast<uint8_t*>(new_ptr); | 26 return reinterpret_cast<uint8_t*>(new_ptr); |
| 42 } | 27 } |
| 43 | 28 |
| 44 | 29 |
| 45 // TODO(turnidge): Move to DartLibraryCalls. | 30 // TODO(turnidge): Move to DartLibraryCalls. |
| 46 static RawObject* ReceivePortCreate(Dart_Port port_id) { | 31 static RawObject* ReceivePortCreate(Dart_Port port_id) { |
| 47 Isolate* isolate = Isolate::Current(); | 32 Isolate* isolate = Isolate::Current(); |
| 48 Function& func = | 33 Function& func = |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 const Object& port = Object::Handle( | 182 const Object& port = Object::Handle( |
| 198 DartLibraryCalls::NewSendPort(state->isolate()->main_port())); | 183 DartLibraryCalls::NewSendPort(state->isolate()->main_port())); |
| 199 if (port.IsError()) { | 184 if (port.IsError()) { |
| 200 state->Cleanup(); | 185 state->Cleanup(); |
| 201 delete state; | 186 delete state; |
| 202 Exceptions::PropagateError(Error::Cast(port)); | 187 Exceptions::PropagateError(Error::Cast(port)); |
| 203 } | 188 } |
| 204 | 189 |
| 205 // Start the new isolate if it is already marked as runnable. | 190 // Start the new isolate if it is already marked as runnable. |
| 206 MutexLocker ml(state->isolate()->mutex()); | 191 MutexLocker ml(state->isolate()->mutex()); |
| 207 state->isolate()->set_spawn_data(reinterpret_cast<uword>(state)); | 192 state->isolate()->set_spawn_state(state); |
| 208 if (state->isolate()->is_runnable()) { | 193 if (state->isolate()->is_runnable()) { |
| 209 state->isolate()->Run(); | 194 state->isolate()->Run(); |
| 210 } | 195 } |
| 211 | 196 |
| 212 return port.raw(); | 197 return port.raw(); |
| 213 } | 198 } |
| 214 | 199 |
| 215 | 200 |
| 216 DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 1) { | 201 DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 1) { |
| 217 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0)); | 202 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 245 |
| 261 // The control port is being accessed as a regular port from Dart code. This | 246 // The control port is being accessed as a regular port from Dart code. This |
| 262 // is most likely due to the _startIsolate code in dart:isolate. Account for | 247 // is most likely due to the _startIsolate code in dart:isolate. Account for |
| 263 // this by increasing the number of open control ports. | 248 // this by increasing the number of open control ports. |
| 264 isolate->message_handler()->increment_control_ports(); | 249 isolate->message_handler()->increment_control_ports(); |
| 265 | 250 |
| 266 return port.raw(); | 251 return port.raw(); |
| 267 } | 252 } |
| 268 | 253 |
| 269 } // namespace dart | 254 } // namespace dart |
| OLD | NEW |