[JSC] Improve constants and add comments for CodeBlockHash
https://bugs.webkit.org/show_bug.cgi?id=183982

Rubber-stamped by Mark Lam.

* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::CodeBlockHash):
* bytecode/ParseHash.cpp:
(JSC::ParseHash::ParseHash):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@229953 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 317f9eb..3d32a00 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,5 +1,17 @@
 2018-03-24  Yusuke Suzuki  <utatane.tea@gmail.com>
 
+        [JSC] Improve constants and add comments for CodeBlockHash
+        https://bugs.webkit.org/show_bug.cgi?id=183982
+
+        Rubber-stamped by Mark Lam.
+
+        * bytecode/CodeBlockHash.cpp:
+        (JSC::CodeBlockHash::CodeBlockHash):
+        * bytecode/ParseHash.cpp:
+        (JSC::ParseHash::ParseHash):
+
+2018-03-24  Yusuke Suzuki  <utatane.tea@gmail.com>
+
         [JSC] Add options to report parsing and bytecode compiling times
         https://bugs.webkit.org/show_bug.cgi?id=183982
 
diff --git a/Source/JavaScriptCore/bytecode/CodeBlockHash.cpp b/Source/JavaScriptCore/bytecode/CodeBlockHash.cpp
index bdb74c4..ee1b03d 100644
--- a/Source/JavaScriptCore/bytecode/CodeBlockHash.cpp
+++ b/Source/JavaScriptCore/bytecode/CodeBlockHash.cpp
@@ -46,9 +46,8 @@
     sha1.computeHash(digest);
     m_hash = digest[0] | (digest[1] << 8) | (digest[2] << 16) | (digest[3] << 24);
 
-    // Ensure that 0 corresponds to the hash not having been computed.
     if (m_hash == 0 || m_hash == 1)
-        m_hash += 0xbb4472;
+        m_hash += 0x2d5a93d0; // Ensures a non-zero hash, and gets us #Azero0 for CodeForCall and #Azero1 for CodeForConstruct.
     static_assert(static_cast<unsigned>(CodeForCall) == 0, "");
     static_assert(static_cast<unsigned>(CodeForConstruct) == 1, "");
     m_hash ^= static_cast<unsigned>(kind);
diff --git a/Source/JavaScriptCore/bytecode/ParseHash.cpp b/Source/JavaScriptCore/bytecode/ParseHash.cpp
index 0c6fe64..cde1b08 100644
--- a/Source/JavaScriptCore/bytecode/ParseHash.cpp
+++ b/Source/JavaScriptCore/bytecode/ParseHash.cpp
@@ -40,9 +40,8 @@
     sha1.computeHash(digest);
     unsigned hash = digest[0] | (digest[1] << 8) | (digest[2] << 16) | (digest[3] << 24);
 
-    // Ensure that 0 corresponds to the hash not having been computed.
     if (hash == 0 || hash == 1)
-        hash += 0xbb4472;
+        hash += 0x2d5a93d0; // Ensures a non-zero hash, and gets us #Azero0 for CodeForCall and #Azero1 for CodeForConstruct.
     static_assert(static_cast<unsigned>(CodeForCall) == 0, "");
     static_assert(static_cast<unsigned>(CodeForConstruct) == 1, "");
     unsigned hashForCall = hash ^ static_cast<unsigned>(CodeForCall);