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

Unified Diff: src/objects-inl.h

Issue 6489: Exclude the bit-field bits from string hash codes. String hash codes... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
===================================================================
--- src/objects-inl.h (revision 435)
+++ src/objects-inl.h (working copy)
@@ -484,6 +484,12 @@
#define WRITE_INT_FIELD(p, offset, value) \
(*reinterpret_cast<int*>(FIELD_ADDR(p, offset)) = value)
+#define READ_UINT32_FIELD(p, offset) \
+ (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)))
+
+#define WRITE_UINT32_FIELD(p, offset, value) \
+ (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value)
+
#define READ_SHORT_FIELD(p, offset) \
(*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)))
@@ -1204,13 +1210,13 @@
}
-int String::length_field() {
- return READ_INT_FIELD(this, kLengthOffset);
+uint32_t String::length_field() {
+ return READ_UINT32_FIELD(this, kLengthOffset);
}
-void String::set_length_field(int value) {
- WRITE_INT_FIELD(this, kLengthOffset, value);
+void String::set_length_field(uint32_t value) {
+ WRITE_UINT32_FIELD(this, kLengthOffset, value);
}
@@ -2070,16 +2076,16 @@
uint32_t String::Hash() {
// Fast case: has hash code already been computed?
- int hash = length_field();
- if (hash & kHashComputedMask) return hash;
+ uint32_t field = length_field();
+ if (field & kHashComputedMask) return field >> kHashShift;
// Slow case: compute hash code and set it..
return ComputeAndSetHash();
}
bool String::AsArrayIndex(uint32_t* index) {
- int hash = length_field();
- if ((hash & kHashComputedMask) && !(hash & kIsArrayIndexMask)) return false;
+ uint32_t field = length_field();
+ if ((field & kHashComputedMask) && !(field & kIsArrayIndexMask)) return false;
return SlowAsArrayIndex(index);
}
« no previous file with comments | « src/objects.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698