-
Notifications
You must be signed in to change notification settings - Fork 831
Source map fixes #6550
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
Source map fixes #6550
Changes from all commits
1a79a7f
9fc48ab
e045086
e08fe3b
7292806
63ddcfd
4994c67
b68e90d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -443,8 +443,13 @@ class BinaryenIRToBinaryWriter | |
| void emitDelegate(Try* curr) { writer.emitDelegate(curr); } | ||
| void emitScopeEnd(Expression* curr) { writer.emitScopeEnd(curr); } | ||
| void emitFunctionEnd() { | ||
| // Indicate the debug location corresponding to the end opcode | ||
| // that terminates the function code. | ||
| if (func->epilogLocation.size()) { | ||
| parent.writeDebugLocation(*func->epilogLocation.begin()); | ||
| } else { | ||
| // The end opcode has no debug location. | ||
| parent.writeNoDebugLocation(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed, since we prevent smearing across functions in another way anyhow? That is, this is the end of the function, so marking no-debug will not help any code but the next function, which is already handled by this PR elsewhere I think.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to prevent the debug location on the last instruction to smear on the function epilogue (that is, the (func
;;@ a:1:1
(nop)
;;@
)does not get turned into this: (func
;;@ a:1:1
(nop)
;;@ a:1:1
)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, thanks. Maybe add a comment saying that? |
||
| } | ||
| writer.emitFunctionEnd(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| ;; RUN: wasm-opt %s -g -o %t.wasm -osm %t.wasm.map | ||
| ;; RUN: echo >> %t.wasm.map | ||
| ;; RUN: cat %t.wasm.map | filecheck %s | ||
|
|
||
| ;; Also test with StackIR, which should have identical results. | ||
| ;; | ||
| ;; RUN: wasm-opt %s --generate-stack-ir -o %t.wasm -osm %t.map -g -q | ||
| ;; RUN: echo >> %t.wasm.map | ||
| ;; RUN: cat %t.wasm.map | filecheck %s | ||
|
|
||
| ;; Check that the debug locations do not smear beyond a function | ||
| ;; epilogue to the next function. The encoded segment 'C' means that | ||
| ;; the previous segment is indeed one-byte long. | ||
| ;; CHECK: {"version":3,"sources":["foo"],"names":[],"mappings":"yBAAC,C,GACC"} | ||
| (module | ||
| (func $0 | ||
| ;;@ foo:1:1 | ||
| ) | ||
| (func $1 | ||
| ;;@ foo:2:2 | ||
| ) | ||
| ) |
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.
How does this ensure it only affects the first instruction and not later ones?
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.
It should affect later instructions as well.
This piece of code:
is printed as:
So they should result in the same debug information when read back.
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.
Ah, you mean by the normal rules of propagating from the parent to children? So the first instruction inherits from the prolog, and children of the first instruction inherit from the first instruction, so effectively they inherit from the prologue too? If so that makes sense but the comment was confusing me. Perhaps
The first instruction may inherit its location from the function prologcould beInstructions may inherit their locations from the function prolog.- ?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.
Actually, on reading the code again, I think a simpler way to do this would be, instead of adding code here, to add code to
getPrevious. That method could look at the function prologue if it does not find something else.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.
I'm not sure what you mean since
getPreviousreturns a pointer to an expression. Do you mean I should move some of the code here togetPreviousso that it returns an optional location instead?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.
Maybe I'm missing something, but right now
getPreviousisI am suggesting it be something like
Then this function needs no changes, and can keep calling
getPrevious()on line 63 and if it returns a non-null value, to use that.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.
But
prologLocationhas typestd::set<Function::DebugLocation>.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.
Ah, right. Then more code would need to move into
getPrevious, and then really it would need to be renamed. I agree it's not worth it, sorry for not thinking this totally through.