| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 319 |
| 320 | 320 |
| 321 struct CodeMoveStruct { | 321 struct CodeMoveStruct { |
| 322 static const char kTag = 'M'; | 322 static const char kTag = 'M'; |
| 323 | 323 |
| 324 Address from_address; | 324 Address from_address; |
| 325 Address to_address; | 325 Address to_address; |
| 326 }; | 326 }; |
| 327 | 327 |
| 328 | 328 |
| 329 struct SnapshotPositionStruct { | |
| 330 static const char kTag = 'P'; | |
| 331 | |
| 332 Address address; | |
| 333 int32_t position; | |
| 334 }; | |
| 335 | |
| 336 | |
| 337 static const char kCodeMovingGCTag = 'G'; | 329 static const char kCodeMovingGCTag = 'G'; |
| 338 | 330 |
| 339 | 331 |
| 340 // 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. |
| 341 static const char kLogExt[]; | 333 static const char kLogExt[]; |
| 342 | 334 |
| 343 // File buffer size of the low-level log. We don't use the default to | 335 // File buffer size of the low-level log. We don't use the default to |
| 344 // minimize the associated overhead. | 336 // minimize the associated overhead. |
| 345 static const int kLogBufferSize = 2 * MB; | 337 static const int kLogBufferSize = 2 * MB; |
| 346 | 338 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 } | 411 } |
| 420 | 412 |
| 421 void LowLevelLogger::CodeMoveEvent(AbstractCode* from, Address to) { | 413 void LowLevelLogger::CodeMoveEvent(AbstractCode* from, Address to) { |
| 422 CodeMoveStruct event; | 414 CodeMoveStruct event; |
| 423 event.from_address = from->instruction_start(); | 415 event.from_address = from->instruction_start(); |
| 424 size_t header_size = from->instruction_start() - from->address(); | 416 size_t header_size = from->instruction_start() - from->address(); |
| 425 event.to_address = to + header_size; | 417 event.to_address = to + header_size; |
| 426 LogWriteStruct(event); | 418 LogWriteStruct(event); |
| 427 } | 419 } |
| 428 | 420 |
| 429 void LowLevelLogger::SnapshotPositionEvent(HeapObject* obj, int pos) { | |
| 430 if (obj->IsAbstractCode()) { | |
| 431 SnapshotPositionStruct event; | |
| 432 event.address = | |
| 433 obj->address() + | |
| 434 (obj->IsCode() ? Code::kHeaderSize : BytecodeArray::kHeaderSize); | |
| 435 event.position = pos; | |
| 436 LogWriteStruct(event); | |
| 437 } | |
| 438 } | |
| 439 | |
| 440 | 421 |
| 441 void LowLevelLogger::LogWriteBytes(const char* bytes, int size) { | 422 void LowLevelLogger::LogWriteBytes(const char* bytes, int size) { |
| 442 size_t rv = fwrite(bytes, 1, size, ll_output_handle_); | 423 size_t rv = fwrite(bytes, 1, size, ll_output_handle_); |
| 443 DCHECK(static_cast<size_t>(size) == rv); | 424 DCHECK(static_cast<size_t>(size) == rv); |
| 444 USE(rv); | 425 USE(rv); |
| 445 } | 426 } |
| 446 | 427 |
| 447 | 428 |
| 448 void LowLevelLogger::CodeMovingGCEvent() { | 429 void LowLevelLogger::CodeMovingGCEvent() { |
| 449 const char tag = kCodeMovingGCTag; | 430 const char tag = kCodeMovingGCTag; |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 | 1270 |
| 1290 | 1271 |
| 1291 void Logger::CodeNameEvent(Address addr, int pos, const char* code_name) { | 1272 void Logger::CodeNameEvent(Address addr, int pos, const char* code_name) { |
| 1292 if (code_name == NULL) return; // Not a code object. | 1273 if (code_name == NULL) return; // Not a code object. |
| 1293 Log::MessageBuilder msg(log_); | 1274 Log::MessageBuilder msg(log_); |
| 1294 msg.Append("%s,%d,", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos); | 1275 msg.Append("%s,%d,", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos); |
| 1295 msg.AppendDoubleQuotedString(code_name); | 1276 msg.AppendDoubleQuotedString(code_name); |
| 1296 msg.WriteToLogFile(); | 1277 msg.WriteToLogFile(); |
| 1297 } | 1278 } |
| 1298 | 1279 |
| 1299 void Logger::SnapshotPositionEvent(HeapObject* obj, int pos) { | |
| 1300 if (!log_->IsEnabled()) return; | |
| 1301 LL_LOG(SnapshotPositionEvent(obj, pos)); | |
| 1302 if (!FLAG_log_snapshot_positions) return; | |
| 1303 Log::MessageBuilder msg(log_); | |
| 1304 msg.Append("%s,", kLogEventsNames[SNAPSHOT_POSITION_EVENT]); | |
| 1305 msg.AppendAddress(obj->address()); | |
| 1306 msg.Append(",%d", pos); | |
| 1307 msg.WriteToLogFile(); | |
| 1308 } | |
| 1309 | |
| 1310 | 1280 |
| 1311 void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) { | 1281 void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) { |
| 1312 if (!is_logging_code_events()) return; | 1282 if (!is_logging_code_events()) return; |
| 1313 MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to); | 1283 MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to); |
| 1314 } | 1284 } |
| 1315 | 1285 |
| 1316 | 1286 |
| 1317 void Logger::MoveEventInternal(LogEventsAndTags event, | 1287 void Logger::MoveEventInternal(LogEventsAndTags event, |
| 1318 Address from, | 1288 Address from, |
| 1319 Address to) { | 1289 Address to) { |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 } | 1744 } |
| 1775 } | 1745 } |
| 1776 } | 1746 } |
| 1777 | 1747 |
| 1778 | 1748 |
| 1779 bool Logger::SetUp(Isolate* isolate) { | 1749 bool Logger::SetUp(Isolate* isolate) { |
| 1780 // Tests and EnsureInitialize() can call this twice in a row. It's harmless. | 1750 // Tests and EnsureInitialize() can call this twice in a row. It's harmless. |
| 1781 if (is_initialized_) return true; | 1751 if (is_initialized_) return true; |
| 1782 is_initialized_ = true; | 1752 is_initialized_ = true; |
| 1783 | 1753 |
| 1784 // --ll-prof implies --log-code and --log-snapshot-positions. | |
| 1785 if (FLAG_ll_prof) { | |
| 1786 FLAG_log_snapshot_positions = true; | |
| 1787 } | |
| 1788 | |
| 1789 std::ostringstream log_file_name; | 1754 std::ostringstream log_file_name; |
| 1790 PrepareLogFileName(log_file_name, isolate, FLAG_logfile); | 1755 PrepareLogFileName(log_file_name, isolate, FLAG_logfile); |
| 1791 log_->Initialize(log_file_name.str().c_str()); | 1756 log_->Initialize(log_file_name.str().c_str()); |
| 1792 | 1757 |
| 1793 | 1758 |
| 1794 if (FLAG_perf_basic_prof) { | 1759 if (FLAG_perf_basic_prof) { |
| 1795 perf_basic_logger_ = new PerfBasicLogger(); | 1760 perf_basic_logger_ = new PerfBasicLogger(); |
| 1796 addCodeEventListener(perf_basic_logger_); | 1761 addCodeEventListener(perf_basic_logger_); |
| 1797 } | 1762 } |
| 1798 | 1763 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1885 removeCodeEventListener(jit_logger_); | 1850 removeCodeEventListener(jit_logger_); |
| 1886 delete jit_logger_; | 1851 delete jit_logger_; |
| 1887 jit_logger_ = NULL; | 1852 jit_logger_ = NULL; |
| 1888 } | 1853 } |
| 1889 | 1854 |
| 1890 return log_->Close(); | 1855 return log_->Close(); |
| 1891 } | 1856 } |
| 1892 | 1857 |
| 1893 } // namespace internal | 1858 } // namespace internal |
| 1894 } // namespace v8 | 1859 } // namespace v8 |
| OLD | NEW |