void CpuProfiler::StartCollectingProfile(const char* title) {
if (profiles_->StartProfiling(title, next_profile_uid_++)) {
StartProcessorIfNotStarted();
+ generator_->AddCurrentStack();
}
}
void CpuProfiler::StartCollectingProfile(String* title) {
- if (profiles_->StartProfiling(title, next_profile_uid_++)) {
- StartProcessorIfNotStarted();
- }
+ StartCollectingProfile(profiles_->GetName(title));
}
#ifdef ENABLE_LOGGING_AND_PROFILING
#include "v8.h"
+#include "frames-inl.h"
#include "global-handles.h"
#include "profile-generator-inl.h"
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
#endif // ENABLE_LOGGING_AND_PROFILING
CpuProfile* GetProfile(int security_token_id, unsigned uid);
inline bool is_last_profile();
+ const char* GetName(String* name);
CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag,
String* name, String* resource_name, int line_number);
CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name);
private:
INLINE(const char* GetFunctionName(String* name));
INLINE(const char* GetFunctionName(const char* name));
- const char* GetName(String* name);
const char* GetName(int args_count);
List<CpuProfile*>* GetProfilesList(int security_token_id);
int TokenToIndex(int security_token_id);
return sample_rate_calc_.ticks_per_ms();
}
+ // Samples stack and adds it to current profiles.
+ void AddCurrentStack();
+
static const char* kAnonymousFunctionName;
static const char* kProgramEntryName;
static const char* kGarbageCollectorEntryName;