| 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 <iomanip> | 5 #include <iomanip> |
| 6 #include <sstream> | 6 #include <sstream> |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 return JSReceiver::GetOrCreateIdentityHash(Handle<JSReceiver>::cast(object)); | 676 return JSReceiver::GetOrCreateIdentityHash(Handle<JSReceiver>::cast(object)); |
| 677 } | 677 } |
| 678 | 678 |
| 679 | 679 |
| 680 bool Object::SameValue(Object* other) { | 680 bool Object::SameValue(Object* other) { |
| 681 if (other == this) return true; | 681 if (other == this) return true; |
| 682 | 682 |
| 683 // The object is either a number, a name, an odd-ball, | 683 // The object is either a number, a name, an odd-ball, |
| 684 // a real JS object, or a Harmony proxy. | 684 // a real JS object, or a Harmony proxy. |
| 685 if (IsNumber() && other->IsNumber()) { | 685 if (IsNumber() && other->IsNumber()) { |
| 686 double this_value = Number(); | 686 return v8::internal::SameValue(Number(), other->Number()); |
| 687 double other_value = other->Number(); | |
| 688 bool equal = this_value == other_value; | |
| 689 // SameValue(NaN, NaN) is true. | |
| 690 if (!equal) return std::isnan(this_value) && std::isnan(other_value); | |
| 691 // SameValue(0.0, -0.0) is false. | |
| 692 return (this_value != 0) || ((1 / this_value) == (1 / other_value)); | |
| 693 } | 687 } |
| 694 if (IsString() && other->IsString()) { | 688 if (IsString() && other->IsString()) { |
| 695 return String::cast(this)->Equals(String::cast(other)); | 689 return String::cast(this)->Equals(String::cast(other)); |
| 696 } | 690 } |
| 697 return false; | 691 return false; |
| 698 } | 692 } |
| 699 | 693 |
| 700 | 694 |
| 701 bool Object::SameValueZero(Object* other) { | 695 bool Object::SameValueZero(Object* other) { |
| 702 if (other == this) return true; | 696 if (other == this) return true; |
| 703 | 697 |
| 704 // The object is either a number, a name, an odd-ball, | 698 // The object is either a number, a name, an odd-ball, |
| 705 // a real JS object, or a Harmony proxy. | 699 // a real JS object, or a Harmony proxy. |
| 706 if (IsNumber() && other->IsNumber()) { | 700 if (IsNumber() && other->IsNumber()) { |
| 707 double this_value = Number(); | 701 return v8::internal::SameValueZero(Number(), other->Number()); |
| 708 double other_value = other->Number(); | |
| 709 // +0 == -0 is true | |
| 710 return this_value == other_value | |
| 711 || (std::isnan(this_value) && std::isnan(other_value)); | |
| 712 } | 702 } |
| 713 if (IsString() && other->IsString()) { | 703 if (IsString() && other->IsString()) { |
| 714 return String::cast(this)->Equals(String::cast(other)); | 704 return String::cast(this)->Equals(String::cast(other)); |
| 715 } | 705 } |
| 716 return false; | 706 return false; |
| 717 } | 707 } |
| 718 | 708 |
| 719 | 709 |
| 720 void Object::ShortPrint(FILE* out) { | 710 void Object::ShortPrint(FILE* out) { |
| 721 OFStream os(out); | 711 OFStream os(out); |
| (...skipping 15398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16120 Handle<Object> new_value) { | 16110 Handle<Object> new_value) { |
| 16121 if (cell->value() != *new_value) { | 16111 if (cell->value() != *new_value) { |
| 16122 cell->set_value(*new_value); | 16112 cell->set_value(*new_value); |
| 16123 Isolate* isolate = cell->GetIsolate(); | 16113 Isolate* isolate = cell->GetIsolate(); |
| 16124 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16114 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 16125 isolate, DependentCode::kPropertyCellChangedGroup); | 16115 isolate, DependentCode::kPropertyCellChangedGroup); |
| 16126 } | 16116 } |
| 16127 } | 16117 } |
| 16128 } // namespace internal | 16118 } // namespace internal |
| 16129 } // namespace v8 | 16119 } // namespace v8 |
| OLD | NEW |