| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/log.h" | 5 #include "src/log.h" |
| 6 | 6 |
| 7 #include <cstdarg> | 7 #include <cstdarg> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 SharedFunctionInfo* shared) override {} | 235 SharedFunctionInfo* shared) override {} |
| 236 | 236 |
| 237 private: | 237 private: |
| 238 void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared, | 238 void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared, |
| 239 const char* name, int length) override; | 239 const char* name, int length) override; |
| 240 | 240 |
| 241 // Extension added to V8 log file name to get the low-level log name. | 241 // Extension added to V8 log file name to get the low-level log name. |
| 242 static const char kFilenameFormatString[]; | 242 static const char kFilenameFormatString[]; |
| 243 static const int kFilenameBufferPadding; | 243 static const int kFilenameBufferPadding; |
| 244 | 244 |
| 245 // File buffer size of the low-level log. We don't use the default to | |
| 246 // minimize the associated overhead. | |
| 247 static const int kLogBufferSize = 2 * MB; | |
| 248 | |
| 249 FILE* perf_output_handle_; | 245 FILE* perf_output_handle_; |
| 250 }; | 246 }; |
| 251 | 247 |
| 252 const char PerfBasicLogger::kFilenameFormatString[] = "/tmp/perf-%d.map"; | 248 const char PerfBasicLogger::kFilenameFormatString[] = "/tmp/perf-%d.map"; |
| 253 // Extra space for the PID in the filename | 249 // Extra space for the PID in the filename |
| 254 const int PerfBasicLogger::kFilenameBufferPadding = 16; | 250 const int PerfBasicLogger::kFilenameBufferPadding = 16; |
| 255 | 251 |
| 256 PerfBasicLogger::PerfBasicLogger() | 252 PerfBasicLogger::PerfBasicLogger() |
| 257 : perf_output_handle_(NULL) { | 253 : perf_output_handle_(NULL) { |
| 258 // Open the perf JIT dump file. | 254 // Open the perf JIT dump file. |
| 259 int bufferSize = sizeof(kFilenameFormatString) + kFilenameBufferPadding; | 255 int bufferSize = sizeof(kFilenameFormatString) + kFilenameBufferPadding; |
| 260 ScopedVector<char> perf_dump_name(bufferSize); | 256 ScopedVector<char> perf_dump_name(bufferSize); |
| 261 int size = SNPrintF( | 257 int size = SNPrintF( |
| 262 perf_dump_name, | 258 perf_dump_name, |
| 263 kFilenameFormatString, | 259 kFilenameFormatString, |
| 264 base::OS::GetCurrentProcessId()); | 260 base::OS::GetCurrentProcessId()); |
| 265 CHECK_NE(size, -1); | 261 CHECK_NE(size, -1); |
| 266 perf_output_handle_ = | 262 perf_output_handle_ = |
| 267 base::OS::FOpen(perf_dump_name.start(), base::OS::LogFileOpenMode); | 263 base::OS::FOpen(perf_dump_name.start(), base::OS::LogFileOpenMode); |
| 268 CHECK_NOT_NULL(perf_output_handle_); | 264 CHECK_NOT_NULL(perf_output_handle_); |
| 269 setvbuf(perf_output_handle_, NULL, _IOFBF, kLogBufferSize); | 265 setvbuf(perf_output_handle_, NULL, _IOLBF, 0); |
| 270 } | 266 } |
| 271 | 267 |
| 272 | 268 |
| 273 PerfBasicLogger::~PerfBasicLogger() { | 269 PerfBasicLogger::~PerfBasicLogger() { |
| 274 fclose(perf_output_handle_); | 270 fclose(perf_output_handle_); |
| 275 perf_output_handle_ = NULL; | 271 perf_output_handle_ = NULL; |
| 276 } | 272 } |
| 277 | 273 |
| 278 void PerfBasicLogger::LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*, | 274 void PerfBasicLogger::LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*, |
| 279 const char* name, int length) { | 275 const char* name, int length) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 Address to_address; | 321 Address to_address; |
| 326 }; | 322 }; |
| 327 | 323 |
| 328 | 324 |
| 329 static const char kCodeMovingGCTag = 'G'; | 325 static const char kCodeMovingGCTag = 'G'; |
| 330 | 326 |
| 331 | 327 |
| 332 // Extension added to V8 log file name to get the low-level log name. | 328 // Extension added to V8 log file name to get the low-level log name. |
| 333 static const char kLogExt[]; | 329 static const char kLogExt[]; |
| 334 | 330 |
| 335 // File buffer size of the low-level log. We don't use the default to | |
| 336 // minimize the associated overhead. | |
| 337 static const int kLogBufferSize = 2 * MB; | |
| 338 | |
| 339 void LogCodeInfo(); | 331 void LogCodeInfo(); |
| 340 void LogWriteBytes(const char* bytes, int size); | 332 void LogWriteBytes(const char* bytes, int size); |
| 341 | 333 |
| 342 template <typename T> | 334 template <typename T> |
| 343 void LogWriteStruct(const T& s) { | 335 void LogWriteStruct(const T& s) { |
| 344 char tag = T::kTag; | 336 char tag = T::kTag; |
| 345 LogWriteBytes(reinterpret_cast<const char*>(&tag), sizeof(tag)); | 337 LogWriteBytes(reinterpret_cast<const char*>(&tag), sizeof(tag)); |
| 346 LogWriteBytes(reinterpret_cast<const char*>(&s), sizeof(s)); | 338 LogWriteBytes(reinterpret_cast<const char*>(&s), sizeof(s)); |
| 347 } | 339 } |
| 348 | 340 |
| 349 FILE* ll_output_handle_; | 341 FILE* ll_output_handle_; |
| 350 }; | 342 }; |
| 351 | 343 |
| 352 const char LowLevelLogger::kLogExt[] = ".ll"; | 344 const char LowLevelLogger::kLogExt[] = ".ll"; |
| 353 | 345 |
| 354 LowLevelLogger::LowLevelLogger(const char* name) | 346 LowLevelLogger::LowLevelLogger(const char* name) |
| 355 : ll_output_handle_(NULL) { | 347 : ll_output_handle_(NULL) { |
| 356 // Open the low-level log file. | 348 // Open the low-level log file. |
| 357 size_t len = strlen(name); | 349 size_t len = strlen(name); |
| 358 ScopedVector<char> ll_name(static_cast<int>(len + sizeof(kLogExt))); | 350 ScopedVector<char> ll_name(static_cast<int>(len + sizeof(kLogExt))); |
| 359 MemCopy(ll_name.start(), name, len); | 351 MemCopy(ll_name.start(), name, len); |
| 360 MemCopy(ll_name.start() + len, kLogExt, sizeof(kLogExt)); | 352 MemCopy(ll_name.start() + len, kLogExt, sizeof(kLogExt)); |
| 361 ll_output_handle_ = | 353 ll_output_handle_ = |
| 362 base::OS::FOpen(ll_name.start(), base::OS::LogFileOpenMode); | 354 base::OS::FOpen(ll_name.start(), base::OS::LogFileOpenMode); |
| 363 setvbuf(ll_output_handle_, NULL, _IOFBF, kLogBufferSize); | 355 setvbuf(ll_output_handle_, NULL, _IOLBF, 0); |
| 364 | 356 |
| 365 LogCodeInfo(); | 357 LogCodeInfo(); |
| 366 } | 358 } |
| 367 | 359 |
| 368 | 360 |
| 369 LowLevelLogger::~LowLevelLogger() { | 361 LowLevelLogger::~LowLevelLogger() { |
| 370 fclose(ll_output_handle_); | 362 fclose(ll_output_handle_); |
| 371 ll_output_handle_ = NULL; | 363 ll_output_handle_ = NULL; |
| 372 } | 364 } |
| 373 | 365 |
| (...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1850 removeCodeEventListener(jit_logger_); | 1842 removeCodeEventListener(jit_logger_); |
| 1851 delete jit_logger_; | 1843 delete jit_logger_; |
| 1852 jit_logger_ = NULL; | 1844 jit_logger_ = NULL; |
| 1853 } | 1845 } |
| 1854 | 1846 |
| 1855 return log_->Close(); | 1847 return log_->Close(); |
| 1856 } | 1848 } |
| 1857 | 1849 |
| 1858 } // namespace internal | 1850 } // namespace internal |
| 1859 } // namespace v8 | 1851 } // namespace v8 |
| OLD | NEW |