Chromium Code Reviews| Index: runtime/vm/isolate.cc |
| =================================================================== |
| --- runtime/vm/isolate.cc (revision 3366) |
| +++ runtime/vm/isolate.cc (working copy) |
| @@ -28,7 +28,9 @@ |
| namespace dart { |
| DEFINE_FLAG(bool, report_invocation_count, false, |
| - "Count function invocations and report."); |
| + "Count function invocations and report."); |
| +DEFINE_FLAG(bool, trace_isolates, false, |
| + "Trace isolate creation and shut down."); |
| DECLARE_FLAG(bool, generate_gdb_symbols); |
| @@ -37,6 +39,7 @@ |
| message_queue_(NULL), |
| post_message_callback_(NULL), |
| close_port_callback_(NULL), |
| + name_(NULL), |
| num_ports_(0), |
| live_ports_(0), |
| main_port_(0), |
| @@ -69,6 +72,7 @@ |
| Isolate::~Isolate() { |
| + delete [] name_; |
| delete message_queue_; |
| delete heap_; |
| delete object_store_; |
| @@ -107,7 +111,7 @@ |
| } |
| -Isolate* Isolate::Init() { |
| +Isolate* Isolate::Init(const char* name_prefix) { |
| Isolate* result = new Isolate(); |
| ASSERT(result != NULL); |
| @@ -133,14 +137,35 @@ |
| // main thread. |
| result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result)); |
| result->set_main_port(PortMap::CreatePort()); |
| + result->BuildName(name_prefix); |
|
siva
2012/01/18 06:26:03
Should the name be built only if tracing is enable
turnidge
2012/01/18 21:29:21
I plan to also use it when reporting top-level unc
siva
2012/01/18 22:06:08
Can this be done lazily when it is actually needed
turnidge
2012/01/26 18:07:11
Well, the information being passed to this functio
|
| result->debugger_ = new Debugger(); |
| result->debugger_->Initialize(result); |
| - |
| + if (FLAG_trace_isolates) { |
| + if (strcmp(name_prefix, "vm-isolate") != 0) { |
| + OS::Print("[+] Starting isolate:\n" |
| + "\tisolate: %s\n", result->name()); |
| + } |
| + } |
| return result; |
| } |
| +void Isolate::BuildName(const char* name_prefix) { |
| + if (name_) { |
| + delete [] name_; |
| + name_ = NULL; |
| + } |
|
siva
2012/01/18 06:26:03
Under what circumstances would name_ be non null o
turnidge
2012/01/18 21:29:21
It can't happen. It used to happen in an earlier
|
| + if (name_prefix == NULL) { |
| + name_prefix = "isolate"; |
| + } |
| + const char* kFormat = "%s-%lld"; |
|
siva
2012/01/18 06:26:03
Maybe add a TODO here that generation issues in th
turnidge
2012/01/18 21:29:21
What generation issues?
siva
2012/01/18 22:06:08
i.e if an isolate dies and another isolate is crea
turnidge
2012/01/26 18:07:11
I do not believe that we reuse port numbers curren
|
| + intptr_t len = OS::SNPrint(NULL, 0, kFormat, name_prefix, main_port()) + 1; |
| + name_ = new char[len]; |
| + OS::SNPrint(name_, len, kFormat, name_prefix, main_port()); |
| +} |
| + |
| + |
| // TODO(5411455): Use flag to override default value and Validate the |
| // stack size by querying OS. |
| uword Isolate::GetSpecifiedStackSize() { |
| @@ -256,7 +281,10 @@ |
| if (FLAG_generate_gdb_symbols) { |
| DebugInfo::UnregisterAllSections(); |
| } |
| - |
| + if (FLAG_trace_isolates) { |
| + OS::Print("[-] Stopping isolate:\n" |
| + "\tisolate: %s\n", name()); |
| + } |
| // TODO(5411455): For now just make sure there are no current isolates |
| // as we are shutting down the isolate. |
| SetCurrent(NULL); |