Index: runtime/vm/isolate.cc |
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc |
index b89db64127603e35e642051b503d8e6f1a61d801..bc5f163e305172cc3b04972b42df746ecebf5f57 100644 |
--- a/runtime/vm/isolate.cc |
+++ b/runtime/vm/isolate.cc |
@@ -22,8 +22,10 @@ |
#include "vm/object_store.h" |
#include "vm/parser.h" |
#include "vm/port.h" |
+#include "vm/profiler.h" |
#include "vm/reusable_handles.h" |
#include "vm/service.h" |
+#include "vm/signal_handler.h" |
#include "vm/simulator.h" |
#include "vm/stack_frame.h" |
#include "vm/stub_code.h" |
@@ -309,6 +311,8 @@ Isolate::Isolate() |
stack_frame_index_(-1), |
object_histogram_(NULL), |
object_id_ring_(NULL), |
+ profiler_data_(NULL), |
+ profiler_data_mutex_(new Mutex()), |
REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) |
reusable_handles_() { |
if (FLAG_print_object_histogram && (Dart::vm_isolate() != NULL)) { |
@@ -330,6 +334,8 @@ Isolate::~Isolate() { |
#endif |
delete mutex_; |
mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. |
+ delete profiler_data_mutex_; |
+ profiler_data_mutex_ = NULL; |
delete message_handler_; |
message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. |
ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. |
@@ -337,7 +343,15 @@ Isolate::~Isolate() { |
} |
void Isolate::SetCurrent(Isolate* current) { |
+ ScopedSignalBlocker ssb; |
+ Isolate* old_isolate = Current(); |
+ if (old_isolate != NULL) { |
+ ProfilerManager::DescheduleIsolate(old_isolate); |
+ } |
Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current)); |
+ if (current != NULL) { |
+ ProfilerManager::ScheduleIsolate(current); |
+ } |
} |
@@ -397,6 +411,10 @@ Isolate* Isolate::Init(const char* name_prefix) { |
"\tisolate: %s\n", result->name()); |
} |
} |
+ |
+ // Setup for profiling. |
+ ProfilerManager::SetupIsolateForProfiling(result); |
+ |
return result; |
} |
@@ -444,6 +462,21 @@ void Isolate::SetStackLimit(uword limit) { |
} |
+bool Isolate::GetStackBounds(uintptr_t* lower, uintptr_t* upper) { |
+ uintptr_t stack_lower = stack_limit(); |
+ if (stack_lower == static_cast<uintptr_t>(~0)) { |
+ stack_lower = saved_stack_limit(); |
+ } |
+ if (stack_lower == static_cast<uintptr_t>(~0)) { |
+ return false; |
+ } |
+ uintptr_t stack_upper = stack_lower + GetSpecifiedStackSize(); |
+ *lower = stack_lower; |
+ *upper = stack_upper; |
+ return true; |
+} |
+ |
+ |
void Isolate::ScheduleInterrupts(uword interrupt_bits) { |
// TODO(turnidge): Can't use MutexLocker here because MutexLocker is |
// a StackResource, which requires a current isolate. Should |
@@ -674,6 +707,13 @@ void Isolate::Shutdown() { |
StackZone stack_zone(this); |
HandleScope handle_scope(this); |
+ ScopedSignalBlocker ssb; |
+ |
+ ProfilerManager::DescheduleIsolate(this); |
+ |
+ // ProfilerManager::WriteTracing(this, this->name(), this->main_port()); |
siva
2013/11/11 03:51:54
why is this commented out?
Cutch
2013/11/18 20:48:54
Was for debugging. Removed.
|
+ |
+ |
if (FLAG_print_object_histogram) { |
heap()->CollectAllGarbage(); |
object_histogram()->Print(); |
@@ -715,6 +755,7 @@ void Isolate::Shutdown() { |
// TODO(5411455): For now just make sure there are no current isolates |
// as we are shutting down the isolate. |
SetCurrent(NULL); |
+ ProfilerManager::ShutdownIsolateForProfiling(this); |
} |