Revision: 4766
Author: [email protected]
Date: Tue Jun  1 06:35:09 2010
Log: added function
http://code.google.com/p/v8/source/detail?r=4766

Modified:
 /branches/bleeding_edge/src/cpu-profiler.cc
 /branches/bleeding_edge/src/profile-generator.cc
 /branches/bleeding_edge/src/profile-generator.h

=======================================
--- /branches/bleeding_edge/src/cpu-profiler.cc Fri May 21 22:27:19 2010
+++ /branches/bleeding_edge/src/cpu-profiler.cc Tue Jun  1 06:35:09 2010
@@ -415,14 +415,13 @@
 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));
 }


=======================================
--- /branches/bleeding_edge/src/profile-generator.cc Mon May 31 03:09:07 2010 +++ /branches/bleeding_edge/src/profile-generator.cc Tue Jun 1 06:35:09 2010
@@ -28,6 +28,7 @@
 #ifdef ENABLE_LOGGING_AND_PROFILING

 #include "v8.h"
+#include "frames-inl.h"
 #include "global-handles.h"

 #include "profile-generator-inl.h"
@@ -806,6 +807,22 @@

   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

=======================================
--- /branches/bleeding_edge/src/profile-generator.h     Tue May 18 07:19:33 2010
+++ /branches/bleeding_edge/src/profile-generator.h     Tue Jun  1 06:35:09 2010
@@ -260,6 +260,7 @@
   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);
@@ -274,7 +275,6 @@
  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);
@@ -380,6 +380,9 @@
   INLINE(double actual_sampling_rate()) {
     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;

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to