Bug 1487023: Replace the self-hosted SameValue function with Object.is. r=mgaudet
authorAndré Bargull <andre.bargull@gmail.com>
Wed, 29 Aug 2018 02:41:28 -0700
changeset 491776 7d527975aa0e9ee49b01c3120f4738e254a4424f
parent 491775 6fd2ee9bacf2869ba06830ea0e15da28ef2dea75
child 491777 bc6567e31d48dd62be7df4a9d11fd74621858b53
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmgaudet
bugs1487023
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1487023: Replace the self-hosted SameValue function with Object.is. r=mgaudet
js/src/builtin/Object.cpp
js/src/builtin/Object.h
js/src/builtin/Utilities.js
js/src/vm/SelfHosting.cpp
--- a/js/src/builtin/Object.cpp
+++ b/js/src/builtin/Object.cpp
@@ -1650,18 +1650,18 @@ obj_entries(JSContext* cx, unsigned argc
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     // Steps 1-3.
     return EnumerableOwnProperties<EnumerableOwnPropertiesKind::KeysAndValues>(cx, args);
 }
 
 /* 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);
 
     bool same;
     if (!SameValue(cx, args.get(0), args.get(1), &same))
         return false;
 
     args.rval().setBoolean(same);
--- a/js/src/builtin/Object.h
+++ b/js/src/builtin/Object.h
@@ -31,16 +31,19 @@ ObjectCreateWithTemplate(JSContext* cx, 
 // Object methods exposed so they can be installed in the self-hosting global.
 MOZ_MUST_USE bool
 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);
 
 MOZ_MUST_USE bool
 obj_toString(JSContext* cx, unsigned argc, JS::Value* vp);
 
 JSString*
 ObjectClassToString(JSContext* cx, HandleObject obj);
 
--- a/js/src/builtin/Utilities.js
+++ b/js/src/builtin/Utilities.js
@@ -106,25 +106,16 @@ function ToLength(v) {
     v = std_Math_max(v, 0);
 
     // Step 3.
     // Math.pow(2, 53) - 1 = 0x1fffffffffffff
     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) {
     return x === y || (x !== x && y !== y);
 }
 
 // ES 2017 draft (April 6, 2016) 7.3.9
 function GetMethod(V, P) {
     // Step 1.
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -2440,16 +2440,17 @@ static const JSFunctionSpec intrinsic_fu
     JS_INLINABLE_FN("_FinishBoundFunctionInit", intrinsic_FinishBoundFunctionInit, 3,0,
                     IntrinsicFinishBoundFunctionInit),
     JS_FN("RuntimeDefaultLocale",    intrinsic_RuntimeDefaultLocale,    0,0),
     JS_FN("IsRuntimeDefaultLocale",  intrinsic_IsRuntimeDefaultLocale,  1,0),
     JS_FN("AddContentTelemetry",     intrinsic_AddContentTelemetry,     2,0),
     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),
     JS_INLINABLE_FN("SubstringKernel", intrinsic_SubstringKernel,       3,0,
                     IntrinsicSubstringKernel),
     JS_INLINABLE_FN("ObjectHasPrototype",               intrinsic_ObjectHasPrototype,      2,0,
                     IntrinsicObjectHasPrototype),
     JS_INLINABLE_FN("UnsafeSetReservedSlot",            intrinsic_UnsafeSetReservedSlot,   3,0,