-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Source maps (Refs #1252, Reopens #1267) #1274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Let's add an html file in the test directory. We can't do automatic testing of source maps actually working, but it would hugely help manual bisecting in the future, if all we need to do to verify things manually are to open a web page. |
Test added. |
Are you still working on this branch? (The last commit looks like a wip.) |
Oops, the last two commits were not meant to be pushed. I've unpushed them now... could you have a look to see if this branch now works for you (with Chrome 28)? It'd be nice to have this merged in, and then we can handle optimized source maps later on. (Should work in Nightly too as long as the path passed to |
The test doesn't pass for me,
|
Ok, I updated node, now I see
|
Tweak behavior of post_build; the `post2` hook now expects a function.
Chrome and FF seem to be able to handle the extra empty lines, but no harm making things more accurate. One thing less to worry about when debugging.
This makes it easier to reason about the remainder...
I've rebased the entire branch on incoming, and I've added support for source maps for optimized builds. Basically I hacked the uglify code generator to emit (Also, as discussed offline, the error messages in the above two comments were caused by my usage of newer Node features. We've now upgraded the minimum required version to v0.8, so that should be fine now.) Edit: Hunting down some possible line number inaccuracies at the moment. |
Update on current status of the 'inaccuracies': It turns out that we don't parse the LLVM line numbers correctly if the instruction spans more than two lines. In particular,
Assuming that line number metadata is always added to the end of the instruction, we might be able to fix this simply by assigning every LLVM instruction a line number based on the line where it ends, rather than the line where it begins. |
Interesting, but I am not too worried about slightly incorrect llvm debug info - optimizations like inlining often make debugging trickier anyhow ;) I am more concerned with our making sure that there are no regressions on the test suite with such a change to uglify, and also no slowdowns as well, since this is a bug chunk of our compilation time. We should measure a few of the larger tests like poppler before and after this change. |
(i see you just added more code, please comment in the bug here to ping me when this is ready for review) |
Line numbering of exceptions now work (better) in optimized mode.
NodeWithToken is a string-like type produced by the parser during 'embed tokens' mode, which allows us to track line numbers.
Makes for an easier-to-review pull request.
* Now works on FF Nightly * Test does not run unless explicitly requested
So to be sure I follow, does the isArray change get rid of half the previous slowdown? And the rest is == vs ===, which we still suffer from, but it was countered by optimizing other uses of ==/===? |
Yeah, the isArray change in calculating |
Ok, then I am not sure what the change is that you said you prefer to not do. Can you elaborate a little more on what it would look like, and what speedup we could expect from it? |
Right now in non-debug mode our tokens are of the form
In debug mode they get replaced by
So we have to compare If instead we write a pass that does something like
Then we would be able to use strict comparison on All that said, I'm not entirely confident that we would see a significant increase. Yesterday I converted the other equals operators in |
What is performance like when you revert the isArray optimization? That should tell us how much the rest is. |
I did one better and replaced all the |
Thanks! Yeah, I really don't think we can afford to give up an 18% speedup. And the extra pass would only be done on debug builds? |
Yup, the extra pass would only be needed if source maps are being produced. |
This allows us to use strict comparisons on the node type.
Turns out it wasn't so difficult after all. I'd just overestimated the difficulty after a week debugging all those edge cases. Anyway, instead of writing an extra pass I modified the parser slightly to add the line numbers to the nodes themselves. Running the tests now; will let you know their results tomorrow morning. Edit: |
This allows us to preserve more line numbers when debugging.
Great! What is performance like now? |
I got about the same performance on sqlite that I mentioned previously -- ~13.68s. I haven't re-measured poppler yet. |
Ok, great. I'll do some testing too. |
There is a small conflict now in this branch, I fixed a js optimizer crash yesterday. trivial though |
I'm running tests on this now, no need to rebase it for that conflict. |
@@ -2031,6 +2035,7 @@ function eliminate(ast, memSafe) { | |||
// examine body and note locals | |||
var hasSwitch = false; | |||
traverse(func, function(node, type) { | |||
if (debug && type) type = type.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed here and nowhere else?
I am about to merge this. But as followups, I had one question above, and also: I still see two isArray checks, are they still needed/helpful? |
Merged, thanks! Let's not forget the two followups though. One other thing i noticed was not addressed was changing |
I profiled the isArray stuff and it looks like using the typeof checks ( The The reason for the Thanks for reviewing and merging! |
Source mapping mentions "unable to find original file" on some things in the test suite, like |
I think what is happening is that the static libraries are getting built in some directory, then the resulting bitcode files are getting copied over into a different directory before being linked. The sourcemapper script tries to look for the original source files at link time and thus cannot find them.
|
Yeah, I don't think there's a great way to fix this. Ideally we'd want clang to output absolute paths in its LLVM debug info, but the only time it does that is if we pass in an absolute source path when invoking it. We could have a post-bitcode-compilation pass that rewrote the bitcode output to use absolute paths, but that seems like too much work. It looks like we're generating source maps when testing |
Ok, got it. Makes sense about |
em++ -g tests/exceptions/typed.cpp -o typed.html
should give an effective demonstration of source maps at work.I'm not entirely sure how to fit a test for the HTML generation portion into the test suite. However, the code for that part is fairly simple, so a test may not be absolutely necessary...