OLD | NEW |
---|---|
1 // Copyright (c) 2009, Google Inc. | 1 // Copyright (c) 2009, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 { | 247 { |
248 if (m_isolate) { | 248 if (m_isolate) { |
249 Dart_EnterIsolate(m_isolate); | 249 Dart_EnterIsolate(m_isolate); |
250 return; | 250 return; |
251 } | 251 } |
252 | 252 |
253 // FIXME: proper error reporting. | 253 // FIXME: proper error reporting. |
254 char* errorMessage = 0; | 254 char* errorMessage = 0; |
255 m_isolate = createIsolate(scriptURL.utf8().data(), entryPoint.utf8().data(), document, true, &errorMessage); | 255 m_isolate = createIsolate(scriptURL.utf8().data(), entryPoint.utf8().data(), document, true, &errorMessage); |
256 ASSERT(m_isolate); | 256 ASSERT(m_isolate); |
257 if (getenv("DARTIUM_VMSERVICE")) { | 257 if (true) { |
Jacob
2014/01/08 18:47:10
remove
if (true) {
Cutch
2014/01/10 21:34:26
Done.
| |
258 // createIsolate exits with current isolate set to m_isolate, we need to | 258 // createIsolate exits with current isolate set to m_isolate, we need to |
259 // exit it so we can startup the service. | 259 // exit it so we can startup the service. |
260 Dart_ExitIsolate(); | 260 Dart_ExitIsolate(); |
261 | 261 // Start the service. |
262 bool result = DartService::Start(document); | 262 bool result = DartService::Start(document); |
263 UNUSED_PARAM(result); | 263 UNUSED_PARAM(result); |
264 ASSERT(result); | 264 ASSERT(result); |
265 ASSERT(!Dart_CurrentIsolate()); | 265 ASSERT(!Dart_CurrentIsolate()); |
266 | 266 // Register DOM isolate with service. |
267 Dart_EnterIsolate(m_isolate); | 267 Dart_EnterIsolate(m_isolate); |
268 Dart_EnterScope(); | 268 Dart_EnterScope(); |
269 DartService::SendIsolateStartupMessage(); | 269 Dart_RegisterWithService(); |
270 Dart_ExitScope(); | 270 Dart_ExitScope(); |
271 } | 271 } |
272 | 272 |
273 } | 273 } |
274 | 274 |
275 void DartController::shutdownIsolate(Dart_Isolate isolate) | 275 void DartController::shutdownIsolate(Dart_Isolate isolate) |
276 { | 276 { |
277 DartDOMData* domData = DartDOMData::current(); | 277 DartDOMData* domData = DartDOMData::current(); |
278 ASSERT(domData->isDOMEnabled()); | 278 ASSERT(domData->isDOMEnabled()); |
279 // If the following assert triggers, we have hit dartbug.com/14183 | 279 // If the following assert triggers, we have hit dartbug.com/14183 |
280 // FIXME: keep the isolate alive until the recursion level is 0. | 280 // FIXME: keep the isolate alive until the recursion level is 0. |
281 ASSERT(!*(domData->recursion())); | 281 ASSERT(!*(domData->recursion())); |
282 DartDebugServer::shared().unregisterIsolate(isolate); | 282 DartDebugServer::shared().unregisterIsolate(isolate); |
283 DartIsolateDestructionObservers* observers = domData->isolateDestructionObse rvers(); | 283 DartIsolateDestructionObservers* observers = domData->isolateDestructionObse rvers(); |
284 for (DartIsolateDestructionObservers::iterator it = observers->begin(); it ! = observers->end(); ++it) | 284 for (DartIsolateDestructionObservers::iterator it = observers->begin(); it ! = observers->end(); ++it) |
285 (*it)->isolateDestroyed(); | 285 (*it)->isolateDestroyed(); |
286 Dart_ShutdownIsolate(); | 286 Dart_ShutdownIsolate(); |
287 // Stop the service. | |
288 DartService::Stop(); | |
289 delete domData; | 287 delete domData; |
290 } | 288 } |
291 | 289 |
292 DartController::DartController(Frame* frame) | 290 DartController::DartController(Frame* frame) |
293 : m_frame(frame) | 291 : m_frame(frame) |
294 , m_isolate(0) | 292 , m_isolate(0) |
295 , m_asyncLoader(0) | 293 , m_asyncLoader(0) |
296 , m_npObjectMap() | 294 , m_npObjectMap() |
297 { | 295 { |
298 // The DartController's constructor must be called in the Frame's | 296 // The DartController's constructor must be called in the Frame's |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 | 399 |
402 applicationLoader->load(asyncLoader); | 400 applicationLoader->load(asyncLoader); |
403 Dart_IsolateMakeRunnable(m_isolate); | 401 Dart_IsolateMakeRunnable(m_isolate); |
404 } | 402 } |
405 | 403 |
406 private: | 404 private: |
407 Dart_Isolate m_isolate; | 405 Dart_Isolate m_isolate; |
408 String m_url; | 406 String m_url; |
409 }; | 407 }; |
410 | 408 |
409 | |
410 void DartController::shutdownIsolateCallback(void* data) | |
Jacob
2014/01/08 18:47:10
The method name seems generic while the behavior i
Cutch
2014/01/10 21:34:26
This method was registered as the isolate shutdown
| |
411 { | |
412 Dart_UnregisterFromService(); | |
413 } | |
414 | |
siva
2014/01/10 00:10:13
See comment in other CL, we need to see if it make
| |
415 | |
416 Dart_Isolate DartController::createServiceIsolateCallback(void* callbackData, ch ar** error) | |
417 { | |
418 Document* document = static_cast<Document*>(callbackData); | |
419 Dart_Isolate serviceIsolate = DartController::createIsolate("dart:vmservice_ dartium", "main", document, true, error); | |
Jacob
2014/01/08 18:47:10
As the package is internal only, change the name f
Cutch
2014/01/10 21:34:26
This isn't a library that a user could ever encoun
| |
420 Dart_ExitIsolate(); | |
421 return serviceIsolate; | |
422 } | |
423 | |
424 | |
411 Dart_Isolate DartController::createPureIsolateCallback(const char* scriptURL, co nst char* entryPoint, void* data, char** errorMsg) | 425 Dart_Isolate DartController::createPureIsolateCallback(const char* scriptURL, co nst char* entryPoint, void* data, char** errorMsg) |
412 { | 426 { |
413 bool isSpawnUri = scriptURL ? true : false; | 427 bool isSpawnUri = scriptURL ? true : false; |
414 | 428 |
415 if (!isSpawnUri) { | 429 if (!isSpawnUri) { |
416 // Determine the parent Isolate's URL as we will be using the same for c reating | 430 // Determine the parent Isolate's URL as we will be using the same for c reating |
417 // the isolate being spawned using spawnFunction. | 431 // the isolate being spawned using spawnFunction. |
418 DartApiScope apiScope; | 432 DartApiScope apiScope; |
419 Dart_Handle parentIsolateRootLibrary = Dart_RootLibrary(); | 433 Dart_Handle parentIsolateRootLibrary = Dart_RootLibrary(); |
420 if (Dart_IsError(parentIsolateRootLibrary)) { | 434 if (Dart_IsError(parentIsolateRootLibrary)) { |
(...skipping 23 matching lines...) Expand all Loading... | |
444 *errorMsg = strdup("spawnFunction is not supported from a dom-enabled is olate. Please use spawnUri instead."); | 458 *errorMsg = strdup("spawnFunction is not supported from a dom-enabled is olate. Please use spawnUri instead."); |
445 return 0; | 459 return 0; |
446 } | 460 } |
447 | 461 |
448 ASSERT(context->isDocument()); | 462 ASSERT(context->isDocument()); |
449 Document* document = static_cast<Document*>(context); | 463 Document* document = static_cast<Document*>(context); |
450 | 464 |
451 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg); | 465 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg); |
452 { | 466 { |
453 Dart_EnterScope(); | 467 Dart_EnterScope(); |
454 DartService::SendIsolateStartupMessage(); | 468 Dart_RegisterWithService(); |
455 Dart_ExitScope(); | 469 Dart_ExitScope(); |
456 } | 470 } |
457 | 471 |
458 if (!isolate) { | 472 if (!isolate) { |
459 // This triggers an exception in the caller. | 473 // This triggers an exception in the caller. |
460 *errorMsg = strdup("Isolate spawn failed."); | 474 *errorMsg = strdup("Isolate spawn failed."); |
461 return 0; | 475 return 0; |
462 } | 476 } |
463 | 477 |
464 // FIXME: If a spawnFunction, we should not need to request resources again. But, it's not clear | 478 // FIXME: If a spawnFunction, we should not need to request resources again. But, it's not clear |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 | 607 |
594 char flagsProp[DartUtilities::PROP_VALUE_MAX_LEN]; | 608 char flagsProp[DartUtilities::PROP_VALUE_MAX_LEN]; |
595 int propLen = DartUtilities::getProp( | 609 int propLen = DartUtilities::getProp( |
596 "DART_FLAGS", flagsProp, DartUtilities::PROP_VALUE_MAX_LEN); | 610 "DART_FLAGS", flagsProp, DartUtilities::PROP_VALUE_MAX_LEN); |
597 if (propLen > 0) { | 611 if (propLen > 0) { |
598 setDartFlags(flagsProp); | 612 setDartFlags(flagsProp); |
599 } else { | 613 } else { |
600 setDartFlags(0); | 614 setDartFlags(0); |
601 } | 615 } |
602 | 616 |
603 // FIXME(antonm): implement proper shutdown callback. | |
604 // FIXME(antonm): implement proper unhandled exception callback. | 617 // FIXME(antonm): implement proper unhandled exception callback. |
605 Dart_Initialize(&createPureIsolateCallback, 0, 0, DartService::VmServiceShut downCallback, openFileCallback, readFileCallback, writeFileCallback, closeFileCa llback, generateEntropy); | 618 Dart_Initialize(&createPureIsolateCallback, 0, 0, shutdownIsolateCallback, o penFileCallback, readFileCallback, writeFileCallback, closeFileCallback, generat eEntropy, createServiceIsolateCallback); |
606 hasBeenInitialized = true; | 619 hasBeenInitialized = true; |
607 } | 620 } |
608 | 621 |
609 static bool checkForExpiration() | 622 static bool checkForExpiration() |
610 { | 623 { |
611 const time_t ExpirationTimeSecsSinceEpoch = | 624 const time_t ExpirationTimeSecsSinceEpoch = |
612 #include "bindings/dart/ExpirationTimeSecsSinceEpoch.time_t" | 625 #include "bindings/dart/ExpirationTimeSecsSinceEpoch.time_t" |
613 ; | 626 ; |
614 const char* override = getenv("DARTIUM_EXPIRATION_TIME"); | 627 const char* override = getenv("DARTIUM_EXPIRATION_TIME"); |
615 time_t expiration; | 628 time_t expiration; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
880 Dart_Handle libraryIdHandle = Dart_ListGetAt(libraryIdList, i); | 893 Dart_Handle libraryIdHandle = Dart_ListGetAt(libraryIdList, i); |
881 Dart_Handle exception = 0; | 894 Dart_Handle exception = 0; |
882 intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception ); | 895 intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception ); |
883 ASSERT(!exception); | 896 ASSERT(!exception); |
884 DartScriptState* scriptState = lookupScriptStateFromLibraryIdMap(isolate , v8Context, libraryIdMap, libraryId); | 897 DartScriptState* scriptState = lookupScriptStateFromLibraryIdMap(isolate , v8Context, libraryIdMap, libraryId); |
885 result.append(scriptState); | 898 result.append(scriptState); |
886 } | 899 } |
887 } | 900 } |
888 | 901 |
889 } | 902 } |
OLD | NEW |