| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "accessors.h" | 7 #include "accessors.h" |
| 8 #include "allocation-site-scopes.h" | 8 #include "allocation-site-scopes.h" |
| 9 #include "api.h" | 9 #include "api.h" |
| 10 #include "arguments.h" | 10 #include "arguments.h" |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 // SameValue(0.0, -0.0) is false. | 968 // SameValue(0.0, -0.0) is false. |
| 969 return (this_value != 0) || ((1 / this_value) == (1 / other_value)); | 969 return (this_value != 0) || ((1 / this_value) == (1 / other_value)); |
| 970 } | 970 } |
| 971 if (IsString() && other->IsString()) { | 971 if (IsString() && other->IsString()) { |
| 972 return String::cast(this)->Equals(String::cast(other)); | 972 return String::cast(this)->Equals(String::cast(other)); |
| 973 } | 973 } |
| 974 return false; | 974 return false; |
| 975 } | 975 } |
| 976 | 976 |
| 977 | 977 |
| 978 bool Object::SameValueZero(Object* other) { |
| 979 if (other == this) return true; |
| 980 |
| 981 // The object is either a number, a name, an odd-ball, |
| 982 // a real JS object, or a Harmony proxy. |
| 983 if (IsNumber() && other->IsNumber()) { |
| 984 double this_value = Number(); |
| 985 double other_value = other->Number(); |
| 986 // +0 == -0 is true |
| 987 return this_value == other_value |
| 988 || (std::isnan(this_value) && std::isnan(other_value)); |
| 989 } |
| 990 if (IsString() && other->IsString()) { |
| 991 return String::cast(this)->Equals(String::cast(other)); |
| 992 } |
| 993 return false; |
| 994 } |
| 995 |
| 996 |
| 978 void Object::ShortPrint(FILE* out) { | 997 void Object::ShortPrint(FILE* out) { |
| 979 HeapStringAllocator allocator; | 998 HeapStringAllocator allocator; |
| 980 StringStream accumulator(&allocator); | 999 StringStream accumulator(&allocator); |
| 981 ShortPrint(&accumulator); | 1000 ShortPrint(&accumulator); |
| 982 accumulator.OutputToFile(out); | 1001 accumulator.OutputToFile(out); |
| 983 } | 1002 } |
| 984 | 1003 |
| 985 | 1004 |
| 986 void Object::ShortPrint(StringStream* accumulator) { | 1005 void Object::ShortPrint(StringStream* accumulator) { |
| 987 if (IsSmi()) { | 1006 if (IsSmi()) { |
| (...skipping 15334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16322 ASSERT(!IsObsolete()); | 16341 ASSERT(!IsObsolete()); |
| 16323 | 16342 |
| 16324 DisallowHeapAllocation no_gc; | 16343 DisallowHeapAllocation no_gc; |
| 16325 ASSERT(!key->IsTheHole()); | 16344 ASSERT(!key->IsTheHole()); |
| 16326 Object* hash = key->GetHash(); | 16345 Object* hash = key->GetHash(); |
| 16327 if (hash->IsUndefined()) return kNotFound; | 16346 if (hash->IsUndefined()) return kNotFound; |
| 16328 for (int entry = HashToEntry(Smi::cast(hash)->value()); | 16347 for (int entry = HashToEntry(Smi::cast(hash)->value()); |
| 16329 entry != kNotFound; | 16348 entry != kNotFound; |
| 16330 entry = ChainAt(entry)) { | 16349 entry = ChainAt(entry)) { |
| 16331 Object* candidate = KeyAt(entry); | 16350 Object* candidate = KeyAt(entry); |
| 16332 if (candidate->SameValue(*key)) | 16351 if (candidate->SameValueZero(*key)) |
| 16333 return entry; | 16352 return entry; |
| 16334 } | 16353 } |
| 16335 return kNotFound; | 16354 return kNotFound; |
| 16336 } | 16355 } |
| 16337 | 16356 |
| 16338 | 16357 |
| 16339 template<class Derived, class Iterator, int entrysize> | 16358 template<class Derived, class Iterator, int entrysize> |
| 16340 int OrderedHashTable<Derived, Iterator, entrysize>::AddEntry(int hash) { | 16359 int OrderedHashTable<Derived, Iterator, entrysize>::AddEntry(int hash) { |
| 16341 ASSERT(!IsObsolete()); | 16360 ASSERT(!IsObsolete()); |
| 16342 | 16361 |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17228 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17247 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 17229 static const char* error_messages_[] = { | 17248 static const char* error_messages_[] = { |
| 17230 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17249 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 17231 }; | 17250 }; |
| 17232 #undef ERROR_MESSAGES_TEXTS | 17251 #undef ERROR_MESSAGES_TEXTS |
| 17233 return error_messages_[reason]; | 17252 return error_messages_[reason]; |
| 17234 } | 17253 } |
| 17235 | 17254 |
| 17236 | 17255 |
| 17237 } } // namespace v8::internal | 17256 } } // namespace v8::internal |
| OLD | NEW |