Bug 1424394 - Pass va_list* rather than va_list to certain TokenStream error-reporting functions, to hack around issues reported in bug 1363116. r=arai
authorJeff Walden <jwalden@mit.edu>
Sat, 02 Dec 2017 00:41:29 -0800
changeset 396252 35fb9aa192a809fe8bdf3bb80bc249c5b901e5bb
parent 396251 fc3d9bc177b77a645118d9ed512ae7018a1834dc
child 396253 ac57e88e07bd23a14edf050b79451c55c382c0b6
push id33087
push userdluca@mozilla.com
push dateThu, 14 Dec 2017 09:54:55 +0000
treeherdermozilla-central@8062887ff0d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1424394, 1363116
milestone59.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 1424394 - Pass va_list* rather than va_list to certain TokenStream error-reporting functions, to hack around issues reported in bug 1363116. r=arai
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/Parser.cpp
js/src/frontend/TokenStream.cpp
js/src/frontend/TokenStream.h
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -3579,17 +3579,17 @@ BytecodeEmitter::reportExtraWarning(Pars
     TokenPos pos = pn ? pn->pn_pos : tokenStream().currentToken().pos;
 
     va_list args;
     va_start(args, errorNumber);
 
     // FIXME: parser.tokenStream() should be a TokenStreamAnyChars for bug 1351107,
     // but caused problems, cf. bug 1363116.
     bool result = parser.tokenStream()
-                        .reportExtraWarningErrorNumberVA(nullptr, pos.begin, errorNumber, args);
+                        .reportExtraWarningErrorNumberVA(nullptr, pos.begin, errorNumber, &args);
 
     va_end(args);
     return result;
 }
 
 bool
 BytecodeEmitter::emitNewInit(JSProtoKey key)
 {
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -680,58 +680,58 @@ ParserBase::warningAt(uint32_t offset, u
 
 bool
 ParserBase::extraWarning(unsigned errorNumber, ...)
 {
     va_list args;
     va_start(args, errorNumber);
 
     bool result =
-        tokenStream.reportExtraWarningErrorNumberVA(nullptr, pos().begin, errorNumber, args);
+        tokenStream.reportExtraWarningErrorNumberVA(nullptr, pos().begin, errorNumber, &args);
 
     va_end(args);
     return result;
 }
 
 bool
 ParserBase::extraWarningAt(uint32_t offset, unsigned errorNumber, ...)
 {
     va_list args;
     va_start(args, errorNumber);
 
     bool result =
-        tokenStream.reportExtraWarningErrorNumberVA(nullptr, offset, errorNumber, args);
+        tokenStream.reportExtraWarningErrorNumberVA(nullptr, offset, errorNumber, &args);
 
     va_end(args);
     return result;
 }
 
 bool
 ParserBase::strictModeError(unsigned errorNumber, ...)
 {
     va_list args;
     va_start(args, errorNumber);
 
     bool res =
         tokenStream.reportStrictModeErrorNumberVA(nullptr, pos().begin, pc->sc()->strict(),
-                                                  errorNumber, args);
+                                                  errorNumber, &args);
 
     va_end(args);
     return res;
 }
 
 bool
 ParserBase::strictModeErrorAt(uint32_t offset, unsigned errorNumber, ...)
 {
     va_list args;
     va_start(args, errorNumber);
 
     bool res =
         tokenStream.reportStrictModeErrorNumberVA(nullptr, offset, pc->sc()->strict(),
-                                                  errorNumber, args);
+                                                  errorNumber, &args);
 
     va_end(args);
     return res;
 }
 
 bool
 ParserBase::reportNoOffset(ParseReportKind kind, bool strict, unsigned errorNumber, ...)
 {
@@ -754,21 +754,21 @@ ParserBase::reportNoOffset(ParseReportKi
                 tokenStream.compileWarning(Move(metadata), nullptr, JSREPORT_WARNING, errorNumber,
                                            args);
         }
 
         break;
       }
       case ParseExtraWarning:
         result = tokenStream.reportExtraWarningErrorNumberVA(nullptr, TokenStream::NoOffset,
-                                                             errorNumber, args);
+                                                             errorNumber, &args);
         break;
       case ParseStrictError:
         result = tokenStream.reportStrictModeErrorNumberVA(nullptr, TokenStream::NoOffset, strict,
-                                                           errorNumber, args);
+                                                           errorNumber, &args);
         break;
     }
 
     va_end(args);
     return result;
 }
 
 #define ABORTED_SYNTAX_PARSE_SENTINEL (SyntaxParser*)(0x1)
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -665,32 +665,32 @@ TokenStream::seek(const Position& pos, c
     if (!srcCoords.fill(other.srcCoords))
         return false;
     seek(pos);
     return true;
 }
 
 bool
 TokenStream::reportStrictModeErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
-                                           bool strictMode, unsigned errorNumber, va_list args)
+                                           bool strictMode, unsigned errorNumber, va_list* args)
 {
     if (!strictMode && !options().extraWarningsOption)
         return true;
 
     ErrorMetadata metadata;
     if (!computeErrorMetadata(&metadata, offset))
         return false;
 
     if (strictMode) {
-        ReportCompileError(cx, Move(metadata), Move(notes), JSREPORT_ERROR, errorNumber, args);
+        ReportCompileError(cx, Move(metadata), Move(notes), JSREPORT_ERROR, errorNumber, *args);
         return false;
     }
 
     return compileWarning(Move(metadata), Move(notes), JSREPORT_WARNING | JSREPORT_STRICT,
-                          errorNumber, args);
+                          errorNumber, *args);
 }
 
 bool
 TokenStreamAnyChars::compileWarning(ErrorMetadata&& metadata, UniquePtr<JSErrorNotes> notes,
                                     unsigned flags, unsigned errorNumber, va_list args)
 {
     if (options().werrorOption) {
         flags &= ~JSREPORT_WARNING;
@@ -834,17 +834,17 @@ TokenStream::offset() const
 }
 
 bool
 TokenStream::reportStrictModeError(unsigned errorNumber, ...)
 {
     va_list args;
     va_start(args, errorNumber);
     bool result = reportStrictModeErrorNumberVA(nullptr, currentToken().pos.begin, strictMode(),
-                                                errorNumber, args);
+                                                errorNumber, &args);
     va_end(args);
     return result;
 }
 
 void
 TokenStream::reportError(unsigned errorNumber, ...)
 {
     va_list args;
@@ -883,27 +883,27 @@ TokenStream::warning(unsigned errorNumbe
         compileWarning(Move(metadata), nullptr, JSREPORT_WARNING, errorNumber, args);
 
     va_end(args);
     return result;
 }
 
 bool
 TokenStream::reportExtraWarningErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
-                                             unsigned errorNumber, va_list args)
+                                             unsigned errorNumber, va_list* args)
 {
     if (!options().extraWarningsOption)
         return true;
 
     ErrorMetadata metadata;
     if (!computeErrorMetadata(&metadata, offset))
         return false;
 
     return compileWarning(Move(metadata), Move(notes), JSREPORT_STRICT | JSREPORT_WARNING,
-                          errorNumber, args);
+                          errorNumber, *args);
 }
 
 void
 TokenStream::error(unsigned errorNumber, ...)
 {
     va_list args;
     va_start(args, errorNumber);
 
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -689,20 +689,24 @@ class MOZ_STACK_CLASS TokenStream final 
 
   public:
     // Compute error metadata for an error at the given offset.
     MOZ_MUST_USE bool computeErrorMetadata(ErrorMetadata* err, uint32_t offset);
 
     // General-purpose error reporters.  You should avoid calling these
     // directly, and instead use the more succinct alternatives (error(),
     // warning(), &c.) in TokenStream, Parser, and BytecodeEmitter.
+    //
+    // These functions take a |va_list*| parameter, not a |va_list| parameter,
+    // to hack around bug 1363116.  (Longer-term, the right fix is of course to
+    // not use ellipsis functions or |va_list| at all in error reporting.)
     bool reportStrictModeErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
-                                       bool strictMode, unsigned errorNumber, va_list args);
+                                       bool strictMode, unsigned errorNumber, va_list* args);
     bool reportExtraWarningErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
-                                         unsigned errorNumber, va_list args);
+                                         unsigned errorNumber, va_list* args);
 
     JSAtom* getRawTemplateStringAtom() {
         MOZ_ASSERT(currentToken().type == TOK_TEMPLATE_HEAD ||
                    currentToken().type == TOK_NO_SUBS_TEMPLATE);
         const CharT* cur = userbuf.rawCharPtrAt(currentToken().pos.begin + 1);
         const CharT* end;
         if (currentToken().type == TOK_TEMPLATE_HEAD) {
             // Of the form    |`...${|   or   |}...${|