From b82c20b28b4c938c3fe35abbeb35d65909eb48bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Wed, 29 Aug 2018 02:41:28 -0700 Subject: [PATCH] Bug 1487023: Replace the self-hosted SameValue function with Object.is. r=mgaudet --- js/src/builtin/Object.cpp | 4 ++-- js/src/builtin/Object.h | 3 +++ js/src/builtin/Utilities.js | 9 --------- js/src/vm/SelfHosting.cpp | 1 + 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/js/src/builtin/Object.cpp b/js/src/builtin/Object.cpp index 8373cec64ad4..44063da5f4dc 100644 --- a/js/src/builtin/Object.cpp +++ b/js/src/builtin/Object.cpp @@ -1655,8 +1655,8 @@ obj_entries(JSContext* cx, unsigned argc, Value* vp) } /* ES6 draft 15.2.3.16 */ -static bool -obj_is(JSContext* cx, unsigned argc, Value* vp) +bool +js::obj_is(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); diff --git a/js/src/builtin/Object.h b/js/src/builtin/Object.h index 5ad4aa65ab86..eafd4b6d07c4 100644 --- a/js/src/builtin/Object.h +++ b/js/src/builtin/Object.h @@ -35,6 +35,9 @@ obj_propertyIsEnumerable(JSContext* cx, unsigned argc, Value* vp); MOZ_MUST_USE bool obj_create(JSContext* cx, unsigned argc, JS::Value* vp); +MOZ_MUST_USE bool +obj_is(JSContext* cx, unsigned argc, JS::Value* vp); + MOZ_MUST_USE bool obj_getOwnPropertyNames(JSContext* cx, unsigned argc, JS::Value* vp); diff --git a/js/src/builtin/Utilities.js b/js/src/builtin/Utilities.js index 6b899240bb37..ebb120f46ffe 100644 --- a/js/src/builtin/Utilities.js +++ b/js/src/builtin/Utilities.js @@ -110,15 +110,6 @@ function ToLength(v) { return std_Math_min(v, 0x1fffffffffffff); } -// ES2017 draft rev aebf014403a3e641fb1622aec47c40f051943527 -// 7.2.9 SameValue ( x, y ) -function SameValue(x, y) { - if (x === y) { - return (x !== 0) || (1 / x === 1 / y); - } - return (x !== x && y !== y); -} - // ES2017 draft rev aebf014403a3e641fb1622aec47c40f051943527 // 7.2.10 SameValueZero ( x, y ) function SameValueZero(x, y) { diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 5524bf755753..54e0e46f55df 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -2445,6 +2445,7 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_FN("_DefineDataProperty", intrinsic_DefineDataProperty, 4,0), JS_FN("_DefineProperty", intrinsic_DefineProperty, 6,0), JS_FN("CopyDataPropertiesOrGetOwnKeys", intrinsic_CopyDataPropertiesOrGetOwnKeys, 3,0), + JS_INLINABLE_FN("SameValue", js::obj_is, 2,0, ObjectIs), JS_INLINABLE_FN("_IsConstructing", intrinsic_IsConstructing, 0,0, IntrinsicIsConstructing),