Closed Bug 618650 Opened 11 years ago Closed 6 years ago

map JS source coordinates to source language that was translated to JS


(Core :: JavaScript Engine, defect)

Not set





(Reporter: brendan, Assigned: jimb)


(Blocks 1 open bug)


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

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).

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.

Assignee: general → jimb
Mark Miller cited

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

Blocks: js::dbg2
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")
(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.
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".
(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.
GWT 2.5 plugin-free debugger Super Dev Mode relies on Source Maps:
Is this bug still valid?
Echoing Florian ^ Is this bug still valid?
Flags: needinfo?(nfitzgerald)
Yeah, we've been done here for years. For specific bugs related to source mapping, file bugs that block
Closed: 6 years ago
Flags: needinfo?(nfitzgerald)
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.