Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index db419b0c04b77b5ba4d80c4dba66da83fa30a4bb..9fd725cf408a45e1c5c6e045b2434a488426034c 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -2199,6 +2199,24 @@ Object* GetSimpleHash(Object* object) { |
uint32_t hash = Oddball::cast(object)->to_string()->Hash(); |
return Smi::FromInt(hash); |
} |
+ if (object->IsByteArray()) { |
+ ByteArray* array = ByteArray::cast(object); |
+ int size = array->Size(); |
+ uint32_t hash = kZeroHashSeed; |
+ uint32_t* data = reinterpret_cast<uint32_t*>(array->GetDataStartAddress()); |
+ for (int i = 0; i < size / 4; i += 4) { |
Yang
2017/04/04 21:15:18
Do we really need to hash the entire byte array? F
kozy
2017/04/04 23:08:12
Done.
|
+ hash = ComputeIntegerHash(hash, *data); |
+ ++data; |
+ } |
+ int tail_start = size - size % 4; |
+ uint32_t tail = 0; |
+ for (int i = tail_start; i < size; ++i) { |
+ tail |= array->get(i); |
+ tail <<= 8; |
+ } |
+ hash = ComputeIntegerHash(hash, tail); |
+ return Smi::FromInt(hash); |
+ } |
DCHECK(object->IsJSReceiver()); |
// Simply return the receiver as it is guaranteed to not be a SMI. |
return object; |