| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_OS_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 7 | 7 |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 | 9 |
| 10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #ifndef PRODUCT | 34 #ifndef PRODUCT |
| 35 | 35 |
| 36 DEFINE_FLAG(bool, generate_perf_events_symbols, false, | 36 DEFINE_FLAG(bool, generate_perf_events_symbols, false, |
| 37 "Generate events symbols for profiling with perf"); | 37 "Generate events symbols for profiling with perf"); |
| 38 | 38 |
| 39 // Linux CodeObservers. | 39 // Linux CodeObservers. |
| 40 class PerfCodeObserver : public CodeObserver { | 40 class PerfCodeObserver : public CodeObserver { |
| 41 public: | 41 public: |
| 42 PerfCodeObserver() : out_file_(NULL) { | 42 PerfCodeObserver() : out_file_(NULL) { |
| 43 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); | 43 Dart_FileOpenCallback file_open = Dart::file_open_callback(); |
| 44 if (file_open == NULL) { | 44 if (file_open == NULL) { |
| 45 return; | 45 return; |
| 46 } | 46 } |
| 47 intptr_t pid = getpid(); | 47 intptr_t pid = getpid(); |
| 48 char* filename = OS::SCreate(NULL, "/tmp/perf-%" Pd ".map", pid); | 48 char* filename = OS::SCreate(NULL, "/tmp/perf-%" Pd ".map", pid); |
| 49 out_file_ = (*file_open)(filename, true); | 49 out_file_ = (*file_open)(filename, true); |
| 50 free(filename); | 50 free(filename); |
| 51 } | 51 } |
| 52 | 52 |
| 53 ~PerfCodeObserver() { | 53 ~PerfCodeObserver() { |
| 54 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); | 54 Dart_FileCloseCallback file_close = Dart::file_close_callback(); |
| 55 if ((file_close == NULL) || (out_file_ == NULL)) { | 55 if ((file_close == NULL) || (out_file_ == NULL)) { |
| 56 return; | 56 return; |
| 57 } | 57 } |
| 58 (*file_close)(out_file_); | 58 (*file_close)(out_file_); |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual bool IsActive() const { | 61 virtual bool IsActive() const { |
| 62 return FLAG_generate_perf_events_symbols && (out_file_ != NULL); | 62 return FLAG_generate_perf_events_symbols && (out_file_ != NULL); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void Notify(const char* name, | 65 virtual void Notify(const char* name, |
| 66 uword base, | 66 uword base, |
| 67 uword prologue_offset, | 67 uword prologue_offset, |
| 68 uword size, | 68 uword size, |
| 69 bool optimized) { | 69 bool optimized) { |
| 70 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); | 70 Dart_FileWriteCallback file_write = Dart::file_write_callback(); |
| 71 if ((file_write == NULL) || (out_file_ == NULL)) { | 71 if ((file_write == NULL) || (out_file_ == NULL)) { |
| 72 return; | 72 return; |
| 73 } | 73 } |
| 74 const char* marker = optimized ? "*" : ""; | 74 const char* marker = optimized ? "*" : ""; |
| 75 char* buffer = OS::SCreate(Thread::Current()->zone(), | 75 char* buffer = OS::SCreate(Thread::Current()->zone(), |
| 76 "%" Px " %" Px " %s%s\n", base, size, marker, name); | 76 "%" Px " %" Px " %s%s\n", base, size, marker, name); |
| 77 { | 77 { |
| 78 MutexLocker ml(CodeObservers::mutex()); | 78 MutexLocker ml(CodeObservers::mutex()); |
| 79 (*file_write)(buffer, strlen(buffer), out_file_); | 79 (*file_write)(buffer, strlen(buffer), out_file_); |
| 80 } | 80 } |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 | 406 |
| 407 | 407 |
| 408 void OS::Exit(int code) { | 408 void OS::Exit(int code) { |
| 409 exit(code); | 409 exit(code); |
| 410 } | 410 } |
| 411 | 411 |
| 412 } // namespace dart | 412 } // namespace dart |
| 413 | 413 |
| 414 #endif // defined(TARGET_OS_LINUX) | 414 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |