Backed out changeset 28bbd9862551 (bug 891107) for mochitest-other failure on a CLOSED TREE
authorTooru Fujisawa <arai_a@mac.com>
Sat, 18 Apr 2015 05:51:22 +0900
changeset 239786 ecdde43f6d6aaa7855910160379c2bf0a2891801
parent 239785 139ae480928c86e542599d5d47b4da16856fe515
child 239787 f56304442f9fcdc9377934ba3ec8ad645aa88278
push id58627
push userarai_a@mac.com
push dateFri, 17 Apr 2015 20:54:46 +0000
treeherdermozilla-inbound@f56304442f9f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs891107
milestone40.0a1
backs out28bbd9862551e953769939e797dd6723f6194f79
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
Backed out changeset 28bbd9862551 (bug 891107) for mochitest-other failure on a CLOSED TREE
js/src/ctypes/CTypes.cpp
js/src/ctypes/ctypes.msg
js/src/jit-test/tests/ctypes/argument-length-abi.js
js/src/jit-test/tests/ctypes/argument-length-array.js
js/src/jit-test/tests/ctypes/argument-length-cdata.js
js/src/jit-test/tests/ctypes/argument-length-ctypes.js
js/src/jit-test/tests/ctypes/argument-length-finalizer.js
js/src/jit-test/tests/ctypes/argument-length-function.js
js/src/jit-test/tests/ctypes/argument-length-int64.js
js/src/jit-test/tests/ctypes/argument-length-pointer.js
js/src/jit-test/tests/ctypes/argument-length-primitive.js
js/src/jit-test/tests/ctypes/argument-length-struct.js
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -1230,25 +1230,16 @@ ArgumentConvError(JSContext* cx, HandleV
   JS_snprintf(indexStr, 16, "%u", argIndex + 1);
 
   JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
                        CTYPESMSG_CONV_ERROR_ARG, valStr, indexStr, funStr);
   return false;
 }
 
 static bool
-ArgumentLengthError(JSContext* cx, const char* fun, const char* count,
-                    const char* s)
-{
-  JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
-                       CTYPESMSG_WRONG_ARG_LENGTH, fun, count, s);
-  return false;
-}
-
-static bool
 ArrayLengthMismatch(JSContext* cx, unsigned expectedLength, HandleObject arrObj,
                     unsigned actualLength, HandleValue actual,
                     ConversionType convType)
 {
   MOZ_ASSERT(arrObj && CType::IsCType(arrObj));
 
   JSAutoByteString valBytes;
   const char* valStr = CTypesToSourceForError(cx, actual, valBytes);
@@ -3838,17 +3829,18 @@ CType::ConstructData(JSContext* cx,
 }
 
 bool
 CType::ConstructBasic(JSContext* cx,
                       HandleObject obj,
                       const CallArgs& args)
 {
   if (args.length() > 1) {
-    return ArgumentLengthError(cx, "CType constructor", "at most one", "");
+    JS_ReportError(cx, "CType constructor takes zero or one argument");
+    return false;
   }
 
   // construct a CData object
   RootedObject result(cx, CData::Create(cx, obj, NullPtr(), nullptr, true));
   if (!result)
     return false;
 
   if (args.length() == 1) {
@@ -4360,17 +4352,18 @@ CType::CreateArray(JSContext* cx, unsign
     return false;
   if (!CType::IsCType(baseType)) {
     JS_ReportError(cx, "not a CType");
     return false;
   }
 
   // Construct and return a new ArrayType object.
   if (args.length() > 1) {
-    return ArgumentLengthError(cx, "CType.prototype.array", "at most one", "");
+    JS_ReportError(cx, "array takes zero or one argument");
+    return false;
   }
 
   // Convert the length argument to a size_t.
   size_t length = 0;
   if (args.length() == 1 && !jsvalToSize(cx, args[0], false, &length)) {
     JS_ReportError(cx, "argument must be a nonnegative integer");
     return false;
   }
@@ -4499,17 +4492,18 @@ ABI::IsABI(JSObject* obj)
   return JS_GetClass(obj) == &sCABIClass;
 }
 
 bool
 ABI::ToSource(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   if (args.length() != 0) {
-    return ArgumentLengthError(cx, "ABI.prototype.toSource", "no", "s");
+    JS_ReportError(cx, "toSource takes zero arguments");
+    return false;
   }
 
   JSObject* obj = JS_THIS_OBJECT(cx, vp);
   if (!obj)
     return false;
   if (!ABI::IsABI(obj)) {
     JS_ReportError(cx, "not an ABI");
     return false;
@@ -4543,17 +4537,18 @@ ABI::ToSource(JSContext* cx, unsigned ar
 *******************************************************************************/
 
 bool
 PointerType::Create(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   // Construct and return a new PointerType object.
   if (args.length() != 1) {
-    return ArgumentLengthError(cx, "PointerType", "one", "");
+    JS_ReportError(cx, "PointerType takes one argument");
+    return false;
   }
 
   jsval arg = args[0];
   RootedObject obj(cx);
   if (arg.isPrimitive() || !CType::IsCType(obj = &arg.toObject())) {
     JS_ReportError(cx, "first argument must be a CType");
     return false;
   }
@@ -4608,18 +4603,18 @@ PointerType::ConstructData(JSContext* cx
                            const CallArgs& args)
 {
   if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_pointer) {
     JS_ReportError(cx, "not a PointerType");
     return false;
   }
 
   if (args.length() > 3) {
-    return ArgumentLengthError(cx, "PointerType constructor", "0, 1, 2, or 3",
-                               "s");
+    JS_ReportError(cx, "constructor takes 0, 1, 2, or 3 arguments");
+    return false;
   }
 
   RootedObject result(cx, CData::Create(cx, obj, NullPtr(), nullptr, true));
   if (!result)
     return false;
 
   // Set return value early, must not observe *vp after
   args.rval().setObject(*result);
@@ -4643,17 +4638,18 @@ PointerType::ConstructData(JSContext* cx
   bool looksLikeClosure = CType::GetTypeCode(baseObj) == TYPE_function &&
                           args[0].isObject() && JS::IsCallable(&args[0].toObject());
 
   //
   // Case 2 - Initialized pointer
   //
   if (!looksLikeClosure) {
     if (args.length() != 1) {
-      return ArgumentLengthError(cx, "FunctionType constructor", "one", "");
+      JS_ReportError(cx, "first argument must be a function");
+      return false;
     }
     return ExplicitConvert(cx, args[0], obj, CData::GetData(result),
                            ConversionType::Construct);
   }
 
   //
   // Case 3 - Closure
   //
@@ -4844,17 +4840,18 @@ PointerType::ContentsSetter(JSContext* c
 *******************************************************************************/
 
 bool
 ArrayType::Create(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   // Construct and return a new ArrayType object.
   if (args.length() < 1 || args.length() > 2) {
-    return ArgumentLengthError(cx, "ArrayType", "one or two", "s");
+    JS_ReportError(cx, "ArrayType takes one or two arguments");
+    return false;
   }
 
   if (args[0].isPrimitive() ||
       !CType::IsCType(&args[0].toObject())) {
     JS_ReportError(cx, "first argument must be a CType");
     return false;
   }
 
@@ -4944,24 +4941,24 @@ ArrayType::ConstructData(JSContext* cx,
   // Decide whether we have an object to initialize from. We'll override this
   // if we get a length argument instead.
   bool convertObject = args.length() == 1;
 
   // Check if we're an array of undefined length. If we are, allow construction
   // with a length argument, or with an actual JS array.
   if (CType::IsSizeDefined(obj)) {
     if (args.length() > 1) {
-      return ArgumentLengthError(cx, "size defined ArrayType constructor",
-                                 "at most one", "");
+      JS_ReportError(cx, "constructor takes zero or one argument");
+      return false;
     }
 
   } else {
     if (args.length() != 1) {
-      return ArgumentLengthError(cx, "size undefined ArrayType constructor",
-                                 "one", "");
+      JS_ReportError(cx, "constructor takes one argument");
+      return false;
     }
 
     RootedObject baseType(cx, GetBaseType(obj));
 
     size_t length;
     if (jsvalToSize(cx, args[0], false, &length)) {
       // Have a length, rather than an object to initialize from.
       convertObject = false;
@@ -5266,18 +5263,18 @@ ArrayType::AddressOfElement(JSContext* c
 
   RootedObject typeObj(cx, CData::GetCType(obj));
   if (CType::GetTypeCode(typeObj) != TYPE_array) {
     JS_ReportError(cx, "not an ArrayType");
     return false;
   }
 
   if (args.length() != 1) {
-    return ArgumentLengthError(cx, "ArrayType.prototype.addressOfElement",
-                               "one", "");
+    JS_ReportError(cx, "addressOfElement takes one argument");
+    return false;
   }
 
   RootedObject baseType(cx, GetBaseType(typeObj));
   RootedObject pointerType(cx, PointerType::CreateInternal(cx, baseType));
   if (!pointerType)
     return false;
 
   // Create a PointerType CData object containing null.
@@ -5387,17 +5384,18 @@ AddFieldToArray(JSContext* cx,
 
 bool
 StructType::Create(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
 
   // Construct and return a new StructType object.
   if (args.length() < 1 || args.length() > 2) {
-    return ArgumentLengthError(cx, "StructType", "one or two", "s");
+    JS_ReportError(cx, "StructType takes one or two arguments");
+    return false;
   }
 
   jsval name = args[0];
   if (!name.isString()) {
     JS_ReportError(cx, "first argument must be a string");
     return false;
   }
 
@@ -5675,17 +5673,18 @@ StructType::Define(JSContext* cx, unsign
   }
 
   if (CType::IsSizeDefined(obj)) {
     JS_ReportError(cx, "StructType has already been defined");
     return false;
   }
 
   if (args.length() != 1) {
-    return ArgumentLengthError(cx, "StructType.prototype.define", "one", "");
+    JS_ReportError(cx, "define takes one argument");
+    return false;
   }
 
   jsval arg = args[0];
   if (arg.isPrimitive()) {
     JS_ReportError(cx, "argument must be an array");
     return false;
   }
   RootedObject arr(cx, arg.toObjectOrNull());
@@ -5762,24 +5761,19 @@ StructType::ConstructData(JSContext* cx,
                            buffer + field.mOffset, ConversionType::Construct,
                            nullptr, NullPtr(), 0, obj, field.mIndex))
         return false;
     }
 
     return true;
   }
 
-  size_t count = fields->count();
-  if (count >= 2) {
-    char fieldLengthStr[32];
-    JS_snprintf(fieldLengthStr, 32, "0, 1, or %u", count);
-    return ArgumentLengthError(cx, "StructType constructor", fieldLengthStr,
-                               "s");
-  }
-  return ArgumentLengthError(cx, "StructType constructor", "at most one", "");
+  JS_ReportError(cx, "constructor takes 0, 1, or %u arguments",
+    fields->count());
+  return false;
 }
 
 const FieldInfoHash*
 StructType::GetFieldInfo(JSObject* obj)
 {
   MOZ_ASSERT(CType::IsCType(obj));
   MOZ_ASSERT(CType::GetTypeCode(obj) == TYPE_struct);
 
@@ -5965,18 +5959,18 @@ StructType::AddressOfField(JSContext* cx
 
   JSObject* typeObj = CData::GetCType(obj);
   if (CType::GetTypeCode(typeObj) != TYPE_struct) {
     JS_ReportError(cx, "not a StructType");
     return false;
   }
 
   if (args.length() != 1) {
-    return ArgumentLengthError(cx, "StructType.prototype.addressOfField",
-                               "one", "");
+    JS_ReportError(cx, "addressOfField takes one argument");
+    return false;
   }
 
   if (!args[0].isString()) {
     JS_ReportError(cx, "argument must be a string");
     return false;
   }
 
   JSFlatString* str = JS_FlattenString(cx, args[0].toString());
@@ -6310,17 +6304,18 @@ CreateFunctionInfo(JSContext* cx,
 }
 
 bool
 FunctionType::Create(JSContext* cx, unsigned argc, jsval* vp)
 {
   // Construct and return a new FunctionType object.
   CallArgs args = CallArgsFromVp(argc, vp);
   if (args.length() < 2 || args.length() > 3) {
-    return ArgumentLengthError(cx, "FunctionType", "two or three", "s");
+    JS_ReportError(cx, "FunctionType takes two or three arguments");
+    return false;
   }
 
   AutoValueVector argTypes(cx);
   RootedObject arrayObj(cx, nullptr);
 
   if (args.length() == 3) {
     // Prepare an array of jsvals for the arguments.
     if (args[2].isObject())
@@ -7155,17 +7150,18 @@ CData::ValueSetter(JSContext* cx, JS::Ca
                          ConversionType::Setter, nullptr);
 }
 
 bool
 CData::Address(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   if (args.length() != 0) {
-    return ArgumentLengthError(cx, "CData.prototype.address", "no", "s");
+    JS_ReportError(cx, "address takes zero arguments");
+    return false;
   }
 
   RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
   if (!obj)
     return false;
   if (!IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return false;
@@ -7189,17 +7185,18 @@ CData::Address(JSContext* cx, unsigned a
   return true;
 }
 
 bool
 CData::Cast(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   if (args.length() != 2) {
-    return ArgumentLengthError(cx, "ctypes.cast", "two", "s");
+    JS_ReportError(cx, "cast takes two arguments");
+    return false;
   }
 
   if (args[0].isPrimitive() || !CData::IsCData(&args[0].toObject())) {
     JS_ReportError(cx, "first argument must be a CData");
     return false;
   }
   RootedObject sourceData(cx, &args[0].toObject());
   JSObject* sourceType = CData::GetCType(sourceData);
@@ -7229,17 +7226,18 @@ CData::Cast(JSContext* cx, unsigned argc
   return true;
 }
 
 bool
 CData::GetRuntime(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   if (args.length() != 1) {
-    return ArgumentLengthError(cx, "ctypes.getRuntime", "one", "");
+    JS_ReportError(cx, "getRuntime takes one argument");
+    return false;
   }
 
   if (args[0].isPrimitive() || !CType::IsCType(&args[0].toObject())) {
     JS_ReportError(cx, "first argument must be a CType");
     return false;
   }
 
   RootedObject targetType(cx, &args[0].toObject());
@@ -7261,21 +7259,18 @@ CData::GetRuntime(JSContext* cx, unsigne
 
 typedef JS::TwoByteCharsZ (*InflateUTF8Method)(JSContext*, const JS::UTF8Chars, size_t*);
 
 static bool
 ReadStringCommon(JSContext* cx, InflateUTF8Method inflateUTF8, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   if (args.length() != 0) {
-    if (inflateUTF8 == JS::UTF8CharsToNewTwoByteCharsZ) {
-      return ArgumentLengthError(cx, "CData.prototype.readString", "no", "s");
-    }
-    return ArgumentLengthError(cx, "CData.prototype.readStringReplaceMalformed",
-                               "no", "s");
+    JS_ReportError(cx, "readString takes zero arguments");
+    return false;
   }
 
   JSObject* obj = CDataFinalizer::GetCData(cx, JS_THIS_OBJECT(cx, vp));
   if (!obj || !CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return false;
   }
 
@@ -7380,17 +7375,18 @@ CData::GetSourceString(JSContext* cx, Ha
   return NewUCString(cx, source);
 }
 
 bool
 CData::ToSource(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   if (args.length() != 0) {
-    return ArgumentLengthError(cx, "CData.prototype.toSource", "no", "s");
+    JS_ReportError(cx, "toSource takes zero arguments");
+    return false;
   }
 
   JSObject* obj = JS_THIS_OBJECT(cx, vp);
   if (!obj)
     return false;
   if (!CData::IsCData(obj) && !CData::IsCDataProto(obj)) {
     JS_ReportError(cx, "not a CData");
     return false;
@@ -7608,17 +7604,18 @@ CDataFinalizer::Construct(JSContext* cx,
   // Get arguments
   if (args.length() == 0) { // Special case: the empty (already finalized) object
     JSObject* objResult = JS_NewObjectWithGivenProto(cx, &sCDataFinalizerClass, objProto);
     args.rval().setObject(*objResult);
     return true;
   }
 
   if (args.length() != 2) {
-    return ArgumentLengthError(cx, "CDataFinalizer constructor", "two", "s");
+    JS_ReportError(cx, "CDataFinalizer takes 2 arguments");
+    return false;
   }
 
   JS::HandleValue valCodePtr = args[1];
   if (!valCodePtr.isObject()) {
     return TypeError(cx, "_a CData object_ of a function pointer type",
                      valCodePtr);
   }
   JSObject* objCodePtr = &valCodePtr.toObject();
@@ -7822,18 +7819,18 @@ CDataFinalizer::CallFinalizer(CDataFinal
  * Does not call the finalizer. Cleans up the Private memory and releases all
  * strong references.
  */
 bool
 CDataFinalizer::Methods::Forget(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   if (args.length() != 0) {
-    return ArgumentLengthError(cx, "CDataFinalizer.prototype.forget", "no",
-                               "s");
+    JS_ReportError(cx, "CDataFinalizer.prototype.forget takes no arguments");
+    return false;
   }
 
   JS::Rooted<JSObject*> obj(cx, args.thisv().toObjectOrNull());
   if (!obj)
     return false;
   if (!CDataFinalizer::IsCDataFinalizer(obj)) {
     JS_ReportError(cx, "not a CDataFinalizer");
     return false;
@@ -7870,18 +7867,18 @@ CDataFinalizer::Methods::Forget(JSContex
  * Calls the finalizer, cleans up the Private memory and releases all
  * strong references.
  */
 bool
 CDataFinalizer::Methods::Dispose(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   if (args.length() != 0) {
-    return ArgumentLengthError(cx, "CDataFinalizer.prototype.dispose", "no",
-                               "s");
+    JS_ReportError(cx, "CDataFinalizer.prototype.dispose takes no arguments");
+    return false;
   }
 
   RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
   if (!obj)
     return false;
   if (!CDataFinalizer::IsCDataFinalizer(obj)) {
     JS_ReportError(cx, "not a CDataFinalizer");
     return false;
@@ -8044,22 +8041,18 @@ Int64Base::GetInt(JSObject* obj) {
 
 bool
 Int64Base::ToString(JSContext* cx,
                     JSObject* obj,
                     const CallArgs& args,
                     bool isUnsigned)
 {
   if (args.length() > 1) {
-    if (isUnsigned) {
-      return ArgumentLengthError(cx, "UInt64.prototype.toString",
-                                 "at most one", "");
-    }
-    return ArgumentLengthError(cx, "Int64.prototype.toString",
-                               "at most one", "");
+    JS_ReportError(cx, "toString takes zero or one argument");
+    return false;
   }
 
   int radix = 10;
   if (args.length() == 1) {
     jsval arg = args[0];
     if (arg.isInt32())
       radix = arg.toInt32();
     if (!arg.isInt32() || radix < 2 || radix > 36) {
@@ -8085,20 +8078,18 @@ Int64Base::ToString(JSContext* cx,
 
 bool
 Int64Base::ToSource(JSContext* cx,
                     JSObject* obj,
                     const CallArgs& args,
                     bool isUnsigned)
 {
   if (args.length() != 0) {
-    if (isUnsigned) {
-      return ArgumentLengthError(cx, "UInt64.prototype.toSource", "no", "s");
-    }
-    return ArgumentLengthError(cx, "Int64.prototype.toSource", "no", "s");
+    JS_ReportError(cx, "toSource takes zero arguments");
+    return false;
   }
 
   // Return a decimal string suitable for constructing the number.
   AutoString source;
   if (isUnsigned) {
     AppendString(source, "ctypes.UInt64(\"");
     IntegerToString(GetInt(obj), 10, source);
   } else {
@@ -8119,17 +8110,18 @@ bool
 Int64::Construct(JSContext* cx,
                  unsigned argc,
                  jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
 
   // Construct and return a new Int64 object.
   if (args.length() != 1) {
-    return ArgumentLengthError(cx, "Int64 constructor", "one", "");
+    JS_ReportError(cx, "Int64 takes one argument");
+    return false;
   }
 
   int64_t i = 0;
   if (!jsvalToBigInteger(cx, args[0], true, &i)) {
     return ArgumentConvError(cx, args[0], "Int64", 0);
   }
 
   // Get ctypes.Int64.prototype from the 'prototype' property of the ctor.
@@ -8182,20 +8174,18 @@ Int64::ToSource(JSContext* cx, unsigned 
 
   return Int64Base::ToSource(cx, obj, args, false);
 }
 
 bool
 Int64::Compare(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
-  if (args.length() != 2) {
-    return ArgumentLengthError(cx, "Int64.compare", "two", "s");
-  }
-  if (args[0].isPrimitive() ||
+  if (args.length() != 2 ||
+      args[0].isPrimitive() ||
       args[1].isPrimitive() ||
       !Int64::IsInt64(&args[0].toObject()) ||
       !Int64::IsInt64(&args[1].toObject())) {
     JS_ReportError(cx, "compare takes two Int64 arguments");
     return false;
   }
 
   JSObject* obj1 = &args[0].toObject();
@@ -8217,40 +8207,36 @@ Int64::Compare(JSContext* cx, unsigned a
 #define LO_MASK ((uint64_t(1) << 32) - 1)
 #define INT64_LO(i) ((i) & LO_MASK)
 #define INT64_HI(i) ((i) >> 32)
 
 bool
 Int64::Lo(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
-  if (args.length() != 1) {
-    return ArgumentLengthError(cx, "Int64.lo", "one", "");
-  }
-  if (args[0].isPrimitive() || !Int64::IsInt64(&args[0].toObject())) {
+  if (args.length() != 1 || args[0].isPrimitive() ||
+      !Int64::IsInt64(&args[0].toObject())) {
     JS_ReportError(cx, "lo takes one Int64 argument");
     return false;
   }
 
   JSObject* obj = &args[0].toObject();
   int64_t u = Int64Base::GetInt(obj);
   double d = uint32_t(INT64_LO(u));
 
   args.rval().setNumber(d);
   return true;
 }
 
 bool
 Int64::Hi(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
-  if (args.length() != 1) {
-    return ArgumentLengthError(cx, "Int64.hi", "one", "");
-  }
-  if (args[0].isPrimitive() || !Int64::IsInt64(&args[0].toObject())) {
+  if (args.length() != 1 || args[0].isPrimitive() ||
+      !Int64::IsInt64(&args[0].toObject())) {
     JS_ReportError(cx, "hi takes one Int64 argument");
     return false;
   }
 
   JSObject* obj = &args[0].toObject();
   int64_t u = Int64Base::GetInt(obj);
   double d = int32_t(INT64_HI(u));
 
@@ -8258,17 +8244,18 @@ Int64::Hi(JSContext* cx, unsigned argc, 
   return true;
 }
 
 bool
 Int64::Join(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   if (args.length() != 2) {
-    return ArgumentLengthError(cx, "Int64.join", "two", "s");
+    JS_ReportError(cx, "join takes two arguments");
+    return false;
   }
 
   int32_t hi;
   uint32_t lo;
   if (!jsvalToInteger(cx, args[0], &hi))
     return ArgumentConvError(cx, args[0], "Int64.join", 0);
   if (!jsvalToInteger(cx, args[1], &lo))
     return ArgumentConvError(cx, args[1], "Int64.join", 1);
@@ -8294,17 +8281,18 @@ bool
 UInt64::Construct(JSContext* cx,
                   unsigned argc,
                   jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
 
   // Construct and return a new UInt64 object.
   if (args.length() != 1) {
-    return ArgumentLengthError(cx, "UInt64 constructor", "one", "");
+    JS_ReportError(cx, "UInt64 takes one argument");
+    return false;
   }
 
   uint64_t u = 0;
   if (!jsvalToBigInteger(cx, args[0], true, &u)) {
     return ArgumentConvError(cx, args[0], "UInt64", 0);
   }
 
   // Get ctypes.UInt64.prototype from the 'prototype' property of the ctor.
@@ -8357,20 +8345,18 @@ UInt64::ToSource(JSContext* cx, unsigned
 
   return Int64Base::ToSource(cx, obj, args, true);
 }
 
 bool
 UInt64::Compare(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
-  if (args.length() != 2) {
-    return ArgumentLengthError(cx, "UInt64.compare", "two", "s");
-  }
-  if (args[0].isPrimitive() ||
+  if (args.length() != 2 ||
+      args[0].isPrimitive() ||
       args[1].isPrimitive() ||
       !UInt64::IsUInt64(&args[0].toObject()) ||
       !UInt64::IsUInt64(&args[1].toObject())) {
     JS_ReportError(cx, "compare takes two UInt64 arguments");
     return false;
   }
 
   JSObject* obj1 = &args[0].toObject();
@@ -8388,40 +8374,36 @@ UInt64::Compare(JSContext* cx, unsigned 
 
   return true;
 }
 
 bool
 UInt64::Lo(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
-  if (args.length() != 1) {
-    return ArgumentLengthError(cx, "UInt64.lo", "one", "");
-  }
-  if (args[0].isPrimitive() || !UInt64::IsUInt64(&args[0].toObject())) {
+  if (args.length() != 1 || args[0].isPrimitive() ||
+      !UInt64::IsUInt64(&args[0].toObject())) {
     JS_ReportError(cx, "lo takes one UInt64 argument");
     return false;
   }
 
   JSObject* obj = &args[0].toObject();
   uint64_t u = Int64Base::GetInt(obj);
   double d = uint32_t(INT64_LO(u));
 
   args.rval().setDouble(d);
   return true;
 }
 
 bool
 UInt64::Hi(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
-  if (args.length() != 1) {
-    return ArgumentLengthError(cx, "UInt64.hi", "one", "");
-  }
-  if (args[0].isPrimitive() || !UInt64::IsUInt64(&args[0].toObject())) {
+  if (args.length() != 1 || args[0].isPrimitive() ||
+      !UInt64::IsUInt64(&args[0].toObject())) {
     JS_ReportError(cx, "hi takes one UInt64 argument");
     return false;
   }
 
   JSObject* obj = &args[0].toObject();
   uint64_t u = Int64Base::GetInt(obj);
   double d = uint32_t(INT64_HI(u));
 
@@ -8429,17 +8411,18 @@ UInt64::Hi(JSContext* cx, unsigned argc,
   return true;
 }
 
 bool
 UInt64::Join(JSContext* cx, unsigned argc, jsval* vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   if (args.length() != 2) {
-    return ArgumentLengthError(cx, "UInt64.join", "two", "s");
+    JS_ReportError(cx, "join takes two arguments");
+    return false;
   }
 
   uint32_t hi;
   uint32_t lo;
   if (!jsvalToInteger(cx, args[0], &hi))
     return ArgumentConvError(cx, args[0], "UInt64.join", 0);
   if (!jsvalToInteger(cx, args[1], &lo))
     return ArgumentConvError(cx, args[1], "UInt64.join", 1);
--- a/js/src/ctypes/ctypes.msg
+++ b/js/src/ctypes/ctypes.msg
@@ -27,11 +27,8 @@ MSG_DEF(CTYPESMSG_ARRAY_OVERFLOW,4, JSEX
 
 /* struct */
 MSG_DEF(CTYPESMSG_FIELD_MISMATCH,5, JSEXN_TYPEERR, "property count of {0} does not match to field count of the type {1} (expected {2}, got {3}){4}")
 MSG_DEF(CTYPESMSG_PROP_NONSTRING,3, JSEXN_TYPEERR, "property name {0} of {1} is not a string{2}")
 
 /* data finalizer */
 MSG_DEF(CTYPESMSG_EMPTY_FIN,     1, JSEXN_TYPEERR, "attempting to convert an empty CDataFinalizer{0}")
 MSG_DEF(CTYPESMSG_FIN_SIZE_ERROR,2, JSEXN_TYPEERR, "expected an object with the same size as argument 1 of {0}, got {1}")
-
-/* native function */
-MSG_DEF(CTYPESMSG_WRONG_ARG_LENGTH,3, JSEXN_TYPEERR, "{0} takes {1} argument{2}")
deleted file mode 100644
--- a/js/src/jit-test/tests/ctypes/argument-length-abi.js
+++ /dev/null
@@ -1,9 +0,0 @@
-load(libdir + 'asserts.js');
-
-function test() {
-  assertTypeErrorMessage(() => { ctypes.default_abi.toSource(1); },
-                         "ABI.prototype.toSource takes no arguments");
-}
-
-if (typeof ctypes === "object")
-  test();
deleted file mode 100644
--- a/js/src/jit-test/tests/ctypes/argument-length-array.js
+++ /dev/null
@@ -1,15 +0,0 @@
-load(libdir + 'asserts.js');
-
-function test() {
-  assertTypeErrorMessage(() => { ctypes.ArrayType(); },
-                         "ArrayType takes one or two arguments");
-  assertTypeErrorMessage(() => { ctypes.int32_t.array(10)(1, 2); },
-                         "size defined ArrayType constructor takes at most one argument");
-  assertTypeErrorMessage(() => { ctypes.int32_t.array()(1, 2); },
-                         "size undefined ArrayType constructor takes one argument");
-  assertTypeErrorMessage(() => { ctypes.int32_t.array(10)().addressOfElement(); },
-                         "ArrayType.prototype.addressOfElement takes one argument");
-}
-
-if (typeof ctypes === "object")
-  test();
deleted file mode 100644
--- a/js/src/jit-test/tests/ctypes/argument-length-cdata.js
+++ /dev/null
@@ -1,15 +0,0 @@
-load(libdir + 'asserts.js');
-
-function test() {
-  assertTypeErrorMessage(() => { ctypes.int32_t(0).address(1); },
-                         "CData.prototype.address takes no arguments");
-  assertTypeErrorMessage(() => { ctypes.char.array(10)().readString(1); },
-                         "CData.prototype.readString takes no arguments");
-  assertTypeErrorMessage(() => { ctypes.char.array(10)().readStringReplaceMalformed(1); },
-                         "CData.prototype.readStringReplaceMalformed takes no arguments");
-  assertTypeErrorMessage(() => { ctypes.int32_t(0).toSource(1); },
-                         "CData.prototype.toSource takes no arguments");
-}
-
-if (typeof ctypes === "object")
-  test();
deleted file mode 100644
--- a/js/src/jit-test/tests/ctypes/argument-length-ctypes.js
+++ /dev/null
@@ -1,11 +0,0 @@
-load(libdir + 'asserts.js');
-
-function test() {
-  assertTypeErrorMessage(() => { ctypes.cast(); },
-                         "ctypes.cast takes two arguments");
-  assertTypeErrorMessage(() => { ctypes.getRuntime(); },
-                         "ctypes.getRuntime takes one argument");
-}
-
-if (typeof ctypes === "object")
-  test();
deleted file mode 100644
--- a/js/src/jit-test/tests/ctypes/argument-length-finalizer.js
+++ /dev/null
@@ -1,16 +0,0 @@
-load(libdir + 'asserts.js');
-
-function test() {
-  assertTypeErrorMessage(() => { ctypes.CDataFinalizer(1); },
-                         "CDataFinalizer constructor takes two arguments");
-
-  let fin = ctypes.CDataFinalizer(ctypes.int32_t(0), ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, [ctypes.int32_t]).ptr(x => x));
-  assertTypeErrorMessage(() => { fin.forget(1); },
-                         "CDataFinalizer.prototype.forget takes no arguments");
-  assertTypeErrorMessage(() => { fin.dispose(1); },
-                         "CDataFinalizer.prototype.dispose takes no arguments");
-  fin.forget();
-}
-
-if (typeof ctypes === "object")
-  test();
deleted file mode 100644
--- a/js/src/jit-test/tests/ctypes/argument-length-function.js
+++ /dev/null
@@ -1,11 +0,0 @@
-load(libdir + 'asserts.js');
-
-function test() {
-  assertTypeErrorMessage(() => { ctypes.FunctionType(); },
-                         "FunctionType takes two or three arguments");
-  assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.void_t, []).ptr({}, 1); },
-                         "FunctionType constructor takes one argument");
-}
-
-if (typeof ctypes === "object")
-  test();
deleted file mode 100644
--- a/js/src/jit-test/tests/ctypes/argument-length-int64.js
+++ /dev/null
@@ -1,36 +0,0 @@
-load(libdir + 'asserts.js');
-
-function test() {
-  assertTypeErrorMessage(() => { ctypes.Int64(1).toString(1, 2); },
-                         "Int64.prototype.toString takes at most one argument");
-  assertTypeErrorMessage(() => { ctypes.Int64(1).toSource(1); },
-                         "Int64.prototype.toSource takes no arguments");
-  assertTypeErrorMessage(() => { ctypes.Int64(); },
-                         "Int64 constructor takes one argument");
-  assertTypeErrorMessage(() => { ctypes.Int64.compare(); },
-                         "Int64.compare takes two arguments");
-  assertTypeErrorMessage(() => { ctypes.Int64.lo(); },
-                         "Int64.lo takes one argument");
-  assertTypeErrorMessage(() => { ctypes.Int64.hi(); },
-                         "Int64.hi takes one argument");
-  assertTypeErrorMessage(() => { ctypes.Int64.join(); },
-                         "Int64.join takes two arguments");
-
-  assertTypeErrorMessage(() => { ctypes.UInt64(1).toString(1, 2); },
-                         "UInt64.prototype.toString takes at most one argument");
-  assertTypeErrorMessage(() => { ctypes.UInt64(1).toSource(1); },
-                         "UInt64.prototype.toSource takes no arguments");
-  assertTypeErrorMessage(() => { ctypes.UInt64(); },
-                         "UInt64 constructor takes one argument");
-  assertTypeErrorMessage(() => { ctypes.UInt64.compare(); },
-                         "UInt64.compare takes two arguments");
-  assertTypeErrorMessage(() => { ctypes.UInt64.lo(); },
-                         "UInt64.lo takes one argument");
-  assertTypeErrorMessage(() => { ctypes.UInt64.hi(); },
-                         "UInt64.hi takes one argument");
-  assertTypeErrorMessage(() => { ctypes.UInt64.join(); },
-                         "UInt64.join takes two arguments");
-}
-
-if (typeof ctypes === "object")
-  test();
deleted file mode 100644
--- a/js/src/jit-test/tests/ctypes/argument-length-pointer.js
+++ /dev/null
@@ -1,11 +0,0 @@
-load(libdir + 'asserts.js');
-
-function test() {
-  assertTypeErrorMessage(() => { ctypes.PointerType(); },
-                         "PointerType takes one argument");
-  assertTypeErrorMessage(() => { ctypes.int32_t.ptr(1, 2, 3, 4); },
-                         "PointerType constructor takes 0, 1, 2, or 3 arguments");
-}
-
-if (typeof ctypes === "object")
-  test();
deleted file mode 100644
--- a/js/src/jit-test/tests/ctypes/argument-length-primitive.js
+++ /dev/null
@@ -1,11 +0,0 @@
-load(libdir + 'asserts.js');
-
-function test() {
-  assertTypeErrorMessage(() => { ctypes.int32_t(1, 2, 3); },
-                         "CType constructor takes at most one argument");
-  assertTypeErrorMessage(() => { ctypes.int32_t.array(1, 2); },
-                         "CType.prototype.array takes at most one argument");
-}
-
-if (typeof ctypes === "object")
-  test();
deleted file mode 100644
--- a/js/src/jit-test/tests/ctypes/argument-length-struct.js
+++ /dev/null
@@ -1,17 +0,0 @@
-load(libdir + 'asserts.js');
-
-function test() {
-  assertTypeErrorMessage(() => { ctypes.StructType(); },
-                         "StructType takes one or two arguments");
-  assertTypeErrorMessage(() => { ctypes.StructType("a").define(); },
-                         "StructType.prototype.define takes one argument");
-  assertTypeErrorMessage(() => { ctypes.StructType("a", [])(1, 2, 3); },
-                         "StructType constructor takes at most one argument");
-  assertTypeErrorMessage(() => { ctypes.StructType("a", [ {"x": ctypes.int32_t }, {"y": ctypes.int32_t }, {"z": ctypes.int32_t }])(1, 2); },
-                         "StructType constructor takes 0, 1, or 3 arguments");
-  assertTypeErrorMessage(() => { ctypes.StructType("a", [ {"x": ctypes.int32_t } ])().addressOfField(); },
-                         "StructType.prototype.addressOfField takes one argument");
-}
-
-if (typeof ctypes === "object")
-  test();