Bug 1297706 - Fix FunctionBox::setStart to get the correct line/column. r=njn
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 06 Sep 2016 16:16:39 +0200
changeset 354120 25fbd73ef4274de2566290a5e54b424e688fbb69
parent 354119 47b96bd9bad4e5e78b3d40ebacd190c44cfe26e0
child 354121 c07fb82e97a54ebbe9aeefd566db6836c63a5abb
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1297706
milestone51.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 1297706 - Fix FunctionBox::setStart to get the correct line/column. r=njn
js/src/frontend/SharedContext.h
js/src/frontend/TokenStream.h
js/src/jit-test/tests/arrow-functions/column-number.js
--- a/js/src/frontend/SharedContext.h
+++ b/js/src/frontend/SharedContext.h
@@ -577,18 +577,17 @@ class FunctionBox : public ObjectBox, pu
     // certain parsing features that are necessary in general, but unnecessary
     // for validated asm.js.
     bool useAsmOrInsideUseAsm() const {
         return useAsm || insideUseAsm;
     }
 
     void setStart(const TokenStream& tokenStream) {
         bufStart = tokenStream.currentToken().pos.begin;
-        startLine = tokenStream.getLineno();
-        startColumn = tokenStream.getColumn();
+        tokenStream.srcCoords.lineNumAndColumnIndex(bufStart, &startLine, &startColumn);
     }
 
     void trace(JSTracer* trc) override;
 };
 
 inline FunctionBox*
 SharedContext::asFunctionBox()
 {
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -328,18 +328,16 @@ class MOZ_STACK_CLASS TokenStream
 
     // Accessors.
     const Token& currentToken() const { return tokens[cursor]; }
     bool isCurrentTokenType(TokenKind type) const {
         return currentToken().type == type;
     }
     const CharBuffer& getTokenbuf() const { return tokenbuf; }
     const char* getFilename() const { return filename; }
-    unsigned getLineno() const { return lineno; }
-    unsigned getColumn() const { return userbuf.offset() - linebase - 1; }
     bool getMutedErrors() const { return mutedErrors; }
     JSVersion versionNumber() const { return VersionNumber(options().version); }
     JSVersion versionWithFlags() const { return options().version; }
 
     PropertyName* currentName() const {
         if (isCurrentTokenType(TOK_YIELD))
             return cx->names().yield;
         MOZ_ASSERT(isCurrentTokenType(TOK_NAME));
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/arrow-functions/column-number.js
@@ -0,0 +1,6 @@
+function f() { return g(abcd => Error()); }
+function g(x) { return x(); }
+var err = f(1, 2);
+var lines = err.stack.split("\n");
+assertEq(lines[0].endsWith(":1:33"), true);
+assertEq(lines[1].endsWith(":2:24"), true);