Reviewers: Søren Gjesse,

Description:
Merge fixes from r5373, r5384 into 2.3 branch.

These fixes are for CPU profiler.


Please review this at http://codereview.chromium.org/3288004/show

SVN Base: http://v8.googlecode.com/svn/branches/2.3/

Affected files:
  M     src/circular-queue.cc
  M     src/profile-generator.h
  M     src/profile-generator.cc
  M     src/version.cc
  M     test/cctest/test-profile-generator.cc


Index: src/circular-queue.cc
===================================================================
--- src/circular-queue.cc       (revision 5385)
+++ src/circular-queue.cc       (working copy)
@@ -47,8 +47,9 @@
       producer_consumer_distance_(2 * chunk_size_),
       buffer_(NewArray<Cell>(buffer_size_ + 1)) {
   ASSERT(buffer_size_in_chunks > 2);
-  // Only need to keep the first cell of a chunk clean.
-  for (int i = 0; i < buffer_size_; i += chunk_size_) {
+  // Clean up the whole buffer to avoid encountering a random kEnd
+  // while enqueuing.
+  for (int i = 0; i < buffer_size_; ++i) {
     buffer_[i] = kClear;
   }
   buffer_[buffer_size_] = kEnd;
Index: src/profile-generator.cc
===================================================================
--- src/profile-generator.cc    (revision 5385)
+++ src/profile-generator.cc    (working copy)
@@ -492,6 +492,10 @@
bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid) {
   ASSERT(uid > 0);
   current_profiles_semaphore_->Wait();
+  if (current_profiles_.length() >= kMaxSimultaneousProfiles) {
+    current_profiles_semaphore_->Signal();
+    return false;
+  }
   for (int i = 0; i < current_profiles_.length(); ++i) {
     if (strcmp(current_profiles_[i]->title(), title) == 0) {
       // Ignore attempts to start profile with the same title.
Index: src/profile-generator.h
===================================================================
--- src/profile-generator.h     (revision 5385)
+++ src/profile-generator.h     (working copy)
@@ -299,6 +299,9 @@
   // Called from profile generator thread.
   void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path);

+  // Limits the number of profiles that can be simultaneously collected.
+  static const int kMaxSimultaneousProfiles = 100;
+
  private:
   const char* GetName(int args_count);
   const char* GetFunctionName(String* name) {
Index: src/version.cc
===================================================================
--- src/version.cc      (revision 5385)
+++ src/version.cc      (working copy)
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     2
 #define MINOR_VERSION     3
 #define BUILD_NUMBER      11
-#define PATCH_LEVEL       3
+#define PATCH_LEVEL       4
 #define CANDIDATE_VERSION false

 // Define SONAME to have the SCons build the put a specific SONAME into the
Index: test/cctest/test-profile-generator.cc
===================================================================
--- test/cctest/test-profile-generator.cc       (revision 5385)
+++ test/cctest/test-profile-generator.cc       (working copy)
@@ -775,4 +775,21 @@
   CHECK_EQ(0, current->children()->length());
 }

+
+TEST(Issue51919) {
+  CpuProfilesCollection collection;
+  i::EmbeddedVector<char*,
+      CpuProfilesCollection::kMaxSimultaneousProfiles> titles;
+ for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) {
+    i::Vector<char> title = i::Vector<char>::New(16);
+    i::OS::SNPrintF(title, "%d", i);
+ CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0.
+    titles[i] = title.start();
+  }
+  CHECK(!collection.StartProfiling(
+      "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1));
+  for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
+    i::DeleteArray(titles[i]);
+}
+
 #endif  // ENABLE_LOGGING_AND_PROFILING


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

Reply via email to