Bug 1506323 - Add JS::PrintError to public API. r=tcampbell
☠☠ backed out by 22e8321b69f1 ☠ ☠
authorPhilip Chimento <philip.chimento@gmail.com>
Thu, 15 Nov 2018 16:28:03 +0000
changeset 503316 26933ef9fa13275dd7005d1db78f5268008c25b0
parent 503315 b3412b91afe2f6fabaf3a9b13c65e8ee45d9c1b4
child 503317 7be95c95a3a7254bcff022190ab2be27ca27ac50
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1506323
milestone65.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 1506323 - Add JS::PrintError to public API. r=tcampbell Depends on D11568 Differential Revision: https://phabricator.services.mozilla.com/D11569
js/src/jsapi.h
js/src/shell/js.cpp
js/src/vm/JSContext.cpp
js/src/vm/JSContext.h
js/src/vm/SelfHosting.cpp
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4281,16 +4281,26 @@ SetWarningReporter(JSContext* cx, Warnin
 extern JS_PUBLIC_API(WarningReporter)
 GetWarningReporter(JSContext* cx);
 
 extern JS_PUBLIC_API(bool)
 CreateError(JSContext* cx, JSExnType type, HandleObject stack,
             HandleString fileName, uint32_t lineNumber, uint32_t columnNumber,
             JSErrorReport* report, HandleString message, MutableHandleValue rval);
 
+/*
+ * Prints a full report and returns true if the given report is non-nullptr
+ * and the report doesn't have the JSREPORT_WARNING flag set or reportWarnings
+ * is true.
+ * Returns false otherwise.
+ */
+extern JS_PUBLIC_API(bool)
+PrintError(JSContext* cx, FILE* file, ConstUTF8CharsZ toStringResult,
+           JSErrorReport* report, bool reportWarnings);
+
 /************************************************************************/
 
 /*
  * Weak Maps.
  */
 
 extern JS_PUBLIC_API(JSObject*)
 NewWeakMapObject(JSContext* cx);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -9470,17 +9470,17 @@ js::shell::AutoReportException::~AutoRep
         fflush(stderr);
         JS_ClearPendingException(cx);
         return;
     }
 
     MOZ_ASSERT(!JSREPORT_IS_WARNING(report.report()->flags));
 
     FILE* fp = ErrorFilePointer();
-    PrintError(cx, fp, report.toStringResult(), report.report(), reportWarnings);
+    JS::PrintError(cx, fp, report.toStringResult(), report.report(), reportWarnings);
 
     {
         JS::AutoSaveExceptionState savedExc(cx);
         if (!PrintStackTrace(cx, exn)) {
             fputs("(Unable to print stack trace)\n", fp);
         }
         savedExc.restore();
     }
@@ -9516,17 +9516,17 @@ js::shell::WarningReporter(JSContext* cx
         if (!CreateLastWarningObject(cx, report)) {
             fputs("Unhandled error happened while creating last warning object.\n", fp);
             fflush(fp);
         }
         savedExc.restore();
     }
 
     // Print the warning.
-    PrintError(cx, fp, JS::ConstUTF8CharsZ(), report, reportWarnings);
+    JS::PrintError(cx, fp, JS::ConstUTF8CharsZ(), report, reportWarnings);
 }
 
 static bool
 global_enumerate(JSContext* cx, JS::HandleObject obj, JS::AutoIdVector& properties,
                  bool enumerableOnly)
 {
 #ifdef LAZY_STANDARD_CLASSES
     return JS_NewEnumerateStandardClasses(cx, obj, properties, enumerableOnly);
--- a/js/src/vm/JSContext.cpp
+++ b/js/src/vm/JSContext.cpp
@@ -573,18 +573,18 @@ PrintSingleError(JSContext* cx, FILE* fi
 
     PrintErrorLine(file, prefix.get(), report);
     fputc('\n', file);
 
     fflush(file);
     return true;
 }
 
-bool
-js::PrintError(JSContext* cx, FILE* file, JS::ConstUTF8CharsZ toStringResult,
+JS_PUBLIC_API(bool)
+JS::PrintError(JSContext* cx, FILE* file, JS::ConstUTF8CharsZ toStringResult,
                JSErrorReport* report, bool reportWarnings)
 {
     MOZ_ASSERT(report);
 
     /* Conditionally ignore reported warnings. */
     if (JSREPORT_IS_WARNING(report->flags) && !reportWarnings) {
         return false;
     }
--- a/js/src/vm/JSContext.h
+++ b/js/src/vm/JSContext.h
@@ -1066,26 +1066,16 @@ ExpandErrorArgumentsVA(JSContext* cx, JS
                        const char16_t** messageArgs,
                        ErrorArgumentsType argumentsType,
                        JSErrorNotes::Note* notep, va_list ap);
 
 /* |callee| requires a usage string provided by JS_DefineFunctionsWithHelp. */
 extern void
 ReportUsageErrorASCII(JSContext* cx, HandleObject callee, const char* msg);
 
-/*
- * Prints a full report and returns true if the given report is non-nullptr
- * and the report doesn't have the JSREPORT_WARNING flag set or reportWarnings
- * is true.
- * Returns false otherwise.
- */
-extern bool
-PrintError(JSContext* cx, FILE* file, JS::ConstUTF8CharsZ toStringResult,
-           JSErrorReport* report, bool reportWarnings);
-
 extern void
 ReportIsNotDefined(JSContext* cx, HandlePropertyName name);
 
 extern void
 ReportIsNotDefined(JSContext* cx, HandleId id);
 
 /*
  * Report an attempt to access the property of a null or undefined value (v).
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -75,17 +75,17 @@ using mozilla::IsInRange;
 using mozilla::Maybe;
 
 static void
 selfHosting_WarningReporter(JSContext* cx, JSErrorReport* report)
 {
     MOZ_ASSERT(report);
     MOZ_ASSERT(JSREPORT_IS_WARNING(report->flags));
 
-    PrintError(cx, stderr, JS::ConstUTF8CharsZ(), report, true);
+    JS::PrintError(cx, stderr, JS::ConstUTF8CharsZ(), report, true);
 }
 
 static bool
 intrinsic_ToObject(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     JSObject* obj = ToObject(cx, args[0]);
     if (!obj) {
@@ -2889,17 +2889,17 @@ MaybePrintAndClearPendingException(JSCon
 
     ErrorReport report(cx);
     if (!report.init(cx, exn, js::ErrorReport::WithSideEffects)) {
         fprintf(file, "out of memory initializing ErrorReport\n");
         return;
     }
 
     MOZ_ASSERT(!JSREPORT_IS_WARNING(report.report()->flags));
-    PrintError(cx, file, report.toStringResult(), report.report(), true);
+    JS::PrintError(cx, file, report.toStringResult(), report.report(), true);
 }
 
 class MOZ_STACK_CLASS AutoSelfHostingErrorReporter
 {
     JSContext* cx_;
     JS::WarningReporter oldReporter_;
 
   public: