OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1023 matching lines...) Loading... |
1034 va_end(ap); | 1034 va_end(ap); |
1035 msg.WriteToLogFile(); | 1035 msg.WriteToLogFile(); |
1036 } | 1036 } |
1037 | 1037 |
1038 | 1038 |
1039 void Logger::ApiNamedSecurityCheck(Object* key) { | 1039 void Logger::ApiNamedSecurityCheck(Object* key) { |
1040 if (!log_->IsEnabled() || !FLAG_log_api) return; | 1040 if (!log_->IsEnabled() || !FLAG_log_api) return; |
1041 if (key->IsString()) { | 1041 if (key->IsString()) { |
1042 SmartArrayPointer<char> str = | 1042 SmartArrayPointer<char> str = |
1043 String::cast(key)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1043 String::cast(key)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1044 ApiEvent("api,check-security,\"%s\"\n", *str); | 1044 ApiEvent("api,check-security,\"%s\"\n", str.get()); |
1045 } else if (key->IsSymbol()) { | 1045 } else if (key->IsSymbol()) { |
1046 Symbol* symbol = Symbol::cast(key); | 1046 Symbol* symbol = Symbol::cast(key); |
1047 if (symbol->name()->IsUndefined()) { | 1047 if (symbol->name()->IsUndefined()) { |
1048 ApiEvent("api,check-security,symbol(hash %x)\n", | 1048 ApiEvent("api,check-security,symbol(hash %x)\n", |
1049 Symbol::cast(key)->Hash()); | 1049 Symbol::cast(key)->Hash()); |
1050 } else { | 1050 } else { |
1051 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString( | 1051 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString( |
1052 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1052 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1053 ApiEvent("api,check-security,symbol(\"%s\" hash %x)\n", | 1053 ApiEvent("api,check-security,symbol(\"%s\" hash %x)\n", |
1054 *str, | 1054 str.get(), |
1055 Symbol::cast(key)->Hash()); | 1055 Symbol::cast(key)->Hash()); |
1056 } | 1056 } |
1057 } else if (key->IsUndefined()) { | 1057 } else if (key->IsUndefined()) { |
1058 ApiEvent("api,check-security,undefined\n"); | 1058 ApiEvent("api,check-security,undefined\n"); |
1059 } else { | 1059 } else { |
1060 ApiEvent("api,check-security,['no-name']\n"); | 1060 ApiEvent("api,check-security,['no-name']\n"); |
1061 } | 1061 } |
1062 } | 1062 } |
1063 | 1063 |
1064 | 1064 |
(...skipping 181 matching lines...) Loading... |
1246 JSObject* holder, | 1246 JSObject* holder, |
1247 Object* name) { | 1247 Object* name) { |
1248 ASSERT(name->IsName()); | 1248 ASSERT(name->IsName()); |
1249 if (!log_->IsEnabled() || !FLAG_log_api) return; | 1249 if (!log_->IsEnabled() || !FLAG_log_api) return; |
1250 String* class_name_obj = holder->class_name(); | 1250 String* class_name_obj = holder->class_name(); |
1251 SmartArrayPointer<char> class_name = | 1251 SmartArrayPointer<char> class_name = |
1252 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1252 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1253 if (name->IsString()) { | 1253 if (name->IsString()) { |
1254 SmartArrayPointer<char> property_name = | 1254 SmartArrayPointer<char> property_name = |
1255 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1255 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1256 ApiEvent("api,%s,\"%s\",\"%s\"\n", tag, *class_name, *property_name); | 1256 ApiEvent("api,%s,\"%s\",\"%s\"\n", tag, class_name.get(), |
| 1257 property_name.get()); |
1257 } else { | 1258 } else { |
1258 Symbol* symbol = Symbol::cast(name); | 1259 Symbol* symbol = Symbol::cast(name); |
1259 uint32_t hash = symbol->Hash(); | 1260 uint32_t hash = symbol->Hash(); |
1260 if (symbol->name()->IsUndefined()) { | 1261 if (symbol->name()->IsUndefined()) { |
1261 ApiEvent("api,%s,\"%s\",symbol(hash %x)\n", tag, *class_name, hash); | 1262 ApiEvent("api,%s,\"%s\",symbol(hash %x)\n", tag, class_name.get(), hash); |
1262 } else { | 1263 } else { |
1263 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString( | 1264 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString( |
1264 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1265 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1265 ApiEvent("api,%s,\"%s\",symbol(\"%s\" hash %x)\n", | 1266 ApiEvent("api,%s,\"%s\",symbol(\"%s\" hash %x)\n", |
1266 tag, *class_name, *str, hash); | 1267 tag, class_name.get(), str.get(), hash); |
1267 } | 1268 } |
1268 } | 1269 } |
1269 } | 1270 } |
1270 | 1271 |
1271 void Logger::ApiIndexedPropertyAccess(const char* tag, | 1272 void Logger::ApiIndexedPropertyAccess(const char* tag, |
1272 JSObject* holder, | 1273 JSObject* holder, |
1273 uint32_t index) { | 1274 uint32_t index) { |
1274 if (!log_->IsEnabled() || !FLAG_log_api) return; | 1275 if (!log_->IsEnabled() || !FLAG_log_api) return; |
1275 String* class_name_obj = holder->class_name(); | 1276 String* class_name_obj = holder->class_name(); |
1276 SmartArrayPointer<char> class_name = | 1277 SmartArrayPointer<char> class_name = |
1277 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1278 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1278 ApiEvent("api,%s,\"%s\",%u\n", tag, *class_name, index); | 1279 ApiEvent("api,%s,\"%s\",%u\n", tag, class_name.get(), index); |
1279 } | 1280 } |
1280 | 1281 |
1281 | 1282 |
1282 void Logger::ApiObjectAccess(const char* tag, JSObject* object) { | 1283 void Logger::ApiObjectAccess(const char* tag, JSObject* object) { |
1283 if (!log_->IsEnabled() || !FLAG_log_api) return; | 1284 if (!log_->IsEnabled() || !FLAG_log_api) return; |
1284 String* class_name_obj = object->class_name(); | 1285 String* class_name_obj = object->class_name(); |
1285 SmartArrayPointer<char> class_name = | 1286 SmartArrayPointer<char> class_name = |
1286 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1287 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1287 ApiEvent("api,%s,\"%s\"\n", tag, *class_name); | 1288 ApiEvent("api,%s,\"%s\"\n", tag, class_name.get()); |
1288 } | 1289 } |
1289 | 1290 |
1290 | 1291 |
1291 void Logger::ApiEntryCall(const char* name) { | 1292 void Logger::ApiEntryCall(const char* name) { |
1292 if (!log_->IsEnabled() || !FLAG_log_api) return; | 1293 if (!log_->IsEnabled() || !FLAG_log_api) return; |
1293 ApiEvent("api,%s\n", name); | 1294 ApiEvent("api,%s\n", name); |
1294 } | 1295 } |
1295 | 1296 |
1296 | 1297 |
1297 void Logger::NewEvent(const char* name, void* object, size_t size) { | 1298 void Logger::NewEvent(const char* name, void* object, size_t size) { |
(...skipping 27 matching lines...) Loading... |
1325 Address entry_point) { | 1326 Address entry_point) { |
1326 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1327 if (!FLAG_log_code || !log_->IsEnabled()) return; |
1327 Log::MessageBuilder msg(log_); | 1328 Log::MessageBuilder msg(log_); |
1328 msg.Append("%s,%s,-2,", | 1329 msg.Append("%s,%s,-2,", |
1329 kLogEventsNames[CODE_CREATION_EVENT], | 1330 kLogEventsNames[CODE_CREATION_EVENT], |
1330 kLogEventsNames[CALLBACK_TAG]); | 1331 kLogEventsNames[CALLBACK_TAG]); |
1331 msg.AppendAddress(entry_point); | 1332 msg.AppendAddress(entry_point); |
1332 if (name->IsString()) { | 1333 if (name->IsString()) { |
1333 SmartArrayPointer<char> str = | 1334 SmartArrayPointer<char> str = |
1334 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1335 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1335 msg.Append(",1,\"%s%s\"", prefix, *str); | 1336 msg.Append(",1,\"%s%s\"", prefix, str.get()); |
1336 } else { | 1337 } else { |
1337 Symbol* symbol = Symbol::cast(name); | 1338 Symbol* symbol = Symbol::cast(name); |
1338 if (symbol->name()->IsUndefined()) { | 1339 if (symbol->name()->IsUndefined()) { |
1339 msg.Append(",1,symbol(hash %x)", prefix, symbol->Hash()); | 1340 msg.Append(",1,symbol(hash %x)", prefix, symbol->Hash()); |
1340 } else { | 1341 } else { |
1341 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString( | 1342 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString( |
1342 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1343 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1343 msg.Append(",1,symbol(\"%s\" hash %x)", prefix, *str, symbol->Hash()); | 1344 msg.Append(",1,symbol(\"%s\" hash %x)", prefix, str.get(), |
| 1345 symbol->Hash()); |
1344 } | 1346 } |
1345 } | 1347 } |
1346 msg.Append('\n'); | 1348 msg.Append('\n'); |
1347 msg.WriteToLogFile(); | 1349 msg.WriteToLogFile(); |
1348 } | 1350 } |
1349 | 1351 |
1350 | 1352 |
1351 void Logger::CallbackEvent(Name* name, Address entry_point) { | 1353 void Logger::CallbackEvent(Name* name, Address entry_point) { |
1352 PROFILER_LOG(CallbackEvent(name, entry_point)); | 1354 PROFILER_LOG(CallbackEvent(name, entry_point)); |
1353 CallbackEventInternal("", name, entry_point); | 1355 CallbackEventInternal("", name, entry_point); |
(...skipping 78 matching lines...) Loading... |
1432 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1434 if (!FLAG_log_code || !log_->IsEnabled()) return; |
1433 if (code == isolate_->builtins()->builtin( | 1435 if (code == isolate_->builtins()->builtin( |
1434 Builtins::kLazyCompile)) | 1436 Builtins::kLazyCompile)) |
1435 return; | 1437 return; |
1436 | 1438 |
1437 Log::MessageBuilder msg(log_); | 1439 Log::MessageBuilder msg(log_); |
1438 AppendCodeCreateHeader(&msg, tag, code); | 1440 AppendCodeCreateHeader(&msg, tag, code); |
1439 if (name->IsString()) { | 1441 if (name->IsString()) { |
1440 SmartArrayPointer<char> str = | 1442 SmartArrayPointer<char> str = |
1441 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1443 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1442 msg.Append("\"%s\"", *str); | 1444 msg.Append("\"%s\"", str.get()); |
1443 } else { | 1445 } else { |
1444 msg.AppendSymbolName(Symbol::cast(name)); | 1446 msg.AppendSymbolName(Symbol::cast(name)); |
1445 } | 1447 } |
1446 msg.Append(','); | 1448 msg.Append(','); |
1447 msg.AppendAddress(shared->address()); | 1449 msg.AppendAddress(shared->address()); |
1448 msg.Append(",%s", ComputeMarker(code)); | 1450 msg.Append(",%s", ComputeMarker(code)); |
1449 msg.Append('\n'); | 1451 msg.Append('\n'); |
1450 msg.WriteToLogFile(); | 1452 msg.WriteToLogFile(); |
1451 } | 1453 } |
1452 | 1454 |
(...skipping 10 matching lines...) Loading... |
1463 | 1465 |
1464 if (!is_logging_code_events()) return; | 1466 if (!is_logging_code_events()) return; |
1465 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, source, line, | 1467 CALL_LISTENERS(CodeCreateEvent(tag, code, shared, info, source, line, |
1466 column)); | 1468 column)); |
1467 | 1469 |
1468 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1470 if (!FLAG_log_code || !log_->IsEnabled()) return; |
1469 Log::MessageBuilder msg(log_); | 1471 Log::MessageBuilder msg(log_); |
1470 AppendCodeCreateHeader(&msg, tag, code); | 1472 AppendCodeCreateHeader(&msg, tag, code); |
1471 SmartArrayPointer<char> name = | 1473 SmartArrayPointer<char> name = |
1472 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1474 shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1473 msg.Append("\"%s ", *name); | 1475 msg.Append("\"%s ", name.get()); |
1474 if (source->IsString()) { | 1476 if (source->IsString()) { |
1475 SmartArrayPointer<char> sourcestr = | 1477 SmartArrayPointer<char> sourcestr = |
1476 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1478 String::cast(source)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1477 msg.Append("%s", *sourcestr); | 1479 msg.Append("%s", sourcestr.get()); |
1478 } else { | 1480 } else { |
1479 msg.AppendSymbolName(Symbol::cast(source)); | 1481 msg.AppendSymbolName(Symbol::cast(source)); |
1480 } | 1482 } |
1481 msg.Append(":%d:%d\",", line, column); | 1483 msg.Append(":%d:%d\",", line, column); |
1482 msg.AppendAddress(shared->address()); | 1484 msg.AppendAddress(shared->address()); |
1483 msg.Append(",%s", ComputeMarker(code)); | 1485 msg.Append(",%s", ComputeMarker(code)); |
1484 msg.Append('\n'); | 1486 msg.Append('\n'); |
1485 msg.WriteToLogFile(); | 1487 msg.WriteToLogFile(); |
1486 } | 1488 } |
1487 | 1489 |
(...skipping 569 matching lines...) Loading... |
2057 if (is_initialized_) return true; | 2059 if (is_initialized_) return true; |
2058 is_initialized_ = true; | 2060 is_initialized_ = true; |
2059 | 2061 |
2060 // --ll-prof implies --log-code and --log-snapshot-positions. | 2062 // --ll-prof implies --log-code and --log-snapshot-positions. |
2061 if (FLAG_ll_prof) { | 2063 if (FLAG_ll_prof) { |
2062 FLAG_log_snapshot_positions = true; | 2064 FLAG_log_snapshot_positions = true; |
2063 } | 2065 } |
2064 | 2066 |
2065 SmartArrayPointer<const char> log_file_name = | 2067 SmartArrayPointer<const char> log_file_name = |
2066 PrepareLogFileName(isolate, FLAG_logfile); | 2068 PrepareLogFileName(isolate, FLAG_logfile); |
2067 log_->Initialize(*log_file_name); | 2069 log_->Initialize(log_file_name.get()); |
2068 | 2070 |
2069 | 2071 |
2070 if (FLAG_perf_basic_prof) { | 2072 if (FLAG_perf_basic_prof) { |
2071 perf_basic_logger_ = new PerfBasicLogger(); | 2073 perf_basic_logger_ = new PerfBasicLogger(); |
2072 addCodeEventListener(perf_basic_logger_); | 2074 addCodeEventListener(perf_basic_logger_); |
2073 } | 2075 } |
2074 | 2076 |
2075 if (FLAG_perf_jit_prof) { | 2077 if (FLAG_perf_jit_prof) { |
2076 perf_jit_logger_ = new PerfJitLogger(); | 2078 perf_jit_logger_ = new PerfJitLogger(); |
2077 addCodeEventListener(perf_jit_logger_); | 2079 addCodeEventListener(perf_jit_logger_); |
2078 } | 2080 } |
2079 | 2081 |
2080 if (FLAG_ll_prof) { | 2082 if (FLAG_ll_prof) { |
2081 ll_logger_ = new LowLevelLogger(*log_file_name); | 2083 ll_logger_ = new LowLevelLogger(log_file_name.get()); |
2082 addCodeEventListener(ll_logger_); | 2084 addCodeEventListener(ll_logger_); |
2083 } | 2085 } |
2084 | 2086 |
2085 ticker_ = new Ticker(isolate, kSamplingIntervalMs); | 2087 ticker_ = new Ticker(isolate, kSamplingIntervalMs); |
2086 | 2088 |
2087 if (Log::InitLogAtStart()) { | 2089 if (Log::InitLogAtStart()) { |
2088 is_logging_ = true; | 2090 is_logging_ = true; |
2089 } | 2091 } |
2090 | 2092 |
2091 if (FLAG_prof) { | 2093 if (FLAG_prof) { |
(...skipping 68 matching lines...) Loading... |
2160 if (jit_logger_) { | 2162 if (jit_logger_) { |
2161 removeCodeEventListener(jit_logger_); | 2163 removeCodeEventListener(jit_logger_); |
2162 delete jit_logger_; | 2164 delete jit_logger_; |
2163 jit_logger_ = NULL; | 2165 jit_logger_ = NULL; |
2164 } | 2166 } |
2165 | 2167 |
2166 return log_->Close(); | 2168 return log_->Close(); |
2167 } | 2169 } |
2168 | 2170 |
2169 } } // namespace v8::internal | 2171 } } // namespace v8::internal |
OLD | NEW |