Skip to content
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

[NFC] Source maps: Simplify the code and add comments #5912

Merged
merged 5 commits into from
Sep 6, 2023
Merged

Conversation

kripken
Copy link
Member

@kripken kripken commented Aug 30, 2023

Almost entirely trivial, except for this part:

-  if (nextDebugLocation.availablePos == 0 &&
-      nextDebugLocation.previousPos <= pos) {
+  if (nextDebugLocation.availablePos == 0) {
      return;

I believe removing the extra check has no effect. Removing it does not change
anything in the test suite, and logically, if we set availablePos to 0 then we
definitely want to return here - we set it to 0 to indicate there is nothing left
to read, which is what the code after it does.

As a result, we can remove the previousPos field entirely.

cc @JesseCodeBones - am I missing something about previousPos? Do you have
an example maybe that shows it is needed?

@kripken kripken requested a review from aheejin August 30, 2023 22:40
@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Merging #5912 (ecea659) into main (e8adbdd) will decrease coverage by 0.02%.
Report is 4 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5912      +/-   ##
==========================================
- Coverage   42.63%   42.61%   -0.02%     
==========================================
  Files         484      484              
  Lines       74882    74843      -39     
  Branches    11942    11927      -15     
==========================================
- Hits        31925    31898      -27     
+ Misses      39748    39747       -1     
+ Partials     3209     3198      -11     
Files Changed Coverage Δ
src/wasm-binary.h 83.60% <ø> (ø)
src/wasm/wasm-binary.cpp 53.08% <100.00%> (-0.10%) ⬇️

... and 13 files with indirect coverage changes

Copy link
Member

@aheejin aheejin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is much easier to understand. By the way we had a similar data fields before #5504 - Then it was

std::pair<uint32_t, Function::DebugLocation> nextDebugLocation;

And now it is

size_t nextDebugPos;
Function::DebugLocation nextDebugLocation;

Then I wonder what #5504 was for..? Given that #5504 seemed to fix something and this is NFC I guess I've missed something...

src/wasm-binary.h Outdated Show resolved Hide resolved
src/wasm-binary.h Outdated Show resolved Hide resolved
@kripken
Copy link
Member Author

kripken commented Sep 5, 2023

Given that #5504 seemed to fix something and this is NFC I guess I've missed something...

Yes, I think some parts of that PR were not needed, which are partially reverted here, unless I am mistaken. But other parts of that PR were good fixes, namely

https://github.com/WebAssembly/binaryen/pull/5504/files#diff-666d70a4550a2ccec6247c639d54231a05108efc40af830403dfbc6527b251f7R2762-R2768

and

https://github.com/WebAssembly/binaryen/pull/5504/files#diff-227e746a6f9adba03a777865b9bd74e49db780106f349eae1aaed0ca3d2eb91eL234-R261

kripken and others added 2 commits September 5, 2023 12:40
Co-authored-by: Heejin Ahn <aheejin@gmail.com>
Co-authored-by: Heejin Ahn <aheejin@gmail.com>
@kripken kripken merged commit 9057105 into main Sep 6, 2023
@kripken kripken deleted the debug.nfc branch September 6, 2023 22:54
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
Almost entirely trivial, except for this part:

-  if (nextDebugLocation.availablePos == 0 &&
-      nextDebugLocation.previousPos <= pos) {
+  if (nextDebugLocation.availablePos == 0) {
      return;

I believe removing the extra check has no effect. Removing it does not change
anything in the test suite, and logically, if we set availablePos to 0 then we
definitely want to return here - we set it to 0 to indicate there is nothing left
to read, which is what the code after it does.

As a result, we can remove the previousPos field entirely.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants