Bug 1415076 - Improve error message about defineProperty r=arai
authorShunta Kikuchi <kikuchi1024r@gmail.com>
Tue, 07 Nov 2017 15:28:20 +0900
changeset 444655 52625c644b7cb10f125df9968d7e9dcc16cd86ff
parent 444654 a1b09919ff7932e14aabb5283c5d06a0767b92e8
child 444656 72f9e62daa10025ea10b70a31ec2d92d971b8565
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1415076
milestone58.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 1415076 - Improve error message about defineProperty r=arai
js/src/builtin/Object.js
js/src/builtin/SelfHostingDefines.h
js/src/vm/SelfHosting.cpp
--- a/js/src/builtin/Object.js
+++ b/js/src/builtin/Object.js
@@ -200,17 +200,17 @@ function ObjectOrReflectDefineProperty(o
 
     // Step 2.
     propertyKey = TO_PROPERTY_KEY(propertyKey);
 
     // Step 3 (Call to 6.2.4.5 ToPropertyDescriptor).
 
     // 6.2.4.5 ToPropertyDescriptor, step 1.
     if (!IsObject(attributes))
-        ThrowTypeError(JSMSG_NOT_NONNULL_OBJECT, DecompileArg(2, obj));
+        ThrowArgTypeNotObject(NOT_OBJECT_KIND_DESCRIPTOR, attributes);
 
     // 6.2.4.5 ToPropertyDescriptor, step 2.
     var attrs = 0, hasValue = false;
     var value, getter = null, setter = null;
 
     // 6.2.4.5 ToPropertyDescriptor, steps 3-4.
     if ("enumerable" in attributes)
         attrs |= attributes.enumerable ? ATTR_ENUMERABLE : ATTR_NONENUMERABLE;
--- a/js/src/builtin/SelfHostingDefines.h
+++ b/js/src/builtin/SelfHostingDefines.h
@@ -136,9 +136,11 @@
 #define STRING_GENERICS_TO_UPPER_CASE         20
 #define STRING_GENERICS_TRIM                  21
 #define STRING_GENERICS_TRIM_LEFT             22
 #define STRING_GENERICS_TRIM_RIGHT            23
 #define STRING_GENERICS_METHODS_LIMIT         24
 
 #define INTL_INTERNALS_OBJECT_SLOT 0
 
+#define NOT_OBJECT_KIND_DESCRIPTOR 0
+
 #endif
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -1870,16 +1870,31 @@ intrinsic_WarnDeprecatedStringMethod(JSC
         cx->compartment()->warnedAboutStringGenericsMethods |= mask;
     }
 
     args.rval().setUndefined();
     return true;
 }
 
 static bool
+intrinsic_ThrowArgTypeNotObject(JSContext* cx, unsigned argc ,Value* vp)
+{
+    CallArgs args = CallArgsFromVp(argc,vp);
+    MOZ_ASSERT(args.length() == 2);
+    MOZ_ASSERT(args[0].isNumber());
+    MOZ_ASSERT(!args[1].isObject());
+    if (args[0].toNumber() == NOT_OBJECT_KIND_DESCRIPTOR)
+        ReportNotObjectWithName(cx, "descriptor", args[1]);
+    else
+        MOZ_CRASH("unexpected kind");
+
+    return false;
+}
+
+static bool
 intrinsic_ConstructFunction(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     MOZ_ASSERT(args.length() == 3);
     MOZ_ASSERT(IsConstructor(args[0]));
     MOZ_ASSERT(IsConstructor(args[1]));
     MOZ_ASSERT(args[2].toObject().is<ArrayObject>());
 
@@ -2500,16 +2515,17 @@ static const JSFunctionSpec intrinsic_fu
     JS_FN("FlatStringMatch", FlatStringMatch, 2,0),
     JS_FN("FlatStringSearch", FlatStringSearch, 2,0),
     JS_INLINABLE_FN("StringReplaceString", intrinsic_StringReplaceString, 3, 0,
                     IntrinsicStringReplaceString),
     JS_INLINABLE_FN("StringSplitString", intrinsic_StringSplitString, 2, 0,
                     IntrinsicStringSplitString),
     JS_FN("StringSplitStringLimit", intrinsic_StringSplitStringLimit, 3, 0),
     JS_FN("WarnDeprecatedStringMethod", intrinsic_WarnDeprecatedStringMethod, 2, 0),
+    JS_FN("ThrowArgTypeNotObject", intrinsic_ThrowArgTypeNotObject, 2, 0),
 
     // See builtin/RegExp.h for descriptions of the regexp_* functions.
     JS_FN("regexp_exec_no_statics", regexp_exec_no_statics, 2,0),
     JS_FN("regexp_test_no_statics", regexp_test_no_statics, 2,0),
     JS_FN("regexp_construct_raw_flags", regexp_construct_raw_flags, 2,0),
 
     JS_FN("IsModule", intrinsic_IsInstanceOfBuiltin<ModuleObject>, 1, 0),
     JS_FN("CallModuleMethodIfWrapped",