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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 SharedFunctionInfo* shared) override {} | 234 SharedFunctionInfo* shared) override {} |
235 | 235 |
236 private: | 236 private: |
237 void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared, | 237 void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared, |
238 const char* name, int length) override; | 238 const char* name, int length) override; |
239 | 239 |
240 // Extension added to V8 log file name to get the low-level log name. | 240 // Extension added to V8 log file name to get the low-level log name. |
241 static const char kFilenameFormatString[]; | 241 static const char kFilenameFormatString[]; |
242 static const int kFilenameBufferPadding; | 242 static const int kFilenameBufferPadding; |
243 | 243 |
244 // File buffer size of the low-level log. We don't use the default to | |
245 // minimize the associated overhead. | |
246 static const int kLogBufferSize = 2 * MB; | |
247 | |
248 FILE* perf_output_handle_; | 244 FILE* perf_output_handle_; |
249 }; | 245 }; |
250 | 246 |
251 const char PerfBasicLogger::kFilenameFormatString[] = "/tmp/perf-%d.map"; | 247 const char PerfBasicLogger::kFilenameFormatString[] = "/tmp/perf-%d.map"; |
252 // Extra space for the PID in the filename | 248 // Extra space for the PID in the filename |
253 const int PerfBasicLogger::kFilenameBufferPadding = 16; | 249 const int PerfBasicLogger::kFilenameBufferPadding = 16; |
254 | 250 |
255 PerfBasicLogger::PerfBasicLogger() | 251 PerfBasicLogger::PerfBasicLogger() |
256 : perf_output_handle_(NULL) { | 252 : perf_output_handle_(NULL) { |
257 // Open the perf JIT dump file. | 253 // Open the perf JIT dump file. |
258 int bufferSize = sizeof(kFilenameFormatString) + kFilenameBufferPadding; | 254 int bufferSize = sizeof(kFilenameFormatString) + kFilenameBufferPadding; |
259 ScopedVector<char> perf_dump_name(bufferSize); | 255 ScopedVector<char> perf_dump_name(bufferSize); |
260 int size = SNPrintF( | 256 int size = SNPrintF( |
261 perf_dump_name, | 257 perf_dump_name, |
262 kFilenameFormatString, | 258 kFilenameFormatString, |
263 base::OS::GetCurrentProcessId()); | 259 base::OS::GetCurrentProcessId()); |
264 CHECK_NE(size, -1); | 260 CHECK_NE(size, -1); |
265 perf_output_handle_ = | 261 perf_output_handle_ = |
266 base::OS::FOpen(perf_dump_name.start(), base::OS::LogFileOpenMode); | 262 base::OS::FOpen(perf_dump_name.start(), base::OS::LogFileOpenMode); |
267 CHECK_NOT_NULL(perf_output_handle_); | 263 CHECK_NOT_NULL(perf_output_handle_); |
268 setvbuf(perf_output_handle_, NULL, _IOFBF, kLogBufferSize); | 264 setvbuf(perf_output_handle_, NULL, _IOLBF, 0); |
269 } | 265 } |
270 | 266 |
271 | 267 |
272 PerfBasicLogger::~PerfBasicLogger() { | 268 PerfBasicLogger::~PerfBasicLogger() { |
273 fclose(perf_output_handle_); | 269 fclose(perf_output_handle_); |
274 perf_output_handle_ = NULL; | 270 perf_output_handle_ = NULL; |
275 } | 271 } |
276 | 272 |
277 void PerfBasicLogger::LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*, | 273 void PerfBasicLogger::LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*, |
278 const char* name, int length) { | 274 const char* name, int length) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 Address to_address; | 325 Address to_address; |
330 }; | 326 }; |
331 | 327 |
332 | 328 |
333 static const char kCodeMovingGCTag = 'G'; | 329 static const char kCodeMovingGCTag = 'G'; |
334 | 330 |
335 | 331 |
336 // Extension added to V8 log file name to get the low-level log name. | 332 // Extension added to V8 log file name to get the low-level log name. |
337 static const char kLogExt[]; | 333 static const char kLogExt[]; |
338 | 334 |
339 // File buffer size of the low-level log. We don't use the default to | |
340 // minimize the associated overhead. | |
341 static const int kLogBufferSize = 2 * MB; | |
342 | |
343 void LogCodeInfo(); | 335 void LogCodeInfo(); |
344 void LogWriteBytes(const char* bytes, int size); | 336 void LogWriteBytes(const char* bytes, int size); |
345 | 337 |
346 template <typename T> | 338 template <typename T> |
347 void LogWriteStruct(const T& s) { | 339 void LogWriteStruct(const T& s) { |
348 char tag = T::kTag; | 340 char tag = T::kTag; |
349 LogWriteBytes(reinterpret_cast<const char*>(&tag), sizeof(tag)); | 341 LogWriteBytes(reinterpret_cast<const char*>(&tag), sizeof(tag)); |
350 LogWriteBytes(reinterpret_cast<const char*>(&s), sizeof(s)); | 342 LogWriteBytes(reinterpret_cast<const char*>(&s), sizeof(s)); |
351 } | 343 } |
352 | 344 |
353 FILE* ll_output_handle_; | 345 FILE* ll_output_handle_; |
354 }; | 346 }; |
355 | 347 |
356 const char LowLevelLogger::kLogExt[] = ".ll"; | 348 const char LowLevelLogger::kLogExt[] = ".ll"; |
357 | 349 |
358 LowLevelLogger::LowLevelLogger(const char* name) | 350 LowLevelLogger::LowLevelLogger(const char* name) |
359 : ll_output_handle_(NULL) { | 351 : ll_output_handle_(NULL) { |
360 // Open the low-level log file. | 352 // Open the low-level log file. |
361 size_t len = strlen(name); | 353 size_t len = strlen(name); |
362 ScopedVector<char> ll_name(static_cast<int>(len + sizeof(kLogExt))); | 354 ScopedVector<char> ll_name(static_cast<int>(len + sizeof(kLogExt))); |
363 MemCopy(ll_name.start(), name, len); | 355 MemCopy(ll_name.start(), name, len); |
364 MemCopy(ll_name.start() + len, kLogExt, sizeof(kLogExt)); | 356 MemCopy(ll_name.start() + len, kLogExt, sizeof(kLogExt)); |
365 ll_output_handle_ = | 357 ll_output_handle_ = |
366 base::OS::FOpen(ll_name.start(), base::OS::LogFileOpenMode); | 358 base::OS::FOpen(ll_name.start(), base::OS::LogFileOpenMode); |
367 setvbuf(ll_output_handle_, NULL, _IOFBF, kLogBufferSize); | 359 setvbuf(ll_output_handle_, NULL, _IOLBF, 0); |
368 | 360 |
369 LogCodeInfo(); | 361 LogCodeInfo(); |
370 } | 362 } |
371 | 363 |
372 | 364 |
373 LowLevelLogger::~LowLevelLogger() { | 365 LowLevelLogger::~LowLevelLogger() { |
374 fclose(ll_output_handle_); | 366 fclose(ll_output_handle_); |
375 ll_output_handle_ = NULL; | 367 ll_output_handle_ = NULL; |
376 } | 368 } |
377 | 369 |
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 removeCodeEventListener(jit_logger_); | 1895 removeCodeEventListener(jit_logger_); |
1904 delete jit_logger_; | 1896 delete jit_logger_; |
1905 jit_logger_ = NULL; | 1897 jit_logger_ = NULL; |
1906 } | 1898 } |
1907 | 1899 |
1908 return log_->Close(); | 1900 return log_->Close(); |
1909 } | 1901 } |
1910 | 1902 |
1911 } // namespace internal | 1903 } // namespace internal |
1912 } // namespace v8 | 1904 } // namespace v8 |
OLD | NEW |