Skip to content

A better API to evaluate or precompute an expression #2699

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

Closed
dcodeIO opened this issue Mar 17, 2020 · 2 comments
Closed

A better API to evaluate or precompute an expression #2699

dcodeIO opened this issue Mar 17, 2020 · 2 comments

Comments

@dcodeIO
Copy link
Contributor

dcodeIO commented Mar 17, 2020

We are currently utilizing precompute to find out whether conditions to branches are constant by

  • creating a temporary function
  • using the expression of interest as its body
  • running the precompute pass on that function
  • evaluating the new body
  • removing the temporary function again.

This has downsides in regards to overhead and that we have to replace the expression instead of keeping it intact, leading to not-so-untouched output, and doesn't work if the expression has side-effects.

So I've been thinking about adding an API like BinaryenExpressionEvaluate to aid here, but since precompute is a pass with no header that isn't meant to be used this way, it seems to require substantial code changes that I'm unsure about. Any suggestions how to tackle this? :)

@tlively
Copy link
Member

tlively commented Mar 17, 2020

This shouldn't be too difficult because the interpretation machinery in wasm-interpreter.h is already independent of any particular pass. I would look at how Precompute.cpp integrates the interpreter and do something similar in one of the utils headers, rather than trying to reuse Precompute itself.

@tlively
Copy link
Member

tlively commented Jan 15, 2025

Looks like this was done in #2702.

@tlively tlively closed this as completed Jan 15, 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

No branches or pull requests

2 participants