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

Unified Diff: src/objects.cc

Issue 1234073003: V8: Add utility functions to check SameValue and SameValueZero. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Adam's comments. Created 5 years, 5 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 | src/utils.h » ('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 e53df91d0ba67f99ba9bb1f422a4b68ff9fed72d..97c8b65a465a7f25746301ded12ee29e239dd110 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -683,13 +683,7 @@ bool Object::SameValue(Object* other) {
// The object is either a number, a name, an odd-ball,
// a real JS object, or a Harmony proxy.
if (IsNumber() && other->IsNumber()) {
- double this_value = Number();
- double other_value = other->Number();
- bool equal = this_value == other_value;
- // SameValue(NaN, NaN) is true.
- if (!equal) return std::isnan(this_value) && std::isnan(other_value);
- // SameValue(0.0, -0.0) is false.
- return (this_value != 0) || ((1 / this_value) == (1 / other_value));
+ return v8::internal::SameValue(Number(), other->Number());
}
if (IsString() && other->IsString()) {
return String::cast(this)->Equals(String::cast(other));
@@ -704,11 +698,7 @@ bool Object::SameValueZero(Object* other) {
// The object is either a number, a name, an odd-ball,
// a real JS object, or a Harmony proxy.
if (IsNumber() && other->IsNumber()) {
- double this_value = Number();
- double other_value = other->Number();
- // +0 == -0 is true
- return this_value == other_value
- || (std::isnan(this_value) && std::isnan(other_value));
+ return v8::internal::SameValueZero(Number(), other->Number());
}
if (IsString() && other->IsString()) {
return String::cast(this)->Equals(String::cast(other));
« no previous file with comments | « no previous file | src/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698