added function

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4766 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 610ad370
...@@ -415,14 +415,13 @@ CpuProfiler::~CpuProfiler() { ...@@ -415,14 +415,13 @@ CpuProfiler::~CpuProfiler() {
void CpuProfiler::StartCollectingProfile(const char* title) { void CpuProfiler::StartCollectingProfile(const char* title) {
if (profiles_->StartProfiling(title, next_profile_uid_++)) { if (profiles_->StartProfiling(title, next_profile_uid_++)) {
StartProcessorIfNotStarted(); StartProcessorIfNotStarted();
generator_->AddCurrentStack();
} }
} }
void CpuProfiler::StartCollectingProfile(String* title) { void CpuProfiler::StartCollectingProfile(String* title) {
if (profiles_->StartProfiling(title, next_profile_uid_++)) { StartCollectingProfile(profiles_->GetName(title));
StartProcessorIfNotStarted();
}
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#ifdef ENABLE_LOGGING_AND_PROFILING #ifdef ENABLE_LOGGING_AND_PROFILING
#include "v8.h" #include "v8.h"
#include "frames-inl.h"
#include "global-handles.h" #include "global-handles.h"
#include "profile-generator-inl.h" #include "profile-generator-inl.h"
...@@ -807,6 +808,22 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) { ...@@ -807,6 +808,22 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
profiles_->AddPathToCurrentProfiles(entries); profiles_->AddPathToCurrentProfiles(entries);
} }
void ProfileGenerator::AddCurrentStack() {
TickSample sample;
sample.state = VMState::current_state();
sample.pc = reinterpret_cast<Address>(&sample); // Not NULL.
sample.frames_count = 0;
for (StackTraceFrameIterator it;
!it.done() && sample.frames_count < TickSample::kMaxFramesCount;
it.Advance()) {
JavaScriptFrame* frame = it.frame();
sample.stack[sample.frames_count++] =
reinterpret_cast<Address>(frame->function());
}
RecordTickSample(sample);
}
} } // namespace v8::internal } } // namespace v8::internal
#endif // ENABLE_LOGGING_AND_PROFILING #endif // ENABLE_LOGGING_AND_PROFILING
...@@ -260,6 +260,7 @@ class CpuProfilesCollection { ...@@ -260,6 +260,7 @@ class CpuProfilesCollection {
CpuProfile* GetProfile(int security_token_id, unsigned uid); CpuProfile* GetProfile(int security_token_id, unsigned uid);
inline bool is_last_profile(); inline bool is_last_profile();
const char* GetName(String* name);
CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag,
String* name, String* resource_name, int line_number); String* name, String* resource_name, int line_number);
CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name);
...@@ -274,7 +275,6 @@ class CpuProfilesCollection { ...@@ -274,7 +275,6 @@ class CpuProfilesCollection {
private: private:
INLINE(const char* GetFunctionName(String* name)); INLINE(const char* GetFunctionName(String* name));
INLINE(const char* GetFunctionName(const char* name)); INLINE(const char* GetFunctionName(const char* name));
const char* GetName(String* name);
const char* GetName(int args_count); const char* GetName(int args_count);
List<CpuProfile*>* GetProfilesList(int security_token_id); List<CpuProfile*>* GetProfilesList(int security_token_id);
int TokenToIndex(int security_token_id); int TokenToIndex(int security_token_id);
...@@ -381,6 +381,9 @@ class ProfileGenerator { ...@@ -381,6 +381,9 @@ class ProfileGenerator {
return sample_rate_calc_.ticks_per_ms(); return sample_rate_calc_.ticks_per_ms();
} }
// Samples stack and adds it to current profiles.
void AddCurrentStack();
static const char* kAnonymousFunctionName; static const char* kAnonymousFunctionName;
static const char* kProgramEntryName; static const char* kProgramEntryName;
static const char* kGarbageCollectorEntryName; static const char* kGarbageCollectorEntryName;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment