Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Unified Diff: runtime/vm/isolate.cc

Issue 25909002: Sampling profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/isolate.cc
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index d8ab9a53852f0d8d4789fda623e5a59226beacad..32563091aa5d5ef31305b844958ce83121cbb7c5 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"
@@ -307,6 +309,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)) {
@@ -328,6 +332,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.
@@ -335,7 +341,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);
+ }
}
@@ -358,6 +372,9 @@ Isolate* Isolate::Init(const char* name_prefix) {
Isolate* result = new Isolate();
ASSERT(result != NULL);
+ // Setup for profiling.
+ ProfilerManager::SetupIsolateForProfiling(result);
+
// TODO(5411455): For now just set the recently created isolate as
// the current isolate.
SetCurrent(result);
@@ -650,6 +667,14 @@ void Isolate::Shutdown() {
{
StackZone stack_zone(this);
HandleScope handle_scope(this);
+ #if 0
+ ScopedSignalBlocker ssb;
+
+ ProfilerManager::DescheduleIsolate(this);
+
+ ProfilerManager::WriteTracing(this, this->name(), this->main_port());
+ #endif
siva 2013/10/28 05:19:21 Why is this #ifdefed out.
Cutch 2013/11/04 20:36:05 Debug only dumping of data in about:tracing format
+
if (FLAG_print_object_histogram) {
heap()->CollectAllGarbage();
@@ -692,6 +717,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::ShutdownIsolate(this);
}

Powered by Google App Engine
This is Rietveld 408576698