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