| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 out_file_ = NULL; | 144 out_file_ = NULL; |
| 145 clock_fd_ = -1; | 145 clock_fd_ = -1; |
| 146 clock_id_ = kInvalidClockId; | 146 clock_id_ = kInvalidClockId; |
| 147 code_sequence_ = 0; | 147 code_sequence_ = 0; |
| 148 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); | 148 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); |
| 149 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); | 149 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); |
| 150 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); | 150 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); |
| 151 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) { | 151 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) { |
| 152 return; | 152 return; |
| 153 } | 153 } |
| 154 // The Jitdump code observer writes all jitted code into | 154 // The Jitdump code observer writes all jitted code into the file |
| 155 // /tmp/jit-<pid>.dump, we open the file once on initialization and close | 155 // 'perf.jitdump' in the current working directory. We open the file once |
| 156 // it when the VM is going down. | 156 // on initialization and close it when the VM is going down. |
| 157 { | 157 { |
| 158 // Open the file. | 158 // Open the file. |
| 159 const char* format = "/tmp/jit-%" Pd ".dump"; | 159 const char* filename = "perf.jitdump"; |
| 160 intptr_t pid = getpid(); | |
| 161 intptr_t len = OS::SNPrint(NULL, 0, format, pid); | |
| 162 char* filename = new char[len + 1]; | |
| 163 OS::SNPrint(filename, len + 1, format, pid); | |
| 164 out_file_ = (*file_open)(filename, true); | 160 out_file_ = (*file_open)(filename, true); |
| 165 ASSERT(out_file_ != NULL); | 161 ASSERT(out_file_ != NULL); |
| 166 // Write the jit dump header. | 162 // Write the jit dump header. |
| 167 WriteHeader(); | 163 WriteHeader(); |
| 168 } | 164 } |
| 169 // perf uses an internal clock and because our output is merged with data | 165 // perf uses an internal clock and because our output is merged with data |
| 170 // collected by perf our timestamps must be consistent. Using | 166 // collected by perf our timestamps must be consistent. Using |
| 171 // the posix-clock-module (/dev/trace_clock) as our time source ensures | 167 // the posix-clock-module (/dev/trace_clock) as our time source ensures |
| 172 // we are consistent with the perf timestamps. | 168 // we are consistent with the perf timestamps. |
| 173 clock_id_ = kInvalidClockId; | 169 clock_id_ = kInvalidClockId; |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 } | 616 } |
| 621 | 617 |
| 622 | 618 |
| 623 void OS::Exit(int code) { | 619 void OS::Exit(int code) { |
| 624 exit(code); | 620 exit(code); |
| 625 } | 621 } |
| 626 | 622 |
| 627 } // namespace dart | 623 } // namespace dart |
| 628 | 624 |
| 629 #endif // defined(TARGET_OS_LINUX) | 625 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |