Chromium Code Reviews| 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 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1056 ApiEvent("api,check-security,undefined\n"); | 1056 ApiEvent("api,check-security,undefined\n"); |
| 1057 } else { | 1057 } else { |
| 1058 ApiEvent("api,check-security,['no-name']\n"); | 1058 ApiEvent("api,check-security,['no-name']\n"); |
| 1059 } | 1059 } |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 | 1062 |
| 1063 void Logger::SharedLibraryEvent(const std::string& library_path, | 1063 void Logger::SharedLibraryEvent(const std::string& library_path, |
| 1064 uintptr_t start, | 1064 uintptr_t start, |
| 1065 uintptr_t end) { | 1065 uintptr_t end) { |
| 1066 codeEventHandler()->SharedLibrary(library_path, | |
| 1067 (const void*)start, | |
| 1068 (const void*)end); | |
| 1066 if (!log_->IsEnabled() || !FLAG_prof) return; | 1069 if (!log_->IsEnabled() || !FLAG_prof) return; |
| 1067 Log::MessageBuilder msg(log_); | 1070 Log::MessageBuilder msg(log_); |
| 1068 msg.Append("shared-library,\"%s\",0x%08" V8PRIxPTR ",0x%08" V8PRIxPTR "\n", | 1071 msg.Append("shared-library,\"%s\",0x%08" V8PRIxPTR ",0x%08" V8PRIxPTR "\n", |
| 1069 library_path.c_str(), | 1072 library_path.c_str(), |
| 1070 start, | 1073 start, |
| 1071 end); | 1074 end); |
| 1072 msg.WriteToLogFile(); | 1075 msg.WriteToLogFile(); |
| 1073 } | 1076 } |
| 1074 | 1077 |
| 1075 | 1078 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1346 Code* code, | 1349 Code* code, |
| 1347 const char* comment) { | 1350 const char* comment) { |
| 1348 PROFILER_LOG(CodeCreateEvent(tag, code, comment)); | 1351 PROFILER_LOG(CodeCreateEvent(tag, code, comment)); |
| 1349 | 1352 |
| 1350 if (!is_logging_code_events()) return; | 1353 if (!is_logging_code_events()) return; |
| 1351 CALL_LISTENERS(CodeCreateEvent(tag, code, comment)); | 1354 CALL_LISTENERS(CodeCreateEvent(tag, code, comment)); |
| 1352 | 1355 |
| 1353 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1356 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1354 Log::MessageBuilder msg(log_); | 1357 Log::MessageBuilder msg(log_); |
| 1355 AppendCodeCreateHeader(&msg, tag, code); | 1358 AppendCodeCreateHeader(&msg, tag, code); |
| 1359 msg.StartSubstring(); | |
| 1356 msg.AppendDoubleQuotedString(comment); | 1360 msg.AppendDoubleQuotedString(comment); |
| 1361 msg.EndSubstring(); | |
| 1357 msg.Append('\n'); | 1362 msg.Append('\n'); |
| 1358 msg.WriteToLogFile(); | 1363 msg.WriteToLogFile(); |
| 1364 std::string code_name; | |
| 1365 msg.GetSubstring(&code_name); | |
| 1366 codeEventHandler()->Create((const void*)code->address(), | |
|
Jarin
2014/08/26 08:23:57
If you are interested in the address of actual cod
| |
| 1367 (const int)code->ExecutableSize(), | |
| 1368 code_name); | |
| 1359 } | 1369 } |
| 1360 | 1370 |
| 1361 | 1371 |
| 1362 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1372 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1363 Code* code, | 1373 Code* code, |
| 1364 Name* name) { | 1374 Name* name) { |
| 1365 PROFILER_LOG(CodeCreateEvent(tag, code, name)); | 1375 PROFILER_LOG(CodeCreateEvent(tag, code, name)); |
| 1366 | 1376 |
| 1367 if (!is_logging_code_events()) return; | 1377 if (!is_logging_code_events()) return; |
| 1368 CALL_LISTENERS(CodeCreateEvent(tag, code, name)); | 1378 CALL_LISTENERS(CodeCreateEvent(tag, code, name)); |
| 1369 | 1379 |
| 1370 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1380 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1371 Log::MessageBuilder msg(log_); | 1381 Log::MessageBuilder msg(log_); |
| 1372 AppendCodeCreateHeader(&msg, tag, code); | 1382 AppendCodeCreateHeader(&msg, tag, code); |
| 1383 msg.StartSubstring(); | |
| 1373 if (name->IsString()) { | 1384 if (name->IsString()) { |
| 1374 msg.Append('"'); | 1385 msg.Append('"'); |
| 1375 msg.AppendDetailed(String::cast(name), false); | 1386 msg.AppendDetailed(String::cast(name), false); |
| 1376 msg.Append('"'); | 1387 msg.Append('"'); |
| 1377 } else { | 1388 } else { |
| 1378 msg.AppendSymbolName(Symbol::cast(name)); | 1389 msg.AppendSymbolName(Symbol::cast(name)); |
| 1379 } | 1390 } |
| 1391 msg.EndSubstring(); | |
| 1380 msg.Append('\n'); | 1392 msg.Append('\n'); |
| 1381 msg.WriteToLogFile(); | 1393 msg.WriteToLogFile(); |
| 1394 std::string code_name; | |
| 1395 msg.GetSubstring(&code_name); | |
| 1396 codeEventHandler()->Create((const void*)code->address(), | |
| 1397 (const int)code->ExecutableSize(), | |
| 1398 code_name); | |
| 1382 } | 1399 } |
| 1383 | 1400 |
| 1384 | 1401 |
| 1385 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1402 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1386 Code* code, | 1403 Code* code, |
| 1387 SharedFunctionInfo* shared, | 1404 SharedFunctionInfo* shared, |
| 1388 CompilationInfo* info, | 1405 CompilationInfo* info, |
| 1389 Name* name) { | 1406 Name* name) { |
| 1390 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, name)); | 1407 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, name)); |
| 1391 | 1408 |
| 1392 if (!is_logging_code_events()) return; | 1409 if (!is_logging_code_events()) return; |
| 1393 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, name)); | 1410 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, name)); |
| 1394 | 1411 |
| 1395 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1412 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1396 if (code == isolate_->builtins()->builtin(Builtins::kCompileUnoptimized)) | 1413 if (code == isolate_->builtins()->builtin(Builtins::kCompileUnoptimized)) |
| 1397 return; | 1414 return; |
| 1398 | 1415 |
| 1399 Log::MessageBuilder msg(log_); | 1416 Log::MessageBuilder msg(log_); |
| 1400 AppendCodeCreateHeader(&msg, tag, code); | 1417 AppendCodeCreateHeader(&msg, tag, code); |
| 1418 msg.StartSubstring(); | |
| 1401 if (name->IsString()) { | 1419 if (name->IsString()) { |
| 1402 SmartArrayPointer<char> str = | 1420 SmartArrayPointer<char> str = |
| 1403 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1421 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 1404 msg.Append("\"%s\"", str.get()); | 1422 msg.Append("\"%s\"", str.get()); |
| 1405 } else { | 1423 } else { |
| 1406 msg.AppendSymbolName(Symbol::cast(name)); | 1424 msg.AppendSymbolName(Symbol::cast(name)); |
| 1407 } | 1425 } |
| 1426 msg.EndSubstring(); | |
| 1408 msg.Append(','); | 1427 msg.Append(','); |
| 1409 msg.AppendAddress(shared->address()); | 1428 msg.AppendAddress(shared->address()); |
| 1410 msg.Append(",%s", ComputeMarker(code)); | 1429 msg.Append(",%s", ComputeMarker(code)); |
| 1411 msg.Append('\n'); | 1430 msg.Append('\n'); |
| 1412 msg.WriteToLogFile(); | 1431 msg.WriteToLogFile(); |
| 1432 std::string code_name; | |
| 1433 msg.GetSubstring(&code_name); | |
| 1434 codeEventHandler()->Create((const void*)code->address(), | |
| 1435 (const int)code->ExecutableSize(), | |
| 1436 code_name); | |
| 1413 } | 1437 } |
| 1414 | 1438 |
| 1415 | 1439 |
| 1416 // Although, it is possible to extract source and line from | 1440 // Although, it is possible to extract source and line from |
| 1417 // the SharedFunctionInfo object, we left it to caller | 1441 // the SharedFunctionInfo object, we left it to caller |
| 1418 // to leave logging functions free from heap allocations. | 1442 // to leave logging functions free from heap allocations. |
| 1419 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1443 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1420 Code* code, | 1444 Code* code, |
| 1421 SharedFunctionInfo* shared, | 1445 SharedFunctionInfo* shared, |
| 1422 CompilationInfo* info, | 1446 CompilationInfo* info, |
| 1423 Name* source, int line, int column) { | 1447 Name* source, int line, int column) { |
| 1424 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, source, line, column)); | 1448 PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, source, line, column)); |
| 1425 | 1449 |
| 1426 if (!is_logging_code_events()) return; | 1450 if (!is_logging_code_events()) return; |
| 1427 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, source, line, | 1451 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, source, line, |
| 1428 column)); | 1452 column)); |
| 1429 | 1453 |
| 1430 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1454 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1431 Log::MessageBuilder msg(log_); | 1455 Log::MessageBuilder msg(log_); |
| 1432 AppendCodeCreateHeader(&msg, tag, code); | 1456 AppendCodeCreateHeader(&msg, tag, code); |
| 1457 msg.StartSubstring(); | |
| 1433 SmartArrayPointer<char> name = | 1458 SmartArrayPointer<char> name = |
| 1434 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1459 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 1435 msg.Append("\"%s ", name.get()); | 1460 msg.Append("\"%s ", name.get()); |
| 1436 if (source->IsString()) { | 1461 if (source->IsString()) { |
| 1437 SmartArrayPointer<char> sourcestr = | 1462 SmartArrayPointer<char> sourcestr = |
| 1438 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1463 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 1439 msg.Append("%s", sourcestr.get()); | 1464 msg.Append("%s", sourcestr.get()); |
| 1440 } else { | 1465 } else { |
| 1441 msg.AppendSymbolName(Symbol::cast(source)); | 1466 msg.AppendSymbolName(Symbol::cast(source)); |
| 1442 } | 1467 } |
| 1443 msg.Append(":%d:%d\",", line, column); | 1468 msg.Append(":%d:%d\"", line, column); |
| 1469 msg.EndSubstring(); | |
| 1470 msg.Append(","); | |
| 1444 msg.AppendAddress(shared->address()); | 1471 msg.AppendAddress(shared->address()); |
| 1445 msg.Append(",%s", ComputeMarker(code)); | 1472 msg.Append(",%s", ComputeMarker(code)); |
| 1446 msg.Append('\n'); | 1473 msg.Append('\n'); |
| 1447 msg.WriteToLogFile(); | 1474 msg.WriteToLogFile(); |
| 1475 std::string code_name; | |
| 1476 msg.GetSubstring(&code_name); | |
| 1477 codeEventHandler()->Create((const void*)code->address(), | |
| 1478 (const int)code->ExecutableSize(), | |
| 1479 code_name); | |
| 1448 } | 1480 } |
| 1449 | 1481 |
| 1450 | 1482 |
| 1451 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1483 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1452 Code* code, | 1484 Code* code, |
| 1453 int args_count) { | 1485 int args_count) { |
| 1454 PROFILER_LOG(CodeCreateEvent(tag, code, args_count)); | 1486 PROFILER_LOG(CodeCreateEvent(tag, code, args_count)); |
| 1455 | 1487 |
| 1456 if (!is_logging_code_events()) return; | 1488 if (!is_logging_code_events()) return; |
| 1457 CALL_LISTENERS(CodeCreateEvent(tag, code, args_count)); | 1489 CALL_LISTENERS(CodeCreateEvent(tag, code, args_count)); |
| 1458 | 1490 |
| 1459 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1491 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1460 Log::MessageBuilder msg(log_); | 1492 Log::MessageBuilder msg(log_); |
| 1461 AppendCodeCreateHeader(&msg, tag, code); | 1493 AppendCodeCreateHeader(&msg, tag, code); |
| 1494 msg.StartSubstring(); | |
| 1462 msg.Append("\"args_count: %d\"", args_count); | 1495 msg.Append("\"args_count: %d\"", args_count); |
| 1496 msg.EndSubstring(); | |
| 1463 msg.Append('\n'); | 1497 msg.Append('\n'); |
| 1464 msg.WriteToLogFile(); | 1498 msg.WriteToLogFile(); |
| 1499 std::string code_name; | |
| 1500 msg.GetSubstring(&code_name); | |
| 1501 codeEventHandler()->Create((const void*)code->address(), | |
| 1502 (const int)code->ExecutableSize(), | |
| 1503 code_name); | |
| 1465 } | 1504 } |
| 1466 | 1505 |
| 1467 | 1506 |
| 1468 void Logger::CodeDisableOptEvent(Code* code, | 1507 void Logger::CodeDisableOptEvent(Code* code, |
| 1469 SharedFunctionInfo* shared) { | 1508 SharedFunctionInfo* shared) { |
| 1470 PROFILER_LOG(CodeDisableOptEvent(code, shared)); | 1509 PROFILER_LOG(CodeDisableOptEvent(code, shared)); |
| 1471 | 1510 |
| 1472 if (!is_logging_code_events()) return; | 1511 if (!is_logging_code_events()) return; |
| 1473 CALL_LISTENERS(CodeDisableOptEvent(code, shared)); | 1512 CALL_LISTENERS(CodeDisableOptEvent(code, shared)); |
| 1474 | 1513 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1495 | 1534 |
| 1496 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { | 1535 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { |
| 1497 PROFILER_LOG(RegExpCodeCreateEvent(code, source)); | 1536 PROFILER_LOG(RegExpCodeCreateEvent(code, source)); |
| 1498 | 1537 |
| 1499 if (!is_logging_code_events()) return; | 1538 if (!is_logging_code_events()) return; |
| 1500 CALL_LISTENERS(RegExpCodeCreateEvent(code, source)); | 1539 CALL_LISTENERS(RegExpCodeCreateEvent(code, source)); |
| 1501 | 1540 |
| 1502 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1541 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1503 Log::MessageBuilder msg(log_); | 1542 Log::MessageBuilder msg(log_); |
| 1504 AppendCodeCreateHeader(&msg, REG_EXP_TAG, code); | 1543 AppendCodeCreateHeader(&msg, REG_EXP_TAG, code); |
| 1544 msg.StartSubstring(); | |
| 1505 msg.Append('"'); | 1545 msg.Append('"'); |
| 1506 msg.AppendDetailed(source, false); | 1546 msg.AppendDetailed(source, false); |
| 1507 msg.Append('"'); | 1547 msg.Append('"'); |
| 1548 msg.EndSubstring(); | |
| 1508 msg.Append('\n'); | 1549 msg.Append('\n'); |
| 1509 msg.WriteToLogFile(); | 1550 msg.WriteToLogFile(); |
| 1551 std::string code_name; | |
| 1552 msg.GetSubstring(&code_name); | |
| 1553 codeEventHandler()->Create((const void*)code->address(), | |
| 1554 (const int)code->ExecutableSize(), | |
| 1555 code_name); | |
| 1510 } | 1556 } |
| 1511 | 1557 |
| 1512 | 1558 |
| 1513 void Logger::CodeMoveEvent(Address from, Address to) { | 1559 void Logger::CodeMoveEvent(Address from, Address to) { |
| 1514 PROFILER_LOG(CodeMoveEvent(from, to)); | 1560 PROFILER_LOG(CodeMoveEvent(from, to)); |
| 1515 | 1561 codeEventHandler()->Move((const void*)from, |
| 1562 (const void*)to); | |
| 1516 if (!is_logging_code_events()) return; | 1563 if (!is_logging_code_events()) return; |
| 1517 CALL_LISTENERS(CodeMoveEvent(from, to)); | 1564 CALL_LISTENERS(CodeMoveEvent(from, to)); |
| 1518 MoveEventInternal(CODE_MOVE_EVENT, from, to); | 1565 MoveEventInternal(CODE_MOVE_EVENT, from, to); |
| 1519 } | 1566 } |
| 1520 | 1567 |
| 1521 | 1568 |
| 1522 void Logger::CodeDeleteEvent(Address from) { | 1569 void Logger::CodeDeleteEvent(Address from) { |
| 1523 PROFILER_LOG(CodeDeleteEvent(from)); | 1570 PROFILER_LOG(CodeDeleteEvent(from)); |
| 1571 codeEventHandler()->Delete((const void*)from); | |
|
Jarin
2014/08/26 08:23:57
I think this is never called.
| |
| 1524 | 1572 |
| 1525 if (!is_logging_code_events()) return; | 1573 if (!is_logging_code_events()) return; |
| 1526 CALL_LISTENERS(CodeDeleteEvent(from)); | 1574 CALL_LISTENERS(CodeDeleteEvent(from)); |
| 1527 | 1575 |
| 1528 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1576 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1529 Log::MessageBuilder msg(log_); | 1577 Log::MessageBuilder msg(log_); |
| 1530 msg.Append("%s,", kLogEventsNames[CODE_DELETE_EVENT]); | 1578 msg.Append("%s,", kLogEventsNames[CODE_DELETE_EVENT]); |
| 1531 msg.AppendAddress(from); | 1579 msg.AppendAddress(from); |
| 1532 msg.Append('\n'); | 1580 msg.Append('\n'); |
| 1533 msg.WriteToLogFile(); | 1581 msg.WriteToLogFile(); |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2079 addCodeEventListener(jit_logger_); | 2127 addCodeEventListener(jit_logger_); |
| 2080 if (options & kJitCodeEventEnumExisting) { | 2128 if (options & kJitCodeEventEnumExisting) { |
| 2081 HandleScope scope(isolate_); | 2129 HandleScope scope(isolate_); |
| 2082 LogCodeObjects(); | 2130 LogCodeObjects(); |
| 2083 LogCompiledFunctions(); | 2131 LogCompiledFunctions(); |
| 2084 } | 2132 } |
| 2085 } | 2133 } |
| 2086 } | 2134 } |
| 2087 | 2135 |
| 2088 | 2136 |
| 2137 void Logger::SetCodeEventHandler(v8::CodeEventHandler* handler) { | |
| 2138 code_event_handler_ = handler; | |
| 2139 } | |
| 2140 | |
| 2141 | |
| 2089 Sampler* Logger::sampler() { | 2142 Sampler* Logger::sampler() { |
| 2090 return ticker_; | 2143 return ticker_; |
| 2091 } | 2144 } |
| 2092 | 2145 |
| 2093 | 2146 |
| 2147 CodeEventHandler* Logger::codeEventHandler() { | |
| 2148 if (code_event_handler_ == NULL) | |
| 2149 code_event_handler_ = new StubCodeEventHandler(); | |
| 2150 return code_event_handler_; | |
| 2151 } | |
| 2152 | |
| 2153 | |
| 2094 FILE* Logger::TearDown() { | 2154 FILE* Logger::TearDown() { |
| 2095 if (!is_initialized_) return NULL; | 2155 if (!is_initialized_) return NULL; |
| 2096 is_initialized_ = false; | 2156 is_initialized_ = false; |
| 2097 | 2157 |
| 2098 // Stop the profiler before closing the file. | 2158 // Stop the profiler before closing the file. |
| 2099 if (profiler_ != NULL) { | 2159 if (profiler_ != NULL) { |
| 2100 profiler_->Disengage(); | 2160 profiler_->Disengage(); |
| 2101 delete profiler_; | 2161 delete profiler_; |
| 2102 profiler_ = NULL; | 2162 profiler_ = NULL; |
| 2103 } | 2163 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 2126 if (jit_logger_) { | 2186 if (jit_logger_) { |
| 2127 removeCodeEventListener(jit_logger_); | 2187 removeCodeEventListener(jit_logger_); |
| 2128 delete jit_logger_; | 2188 delete jit_logger_; |
| 2129 jit_logger_ = NULL; | 2189 jit_logger_ = NULL; |
| 2130 } | 2190 } |
| 2131 | 2191 |
| 2132 return log_->Close(); | 2192 return log_->Close(); |
| 2133 } | 2193 } |
| 2134 | 2194 |
| 2135 } } // namespace v8::internal | 2195 } } // namespace v8::internal |
| OLD | NEW |