Bug 1448839: Remove unused native version of Object.defineProperty. r=till
authorAndré Bargull <andre.bargull@gmail.com>
Mon, 26 Mar 2018 05:40:17 -0700
changeset 410475 480ce1d9da6159328623004416eeeb486039d88e
parent 410474 4cd76f6e6217f67a679a66facf705f2670f679d1
child 410476 d3f3380c8b1c9091c4c474278fe7b49669cf7588
push id33729
push userrgurzau@mozilla.com
push dateWed, 28 Mar 2018 21:55:49 +0000
treeherdermozilla-central@6aa3b57955fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1448839
milestone61.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 1448839: Remove unused native version of Object.defineProperty. r=till
js/src/builtin/Object.cpp
js/src/builtin/Object.h
js/src/builtin/Object.js
js/src/builtin/Reflect.cpp
js/src/builtin/Reflect.h
js/src/vm/SelfHosting.cpp
--- a/js/src/builtin/Object.cpp
+++ b/js/src/builtin/Object.cpp
@@ -1750,42 +1750,16 @@ obj_getOwnPropertySymbols(JSContext* cx,
     if (!obj)
         return false;
 
     return GetOwnPropertyKeys(cx, obj,
                               JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS | JSITER_SYMBOLSONLY,
                               args.rval());
 }
 
-/* ES6 draft rev 32 (2015 Feb 2) 19.1.2.4: Object.defineProperty(O, P, Attributes) */
-bool
-js::obj_defineProperty(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-
-    // Steps 1-3.
-    RootedObject obj(cx);
-    if (!GetFirstArgumentAsObject(cx, args, "Object.defineProperty", &obj))
-        return false;
-    RootedId id(cx);
-    if (!ToPropertyKey(cx, args.get(1), &id))
-        return false;
-
-    // Steps 4-5.
-    Rooted<PropertyDescriptor> desc(cx);
-    if (!ToPropertyDescriptor(cx, args.get(2), true, &desc))
-        return false;
-
-    // Steps 6-8.
-    if (!DefineProperty(cx, obj, id, desc))
-        return false;
-    args.rval().setObject(*obj);
-    return true;
-}
-
 /* ES5 15.2.3.7: Object.defineProperties(O, Properties) */
 static bool
 obj_defineProperties(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     /* Steps 1 and 7. */
     RootedObject obj(cx);
--- a/js/src/builtin/Object.h
+++ b/js/src/builtin/Object.h
@@ -17,50 +17,39 @@ class Value;
 } // namespace JS
 
 namespace js {
 
 // Object constructor native. Exposed only so the JIT can know its address.
 MOZ_MUST_USE bool
 obj_construct(JSContext* cx, unsigned argc, JS::Value* vp);
 
-MOZ_MUST_USE bool
-obj_propertyIsEnumerable(JSContext* cx, unsigned argc, Value* vp);
-
 PlainObject*
 ObjectCreateImpl(JSContext* cx, HandleObject proto, NewObjectKind newKind = GenericObject,
                  HandleObjectGroup group = nullptr);
 
 PlainObject*
 ObjectCreateWithTemplate(JSContext* cx, HandlePlainObject templateObj);
 
 // Object methods exposed so they can be installed in the self-hosting global.
 MOZ_MUST_USE bool
-obj_create(JSContext* cx, unsigned argc, JS::Value* vp);
+obj_propertyIsEnumerable(JSContext* cx, unsigned argc, Value* vp);
 
 MOZ_MUST_USE bool
-obj_defineProperty(JSContext* cx, unsigned argc, JS::Value* vp);
+obj_create(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_getPrototypeOf(JSContext* cx, unsigned argc, JS::Value* vp);
-
-
-MOZ_MUST_USE bool
-obj_isExtensible(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);
 
-// Exposed so SelfHosting.cpp can use it in the OwnPropertyKeys intrinsic
 MOZ_MUST_USE bool
 GetOwnPropertyKeys(JSContext* cx, HandleObject obj, unsigned flags, JS::MutableHandleValue rval);
 
 // Exposed for SelfHosting.cpp
 MOZ_MUST_USE bool
 GetOwnPropertyDescriptorToArray(JSContext* cx, unsigned argc, JS::Value* vp);
 
 /*
--- a/js/src/builtin/Object.js
+++ b/js/src/builtin/Object.js
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // ES stage 4 proposal
 function ObjectGetOwnPropertyDescriptors(O) {
     // Step 1.
     var obj = ToObject(O);
 
     // Step 2.
-    var keys = OwnPropertyKeys(obj);
+    var keys = std_Reflect_ownKeys(obj);
 
     // Step 3.
     var descriptors = {};
 
     // Step 4.
     for (var index = 0, len = keys.length; index < len; index++) {
         var key = keys[index];
 
--- a/js/src/builtin/Reflect.cpp
+++ b/js/src/builtin/Reflect.cpp
@@ -82,18 +82,18 @@ js::Reflect_isExtensible(JSContext* cx, 
     if (!IsExtensible(cx, target, &extensible))
         return false;
     args.rval().setBoolean(extensible);
     return true;
 }
 
 // ES2018 draft rev c164be80f7ea91de5526b33d54e5c9321ed03d3f
 // 26.1.10 Reflect.ownKeys ( target )
-static bool
-Reflect_ownKeys(JSContext* cx, unsigned argc, Value* vp)
+bool
+js::Reflect_ownKeys(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     // Step 1.
     RootedObject target(cx, NonNullObjectArg(cx, "`target`", "Reflect.ownKeys", args.get(0)));
     if (!target)
         return false;
 
--- a/js/src/builtin/Reflect.h
+++ b/js/src/builtin/Reflect.h
@@ -19,11 +19,14 @@ InitReflect(JSContext* cx, js::HandleObj
 namespace js {
 
 extern MOZ_MUST_USE bool
 Reflect_getPrototypeOf(JSContext* cx, unsigned argc, Value* vp);
 
 extern MOZ_MUST_USE bool
 Reflect_isExtensible(JSContext* cx, unsigned argc, Value* vp);
 
+extern MOZ_MUST_USE bool
+Reflect_ownKeys(JSContext* cx, unsigned argc, Value* vp);
+
 }
 
 #endif /* builtin_Reflect_h */
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -257,27 +257,16 @@ intrinsic_SubstringKernel(JSContext* cx,
     JSString* substr = SubstringKernel(cx, str, begin, length);
     if (!substr)
         return false;
 
     args.rval().setString(substr);
     return true;
 }
 
-static bool
-intrinsic_OwnPropertyKeys(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    MOZ_ASSERT(args.length() == 1);
-    MOZ_ASSERT(args[0].isObject());
-    RootedObject obj(cx, &args[0].toObject());
-    return GetOwnPropertyKeys(cx, obj, JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS,
-                              args.rval());
-}
-
 static void
 ThrowErrorWithType(JSContext* cx, JSExnType type, const CallArgs& args)
 {
     uint32_t errorNumber = args[0].toInt32();
 
 #ifdef DEBUG
     const JSErrorFormatString* efs = GetErrorMessage(nullptr, errorNumber);
     MOZ_ASSERT(efs->argCount == args.length() - 1);
@@ -2253,16 +2242,17 @@ static const JSFunctionSpec intrinsic_fu
     JS_INLINABLE_FN("std_Object_create",         obj_create,                   2, 0, ObjectCreate),
     JS_FN("std_Object_propertyIsEnumerable",     obj_propertyIsEnumerable,     1,0),
     JS_FN("std_Object_getOwnPropertyNames",      obj_getOwnPropertyNames,      1,0),
     JS_FN("std_Object_toString",                 obj_toString,                 0,0),
 
     JS_INLINABLE_FN("std_Reflect_getPrototypeOf", Reflect_getPrototypeOf,      1,0,
                     ReflectGetPrototypeOf),
     JS_FN("std_Reflect_isExtensible",            Reflect_isExtensible,         1,0),
+    JS_FN("std_Reflect_ownKeys",                 Reflect_ownKeys,              1,0),
 
     JS_FN("std_Set_has",                         SetObject::has,               1,0),
     JS_FN("std_Set_iterator",                    SetObject::values,            0,0),
 
     JS_INLINABLE_FN("std_String_fromCharCode",   str_fromCharCode,             1,0, StringFromCharCode),
     JS_INLINABLE_FN("std_String_fromCodePoint",  str_fromCodePoint,            1,0, StringFromCodePoint),
     JS_INLINABLE_FN("std_String_charCodeAt",     str_charCodeAt,               1,0, StringCharCodeAt),
     JS_FN("std_String_includes",                 str_includes,                 1,0),
@@ -2320,17 +2310,16 @@ static const JSFunctionSpec intrinsic_fu
     JS_FN("ThrowRangeError",         intrinsic_ThrowRangeError,         4,0),
     JS_FN("ThrowTypeError",          intrinsic_ThrowTypeError,          4,0),
     JS_FN("ThrowSyntaxError",        intrinsic_ThrowSyntaxError,        4,0),
     JS_FN("ThrowInternalError",      intrinsic_ThrowInternalError,      4,0),
     JS_FN("GetErrorMessage",         intrinsic_GetErrorMessage,         1,0),
     JS_FN("CreateModuleSyntaxError", intrinsic_CreateModuleSyntaxError, 4,0),
     JS_FN("AssertionFailed",         intrinsic_AssertionFailed,         1,0),
     JS_FN("DumpMessage",             intrinsic_DumpMessage,             1,0),
-    JS_FN("OwnPropertyKeys",         intrinsic_OwnPropertyKeys,         1,0),
     JS_FN("MakeDefaultConstructor",  intrinsic_MakeDefaultConstructor,  2,0),
     JS_FN("_ConstructorForTypedArray", intrinsic_ConstructorForTypedArray, 1,0),
     JS_FN("_NameForTypedArray",      intrinsic_NameForTypedArray, 1,0),
     JS_FN("DecompileArg",            intrinsic_DecompileArg,            2,0),
     JS_INLINABLE_FN("_FinishBoundFunctionInit", intrinsic_FinishBoundFunctionInit, 3,0,
                     IntrinsicFinishBoundFunctionInit),
     JS_FN("RuntimeDefaultLocale",    intrinsic_RuntimeDefaultLocale,    0,0),
     JS_FN("IsRuntimeDefaultLocale",  intrinsic_IsRuntimeDefaultLocale,  1,0),