Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add pass to instrument memory.grow instructions #7388

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

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

loganek
Copy link
Contributor

@loganek loganek commented Mar 21, 2025

I've implemented this functionality as a new pass, however, it could also be an extension of the existing instrument-memory pass. The main reason for that is because I'd like to be able to use this instrumentation in production code, not just for debugging - the instrument-memory pass adds lot more instrumentation which would impact the performance of my code.

Alternatively, I could extend the instrument-memory pass and add a parameter to select instructions that should be instrumented - I'm open for feedback; if that's preferred approach, I'd be happy to update the PR.

@loganek loganek force-pushed the loganek/memory-grow-instrument branch from 0ee3162 to 68f0669 Compare March 21, 2025 09:21
@kripken
Copy link
Member

kripken commented Mar 21, 2025

Those use cases make sense to me. How about this?

  1. Make the existing InstrumentMemory pass also instrument grows - it should do everything basically.
  2. Add a new pass that just instruments grows, which is what you mainly want.
  3. Can maybe put them both in the same file to save a little code.

@loganek
Copy link
Contributor Author

loganek commented Mar 24, 2025

Thanks @kripken for feedback. I don't mind updating the InstrumentMemory to include the memory.grow tracking too. Having said that, I wonder if it makes sense to keep the InstrumentMemoryGrow pass at all, and instead just add some an optional enabled-instructions parameter to the InstrumentMemory pass that allows for choosing which instructions to pick? That'd be a bit more generic and we'd avoid duplicating the same functionality for different passes.

I don't insist on any of the options though, and I'd be happy to leave the decision to you.

@kripken
Copy link
Member

kripken commented Mar 24, 2025

@loganek A pass argument is a nice idea. So by default it instruments everything, but you can pick an explicit subset? That sounds good to me.

@loganek
Copy link
Contributor Author

loganek commented Mar 24, 2025

Yes, that's exactly what I meant. I'll update the PR soon.

@loganek loganek force-pushed the loganek/memory-grow-instrument branch from 68f0669 to b9bf2ee Compare March 25, 2025 11:10
src/passes/InstrumentMemory.cpp Outdated Show resolved Hide resolved
src/passes/InstrumentMemory.cpp Outdated Show resolved Hide resolved
test/lit/passes/instrument-memory-filter.wast Show resolved Hide resolved
@loganek loganek force-pushed the loganek/memory-grow-instrument branch 2 times, most recently from 93f551c to 2dc6c17 Compare April 2, 2025 22:54
src/passes/InstrumentMemory.cpp Outdated Show resolved Hide resolved
src/passes/InstrumentMemory.cpp Show resolved Hide resolved
src/passes/InstrumentMemory.cpp Outdated Show resolved Hide resolved
test/lit/passes/instrument-memory-filter.wast Outdated Show resolved Hide resolved
test/lit/passes/instrument-memory-filter.wast Show resolved Hide resolved
test/lit/passes/instrument-memory-filter.wast Outdated Show resolved Hide resolved
test/lit/passes/instrument-memory64.wast Outdated Show resolved Hide resolved
@loganek loganek force-pushed the loganek/memory-grow-instrument branch from 2dc6c17 to fadb6f2 Compare April 3, 2025 20:15
@@ -406,6 +421,8 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $A (type $1)
(drop (memory.grow (i32.const 4)))
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this is still an issue - ping me for review when it is ready.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you clarify what's the issue here? Is it about lack of comment? I don't mind adding it, but in that case should the comment be added to all the other instructions in this file, as we don't specify any filter so all the memory operations are instrumented.

Copy link
Member

@kripken kripken May 30, 2025

Choose a reason for hiding this comment

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

Sorry, I should have linked to my other comment that this was a followup to,

Maybe add this at the end, not the start? That would make the diff far shorter.

It might be even better in a new function, for easier reading.

(link)

My concern is the location. By putting this new test at the top, look at how large the diff is. All the existing tests end up modified. I am suggesting you add the new stuff at the bottom, to minimize the diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh you're right, updated that.

Also added instruction filter that allows to limit instrumented instructions.
@loganek loganek force-pushed the loganek/memory-grow-instrument branch from fadb6f2 to 4d8a838 Compare June 2, 2025 06:56
@kripken kripken merged commit cc1cc3d into WebAssembly:main Jun 2, 2025
16 checks passed
dschuff added a commit to dschuff/emscripten that referenced this pull request Jun 2, 2025
dschuff added a commit to emscripten-core/emscripten that referenced this pull request Jun 2, 2025
RReverser pushed a commit to RReverser/emscripten that referenced this pull request Jun 5, 2025
Lukasdoe pushed a commit to Lukasdoe/emscripten that referenced this pull request Jun 19, 2025
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.