Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 } | 181 } |
| 182 | 182 |
| 183 | 183 |
| 184 bool ProfilerEventsProcessor::IsKnownFunction(Address start) { | 184 bool ProfilerEventsProcessor::IsKnownFunction(Address start) { |
| 185 HashMap::Entry* entry = | 185 HashMap::Entry* entry = |
| 186 known_functions_->Lookup(start, AddressHash(start), false); | 186 known_functions_->Lookup(start, AddressHash(start), false); |
| 187 return entry != NULL; | 187 return entry != NULL; |
| 188 } | 188 } |
| 189 | 189 |
| 190 | 190 |
| 191 void ProfilerEventsProcessor::RegisterMovedFunctions() { | |
| 192 for (int i = 0; i < moved_functions_.length(); ++i) { | |
| 193 JSFunction* function = moved_functions_[i]; | |
| 194 CpuProfiler::FunctionCreateEvent(function); | |
| 195 } | |
| 196 moved_functions_.Clear(); | |
| 197 } | |
| 198 | |
| 199 | |
| 200 void ProfilerEventsProcessor::RememberMovedFunction(JSFunction* function) { | |
| 201 moved_functions_.Add(function); | |
| 202 } | |
| 203 | |
| 204 | |
| 191 void ProfilerEventsProcessor::RegExpCodeCreateEvent( | 205 void ProfilerEventsProcessor::RegExpCodeCreateEvent( |
| 192 Logger::LogEventsAndTags tag, | 206 Logger::LogEventsAndTags tag, |
| 193 const char* prefix, | 207 const char* prefix, |
| 194 String* name, | 208 String* name, |
| 195 Address start, | 209 Address start, |
| 196 unsigned size) { | 210 unsigned size) { |
| 197 if (FilterOutCodeCreateEvent(tag)) return; | 211 if (FilterOutCodeCreateEvent(tag)) return; |
| 198 CodeEventsContainer evt_rec; | 212 CodeEventsContainer evt_rec; |
| 199 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 213 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
| 200 rec->type = CodeEventRecord::CODE_CREATION; | 214 rec->type = CodeEventRecord::CODE_CREATION; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 security_token_id = singleton_->token_enumerator_->GetTokenId( | 433 security_token_id = singleton_->token_enumerator_->GetTokenId( |
| 420 function->context()->global_context()->security_token()); | 434 function->context()->global_context()->security_token()); |
| 421 } | 435 } |
| 422 singleton_->processor_->FunctionCreateEvent( | 436 singleton_->processor_->FunctionCreateEvent( |
| 423 function->address(), | 437 function->address(), |
| 424 function->code()->address(), | 438 function->code()->address(), |
| 425 security_token_id); | 439 security_token_id); |
| 426 } | 440 } |
| 427 | 441 |
| 428 | 442 |
| 429 void CpuProfiler::FunctionCreateEventFromMove(JSFunction* function, | 443 void CpuProfiler::RegisterMovedFunctions() { |
|
Søren Thygesen Gjesse
2010/10/20 07:08:22
Register -> Process?
mnaganov (inactive)
2010/10/20 08:29:05
Done.
| |
| 430 HeapObject* source) { | 444 singleton_->processor_->RegisterMovedFunctions(); |
| 445 } | |
| 446 | |
| 447 | |
| 448 void CpuProfiler::FunctionCreateEventFromMove(JSFunction* function) { | |
| 431 // This function is called from GC iterators (during Scavenge, | 449 // This function is called from GC iterators (during Scavenge, |
| 432 // MC, and MS), so marking bits can be set on objects. That's | 450 // MC, and MS), so marking bits can be set on objects. That's |
| 433 // why unchecked accessors are used here. | 451 // why unchecked accessors are used here. |
| 434 | 452 |
| 435 // The same function can be reported several times. | 453 // The same function can be reported several times. |
| 436 if (function->unchecked_code() == Builtins::builtin(Builtins::LazyCompile) | 454 if (function->unchecked_code() == Builtins::builtin(Builtins::LazyCompile) |
| 437 || singleton_->processor_->IsKnownFunction(function->address())) return; | 455 || singleton_->processor_->IsKnownFunction(function->address())) return; |
| 438 | 456 |
| 439 int security_token_id = TokenEnumerator::kNoSecurityToken; | 457 singleton_->processor_->RememberMovedFunction(function); |
| 440 // In debug mode, assertions may fail for contexts, | |
| 441 // and we can live without security tokens in debug mode. | |
| 442 #ifndef DEBUG | |
| 443 if (function->unchecked_context()->IsContext()) { | |
| 444 security_token_id = singleton_->token_enumerator_->GetTokenId( | |
| 445 function->context()->global_context()->security_token()); | |
| 446 } | |
| 447 // Security token may not be moved yet. | |
| 448 if (security_token_id == TokenEnumerator::kNoSecurityToken) { | |
| 449 JSFunction* old_function = reinterpret_cast<JSFunction*>(source); | |
| 450 if (old_function->unchecked_context()->IsContext()) { | |
| 451 security_token_id = singleton_->token_enumerator_->GetTokenId( | |
| 452 old_function->context()->global_context()->security_token()); | |
| 453 } | |
| 454 } | |
| 455 #endif | |
| 456 singleton_->processor_->FunctionCreateEvent( | |
| 457 function->address(), | |
| 458 function->unchecked_code()->address(), | |
| 459 security_token_id); | |
| 460 } | 458 } |
| 461 | 459 |
| 462 | 460 |
| 463 void CpuProfiler::FunctionMoveEvent(Address from, Address to) { | 461 void CpuProfiler::FunctionMoveEvent(Address from, Address to) { |
| 464 singleton_->processor_->FunctionMoveEvent(from, to); | 462 singleton_->processor_->FunctionMoveEvent(from, to); |
| 465 } | 463 } |
| 466 | 464 |
| 467 | 465 |
| 468 void CpuProfiler::FunctionDeleteEvent(Address from) { | 466 void CpuProfiler::FunctionDeleteEvent(Address from) { |
| 469 singleton_->processor_->FunctionDeleteEvent(from); | 467 singleton_->processor_->FunctionDeleteEvent(from); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 void CpuProfiler::TearDown() { | 600 void CpuProfiler::TearDown() { |
| 603 #ifdef ENABLE_LOGGING_AND_PROFILING | 601 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 604 if (singleton_ != NULL) { | 602 if (singleton_ != NULL) { |
| 605 delete singleton_; | 603 delete singleton_; |
| 606 } | 604 } |
| 607 singleton_ = NULL; | 605 singleton_ = NULL; |
| 608 #endif | 606 #endif |
| 609 } | 607 } |
| 610 | 608 |
| 611 } } // namespace v8::internal | 609 } } // namespace v8::internal |
| OLD | NEW |