| 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_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 7 | 7 |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 | 9 |
| 10 #include <android/log.h> // NOLINT | 10 #include <android/log.h> // NOLINT |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // Android CodeObservers. | 30 // Android CodeObservers. |
| 31 | 31 |
| 32 #ifndef PRODUCT | 32 #ifndef PRODUCT |
| 33 | 33 |
| 34 DEFINE_FLAG(bool, generate_perf_events_symbols, false, | 34 DEFINE_FLAG(bool, generate_perf_events_symbols, false, |
| 35 "Generate events symbols for profiling with perf"); | 35 "Generate events symbols for profiling with perf"); |
| 36 | 36 |
| 37 class PerfCodeObserver : public CodeObserver { | 37 class PerfCodeObserver : public CodeObserver { |
| 38 public: | 38 public: |
| 39 PerfCodeObserver() : out_file_(NULL) { | 39 PerfCodeObserver() : out_file_(NULL) { |
| 40 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); | 40 Dart_FileOpenCallback file_open = Dart::file_open_callback(); |
| 41 if (file_open == NULL) { | 41 if (file_open == NULL) { |
| 42 return; | 42 return; |
| 43 } | 43 } |
| 44 intptr_t pid = getpid(); | 44 intptr_t pid = getpid(); |
| 45 char* filename = OS::SCreate(NULL, "/tmp/perf-%" Pd ".map", pid); | 45 char* filename = OS::SCreate(NULL, "/tmp/perf-%" Pd ".map", pid); |
| 46 out_file_ = (*file_open)(filename, true); | 46 out_file_ = (*file_open)(filename, true); |
| 47 free(filename); | 47 free(filename); |
| 48 } | 48 } |
| 49 | 49 |
| 50 ~PerfCodeObserver() { | 50 ~PerfCodeObserver() { |
| 51 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); | 51 Dart_FileCloseCallback file_close = Dart::file_close_callback(); |
| 52 if ((file_close == NULL) || (out_file_ == NULL)) { | 52 if ((file_close == NULL) || (out_file_ == NULL)) { |
| 53 return; | 53 return; |
| 54 } | 54 } |
| 55 (*file_close)(out_file_); | 55 (*file_close)(out_file_); |
| 56 } | 56 } |
| 57 | 57 |
| 58 virtual bool IsActive() const { | 58 virtual bool IsActive() const { |
| 59 return FLAG_generate_perf_events_symbols && (out_file_ != NULL); | 59 return FLAG_generate_perf_events_symbols && (out_file_ != NULL); |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual void Notify(const char* name, | 62 virtual void Notify(const char* name, |
| 63 uword base, | 63 uword base, |
| 64 uword prologue_offset, | 64 uword prologue_offset, |
| 65 uword size, | 65 uword size, |
| 66 bool optimized) { | 66 bool optimized) { |
| 67 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); | 67 Dart_FileWriteCallback file_write = Dart::file_write_callback(); |
| 68 if ((file_write == NULL) || (out_file_ == NULL)) { | 68 if ((file_write == NULL) || (out_file_ == NULL)) { |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 const char* marker = optimized ? "*" : ""; | 71 const char* marker = optimized ? "*" : ""; |
| 72 char* buffer = OS::SCreate(Thread::Current()->zone(), | 72 char* buffer = OS::SCreate(Thread::Current()->zone(), |
| 73 "%" Px " %" Px " %s%s\n", base, size, marker, name); | 73 "%" Px " %" Px " %s%s\n", base, size, marker, name); |
| 74 (*file_write)(buffer, strlen(buffer), out_file_); | 74 (*file_write)(buffer, strlen(buffer), out_file_); |
| 75 } | 75 } |
| 76 | 76 |
| 77 private: | 77 private: |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 } | 427 } |
| 428 | 428 |
| 429 | 429 |
| 430 void OS::Exit(int code) { | 430 void OS::Exit(int code) { |
| 431 exit(code); | 431 exit(code); |
| 432 } | 432 } |
| 433 | 433 |
| 434 } // namespace dart | 434 } // namespace dart |
| 435 | 435 |
| 436 #endif // defined(TARGET_OS_ANDROID) | 436 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |