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 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 return instance.raw(); | 1424 return instance.raw(); |
1425 } | 1425 } |
1426 | 1426 |
1427 | 1427 |
1428 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, | 1428 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, |
1429 const Function& func, | 1429 const Function& func, |
1430 const Instance& message) | 1430 const Instance& message) |
1431 : isolate_(NULL), | 1431 : isolate_(NULL), |
1432 parent_port_(parent_port), | 1432 parent_port_(parent_port), |
1433 script_url_(NULL), | 1433 script_url_(NULL), |
| 1434 package_root_(NULL), |
1434 library_url_(NULL), | 1435 library_url_(NULL), |
1435 class_name_(NULL), | 1436 class_name_(NULL), |
1436 function_name_(NULL), | 1437 function_name_(NULL), |
1437 exception_callback_name_(NULL), | 1438 exception_callback_name_(NULL), |
1438 serialized_args_(NULL), | 1439 serialized_args_(NULL), |
1439 serialized_args_len_(0), | 1440 serialized_args_len_(0), |
1440 serialized_message_(NULL), | 1441 serialized_message_(NULL), |
1441 serialized_message_len_(0) { | 1442 serialized_message_len_(0) { |
1442 script_url_ = NULL; | 1443 script_url_ = NULL; |
1443 const Class& cls = Class::Handle(func.Owner()); | 1444 const Class& cls = Class::Handle(func.Owner()); |
1444 const Library& lib = Library::Handle(cls.library()); | 1445 const Library& lib = Library::Handle(cls.library()); |
1445 const String& lib_url = String::Handle(lib.url()); | 1446 const String& lib_url = String::Handle(lib.url()); |
1446 library_url_ = strdup(lib_url.ToCString()); | 1447 library_url_ = strdup(lib_url.ToCString()); |
1447 | 1448 |
1448 const String& func_name = String::Handle(func.name()); | 1449 const String& func_name = String::Handle(func.name()); |
1449 function_name_ = strdup(func_name.ToCString()); | 1450 function_name_ = strdup(func_name.ToCString()); |
1450 if (!cls.IsTopLevel()) { | 1451 if (!cls.IsTopLevel()) { |
1451 const String& class_name = String::Handle(cls.Name()); | 1452 const String& class_name = String::Handle(cls.Name()); |
1452 class_name_ = strdup(class_name.ToCString()); | 1453 class_name_ = strdup(class_name.ToCString()); |
1453 } | 1454 } |
1454 exception_callback_name_ = strdup("_unhandledExceptionCallback"); | 1455 exception_callback_name_ = strdup("_unhandledExceptionCallback"); |
1455 SerializeObject(message, &serialized_message_, &serialized_message_len_); | 1456 SerializeObject(message, &serialized_message_, &serialized_message_len_); |
1456 } | 1457 } |
1457 | 1458 |
1458 | 1459 |
1459 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, | 1460 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, |
1460 const char* script_url, | 1461 const char* script_url, |
| 1462 const char* package_root, |
1461 const Instance& args, | 1463 const Instance& args, |
1462 const Instance& message) | 1464 const Instance& message) |
1463 : isolate_(NULL), | 1465 : isolate_(NULL), |
1464 parent_port_(parent_port), | 1466 parent_port_(parent_port), |
| 1467 package_root_(NULL), |
1465 library_url_(NULL), | 1468 library_url_(NULL), |
1466 class_name_(NULL), | 1469 class_name_(NULL), |
1467 function_name_(NULL), | 1470 function_name_(NULL), |
1468 exception_callback_name_(NULL), | 1471 exception_callback_name_(NULL), |
1469 serialized_args_(NULL), | 1472 serialized_args_(NULL), |
1470 serialized_args_len_(0), | 1473 serialized_args_len_(0), |
1471 serialized_message_(NULL), | 1474 serialized_message_(NULL), |
1472 serialized_message_len_(0) { | 1475 serialized_message_len_(0) { |
1473 script_url_ = strdup(script_url); | 1476 script_url_ = strdup(script_url); |
| 1477 if (package_root != NULL) { |
| 1478 package_root_ = strdup(package_root); |
| 1479 } |
1474 library_url_ = NULL; | 1480 library_url_ = NULL; |
1475 function_name_ = strdup("main"); | 1481 function_name_ = strdup("main"); |
1476 exception_callback_name_ = strdup("_unhandledExceptionCallback"); | 1482 exception_callback_name_ = strdup("_unhandledExceptionCallback"); |
1477 SerializeObject(args, &serialized_args_, &serialized_args_len_); | 1483 SerializeObject(args, &serialized_args_, &serialized_args_len_); |
1478 SerializeObject(message, &serialized_message_, &serialized_message_len_); | 1484 SerializeObject(message, &serialized_message_, &serialized_message_len_); |
1479 } | 1485 } |
1480 | 1486 |
1481 | 1487 |
1482 IsolateSpawnState::~IsolateSpawnState() { | 1488 IsolateSpawnState::~IsolateSpawnState() { |
1483 free(script_url_); | 1489 free(script_url_); |
| 1490 free(package_root_); |
1484 free(library_url_); | 1491 free(library_url_); |
1485 free(function_name_); | 1492 free(function_name_); |
1486 free(class_name_); | 1493 free(class_name_); |
1487 free(exception_callback_name_); | 1494 free(exception_callback_name_); |
1488 free(serialized_args_); | 1495 free(serialized_args_); |
1489 free(serialized_message_); | 1496 free(serialized_message_); |
1490 } | 1497 } |
1491 | 1498 |
1492 | 1499 |
1493 RawObject* IsolateSpawnState::ResolveFunction() { | 1500 RawObject* IsolateSpawnState::ResolveFunction() { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 serialized_message_, serialized_message_len_); | 1560 serialized_message_, serialized_message_len_); |
1554 } | 1561 } |
1555 | 1562 |
1556 | 1563 |
1557 void IsolateSpawnState::Cleanup() { | 1564 void IsolateSpawnState::Cleanup() { |
1558 SwitchIsolateScope switch_scope(I); | 1565 SwitchIsolateScope switch_scope(I); |
1559 Dart::ShutdownIsolate(); | 1566 Dart::ShutdownIsolate(); |
1560 } | 1567 } |
1561 | 1568 |
1562 } // namespace dart | 1569 } // namespace dart |
OLD | NEW |