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

Unified Diff: runtime/vm/code_observers.cc

Issue 11490026: Move generate_perf_events_symbols flag to VM (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: undelete an accidentally deleted line Created 8 years 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
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/vm/dart.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_observers.cc
diff --git a/runtime/vm/code_observers.cc b/runtime/vm/code_observers.cc
index c537febce943c7edcc0d7f506a39a7f49c3fa8ec..6914b07c9fceb62e57280bff1a0afd9d7cf48af5 100644
--- a/runtime/vm/code_observers.cc
+++ b/runtime/vm/code_observers.cc
@@ -11,11 +11,14 @@
#include "vm/os.h"
#include "vm/vtune.h"
#include "vm/zone.h"
+#include "bin/file.h"
siva 2012/12/11 18:02:51 We can't include bin header files directly like th
Max Heinritz 2012/12/11 19:09:25 Done.
namespace dart {
DEFINE_FLAG(bool, generate_gdb_symbols, false,
"Generate symbols of generated dart functions for debugging with GDB");
+DEFINE_FLAG(bool, generate_perf_events_symbols, false,
+ "Generate events symbols for profiling with perf");
intptr_t CodeObservers::observers_length_ = 0;
CodeObserver** CodeObservers::observers_ = NULL;
@@ -56,8 +59,29 @@ bool CodeObservers::AreActive() {
class PerfCodeObserver : public CodeObserver {
public:
+ PerfCodeObserver() {
+ Dart_FileOpenCallback file_open = Isolate::file_open_callback();
+ if (file_open == NULL) {
+ return;
+ }
+ const char* format = "/tmp/perf-%ld.map";
+ intptr_t pid = getpid();
siva 2012/12/11 18:02:51 This may not port to Windows, maybe you should add
Max Heinritz 2012/12/11 19:09:25 Could I do this in another CL? I added a condition
+ intptr_t len = OS::SNPrint(NULL, 0, format, pid);
+ char* filename = new char[len + 1];
+ OS::SNPrint(filename, len + 1, format, pid);
+ out_file_ = (*file_open)(filename);
+ }
+
+ // Not currently being called
+ ~PerfCodeObserver() {
+ Dart_FileCloseCallback file_close = Isolate::file_close_callback();
+ if (file_close != NULL) {
siva 2012/12/11 18:02:51 Also you probably need: ASSERT(out_file_ != NULL);
Max Heinritz 2012/12/11 19:09:25 Done.
+ (*file_close)(out_file_);
+ }
+ }
+
virtual bool IsActive() const {
- return Dart::perf_events_file() != NULL;
+ return FLAG_generate_perf_events_symbols;
}
virtual void Notify(const char* name,
@@ -65,17 +89,19 @@ class PerfCodeObserver : public CodeObserver {
uword prologue_offset,
uword size,
bool optimized) {
+ Dart_FileWriteCallback file_write = Isolate::file_write_callback();
+ ASSERT(file_write != NULL);
const char* format = "%"Px" %"Px" %s%s\n";
const char* marker = optimized ? "*" : "";
intptr_t len = OS::SNPrint(NULL, 0, format, base, size, marker, name);
char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
OS::SNPrint(buffer, len + 1, format, base, size, marker, name);
- Dart_FileWriteCallback file_write = Isolate::file_write_callback();
- ASSERT(file_write != NULL);
- void* file = Dart::perf_events_file();
- ASSERT(file != NULL);
- (*file_write)(buffer, len, file);
+ ASSERT(out_file_ != NULL);
+ (*file_write)(buffer, len, out_file_);
}
+
+ private:
+ void* out_file_;
siva 2012/12/11 18:02:51 Not related to your change but these classes in th
Max Heinritz 2012/12/11 19:09:25 Any action to take here?
};
@@ -131,7 +157,10 @@ class GdbCodeObserver : public CodeObserver {
void CodeObservers::InitOnce() {
+// TODO(meh): move OS-specific logic to separate module
+#if defined(TARGET_OS_LINUX)
siva 2012/12/11 18:02:51 Why does this have to conditional on a OS define,
Max Heinritz 2012/12/11 19:09:25 Done. I had originally added this to prevent crea
Register(new PerfCodeObserver);
+#endif
Register(new PprofCodeObserver);
Register(new GdbCodeObserver);
#if defined(DART_VTUNE_SUPPORT)
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/vm/dart.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698