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

Unified Diff: src/objects.cc

Issue 8390047: Fix identity hash code function to respect flag. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 9 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 | « no previous file | test/cctest/test-dictionary.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 8562c7094f98af7f1468d45edd45b005912bd6a3..9a87ac57d6552d01df1d994fe33133cbbffd4288 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -3589,6 +3589,9 @@ MaybeObject* JSObject::GetIdentityHash(CreationFlag flag) {
Object* stored_value = GetHiddenProperty(GetHeap()->identity_hash_symbol());
if (stored_value->IsSmi()) return stored_value;
+ // Do not generate permanent identity hash code if not requested.
+ if (flag == OMIT_CREATION) return GetHeap()->undefined_value();
+
Smi* hash = GenerateIdentityHash();
MaybeObject* result = SetHiddenProperty(GetHeap()->identity_hash_symbol(),
hash);
@@ -12390,7 +12393,7 @@ MaybeObject* StringDictionary::TransformPropertiesToFastFor(
bool ObjectHashSet::Contains(Object* key) {
// If the object does not have an identity hash, it was never used as a key.
{ MaybeObject* maybe_hash = key->GetHash(OMIT_CREATION);
- if (maybe_hash->IsFailure()) return false;
+ if (maybe_hash->ToObjectUnchecked()->IsUndefined()) return false;
}
return (FindEntry(key) != kNotFound);
}
@@ -12424,7 +12427,7 @@ MaybeObject* ObjectHashSet::Add(Object* key) {
MaybeObject* ObjectHashSet::Remove(Object* key) {
// If the object does not have an identity hash, it was never used as a key.
{ MaybeObject* maybe_hash = key->GetHash(OMIT_CREATION);
- if (maybe_hash->IsFailure()) return this;
+ if (maybe_hash->ToObjectUnchecked()->IsUndefined()) return this;
}
int entry = FindEntry(key);
@@ -12441,7 +12444,9 @@ MaybeObject* ObjectHashSet::Remove(Object* key) {
Object* ObjectHashTable::Lookup(Object* key) {
// If the object does not have an identity hash, it was never used as a key.
{ MaybeObject* maybe_hash = key->GetHash(OMIT_CREATION);
- if (maybe_hash->IsFailure()) GetHeap()->undefined_value();
+ if (maybe_hash->ToObjectUnchecked()->IsUndefined()) {
+ return GetHeap()->undefined_value();
+ }
}
int entry = FindEntry(key);
if (entry == kNotFound) return GetHeap()->undefined_value();
« no previous file with comments | « no previous file | test/cctest/test-dictionary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698