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