Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: runtime/lib/isolate.cc

Issue 822803003: - Allow an isolate to be started in paused state. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/isolate_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 MutexLocker ml(spawned_isolate->mutex()); 205 MutexLocker ml(spawned_isolate->mutex());
206 spawned_isolate->set_spawn_state(state); 206 spawned_isolate->set_spawn_state(state);
207 if (spawned_isolate->is_runnable()) { 207 if (spawned_isolate->is_runnable()) {
208 spawned_isolate->Run(); 208 spawned_isolate->Run();
209 } 209 }
210 210
211 return port.raw(); 211 return port.raw();
212 } 212 }
213 213
214 214
215 DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 3) { 215 DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 4) {
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(Instance, closure, arguments->NativeArgAt(1));
218 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(2)); 218 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(2));
219 GET_NON_NULL_NATIVE_ARGUMENT(Bool, paused, arguments->NativeArgAt(3));
219 if (closure.IsClosure()) { 220 if (closure.IsClosure()) {
220 Function& func = Function::Handle(); 221 Function& func = Function::Handle();
221 func = Closure::function(closure); 222 func = Closure::function(closure);
222 if (func.IsImplicitClosureFunction() && func.is_static()) { 223 if (func.IsImplicitClosureFunction() && func.is_static()) {
223 #if defined(DEBUG) 224 #if defined(DEBUG)
224 Context& ctx = Context::Handle(); 225 Context& ctx = Context::Handle();
225 ctx = Closure::context(closure); 226 ctx = Closure::context(closure);
226 ASSERT(ctx.num_variables() == 0); 227 ASSERT(ctx.num_variables() == 0);
227 #endif 228 #endif
228 return Spawn(isolate, new IsolateSpawnState(port.Id(), func, message)); 229 return Spawn(isolate, new IsolateSpawnState(
230 port.Id(), func, message, paused.value()));
229 } 231 }
230 } 232 }
231 const String& msg = String::Handle(String::New( 233 const String& msg = String::Handle(String::New(
232 "Isolate.spawn expects to be passed a static or top-level function")); 234 "Isolate.spawn expects to be passed a static or top-level function"));
233 Exceptions::ThrowArgumentError(msg); 235 Exceptions::ThrowArgumentError(msg);
234 return Object::null(); 236 return Object::null();
235 } 237 }
236 238
237 239
238 DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 5) { 240 DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 6) {
239 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); 241 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0));
240 GET_NON_NULL_NATIVE_ARGUMENT(String, uri, arguments->NativeArgAt(1)); 242 GET_NON_NULL_NATIVE_ARGUMENT(String, uri, arguments->NativeArgAt(1));
241 GET_NON_NULL_NATIVE_ARGUMENT(Instance, args, arguments->NativeArgAt(2)); 243 GET_NON_NULL_NATIVE_ARGUMENT(Instance, args, arguments->NativeArgAt(2));
242 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(3)); 244 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(3));
243 GET_NATIVE_ARGUMENT(String, package_root, arguments->NativeArgAt(4)); 245 GET_NON_NULL_NATIVE_ARGUMENT(Bool, paused, arguments->NativeArgAt(4));
246 GET_NATIVE_ARGUMENT(String, package_root, arguments->NativeArgAt(5));
244 247
245 // Canonicalize the uri with respect to the current isolate. 248 // Canonicalize the uri with respect to the current isolate.
246 char* error = NULL; 249 char* error = NULL;
247 char* canonical_uri = NULL; 250 char* canonical_uri = NULL;
248 const Library& root_lib = 251 const Library& root_lib =
249 Library::Handle(arguments->isolate()->object_store()->root_library()); 252 Library::Handle(arguments->isolate()->object_store()->root_library());
250 if (!CanonicalizeUri(arguments->isolate(), root_lib, uri, 253 if (!CanonicalizeUri(arguments->isolate(), root_lib, uri,
251 &canonical_uri, &error)) { 254 &canonical_uri, &error)) {
252 const String& msg = String::Handle(String::New(error)); 255 const String& msg = String::Handle(String::New(error));
253 ThrowIsolateSpawnException(msg); 256 ThrowIsolateSpawnException(msg);
254 } 257 }
255 258
256 char* utf8_package_root = NULL; 259 char* utf8_package_root = NULL;
257 if (!package_root.IsNull()) { 260 if (!package_root.IsNull()) {
258 const intptr_t len = Utf8::Length(package_root); 261 const intptr_t len = Utf8::Length(package_root);
259 Zone* zone = isolate->current_zone(); 262 Zone* zone = isolate->current_zone();
260 utf8_package_root = zone->Alloc<char>(len + 1); 263 utf8_package_root = zone->Alloc<char>(len + 1);
261 package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len); 264 package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len);
262 utf8_package_root[len] = '\0'; 265 utf8_package_root[len] = '\0';
263 } 266 }
264 267
265 return Spawn(isolate, new IsolateSpawnState( 268 return Spawn(isolate, new IsolateSpawnState(port.Id(),
266 port.Id(), canonical_uri, utf8_package_root, args, message)); 269 canonical_uri,
270 utf8_package_root,
271 args,
272 message,
273 paused.value()));
267 } 274 }
268 275
269 276
270 DEFINE_NATIVE_ENTRY(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) { 277 DEFINE_NATIVE_ENTRY(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) {
271 const Array& result = Array::Handle(Array::New(3)); 278 const Array& result = Array::Handle(Array::New(3));
272 result.SetAt(0, SendPort::Handle(SendPort::New(isolate->main_port()))); 279 result.SetAt(0, SendPort::Handle(SendPort::New(isolate->main_port())));
273 result.SetAt(1, Capability::Handle( 280 result.SetAt(1, Capability::Handle(
274 Capability::New(isolate->pause_capability()))); 281 Capability::New(isolate->pause_capability())));
275 result.SetAt(2, Capability::Handle( 282 result.SetAt(2, Capability::Handle(
276 Capability::New(isolate->terminate_capability()))); 283 Capability::New(isolate->terminate_capability())));
(...skipping 12 matching lines...) Expand all
289 MessageWriter writer(&data, &allocator); 296 MessageWriter writer(&data, &allocator);
290 writer.WriteMessage(msg); 297 writer.WriteMessage(msg);
291 298
292 PortMap::PostMessage(new Message(port.Id(), 299 PortMap::PostMessage(new Message(port.Id(),
293 data, writer.BytesWritten(), 300 data, writer.BytesWritten(),
294 Message::kOOBPriority)); 301 Message::kOOBPriority));
295 return Object::null(); 302 return Object::null();
296 } 303 }
297 304
298 } // namespace dart 305 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/isolate_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698