OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // Terminate the worker thread by setting running_ to false, | 308 // Terminate the worker thread by setting running_ to false, |
309 // inserting a fake element in the queue and then wait for | 309 // inserting a fake element in the queue and then wait for |
310 // the thread to terminate. | 310 // the thread to terminate. |
311 running_ = false; | 311 running_ = false; |
312 TickSample sample; | 312 TickSample sample; |
313 // Reset 'paused_' flag, otherwise semaphore may not be signalled. | 313 // Reset 'paused_' flag, otherwise semaphore may not be signalled. |
314 resume(); | 314 resume(); |
315 Insert(&sample); | 315 Insert(&sample); |
316 Join(); | 316 Join(); |
317 | 317 |
318 LOG(UncheckedStringEvent("profiler", "end")); | 318 LOG(ISOLATE,UncheckedStringEvent("profiler", "end")); |
319 } | 319 } |
320 | 320 |
321 | 321 |
322 void Profiler::Run() { | 322 void Profiler::Run() { |
323 TickSample sample; | 323 TickSample sample; |
324 bool overflow = Remove(&sample); | 324 bool overflow = Remove(&sample); |
| 325 i::Isolate* isolate = ISOLATE; |
325 while (running_) { | 326 while (running_) { |
326 LOG(TickEvent(&sample, overflow)); | 327 LOG(isolate, TickEvent(&sample, overflow)); |
327 overflow = Remove(&sample); | 328 overflow = Remove(&sample); |
328 } | 329 } |
329 } | 330 } |
330 | 331 |
331 | 332 |
332 // | 333 // |
333 // Logger class implementation. | 334 // Logger class implementation. |
334 // | 335 // |
335 | 336 |
336 Logger::Logger() | 337 Logger::Logger() |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) { | 1163 if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) { |
1163 // It is OK to have negative nesting. | 1164 // It is OK to have negative nesting. |
1164 if (--cpu_profiler_nesting_ == 0) { | 1165 if (--cpu_profiler_nesting_ == 0) { |
1165 profiler_->pause(); | 1166 profiler_->pause(); |
1166 if (FLAG_prof_lazy) { | 1167 if (FLAG_prof_lazy) { |
1167 if (!FLAG_sliding_state_window && !RuntimeProfiler::IsEnabled()) { | 1168 if (!FLAG_sliding_state_window && !RuntimeProfiler::IsEnabled()) { |
1168 ticker_->Stop(); | 1169 ticker_->Stop(); |
1169 } | 1170 } |
1170 FLAG_log_code = false; | 1171 FLAG_log_code = false; |
1171 // Must be the same message as Log::kDynamicBufferSeal. | 1172 // Must be the same message as Log::kDynamicBufferSeal. |
1172 LOG(UncheckedStringEvent("profiler", "pause")); | 1173 LOG(ISOLATE, UncheckedStringEvent("profiler", "pause")); |
1173 } | 1174 } |
1174 --logging_nesting_; | 1175 --logging_nesting_; |
1175 } | 1176 } |
1176 } | 1177 } |
1177 if (flags & | 1178 if (flags & |
1178 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) { | 1179 (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) { |
1179 if (--heap_profiler_nesting_ == 0) { | 1180 if (--heap_profiler_nesting_ == 0) { |
1180 FLAG_log_gc = false; | 1181 FLAG_log_gc = false; |
1181 --logging_nesting_; | 1182 --logging_nesting_; |
1182 } | 1183 } |
1183 } | 1184 } |
1184 if (tag != 0) { | 1185 if (tag != 0) { |
1185 UncheckedIntEvent("close-tag", tag); | 1186 UncheckedIntEvent("close-tag", tag); |
1186 } | 1187 } |
1187 } | 1188 } |
1188 | 1189 |
1189 | 1190 |
1190 void Logger::ResumeProfiler(int flags, int tag) { | 1191 void Logger::ResumeProfiler(int flags, int tag) { |
1191 if (!log_->IsEnabled()) return; | 1192 if (!log_->IsEnabled()) return; |
1192 if (tag != 0) { | 1193 if (tag != 0) { |
1193 UncheckedIntEvent("open-tag", tag); | 1194 UncheckedIntEvent("open-tag", tag); |
1194 } | 1195 } |
1195 if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) { | 1196 if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) { |
1196 if (cpu_profiler_nesting_++ == 0) { | 1197 if (cpu_profiler_nesting_++ == 0) { |
1197 ++logging_nesting_; | 1198 ++logging_nesting_; |
1198 if (FLAG_prof_lazy) { | 1199 if (FLAG_prof_lazy) { |
1199 profiler_->Engage(); | 1200 profiler_->Engage(); |
1200 LOG(UncheckedStringEvent("profiler", "resume")); | 1201 LOG(ISOLATE, UncheckedStringEvent("profiler", "resume")); |
1201 FLAG_log_code = true; | 1202 FLAG_log_code = true; |
1202 LogCompiledFunctions(); | 1203 LogCompiledFunctions(); |
1203 LogAccessorCallbacks(); | 1204 LogAccessorCallbacks(); |
1204 if (!FLAG_sliding_state_window && !ticker_->IsActive()) { | 1205 if (!FLAG_sliding_state_window && !ticker_->IsActive()) { |
1205 ticker_->Start(); | 1206 ticker_->Start(); |
1206 } | 1207 } |
1207 } | 1208 } |
1208 profiler_->resume(); | 1209 profiler_->resume(); |
1209 } | 1210 } |
1210 } | 1211 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 break; | 1347 break; |
1347 case Code::CALL_IC: | 1348 case Code::CALL_IC: |
1348 description = "A call IC from the snapshot"; | 1349 description = "A call IC from the snapshot"; |
1349 tag = Logger::CALL_IC_TAG; | 1350 tag = Logger::CALL_IC_TAG; |
1350 break; | 1351 break; |
1351 case Code::KEYED_CALL_IC: | 1352 case Code::KEYED_CALL_IC: |
1352 description = "A keyed call IC from the snapshot"; | 1353 description = "A keyed call IC from the snapshot"; |
1353 tag = Logger::KEYED_CALL_IC_TAG; | 1354 tag = Logger::KEYED_CALL_IC_TAG; |
1354 break; | 1355 break; |
1355 } | 1356 } |
1356 PROFILE(CodeCreateEvent(tag, code_object, description)); | 1357 PROFILE(ISOLATE, CodeCreateEvent(tag, code_object, description)); |
1357 } | 1358 } |
1358 } | 1359 } |
1359 | 1360 |
1360 | 1361 |
1361 void Logger::LogCodeInfo() { | 1362 void Logger::LogCodeInfo() { |
1362 #ifdef ENABLE_LOGGING_AND_PROFILING | 1363 #ifdef ENABLE_LOGGING_AND_PROFILING |
1363 if (!log_->IsEnabled() || !FLAG_log_code || !FLAG_ll_prof) return; | 1364 if (!log_->IsEnabled() || !FLAG_log_code || !FLAG_ll_prof) return; |
1364 #if V8_TARGET_ARCH_IA32 | 1365 #if V8_TARGET_ARCH_IA32 |
1365 const char arch[] = "ia32"; | 1366 const char arch[] = "ia32"; |
1366 #elif V8_TARGET_ARCH_X64 | 1367 #elif V8_TARGET_ARCH_X64 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 Builtins::LazyCompile)) | 1412 Builtins::LazyCompile)) |
1412 continue; | 1413 continue; |
1413 Handle<SharedFunctionInfo> shared = sfis[i]; | 1414 Handle<SharedFunctionInfo> shared = sfis[i]; |
1414 Handle<String> func_name(shared->DebugName()); | 1415 Handle<String> func_name(shared->DebugName()); |
1415 if (shared->script()->IsScript()) { | 1416 if (shared->script()->IsScript()) { |
1416 Handle<Script> script(Script::cast(shared->script())); | 1417 Handle<Script> script(Script::cast(shared->script())); |
1417 if (script->name()->IsString()) { | 1418 if (script->name()->IsString()) { |
1418 Handle<String> script_name(String::cast(script->name())); | 1419 Handle<String> script_name(String::cast(script->name())); |
1419 int line_num = GetScriptLineNumber(script, shared->start_position()); | 1420 int line_num = GetScriptLineNumber(script, shared->start_position()); |
1420 if (line_num > 0) { | 1421 if (line_num > 0) { |
1421 PROFILE(CodeCreateEvent( | 1422 PROFILE(ISOLATE, |
1422 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | 1423 CodeCreateEvent( |
1423 *code_objects[i], *shared, | 1424 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), |
1424 *script_name, line_num + 1)); | 1425 *code_objects[i], *shared, |
| 1426 *script_name, line_num + 1)); |
1425 } else { | 1427 } else { |
1426 // Can't distinguish eval and script here, so always use Script. | 1428 // Can't distinguish eval and script here, so always use Script. |
1427 PROFILE(CodeCreateEvent( | 1429 PROFILE(ISOLATE, |
1428 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), | 1430 CodeCreateEvent( |
1429 *code_objects[i], *shared, *script_name)); | 1431 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
| 1432 *code_objects[i], *shared, *script_name)); |
1430 } | 1433 } |
1431 } else { | 1434 } else { |
1432 PROFILE(CodeCreateEvent( | 1435 PROFILE(ISOLATE, |
1433 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | 1436 CodeCreateEvent( |
1434 *code_objects[i], *shared, *func_name)); | 1437 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), |
| 1438 *code_objects[i], *shared, *func_name)); |
1435 } | 1439 } |
1436 } else if (shared->IsApiFunction()) { | 1440 } else if (shared->IsApiFunction()) { |
1437 // API function. | 1441 // API function. |
1438 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); | 1442 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); |
1439 Object* raw_call_data = fun_data->call_code(); | 1443 Object* raw_call_data = fun_data->call_code(); |
1440 if (!raw_call_data->IsUndefined()) { | 1444 if (!raw_call_data->IsUndefined()) { |
1441 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | 1445 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); |
1442 Object* callback_obj = call_data->callback(); | 1446 Object* callback_obj = call_data->callback(); |
1443 Address entry_point = v8::ToCData<Address>(callback_obj); | 1447 Address entry_point = v8::ToCData<Address>(callback_obj); |
1444 PROFILE(CallbackEvent(*func_name, entry_point)); | 1448 PROFILE(ISOLATE, CallbackEvent(*func_name, entry_point)); |
1445 } | 1449 } |
1446 } else { | 1450 } else { |
1447 PROFILE(CodeCreateEvent( | 1451 PROFILE(ISOLATE, |
1448 Logger::LAZY_COMPILE_TAG, *code_objects[i], *shared, *func_name)); | 1452 CodeCreateEvent( |
| 1453 Logger::LAZY_COMPILE_TAG, *code_objects[i], |
| 1454 *shared, *func_name)); |
1449 } | 1455 } |
1450 } | 1456 } |
1451 } | 1457 } |
1452 | 1458 |
1453 | 1459 |
1454 void Logger::LogAccessorCallbacks() { | 1460 void Logger::LogAccessorCallbacks() { |
1455 AssertNoAllocation no_alloc; | 1461 AssertNoAllocation no_alloc; |
1456 HeapIterator iterator; | 1462 HeapIterator iterator; |
| 1463 i::Isolate* isolate = ISOLATE; |
1457 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1464 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
1458 if (!obj->IsAccessorInfo()) continue; | 1465 if (!obj->IsAccessorInfo()) continue; |
1459 AccessorInfo* ai = AccessorInfo::cast(obj); | 1466 AccessorInfo* ai = AccessorInfo::cast(obj); |
1460 if (!ai->name()->IsString()) continue; | 1467 if (!ai->name()->IsString()) continue; |
1461 String* name = String::cast(ai->name()); | 1468 String* name = String::cast(ai->name()); |
1462 Address getter_entry = v8::ToCData<Address>(ai->getter()); | 1469 Address getter_entry = v8::ToCData<Address>(ai->getter()); |
1463 if (getter_entry != 0) { | 1470 if (getter_entry != 0) { |
1464 PROFILE(GetterCallbackEvent(name, getter_entry)); | 1471 PROFILE(isolate, GetterCallbackEvent(name, getter_entry)); |
1465 } | 1472 } |
1466 Address setter_entry = v8::ToCData<Address>(ai->setter()); | 1473 Address setter_entry = v8::ToCData<Address>(ai->setter()); |
1467 if (setter_entry != 0) { | 1474 if (setter_entry != 0) { |
1468 PROFILE(SetterCallbackEvent(name, setter_entry)); | 1475 PROFILE(isolate, SetterCallbackEvent(name, setter_entry)); |
1469 } | 1476 } |
1470 } | 1477 } |
1471 } | 1478 } |
1472 | 1479 |
1473 #endif | 1480 #endif |
1474 | 1481 |
1475 | 1482 |
1476 bool Logger::Setup() { | 1483 bool Logger::Setup() { |
1477 #ifdef ENABLE_LOGGING_AND_PROFILING | 1484 #ifdef ENABLE_LOGGING_AND_PROFILING |
1478 // Tests and EnsureInitialize() can call this twice in a row. It's harmless. | 1485 // Tests and EnsureInitialize() can call this twice in a row. It's harmless. |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { | 1647 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { |
1641 ASSERT(sampler->IsActive()); | 1648 ASSERT(sampler->IsActive()); |
1642 ScopedLock lock(mutex_); | 1649 ScopedLock lock(mutex_); |
1643 ASSERT(active_samplers_ != NULL); | 1650 ASSERT(active_samplers_ != NULL); |
1644 bool removed = active_samplers_->RemoveElement(sampler); | 1651 bool removed = active_samplers_->RemoveElement(sampler); |
1645 ASSERT(removed); | 1652 ASSERT(removed); |
1646 USE(removed); | 1653 USE(removed); |
1647 } | 1654 } |
1648 | 1655 |
1649 } } // namespace v8::internal | 1656 } } // namespace v8::internal |
OLD | NEW |