| 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 <stdarg.h> | 5 #include <stdarg.h> |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 name_buffer_->AppendByte(' '); | 196 name_buffer_->AppendByte(' '); |
| 197 if (source->IsString()) { | 197 if (source->IsString()) { |
| 198 name_buffer_->AppendString(String::cast(source)); | 198 name_buffer_->AppendString(String::cast(source)); |
| 199 } else { | 199 } else { |
| 200 name_buffer_->AppendBytes("symbol(hash "); | 200 name_buffer_->AppendBytes("symbol(hash "); |
| 201 name_buffer_->AppendHex(Name::cast(source)->Hash()); | 201 name_buffer_->AppendHex(Name::cast(source)->Hash()); |
| 202 name_buffer_->AppendByte(')'); | 202 name_buffer_->AppendByte(')'); |
| 203 } | 203 } |
| 204 name_buffer_->AppendByte(':'); | 204 name_buffer_->AppendByte(':'); |
| 205 name_buffer_->AppendInt(line); | 205 name_buffer_->AppendInt(line); |
| 206 name_buffer_->AppendByte(':'); |
| 207 name_buffer_->AppendInt(column); |
| 206 LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size()); | 208 LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size()); |
| 207 } | 209 } |
| 208 | 210 |
| 209 | 211 |
| 210 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | 212 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 211 Code* code, | 213 Code* code, |
| 212 int args_count) { | 214 int args_count) { |
| 213 name_buffer_->Init(tag); | 215 name_buffer_->Init(tag); |
| 214 name_buffer_->AppendInt(args_count); | 216 name_buffer_->AppendInt(args_count); |
| 215 LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size()); | 217 LogRecordedBuffer(code, NULL, name_buffer_->get(), name_buffer_->size()); |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 ticker_(NULL), | 934 ticker_(NULL), |
| 933 profiler_(NULL), | 935 profiler_(NULL), |
| 934 log_events_(NULL), | 936 log_events_(NULL), |
| 935 is_logging_(false), | 937 is_logging_(false), |
| 936 log_(new Log(this)), | 938 log_(new Log(this)), |
| 937 perf_basic_logger_(NULL), | 939 perf_basic_logger_(NULL), |
| 938 perf_jit_logger_(NULL), | 940 perf_jit_logger_(NULL), |
| 939 ll_logger_(NULL), | 941 ll_logger_(NULL), |
| 940 jit_logger_(NULL), | 942 jit_logger_(NULL), |
| 941 listeners_(5), | 943 listeners_(5), |
| 944 sampler_thread_(NULL), |
| 942 is_initialized_(false) { | 945 is_initialized_(false) { |
| 943 } | 946 } |
| 944 | 947 |
| 945 | 948 |
| 946 Logger::~Logger() { | 949 Logger::~Logger() { |
| 947 delete log_; | 950 delete log_; |
| 948 } | 951 } |
| 949 | 952 |
| 950 | 953 |
| 951 void Logger::addCodeEventListener(CodeEventListener* listener) { | 954 void Logger::addCodeEventListener(CodeEventListener* listener) { |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 CallbackEventInternal("get ", name, entry_point); | 1325 CallbackEventInternal("get ", name, entry_point); |
| 1323 } | 1326 } |
| 1324 | 1327 |
| 1325 | 1328 |
| 1326 void Logger::SetterCallbackEvent(Name* name, Address entry_point) { | 1329 void Logger::SetterCallbackEvent(Name* name, Address entry_point) { |
| 1327 PROFILER_LOG(SetterCallbackEvent(name, entry_point)); | 1330 PROFILER_LOG(SetterCallbackEvent(name, entry_point)); |
| 1328 CallbackEventInternal("set ", name, entry_point); | 1331 CallbackEventInternal("set ", name, entry_point); |
| 1329 } | 1332 } |
| 1330 | 1333 |
| 1331 | 1334 |
| 1332 static void AppendCodeCreateHeader(Log::MessageBuilder* msg, | 1335 void Logger::CodeCreateEvent(const v8::JitCodeEvent* event) { |
| 1333 Logger::LogEventsAndTags tag, | 1336 if (!is_logging_code_events() || |
| 1334 Code* code) { | 1337 !FLAG_log_code || |
| 1335 ASSERT(msg); | 1338 !log_->IsEnabled()) return; |
| 1336 msg->Append("%s,%s,%d,", | 1339 |
| 1337 kLogEventsNames[Logger::CODE_CREATION_EVENT], | 1340 Log::MessageBuilder msg(log_); |
| 1338 kLogEventsNames[tag], | 1341 msg.Append("%s,", kLogEventsNames[Logger::CODE_CREATION_EVENT]); |
| 1339 code->kind()); | 1342 |
| 1340 msg->AppendAddress(code->address()); | 1343 // Extract the tag name. |
| 1341 msg->Append(",%d,", code->ExecutableSize()); | 1344 unsigned i = 0; |
| 1345 for (; i < event->name.len; i++) { |
| 1346 if (event->name.str[i] == ':') break; |
| 1347 msg.Append(event->name.str[i]); |
| 1348 } |
| 1349 i++; |
| 1350 |
| 1351 msg.Append(",,%p,%d,\"", event->code_start, event->code_len); |
| 1352 |
| 1353 // Have a look at function ComputeMarker |
| 1354 // The first character here might be the marker. |
| 1355 // In that case, get rid of that. |
| 1356 if ((i < event->name.len) && |
| 1357 ((event->name.str[i] == '~') || |
| 1358 (event->name.str[i] == '*'))) |
| 1359 i++; |
| 1360 |
| 1361 for (; i < event->name.len; i++) { |
| 1362 msg.Append(event->name.str[i]); |
| 1363 } |
| 1364 msg.Append("\"\n"); |
| 1365 |
| 1366 msg.WriteToLogFile(); |
| 1342 } | 1367 } |
| 1343 | 1368 |
| 1344 | 1369 |
| 1345 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1370 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1346 Code* code, | 1371 Code* code, |
| 1347 const char* comment) { | 1372 const char* comment) { |
| 1348 PROFILER_LOG(CodeCreateEvent(tag, code, comment)); | 1373 PROFILER_LOG(CodeCreateEvent(tag, code, comment)); |
| 1349 | 1374 |
| 1350 if (!is_logging_code_events()) return; | 1375 if (!is_logging_code_events()) return; |
| 1351 CALL_LISTENERS(CodeCreateEvent(tag, code, comment)); | 1376 CALL_LISTENERS(CodeCreateEvent(tag, code, comment)); |
| 1352 | |
| 1353 if (!FLAG_log_code || !log_->IsEnabled()) return; | |
| 1354 Log::MessageBuilder msg(log_); | |
| 1355 AppendCodeCreateHeader(&msg, tag, code); | |
| 1356 msg.AppendDoubleQuotedString(comment); | |
| 1357 msg.Append('\n'); | |
| 1358 msg.WriteToLogFile(); | |
| 1359 } | 1377 } |
| 1360 | 1378 |
| 1361 | 1379 |
| 1362 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1380 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1363 Code* code, | 1381 Code* code, |
| 1364 Name* name) { | 1382 Name* name) { |
| 1365 PROFILER_LOG(CodeCreateEvent(tag, code, name)); | 1383 PROFILER_LOG(CodeCreateEvent(tag, code, name)); |
| 1366 | 1384 |
| 1367 if (!is_logging_code_events()) return; | 1385 if (!is_logging_code_events()) return; |
| 1368 CALL_LISTENERS(CodeCreateEvent(tag, code, name)); | 1386 CALL_LISTENERS(CodeCreateEvent(tag, code, name)); |
| 1369 | |
| 1370 if (!FLAG_log_code || !log_->IsEnabled()) return; | |
| 1371 Log::MessageBuilder msg(log_); | |
| 1372 AppendCodeCreateHeader(&msg, tag, code); | |
| 1373 if (name->IsString()) { | |
| 1374 msg.Append('"'); | |
| 1375 msg.AppendDetailed(String::cast(name), false); | |
| 1376 msg.Append('"'); | |
| 1377 } else { | |
| 1378 msg.AppendSymbolName(Symbol::cast(name)); | |
| 1379 } | |
| 1380 msg.Append('\n'); | |
| 1381 msg.WriteToLogFile(); | |
| 1382 } | 1387 } |
| 1383 | 1388 |
| 1384 | 1389 |
| 1385 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1390 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1386 Code* code, | 1391 Code* code, |
| 1387 SharedFunctionInfo* shared, | 1392 SharedFunctionInfo* shared, |
| 1388 CompilationInfo* info, | 1393 CompilationInfo* info, |
| 1389 Name* name) { | 1394 Name* name) { |
| 1390 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, name)); | 1395 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, name)); |
| 1391 | 1396 |
| 1392 if (!is_logging_code_events()) return; | 1397 if (!is_logging_code_events()) return; |
| 1393 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, name)); | 1398 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, name)); |
| 1394 | |
| 1395 if (!FLAG_log_code || !log_->IsEnabled()) return; | |
| 1396 if (code == isolate_->builtins()->builtin(Builtins::kCompileUnoptimized)) | |
| 1397 return; | |
| 1398 | |
| 1399 Log::MessageBuilder msg(log_); | |
| 1400 AppendCodeCreateHeader(&msg, tag, code); | |
| 1401 if (name->IsString()) { | |
| 1402 SmartArrayPointer<char> str = | |
| 1403 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | |
| 1404 msg.Append("\"%s\"", str.get()); | |
| 1405 } else { | |
| 1406 msg.AppendSymbolName(Symbol::cast(name)); | |
| 1407 } | |
| 1408 msg.Append(','); | |
| 1409 msg.AppendAddress(shared->address()); | |
| 1410 msg.Append(",%s", ComputeMarker(code)); | |
| 1411 msg.Append('\n'); | |
| 1412 msg.WriteToLogFile(); | |
| 1413 } | 1399 } |
| 1414 | 1400 |
| 1415 | 1401 |
| 1416 // Although, it is possible to extract source and line from | 1402 // Although, it is possible to extract source and line from |
| 1417 // the SharedFunctionInfo object, we left it to caller | 1403 // the SharedFunctionInfo object, we left it to caller |
| 1418 // to leave logging functions free from heap allocations. | 1404 // to leave logging functions free from heap allocations. |
| 1419 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1405 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1420 Code* code, | 1406 Code* code, |
| 1421 SharedFunctionInfo* shared, | 1407 SharedFunctionInfo* shared, |
| 1422 CompilationInfo* info, | 1408 CompilationInfo* info, |
| 1423 Name* source, int line, int column) { | 1409 Name* source, int line, int column) { |
| 1424 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, source, line, column)); | 1410 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, source, line, column)); |
| 1425 | 1411 |
| 1426 if (!is_logging_code_events()) return; | 1412 if (!is_logging_code_events()) return; |
| 1427 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, source, line, | 1413 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, source, line, |
| 1428 column)); | 1414 column)); |
| 1429 | |
| 1430 if (!FLAG_log_code || !log_->IsEnabled()) return; | |
| 1431 Log::MessageBuilder msg(log_); | |
| 1432 AppendCodeCreateHeader(&msg, tag, code); | |
| 1433 SmartArrayPointer<char> name = | |
| 1434 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | |
| 1435 msg.Append("\"%s ", name.get()); | |
| 1436 if (source->IsString()) { | |
| 1437 SmartArrayPointer<char> sourcestr = | |
| 1438 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | |
| 1439 msg.Append("%s", sourcestr.get()); | |
| 1440 } else { | |
| 1441 msg.AppendSymbolName(Symbol::cast(source)); | |
| 1442 } | |
| 1443 msg.Append(":%d:%d\",", line, column); | |
| 1444 msg.AppendAddress(shared->address()); | |
| 1445 msg.Append(",%s", ComputeMarker(code)); | |
| 1446 msg.Append('\n'); | |
| 1447 msg.WriteToLogFile(); | |
| 1448 } | 1415 } |
| 1449 | 1416 |
| 1450 | 1417 |
| 1451 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1418 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1452 Code* code, | 1419 Code* code, |
| 1453 int args_count) { | 1420 int args_count) { |
| 1454 PROFILER_LOG(CodeCreateEvent(tag, code, args_count)); | 1421 PROFILER_LOG(CodeCreateEvent(tag, code, args_count)); |
| 1455 | 1422 |
| 1456 if (!is_logging_code_events()) return; | 1423 if (!is_logging_code_events()) return; |
| 1457 CALL_LISTENERS(CodeCreateEvent(tag, code, args_count)); | 1424 CALL_LISTENERS(CodeCreateEvent(tag, code, args_count)); |
| 1458 | |
| 1459 if (!FLAG_log_code || !log_->IsEnabled()) return; | |
| 1460 Log::MessageBuilder msg(log_); | |
| 1461 AppendCodeCreateHeader(&msg, tag, code); | |
| 1462 msg.Append("\"args_count: %d\"", args_count); | |
| 1463 msg.Append('\n'); | |
| 1464 msg.WriteToLogFile(); | |
| 1465 } | 1425 } |
| 1466 | 1426 |
| 1467 | 1427 |
| 1468 void Logger::CodeDisableOptEvent(Code* code, | 1428 void Logger::CodeDisableOptEvent(Code* code, |
| 1469 SharedFunctionInfo* shared) { | 1429 SharedFunctionInfo* shared) { |
| 1470 PROFILER_LOG(CodeDisableOptEvent(code, shared)); | 1430 PROFILER_LOG(CodeDisableOptEvent(code, shared)); |
| 1471 | 1431 |
| 1472 if (!is_logging_code_events()) return; | 1432 if (!is_logging_code_events()) return; |
| 1473 CALL_LISTENERS(CodeDisableOptEvent(code, shared)); | 1433 CALL_LISTENERS(CodeDisableOptEvent(code, shared)); |
| 1474 | 1434 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1491 CALL_LISTENERS(CodeMovingGCEvent()); | 1451 CALL_LISTENERS(CodeMovingGCEvent()); |
| 1492 base::OS::SignalCodeMovingGC(); | 1452 base::OS::SignalCodeMovingGC(); |
| 1493 } | 1453 } |
| 1494 | 1454 |
| 1495 | 1455 |
| 1496 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { | 1456 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { |
| 1497 PROFILER_LOG(RegExpCodeCreateEvent(code, source)); | 1457 PROFILER_LOG(RegExpCodeCreateEvent(code, source)); |
| 1498 | 1458 |
| 1499 if (!is_logging_code_events()) return; | 1459 if (!is_logging_code_events()) return; |
| 1500 CALL_LISTENERS(RegExpCodeCreateEvent(code, source)); | 1460 CALL_LISTENERS(RegExpCodeCreateEvent(code, source)); |
| 1501 | |
| 1502 if (!FLAG_log_code || !log_->IsEnabled()) return; | |
| 1503 Log::MessageBuilder msg(log_); | |
| 1504 AppendCodeCreateHeader(&msg, REG_EXP_TAG, code); | |
| 1505 msg.Append('"'); | |
| 1506 msg.AppendDetailed(source, false); | |
| 1507 msg.Append('"'); | |
| 1508 msg.Append('\n'); | |
| 1509 msg.WriteToLogFile(); | |
| 1510 } | 1461 } |
| 1511 | 1462 |
| 1512 | 1463 |
| 1464 void Logger::CodeMoveEvent(const v8::JitCodeEvent* event) { |
| 1465 if (!is_logging_code_events()) return; |
| 1466 MoveEventInternal(CODE_MOVE_EVENT, |
| 1467 static_cast<Address>(event->code_start), |
| 1468 static_cast<Address>(event->new_code_start)); |
| 1469 } |
| 1470 |
| 1471 |
| 1513 void Logger::CodeMoveEvent(Address from, Address to) { | 1472 void Logger::CodeMoveEvent(Address from, Address to) { |
| 1514 PROFILER_LOG(CodeMoveEvent(from, to)); | 1473 PROFILER_LOG(CodeMoveEvent(from, to)); |
| 1515 | 1474 |
| 1516 if (!is_logging_code_events()) return; | 1475 if (!is_logging_code_events()) return; |
| 1517 CALL_LISTENERS(CodeMoveEvent(from, to)); | 1476 CALL_LISTENERS(CodeMoveEvent(from, to)); |
| 1518 MoveEventInternal(CODE_MOVE_EVENT, from, to); | 1477 } |
| 1478 |
| 1479 |
| 1480 void Logger::CodeDeleteEvent(const v8::JitCodeEvent* event) { |
| 1481 if (!is_logging_code_events()) return; |
| 1482 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1483 Log::MessageBuilder msg(log_); |
| 1484 msg.Append("%s,", kLogEventsNames[CODE_DELETE_EVENT]); |
| 1485 msg.AppendAddress(static_cast<Address>(event->code_start)); |
| 1486 msg.Append('\n'); |
| 1487 msg.WriteToLogFile(); |
| 1519 } | 1488 } |
| 1520 | 1489 |
| 1521 | 1490 |
| 1522 void Logger::CodeDeleteEvent(Address from) { | 1491 void Logger::CodeDeleteEvent(Address from) { |
| 1523 PROFILER_LOG(CodeDeleteEvent(from)); | 1492 PROFILER_LOG(CodeDeleteEvent(from)); |
| 1524 | 1493 |
| 1525 if (!is_logging_code_events()) return; | 1494 if (!is_logging_code_events()) return; |
| 1526 CALL_LISTENERS(CodeDeleteEvent(from)); | 1495 CALL_LISTENERS(CodeDeleteEvent(from)); |
| 1527 | |
| 1528 if (!FLAG_log_code || !log_->IsEnabled()) return; | |
| 1529 Log::MessageBuilder msg(log_); | |
| 1530 msg.Append("%s,", kLogEventsNames[CODE_DELETE_EVENT]); | |
| 1531 msg.AppendAddress(from); | |
| 1532 msg.Append('\n'); | |
| 1533 msg.WriteToLogFile(); | |
| 1534 } | 1496 } |
| 1535 | 1497 |
| 1536 | 1498 |
| 1537 void Logger::CodeLinePosInfoAddPositionEvent(void* jit_handler_data, | 1499 void Logger::CodeLinePosInfoAddPositionEvent(void* jit_handler_data, |
| 1538 int pc_offset, | 1500 int pc_offset, |
| 1539 int position) { | 1501 int position) { |
| 1540 JIT_LOG(AddCodeLinePosInfoEvent(jit_handler_data, | 1502 JIT_LOG(AddCodeLinePosInfoEvent(jit_handler_data, |
| 1541 pc_offset, | 1503 pc_offset, |
| 1542 position, | 1504 position, |
| 1543 JitCodeEvent::POSITION)); | 1505 JitCodeEvent::POSITION)); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 Log::MessageBuilder msg(log_); | 1656 Log::MessageBuilder msg(log_); |
| 1695 msg.Append("debug-queue-event,%s,%15.3f,%s\n", | 1657 msg.Append("debug-queue-event,%s,%15.3f,%s\n", |
| 1696 event_type, | 1658 event_type, |
| 1697 base::OS::TimeCurrentMillis(), | 1659 base::OS::TimeCurrentMillis(), |
| 1698 parameter_string); | 1660 parameter_string); |
| 1699 DeleteArray(parameter_string); | 1661 DeleteArray(parameter_string); |
| 1700 msg.WriteToLogFile(); | 1662 msg.WriteToLogFile(); |
| 1701 } | 1663 } |
| 1702 | 1664 |
| 1703 | 1665 |
| 1704 void Logger::TickEvent(TickSample* sample, bool overflow) { | 1666 void Logger::LogSample(v8::Sample* sample) { |
| 1705 if (!log_->IsEnabled() || !FLAG_prof) return; | 1667 if (!log_->IsEnabled() || !FLAG_prof) return; |
| 1668 |
| 1706 Log::MessageBuilder msg(log_); | 1669 Log::MessageBuilder msg(log_); |
| 1707 msg.Append("%s,", kLogEventsNames[TICK_EVENT]); | 1670 msg.Append("%s,,%ld,,,", |
| 1708 msg.AppendAddress(sample->pc); | 1671 kLogEventsNames[TICK_EVENT], |
| 1709 msg.Append(",%ld", static_cast<int>(timer_.Elapsed().InMicroseconds())); | 1672 static_cast<int>(timer_.Elapsed().InMicroseconds())); |
| 1710 if (sample->has_external_callback) { | |
| 1711 msg.Append(",1,"); | |
| 1712 msg.AppendAddress(sample->external_callback); | |
| 1713 } else { | |
| 1714 msg.Append(",0,"); | |
| 1715 msg.AppendAddress(sample->tos); | |
| 1716 } | |
| 1717 msg.Append(",%d", static_cast<int>(sample->state)); | |
| 1718 if (overflow) { | |
| 1719 msg.Append(",overflow"); | |
| 1720 } | |
| 1721 for (unsigned i = 0; i < sample->frames_count; ++i) { | 1673 for (unsigned i = 0; i < sample->frames_count; ++i) { |
| 1722 msg.Append(','); | 1674 msg.Append(','); |
| 1723 msg.AppendAddress(static_cast<Address>(sample->stack[i])); | 1675 msg.AppendAddress(static_cast<Address>(sample->stack[i])); |
| 1724 } | 1676 } |
| 1725 msg.Append('\n'); | 1677 msg.Append('\n'); |
| 1726 msg.WriteToLogFile(); | 1678 msg.WriteToLogFile(); |
| 1727 } | 1679 } |
| 1728 | 1680 |
| 1729 | 1681 |
| 1730 void Logger::StopProfiler() { | 1682 void Logger::StopProfiler() { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2051 ticker_ = new Ticker(isolate, kSamplingIntervalMs); | 2003 ticker_ = new Ticker(isolate, kSamplingIntervalMs); |
| 2052 | 2004 |
| 2053 if (Log::InitLogAtStart()) { | 2005 if (Log::InitLogAtStart()) { |
| 2054 is_logging_ = true; | 2006 is_logging_ = true; |
| 2055 } | 2007 } |
| 2056 | 2008 |
| 2057 if (FLAG_prof) { | 2009 if (FLAG_prof) { |
| 2058 profiler_ = new Profiler(isolate); | 2010 profiler_ = new Profiler(isolate); |
| 2059 is_logging_ = true; | 2011 is_logging_ = true; |
| 2060 profiler_->Engage(); | 2012 profiler_->Engage(); |
| 2013 |
| 2014 sampler_thread_ = new SamplerThread( |
| 2015 reinterpret_cast<v8::Isolate*>(isolate)); |
| 2061 } | 2016 } |
| 2062 | 2017 |
| 2063 // TODO(gholap): This one's for the new sampler API. (include/v8-sampler.h) | 2018 // TODO(gholap): This one's for the new sampler API. (include/v8-sampler.h) |
| 2064 // Call to IncreaseProfilingDepth causes the | 2019 // Call to IncreaseProfilingDepth causes the |
| 2065 // SIGPROF signal handler to be installed on the VM thread. | 2020 // SIGPROF signal handler to be installed on the VM thread. |
| 2066 // Figure out whether there's a way to only optionally | 2021 // Figure out whether there's a way to only optionally |
| 2067 // do this based on a runtime flag. | 2022 // do this based on a runtime flag. |
| 2068 ticker_->IncreaseProfilingDepth(); | 2023 ticker_->IncreaseProfilingDepth(); |
| 2069 | 2024 |
| 2070 if (FLAG_log_internal_timer_events || FLAG_prof) timer_.Start(); | 2025 if (FLAG_log_internal_timer_events || FLAG_prof) timer_.Start(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 delete ll_logger_; | 2084 delete ll_logger_; |
| 2130 ll_logger_ = NULL; | 2085 ll_logger_ = NULL; |
| 2131 } | 2086 } |
| 2132 | 2087 |
| 2133 if (jit_logger_) { | 2088 if (jit_logger_) { |
| 2134 removeCodeEventListener(jit_logger_); | 2089 removeCodeEventListener(jit_logger_); |
| 2135 delete jit_logger_; | 2090 delete jit_logger_; |
| 2136 jit_logger_ = NULL; | 2091 jit_logger_ = NULL; |
| 2137 } | 2092 } |
| 2138 | 2093 |
| 2094 if (sampler_thread_) { |
| 2095 delete sampler_thread_; |
| 2096 sampler_thread_ = NULL; |
| 2097 } |
| 2098 |
| 2139 return log_->Close(); | 2099 return log_->Close(); |
| 2140 } | 2100 } |
| 2141 | 2101 |
| 2102 |
| 2103 void Logger::SamplerThread::JitCodeEventHandler(const v8::JitCodeEvent* event) { |
| 2104 switch (event->type) { |
| 2105 case v8::JitCodeEvent::CODE_ADDED: |
| 2106 Isolate::Current()->logger()->CodeCreateEvent(event); |
| 2107 break; |
| 2108 |
| 2109 case v8::JitCodeEvent::CODE_MOVED: |
| 2110 Isolate::Current()->logger()->CodeMoveEvent(event); |
| 2111 break; |
| 2112 |
| 2113 case v8::JitCodeEvent::CODE_REMOVED: |
| 2114 Isolate::Current()->logger()->CodeDeleteEvent(event); |
| 2115 break; |
| 2116 |
| 2117 default: |
| 2118 break; |
| 2119 } |
| 2120 } |
| 2121 |
| 2122 |
| 2123 Logger::SamplerThread::SamplerThread(v8::Isolate* isolate) |
| 2124 : Thread(Thread::Options("d8:sampler")), |
| 2125 isolate_(isolate), |
| 2126 done_sampling_(false) { |
| 2127 reinterpret_cast<Isolate*>(isolate)->logger()->SetCodeEventHandler( |
| 2128 v8::kJitCodeEventDefault, |
| 2129 Logger::SamplerThread::JitCodeEventHandler); |
| 2130 Start(); |
| 2131 } |
| 2132 |
| 2133 |
| 2134 void Logger::SamplerThread::Run() { |
| 2135 Sample sample; |
| 2136 while (!done_sampling_) { |
| 2137 v8::base::OS::Sleep(1); |
| 2138 isolate_->GetSample(&sample); |
| 2139 if (sample.frames_count != 0) { |
| 2140 reinterpret_cast<Isolate*>(isolate_)->logger()->LogSample(&sample); |
| 2141 } |
| 2142 } |
| 2143 } |
| 2144 |
| 2145 |
| 2146 Logger::SamplerThread::~SamplerThread() { |
| 2147 done_sampling_ = true; |
| 2148 Join(); |
| 2149 } |
| 2150 |
| 2142 } } // namespace v8::internal | 2151 } } // namespace v8::internal |
| OLD | NEW |