-
Notifications
You must be signed in to change notification settings - Fork 745
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
Handle single-segment source mapping in source map header decoder #6794
Handle single-segment source mapping in source map header decoder #6794
Conversation
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.
Thanks! The code looks right here.
Please add a test for this - see #5906 for a PR that added similar functionality, so I am hoping the test can be similar to that (maybe extend it?).
(see also the error on CI, there is a minor indentation issue) |
@kripken I've tried to add a unit test.. It's not ideal because I don't have access to the binary reader internals and can't check that the debug information is really parsed, but at least it tests that Can we permanently allow testing this PR please? |
I enabled testing now, but unfortunately I think github will not do that on further pushes to this branch. Github seems to require owners to approve testing each time, for the first PR to a repo. I'm not aware of a way to override that. For a test, this might be good enough, but I was imagining something like We can check in a wasm and a Though, a gtest is also an elegant way to test this. If you prefer that (I'm ok either way) then let's do something like this test: which uses text for the module input and not raw bytes, and does a test on output from the module. |
I need to test Are you suggesting writing a Wat module, then parse it as Module, then serialize it as binary, then using it to initialize E.g. #include "parser/wat-parser.h"
#include "wasm-binary.h"
#include "gtest/gtest.h"
using namespace wasm;
void parseWast(wasm::Module& wasm, const std::string& wast) {
auto parsed = wasm::WATParser::parseModule(wasm, wast);
if (auto* err = parsed.getErr()) {
wasm::Fatal() << err->msg << "\n";
}
}
// Check that debug location parsers can handle single-segment mappings.
TEST(BinaryReaderTest, SourceMappingSingleSegment) {
auto moduleText = "(module)";
Module module;
parseWast(module, moduleText);
BufferWithRandomAccess buffer;
WasmBinaryWriter(&module, buffer, PassOptions());
auto moduleBytes = buffer.getAsChars();
// the rest is the same as before
} (I can't figure out how to use |
Ah, I think you need to copy the line #include "print-test.h" from the top of the example test I linked to. If that's not it, what is the exact error you are seeing? |
Thanks. A few more changes were needed but we figured it out. PTAL. |
Looks good, though this doesn't test the output AFAICT? In my previous comment I suggested two ways in which to do that, but now that I think more about it, I guess there is no debug info to print - is that why you are not testing that? (If so, perhaps add a comment to the test like (Also there is a minor CI error on the order of headers.) |
@kripken a single-segment mapping only has the generated code location info (line/column) but not the source information, so if effectively disables mapping the region of the generated code to a source. It's useful when you have something like: compiled user code, runtime system code (that doesn't correspond to any source code), compiled user code again. In these cases the code in the middle is not mapped, using a single-segment mapping. Normally how I would test this is by checking that If you have a better way to test lmk and I'll update. Please also feel free to update my branch. |
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.
Makes sense, thanks. I added a comment.
To be able to know when we are generating a source map, make `dart compile wasm` aware of the `--no-source-maps` flag. Note: wasm-opt currently cannot handle the mappings we generate. This will be merged after WebAssembly/binaryen#6794 and WebAssembly/binaryen#6795.
Update to the latest g3 version. This version includes WebAssembly/binaryen#6794 which unblocks https://dart-review.googlesource.com/c/sdk/+/378421. Change-Id: I9f4e41df9eb9b49d1048e45d4a12f019412e9887 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379580 Commit-Queue: Ömer Ağacan <[email protected]> Reviewed-by: Martin Kustermann <[email protected]>
This reverts commit a6e8b4e. Reason for revert: Broke Windows SDK targets, binaryen does not seem to build with the C++ compiler used on Windows. Original change's description: > [deps] Update binaryen > > Update to the latest g3 version. > > This version includes WebAssembly/binaryen#6794 > which unblocks https://dart-review.googlesource.com/c/sdk/+/378421. > > Change-Id: I9f4e41df9eb9b49d1048e45d4a12f019412e9887 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379580 > Commit-Queue: Ömer Ağacan <[email protected]> > Reviewed-by: Martin Kustermann <[email protected]> Change-Id: Icb4d51283cff077e40ca0312e51527480a71c3a5 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379600 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Martin Kustermann <[email protected]> Bot-Commit: Rubber Stamper <[email protected]>
Single-segment mappings were already handled in
readNextDebugLocation
, but not inreadSourceMapHeader
.Update
readSourceMapHeader
to handle single-segment mappings.The code to handle single segments is copied from
readNextDebugLocation
.