Reviewers: Erik Corry,
Description:
[objects] seed NumberDictionary (only ia32) now
BUG=
TEST=
[email protected]
Please review this at http://codereview.chromium.org/9148006/
SVN Base: gh:v8/v8@master
Affected files:
M src/ia32/macro-assembler-ia32.cc
M src/objects-inl.h
M src/objects.h
M src/objects.cc
Index: src/ia32/macro-assembler-ia32.cc
diff --git a/src/ia32/macro-assembler-ia32.cc
b/src/ia32/macro-assembler-ia32.cc
index
3356e818922d0ccce2967e4cd2bf6a586917663d..bc46b34099c8fdf36d37f70f751c506d5efaf84a
100644
--- a/src/ia32/macro-assembler-ia32.cc
+++ b/src/ia32/macro-assembler-ia32.cc
@@ -984,11 +984,26 @@ void MacroAssembler::LoadFromNumberDictionary(Label*
miss,
Label done;
+ // First of all lets assign to r1 value of HashSeed
+ if (Serializer::enabled()) {
+ ExternalReference roots_array_start =
+ ExternalReference::roots_array_start(isolate());
+ mov(r1, Immediate(Heap::kStringHashSeedRootIndex));
+ mov(r1, Operand::StaticArray(r1,
+ times_pointer_size,
+ roots_array_start));
+ } else {
+ int32_t seed = isolate()->heap()->StringHashSeed();
+ lea(r1, Operand(seed, RelocInfo::NONE));
+ }
+
+ // Xor original key with a seed
+ xor_(r1, r0);
+
// Compute the hash code from the untagged key. This must be kept in
sync
// with ComputeIntegerHash in utils.h.
//
// hash = ~hash + (hash << 15);
- mov(r1, r0);
not_(r0);
shl(r1, 15);
add(r0, r1);
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
c5cf060829f5867cbfea4dc35d56a0c682e4a486..760fcac69c8d1d52deb41b37e0d645e58330b9f9
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -4535,6 +4535,11 @@ bool NumberDictionaryShape::IsMatch(uint32_t key,
Object* other) {
}
+uint32_t NumberDictionaryShape::MixinSeed(uint32_t key, uint32_t seed) {
+ return key ^ seed;
+}
+
+
uint32_t NumberDictionaryShape::Hash(uint32_t key) {
return ComputeIntegerHash(key);
}
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
9aee6790ceec43e2606d2b65a6d3dd20b3d5ba4f..2a5ba5ab725554d98f7a4fd5a79b7c76ae93cb4d
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -12065,17 +12065,21 @@ void
NumberDictionary::UpdateMaxNumberKey(uint32_t key) {
// If the dictionary requires slow elements an element has already
// been added at a high index.
if (requires_slow_elements()) return;
+ uint32_t hashed_key = NumberDictionaryShape::MixinSeed(
+ key,
+ GetHeap()->StringHashSeed()
+ );
// Check if this index is high enough that we should require slow
// elements.
- if (key > kRequiresSlowElementsLimit) {
+ if (hashed_key > kRequiresSlowElementsLimit) {
set_requires_slow_elements();
return;
}
// Update max key value.
Object* max_index_object = get(kMaxNumberKeyIndex);
- if (!max_index_object->IsSmi() || max_number_key() < key) {
+ if (!max_index_object->IsSmi() || max_number_key() < hashed_key) {
FixedArray::set(kMaxNumberKeyIndex,
- Smi::FromInt(key << kRequiresSlowElementsTagSize));
+ Smi::FromInt(hashed_key <<
kRequiresSlowElementsTagSize));
}
}
@@ -12109,13 +12113,17 @@ Handle<NumberDictionary> NumberDictionary::Set(
MaybeObject* NumberDictionary::Set(uint32_t key,
Object* value,
PropertyDetails details) {
- int entry = FindEntry(key);
- if (entry == kNotFound) return AddNumberEntry(key, value, details);
+ uint32_t hashed_key = NumberDictionaryShape::MixinSeed(
+ key,
+ GetHeap()->StringHashSeed()
+ );
+ int entry = FindEntry(hashed_key);
+ if (entry == kNotFound) return AddNumberEntry(hashed_key, value,
details);
// Preserve enumeration index.
details = PropertyDetails(details.attributes(),
details.type(),
DetailsAt(entry).index());
- MaybeObject* maybe_object_key = NumberDictionaryShape::AsObject(key);
+ MaybeObject* maybe_object_key =
NumberDictionaryShape::AsObject(hashed_key);
Object* object_key;
if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key;
SetEntry(entry, object_key, value, details);
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
717b2ab07204c4f8155cb55cf5927067c3d7083b..737022969e798aba92d09b3237e97a23e46bbef1
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -3000,6 +3000,7 @@ class StringDictionary: public
Dictionary<StringDictionaryShape, String*> {
class NumberDictionaryShape {
public:
static inline bool IsMatch(uint32_t key, Object* other);
+ static inline uint32_t MixinSeed(uint32_t key, uint32_t seed);
static inline uint32_t Hash(uint32_t key);
static inline uint32_t HashForObject(uint32_t key, Object* object);
MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev