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

Side by Side Diff: src/objects.cc

Issue 10658014: Fix Harmony Maps and WeakMaps for undefined values. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Adapted unit test case. Created 8 years, 6 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/runtime.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 12846 matching lines...) Expand 10 before | Expand all | Expand 10 after
12857 return Shrink(key); 12857 return Shrink(key);
12858 } 12858 }
12859 12859
12860 12860
12861 Object* ObjectHashTable::Lookup(Object* key) { 12861 Object* ObjectHashTable::Lookup(Object* key) {
12862 ASSERT(IsKey(key)); 12862 ASSERT(IsKey(key));
12863 12863
12864 // If the object does not have an identity hash, it was never used as a key. 12864 // If the object does not have an identity hash, it was never used as a key.
12865 { MaybeObject* maybe_hash = key->GetHash(OMIT_CREATION); 12865 { MaybeObject* maybe_hash = key->GetHash(OMIT_CREATION);
12866 if (maybe_hash->ToObjectUnchecked()->IsUndefined()) { 12866 if (maybe_hash->ToObjectUnchecked()->IsUndefined()) {
12867 return GetHeap()->undefined_value(); 12867 return GetHeap()->the_hole_value();
12868 } 12868 }
12869 } 12869 }
12870 int entry = FindEntry(key); 12870 int entry = FindEntry(key);
12871 if (entry == kNotFound) return GetHeap()->undefined_value(); 12871 if (entry == kNotFound) return GetHeap()->the_hole_value();
12872 return get(EntryToIndex(entry) + 1); 12872 return get(EntryToIndex(entry) + 1);
12873 } 12873 }
12874 12874
12875 12875
12876 MaybeObject* ObjectHashTable::Put(Object* key, Object* value) { 12876 MaybeObject* ObjectHashTable::Put(Object* key, Object* value) {
12877 ASSERT(IsKey(key)); 12877 ASSERT(IsKey(key));
12878 12878
12879 // Make sure the key object has an identity hash code. 12879 // Make sure the key object has an identity hash code.
12880 int hash; 12880 int hash;
12881 { MaybeObject* maybe_hash = key->GetHash(ALLOW_CREATION); 12881 { MaybeObject* maybe_hash = key->GetHash(ALLOW_CREATION);
12882 if (maybe_hash->IsFailure()) return maybe_hash; 12882 if (maybe_hash->IsFailure()) return maybe_hash;
12883 hash = Smi::cast(maybe_hash->ToObjectUnchecked())->value(); 12883 hash = Smi::cast(maybe_hash->ToObjectUnchecked())->value();
12884 } 12884 }
12885 int entry = FindEntry(key); 12885 int entry = FindEntry(key);
12886 12886
12887 // Check whether to perform removal operation. 12887 // Check whether to perform removal operation.
12888 if (value->IsUndefined()) { 12888 if (value->IsTheHole()) {
12889 if (entry == kNotFound) return this; 12889 if (entry == kNotFound) return this;
12890 RemoveEntry(entry); 12890 RemoveEntry(entry);
12891 return Shrink(key); 12891 return Shrink(key);
12892 } 12892 }
12893 12893
12894 // Key is already in table, just overwrite value. 12894 // Key is already in table, just overwrite value.
12895 if (entry != kNotFound) { 12895 if (entry != kNotFound) {
12896 set(EntryToIndex(entry) + 1, value); 12896 set(EntryToIndex(entry) + 1, value);
12897 return this; 12897 return this;
12898 } 12898 }
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
13298 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13298 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13299 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13299 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13300 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13300 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13301 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13301 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13302 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13302 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13303 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13303 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13304 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13304 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13305 } 13305 }
13306 13306
13307 } } // namespace v8::internal 13307 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698