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

Unified Diff: runtime/vm/code_observers.cc

Issue 11549011: Move generate_perf_events_symbols flag to VM (new issue with @google address) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Prep for commit to trunk 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..f8bac19603bfad5ae901f958692b49e2b17b662d 100644
--- a/runtime/vm/code_observers.cc
+++ b/runtime/vm/code_observers.cc
@@ -16,6 +16,8 @@ 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 +58,34 @@ bool CodeObservers::AreActive() {
class PerfCodeObserver : public CodeObserver {
public:
+ PerfCodeObserver() {
+ Dart_FileOpenCallback file_open = Isolate::file_open_callback();
+ if (file_open == NULL) {
+ return;
+ }
+// TODO(7321): Move OS-specific code for perf profiling to the OS abstraction
+#if defined(TARGET_OS_LINUX)
+ const char* format = "/tmp/perf-%ld.map";
+ intptr_t pid = getpid();
+ 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);
+#endif
+ }
+
+ // Not currently being called
+ ~PerfCodeObserver() {
+ Dart_FileCloseCallback file_close = Isolate::file_close_callback();
+ if (file_close == NULL) {
+ return;
+ }
+ ASSERT(out_file_ != NULL);
+ (*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 +93,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_;
};
@@ -131,7 +161,10 @@ class GdbCodeObserver : public CodeObserver {
void CodeObservers::InitOnce() {
- Register(new PerfCodeObserver);
+// TODO(7321): Move flag registration to the OS abstraction
+ if (FLAG_generate_perf_events_symbols) {
+ Register(new PerfCodeObserver);
+ }
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