| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "vm/isolate.h" | 5 #include "vm/isolate.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/json.h" | 9 #include "platform/json.h" |
| 10 #include "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
| (...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 return instance.raw(); | 1435 return instance.raw(); |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 | 1438 |
| 1439 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, | 1439 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, |
| 1440 const Function& func, | 1440 const Function& func, |
| 1441 const Instance& message) | 1441 const Instance& message) |
| 1442 : isolate_(NULL), | 1442 : isolate_(NULL), |
| 1443 parent_port_(parent_port), | 1443 parent_port_(parent_port), |
| 1444 script_url_(NULL), | 1444 script_url_(NULL), |
| 1445 package_root_(NULL), |
| 1445 library_url_(NULL), | 1446 library_url_(NULL), |
| 1446 class_name_(NULL), | 1447 class_name_(NULL), |
| 1447 function_name_(NULL), | 1448 function_name_(NULL), |
| 1448 exception_callback_name_(NULL), | 1449 exception_callback_name_(NULL), |
| 1449 serialized_args_(NULL), | 1450 serialized_args_(NULL), |
| 1450 serialized_args_len_(0), | 1451 serialized_args_len_(0), |
| 1451 serialized_message_(NULL), | 1452 serialized_message_(NULL), |
| 1452 serialized_message_len_(0) { | 1453 serialized_message_len_(0) { |
| 1453 script_url_ = NULL; | 1454 script_url_ = NULL; |
| 1454 const Class& cls = Class::Handle(func.Owner()); | 1455 const Class& cls = Class::Handle(func.Owner()); |
| 1455 const Library& lib = Library::Handle(cls.library()); | 1456 const Library& lib = Library::Handle(cls.library()); |
| 1456 const String& lib_url = String::Handle(lib.url()); | 1457 const String& lib_url = String::Handle(lib.url()); |
| 1457 library_url_ = strdup(lib_url.ToCString()); | 1458 library_url_ = strdup(lib_url.ToCString()); |
| 1458 | 1459 |
| 1459 const String& func_name = String::Handle(func.name()); | 1460 const String& func_name = String::Handle(func.name()); |
| 1460 function_name_ = strdup(func_name.ToCString()); | 1461 function_name_ = strdup(func_name.ToCString()); |
| 1461 if (!cls.IsTopLevel()) { | 1462 if (!cls.IsTopLevel()) { |
| 1462 const String& class_name = String::Handle(cls.Name()); | 1463 const String& class_name = String::Handle(cls.Name()); |
| 1463 class_name_ = strdup(class_name.ToCString()); | 1464 class_name_ = strdup(class_name.ToCString()); |
| 1464 } | 1465 } |
| 1465 exception_callback_name_ = strdup("_unhandledExceptionCallback"); | 1466 exception_callback_name_ = strdup("_unhandledExceptionCallback"); |
| 1466 SerializeObject(message, &serialized_message_, &serialized_message_len_); | 1467 SerializeObject(message, &serialized_message_, &serialized_message_len_); |
| 1467 } | 1468 } |
| 1468 | 1469 |
| 1469 | 1470 |
| 1470 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, | 1471 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, |
| 1471 const char* script_url, | 1472 const char* script_url, |
| 1473 const char* package_root, |
| 1472 const Instance& args, | 1474 const Instance& args, |
| 1473 const Instance& message) | 1475 const Instance& message) |
| 1474 : isolate_(NULL), | 1476 : isolate_(NULL), |
| 1475 parent_port_(parent_port), | 1477 parent_port_(parent_port), |
| 1478 package_root_(NULL), |
| 1476 library_url_(NULL), | 1479 library_url_(NULL), |
| 1477 class_name_(NULL), | 1480 class_name_(NULL), |
| 1478 function_name_(NULL), | 1481 function_name_(NULL), |
| 1479 exception_callback_name_(NULL), | 1482 exception_callback_name_(NULL), |
| 1480 serialized_args_(NULL), | 1483 serialized_args_(NULL), |
| 1481 serialized_args_len_(0), | 1484 serialized_args_len_(0), |
| 1482 serialized_message_(NULL), | 1485 serialized_message_(NULL), |
| 1483 serialized_message_len_(0) { | 1486 serialized_message_len_(0) { |
| 1484 script_url_ = strdup(script_url); | 1487 script_url_ = strdup(script_url); |
| 1488 if (package_root != NULL) { |
| 1489 package_root_ = strdup(package_root); |
| 1490 } |
| 1485 library_url_ = NULL; | 1491 library_url_ = NULL; |
| 1486 function_name_ = strdup("main"); | 1492 function_name_ = strdup("main"); |
| 1487 exception_callback_name_ = strdup("_unhandledExceptionCallback"); | 1493 exception_callback_name_ = strdup("_unhandledExceptionCallback"); |
| 1488 SerializeObject(args, &serialized_args_, &serialized_args_len_); | 1494 SerializeObject(args, &serialized_args_, &serialized_args_len_); |
| 1489 SerializeObject(message, &serialized_message_, &serialized_message_len_); | 1495 SerializeObject(message, &serialized_message_, &serialized_message_len_); |
| 1490 } | 1496 } |
| 1491 | 1497 |
| 1492 | 1498 |
| 1493 IsolateSpawnState::~IsolateSpawnState() { | 1499 IsolateSpawnState::~IsolateSpawnState() { |
| 1494 free(script_url_); | 1500 free(script_url_); |
| 1501 free(package_root_); |
| 1495 free(library_url_); | 1502 free(library_url_); |
| 1496 free(function_name_); | 1503 free(function_name_); |
| 1497 free(class_name_); | 1504 free(class_name_); |
| 1498 free(exception_callback_name_); | 1505 free(exception_callback_name_); |
| 1499 free(serialized_args_); | 1506 free(serialized_args_); |
| 1500 free(serialized_message_); | 1507 free(serialized_message_); |
| 1501 } | 1508 } |
| 1502 | 1509 |
| 1503 | 1510 |
| 1504 RawObject* IsolateSpawnState::ResolveFunction() { | 1511 RawObject* IsolateSpawnState::ResolveFunction() { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 serialized_message_, serialized_message_len_); | 1571 serialized_message_, serialized_message_len_); |
| 1565 } | 1572 } |
| 1566 | 1573 |
| 1567 | 1574 |
| 1568 void IsolateSpawnState::Cleanup() { | 1575 void IsolateSpawnState::Cleanup() { |
| 1569 SwitchIsolateScope switch_scope(I); | 1576 SwitchIsolateScope switch_scope(I); |
| 1570 Dart::ShutdownIsolate(); | 1577 Dart::ShutdownIsolate(); |
| 1571 } | 1578 } |
| 1572 | 1579 |
| 1573 } // namespace dart | 1580 } // namespace dart |
| OLD | NEW |