Reviewers: Yang,

Message:
ptal - maybe this fixes this regression, but it's really hard to tell locally,
so it's mostly a guess

Description:
add fast path for hashing small cons strings

BUG=437280

Please review this at https://codereview.chromium.org/769453002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+14, -3 lines):
  M src/objects.cc
  M src/objects-inl.h


Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 98d96a8f28ac0747517e1b407753ed869a817ba0..efe7c363b3d6acd0c092a3d23dcaeea293fbfb3a 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -6825,9 +6825,8 @@ uint32_t IteratingStringHasher::Hash(String* string, uint32_t seed) {
   // Nothing to do.
   if (hasher.has_trivial_hash()) return hasher.GetHashField();
   ConsString* cons_string = String::VisitFlat(&hasher, string);
-  if (cons_string != nullptr) {
-    hasher.VisitConsString(cons_string);
-  }
+  if (cons_string == nullptr) return hasher.GetHashField();
+  hasher.VisitConsString(cons_string);
   return hasher.GetHashField();
 }

Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 15fdce65d98a63d8a89c1edbc474e818ec634ee3..89451524076a19e5a7356515e00db8c9e2304bb7 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9298,6 +9298,18 @@ uint32_t StringHasher::ComputeUtf8Hash(Vector<const char> chars,


 void IteratingStringHasher::VisitConsString(ConsString* cons_string) {
+  // Run small ConsStrings through ConsStringIterator.
+  if (cons_string->length() < 64) {
+    ConsStringIterator iter(cons_string);
+    int offset;
+    String* string;
+    while (nullptr != (string = iter.Next(&offset))) {
+      DCHECK_EQ(0, offset);
+      String::VisitFlat(this, string, 0);
+    }
+    return;
+  }
+  // Slow case.
   const int max_length = String::kMaxHashCalcLength;
   int length = std::min(cons_string->length(), max_length);
   if (cons_string->HasOnlyOneByteChars()) {


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to