Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/objects.cc

Issue 11228004: Fix two-char hash to use correct fallback for zero hashes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 12065 matching lines...) Expand 10 before | Expand all | Expand 10 after
12076 hash += hash << 10; 12076 hash += hash << 10;
12077 hash ^= hash >> 6; 12077 hash ^= hash >> 6;
12078 // Char 2. 12078 // Char 2.
12079 hash += c2; 12079 hash += c2;
12080 hash += hash << 10; 12080 hash += hash << 10;
12081 hash ^= hash >> 6; 12081 hash ^= hash >> 6;
12082 // GetHash. 12082 // GetHash.
12083 hash += hash << 3; 12083 hash += hash << 3;
12084 hash ^= hash >> 11; 12084 hash ^= hash >> 11;
12085 hash += hash << 15; 12085 hash += hash << 15;
12086 if ((hash & String::kHashBitMask) == 0) hash = String::kZeroHash; 12086 if ((hash & String::kHashBitMask) == 0) hash = StringHasher::kZeroHash;
12087 #ifdef DEBUG 12087 #ifdef DEBUG
12088 StringHasher hasher(2, seed); 12088 StringHasher hasher(2, seed);
12089 hasher.AddCharacter(c1); 12089 hasher.AddCharacter(c1);
12090 hasher.AddCharacter(c2); 12090 hasher.AddCharacter(c2);
12091 // If this assert fails then we failed to reproduce the two-character 12091 // If this assert fails then we failed to reproduce the two-character
12092 // version of the string hashing algorithm above. One reason could be 12092 // version of the string hashing algorithm above. One reason could be
12093 // that we were passed two digits as characters, since the hash 12093 // that we were passed two digits as characters, since the hash
12094 // algorithm is different in that case. 12094 // algorithm is different in that case.
12095 ASSERT_EQ(static_cast<int>(hasher.GetHash()), static_cast<int>(hash)); 12095 ASSERT_EQ(static_cast<int>(hasher.GetHash()), static_cast<int>(hash));
12096 #endif 12096 #endif
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after
13475 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13475 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13476 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13476 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13477 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13477 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13478 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13478 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13479 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13479 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13480 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13480 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13481 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13481 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13482 } 13482 }
13483 13483
13484 } } // namespace v8::internal 13484 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698