Last Comment Bug 618650 - map JS source coordinates to source language that was translated to JS
: map JS source coordinates to source language that was translated to JS
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: All All
: -- normal with 8 votes (vote)
: ---
Assigned To: Jim Blandy :jimb
: Jason Orendorff [:jorendorff]
Depends on: 568142 669999 670002
Blocks: js::dbg2
  Show dependency treegraph
Reported: 2010-12-12 00:10 PST by Brendan Eich [:brendan]
Modified: 2015-07-02 08:43 PDT (History)
41 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description Brendan Eich [:brendan] 2010-12-12 00:10:48 PST
We added

//@line n "f"

as a magic comment which, when JSOPTION_ATLINE is set, should cause the next line to be taken as line n of the file named "f". This seems to have been regressed by recent scanner changes, but I'll file that separately.

The idea here is to relieve the source-to-JS translator from having to spew such comments all over the place in generated JS. Instead, the generated JS would set an ideally more concise mapping up using, e.g., JSON.

This was proposed by Jeremy Ashkenas at

Comment 1 Brendan Eich [:brendan] 2010-12-12 13:06:48 PST
See bug 618652 for an @line bug with patch and test (I hope it can be a Firefox 4 ride-along, since it is not a blocker).

Comment 2 Brendan Eich [:brendan] 2010-12-12 22:11:08 PST
In case my @line ref might mislead, source coordinates must be finer grained than lines in our minified world. Line and column, as jimb has planned already.

Comment 3 Brendan Eich [:brendan] 2011-02-08 14:31:39 PST
Mark Miller cited

just now. Syntax aside, the idea lines up with this bug.

Comment 4 Patrick Mueller 2011-06-28 04:49:33 PDT
So, SourceMap Format-ish, in terms of the data model, but in say JSON format?

Guess someone can start hacking away at a document describing that.

Thoughts on how to link the SMAP file/data to the final generated source?

- comment at the bottom of the generated source points to a URL of the SMAP file
- SMAP data included literally as a comment in the generated file
- debugger loads the file using a path-math operation of the JS file URL (remove trailing ".js" if there, append ".smap")
Comment 5 Nick Fitzgerald [:fitzgen] [⏰PDT; UTC-7] 2011-06-28 09:16:35 PDT
(In reply to comment #4)
> - SMAP data included literally as a comment in the generated file

I'm not a fan of inlining the mapping data because this same source mapping protocol is going to be used to debug minified code as well as "transpiled" sources. Because of that, it makes sense to have the mapping data be located in a separate file, to keep the js file sizes as small as possible.

I think either of the other two options would be feasible, and don't have a strong opinion either way at this time.
Comment 6 Patrick Mueller 2011-06-28 09:42:06 PDT
Can anyone point to any other SMAP-like stories for debug?  I'm hesitant to even look at the JSR 45 stuff; the link Brendan pointed to in comment #3 appears to be a copy of the JSR 45 specification.  The "original" JSR 45 spec requires a click-through agreement to read, from the jcp site itself.  Would prefer to look at something "cleaner".
Comment 7 Nick Fitzgerald [:fitzgen] [⏰PDT; UTC-7] 2011-06-28 15:53:26 PDT
(In reply to comment #6)
> Can anyone point to any other SMAP-like stories for debug?

You could look at the way that Closure Compiler generates source maps. See the src/com/google/debugging/sourcemap directory in the source code.
Comment 9 David Rees 2012-05-11 13:44:37 PDT
Chrome 18 has sourcemap support -
Comment 10 Walter K. 2012-07-02 14:11:41 PDT
GWT 2.5 plugin-free debugger Super Dev Mode relies on Source Maps:
Comment 11 Florian Bender 2014-11-22 06:48:57 PST
Is this bug still valid?
Comment 12 Jordan Santell [:jsantell] [@jsantell] (Away from Bugzilla for awhile) 2015-07-02 08:32:09 PDT
Echoing Florian ^ Is this bug still valid?
Comment 13 Nick Fitzgerald [:fitzgen] [⏰PDT; UTC-7] 2015-07-02 08:43:20 PDT
Yeah, we've been done here for years. For specific bugs related to source mapping, file bugs that block

Note You need to log in before you can comment on or make changes to this bug.