Revision: 5495
Author: mikhail.naga...@gmail.com
Date: Mon Sep 20 04:53:15 2010
Log: Merge r5492 into 2.3 branch. Fix for showing regexps in profiler.

Review URL: http://codereview.chromium.org/3431016
http://code.google.com/p/v8/source/detail?r=5495

Modified:
 /branches/2.3/src/api.cc
 /branches/2.3/src/cpu-profiler-inl.h
 /branches/2.3/src/profile-generator-inl.h
 /branches/2.3/src/profile-generator.cc
 /branches/2.3/src/profile-generator.h
 /branches/2.3/src/version.cc
 /branches/2.3/test/cctest/test-profile-generator.cc

=======================================
--- /branches/2.3/src/api.cc    Mon Aug 23 04:36:18 2010
+++ /branches/2.3/src/api.cc    Mon Sep 20 04:53:15 2010
@@ -4412,7 +4412,7 @@

 unsigned CpuProfileNode::GetCallUid() const {
   IsDeadCheck("v8::CpuProfileNode::GetCallUid");
- return reinterpret_cast<const i::ProfileNode*>(this)->entry()->call_uid(); + return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid();
 }


=======================================
--- /branches/2.3/src/cpu-profiler-inl.h        Wed May 26 06:27:57 2010
+++ /branches/2.3/src/cpu-profiler-inl.h        Mon Sep 20 04:53:15 2010
@@ -82,14 +82,11 @@

 bool ProfilerEventsProcessor::FilterOutCodeCreateEvent(
     Logger::LogEventsAndTags tag) {
-  // In browser mode, leave only callbacks and non-native JS entries.
-  // We filter out regular expressions as currently we can't tell
- // whether they origin from native scripts, so let's not confise people by
-  // showing them weird regexes they didn't wrote.
   return FLAG_prof_browser_mode
       && (tag != Logger::CALLBACK_TAG
           && tag != Logger::FUNCTION_TAG
           && tag != Logger::LAZY_COMPILE_TAG
+          && tag != Logger::REG_EXP_TAG
           && tag != Logger::SCRIPT_TAG);
 }

=======================================
--- /branches/2.3/src/profile-generator-inl.h   Mon Aug 23 04:36:18 2010
+++ /branches/2.3/src/profile-generator-inl.h   Mon Sep 20 04:53:15 2010
@@ -46,8 +46,7 @@


 CodeEntry::CodeEntry(int security_token_id)
-    : call_uid_(0),
-      tag_(Logger::FUNCTION_TAG),
+    : tag_(Logger::FUNCTION_TAG),
       name_prefix_(kEmptyNamePrefix),
       name_(""),
       resource_name_(""),
@@ -62,8 +61,7 @@
                      const char* resource_name,
                      int line_number,
                      int security_token_id)
-    : call_uid_(next_call_uid_++),
-      tag_(tag),
+    : tag_(tag),
       name_prefix_(name_prefix),
       name_(name),
       resource_name_(resource_name),
=======================================
--- /branches/2.3/src/profile-generator.cc      Tue Aug 31 08:42:07 2010
+++ /branches/2.3/src/profile-generator.cc      Mon Sep 20 04:53:15 2010
@@ -120,17 +120,35 @@


 const char* CodeEntry::kEmptyNamePrefix = "";
-unsigned CodeEntry::next_call_uid_ = 1;


 void CodeEntry::CopyData(const CodeEntry& source) {
-  call_uid_ = source.call_uid_;
   tag_ = source.tag_;
   name_prefix_ = source.name_prefix_;
   name_ = source.name_;
   resource_name_ = source.resource_name_;
   line_number_ = source.line_number_;
 }
+
+
+uint32_t CodeEntry::GetCallUid() const {
+  uint32_t hash = ComputeIntegerHash(tag_);
+  hash ^= static_cast<int32_t>(reinterpret_cast<intptr_t>(name_prefix_));
+  hash ^= static_cast<int32_t>(reinterpret_cast<intptr_t>(name_));
+  hash ^= static_cast<int32_t>(reinterpret_cast<intptr_t>(resource_name_));
+  hash ^= static_cast<int32_t>(line_number_);
+  return hash;
+}
+
+
+bool CodeEntry::IsSameAs(CodeEntry* entry) const {
+  return this == entry
+      || (tag_ == entry->tag_
+          && name_prefix_ == entry->name_prefix_
+          && name_ == entry->name_
+          && resource_name_ == entry->resource_name_
+          && line_number_ == entry->line_number_);
+}


 ProfileNode* ProfileNode::FindChild(CodeEntry* entry) {
=======================================
--- /branches/2.3/src/profile-generator.h       Tue Aug 31 08:42:07 2010
+++ /branches/2.3/src/profile-generator.h       Mon Sep 20 04:53:15 2010
@@ -100,17 +100,17 @@
   INLINE(const char* name() const) { return name_; }
   INLINE(const char* resource_name() const) { return resource_name_; }
   INLINE(int line_number() const) { return line_number_; }
-  INLINE(unsigned call_uid() const) { return call_uid_; }
   INLINE(int security_token_id() const) { return security_token_id_; }

   INLINE(static bool is_js_function_tag(Logger::LogEventsAndTags tag));

   void CopyData(const CodeEntry& source);
+  uint32_t GetCallUid() const;
+  bool IsSameAs(CodeEntry* entry) const;

   static const char* kEmptyNamePrefix;

  private:
-  unsigned call_uid_;
   Logger::LogEventsAndTags tag_;
   const char* name_prefix_;
   const char* name_;
@@ -118,8 +118,6 @@
   int line_number_;
   int security_token_id_;

-  static unsigned next_call_uid_;
-
   DISALLOW_COPY_AND_ASSIGN(CodeEntry);
 };

@@ -147,11 +145,12 @@

  private:
   INLINE(static bool CodeEntriesMatch(void* entry1, void* entry2)) {
-    return entry1 == entry2;
+    return reinterpret_cast<CodeEntry*>(entry1)->IsSameAs(
+        reinterpret_cast<CodeEntry*>(entry2));
   }

   INLINE(static uint32_t CodeEntryHash(CodeEntry* entry)) {
-    return static_cast<int32_t>(reinterpret_cast<intptr_t>(entry));
+    return entry->GetCallUid();
   }

   ProfileTree* tree_;
=======================================
--- /branches/2.3/src/version.cc        Fri Sep 17 06:28:10 2010
+++ /branches/2.3/src/version.cc        Mon Sep 20 04:53:15 2010
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     2
 #define MINOR_VERSION     3
 #define BUILD_NUMBER      11
-#define PATCH_LEVEL       10
+#define PATCH_LEVEL       11
 #define CANDIDATE_VERSION false

 // Define SONAME to have the SCons build the put a specific SONAME into the
=======================================
--- /branches/2.3/test/cctest/test-profile-generator.cc Tue Aug 31 08:42:07 2010 +++ /branches/2.3/test/cctest/test-profile-generator.cc Mon Sep 20 04:53:15 2010
@@ -87,6 +87,24 @@
   CHECK_EQ(childNode2, node.FindOrAddChild(&entry2));
   CHECK_EQ(childNode3, node.FindOrAddChild(&entry3));
 }
+
+
+TEST(ProfileNodeFindOrAddChildForSameFunction) {
+  ProfileNode node(NULL, NULL);
+  CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0,
+                     TokenEnumerator::kNoSecurityToken);
+  ProfileNode* childNode1 = node.FindOrAddChild(&entry1);
+  CHECK_NE(NULL, childNode1);
+  CHECK_EQ(childNode1, node.FindOrAddChild(&entry1));
+  // The same function again.
+  CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "aaa", "", 0,
+                   TokenEnumerator::kNoSecurityToken);
+  CHECK_EQ(childNode1, node.FindOrAddChild(&entry2));
+  // Now with a different security token.
+  CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "aaa", "", 0,
+                   TokenEnumerator::kNoSecurityToken + 1);
+  CHECK_EQ(childNode1, node.FindOrAddChild(&entry3));
+}


 namespace {

--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev

Reply via email to