Chromium Code Reviews| Index: runtime/vm/isolate.cc |
| diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc |
| index 2d578a69180f119ca6ccfca032bcd170282f1b15..d497be932d2a2f3c4c27bfb6fcd049c0d3b6edc8 100644 |
| --- a/runtime/vm/isolate.cc |
| +++ b/runtime/vm/isolate.cc |
| @@ -41,6 +41,8 @@ DEFINE_FLAG(bool, report_usage_count, false, |
| "Track function usage and report."); |
| DEFINE_FLAG(bool, trace_isolates, false, |
| "Trace isolate creation and shut down."); |
| +DEFINE_FLAG(bool, pin_isolates, false, |
| + "Stop isolates from being destroyed automatically."); |
| void Isolate::RegisterClass(const Class& cls) { |
| @@ -282,6 +284,7 @@ Isolate::Isolate() |
| message_notify_callback_(NULL), |
| name_(NULL), |
| start_time_(OS::GetCurrentTimeMicros()), |
| + pin_port_(0), |
| main_port_(0), |
| heap_(NULL), |
| object_store_(NULL), |
| @@ -421,6 +424,7 @@ Isolate* Isolate::Init(const char* name_prefix) { |
| result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result)); |
| result->set_main_port(PortMap::CreatePort(result->message_handler())); |
| result->BuildName(name_prefix); |
| + result->CreatePinPort(); |
|
Ivan Posva
2014/02/27 18:07:16
How about:
if (FLAG_pin_isolates) {
result->Crea
Cutch
2014/02/27 18:13:48
Done.
|
| result->debugger_ = new Debugger(); |
| result->debugger_->Initialize(result); |
| @@ -436,6 +440,32 @@ Isolate* Isolate::Init(const char* name_prefix) { |
| } |
| +void Isolate::CreatePinPort() { |
| + if (!FLAG_pin_isolates) { |
|
Ivan Posva
2014/02/27 18:07:16
See above.
Cutch
2014/02/27 18:13:48
Done.
|
| + return; |
| + } |
| + ASSERT(pin_port_ == 0); |
| + pin_port_ = PortMap::CreatePort(message_handler()); |
| + ASSERT(pin_port_ != 0); |
| + PortMap::SetLive(pin_port_); |
| +} |
| + |
| + |
| +void Isolate::ClosePinPort() { |
| + if (!FLAG_pin_isolates) { |
|
Ivan Posva
2014/02/27 18:07:16
This is equivalent to the pin_port_ == 0 condition
Cutch
2014/02/27 18:13:48
Done.
|
| + return; |
| + } |
| + if (pin_port_ == 0) { |
| + // Support multiple calls to close. |
| + return; |
| + } |
| + ASSERT(pin_port_ != 0); |
| + bool r = PortMap::ClosePort(pin_port_); |
| + ASSERT(r); |
| + pin_port_ = 0; |
| +} |
| + |
| + |
| void Isolate::BuildName(const char* name_prefix) { |
| ASSERT(name_ == NULL); |
| if (name_prefix == NULL) { |