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

Detect effect-less code fragments #39

Open
dgpv opened this issue May 22, 2024 · 2 comments
Open

Detect effect-less code fragments #39

dgpv opened this issue May 22, 2024 · 2 comments
Labels

Comments

@dgpv
Copy link
Owner

dgpv commented May 22, 2024

          I think it would be great to detect 'effect-less' code fragments like  `DUP DROP DUP DROP 2DUP 2DROP DUP DROP`, because it also can help detect the bugs, just like the compiler warnings can tell you that you probably want to look at this piece of code second time.

Right now bsst can only detect always-true enforcement conditions, but not effect-less code. It can be a useful enhancement.

It should be possible to 'turn off the warnings', though. But because the focus of bsst from the beginning was helping to detect the bugs, turning off warnings should result in one big warning at the start of the report, that tells that warnings are off :-)

Originally posted by @dgpv in #33 (comment)

@dgpv dgpv added enhancement New feature or request detection_ehancement labels May 22, 2024
@dgpv
Copy link
Owner Author

dgpv commented Jul 2, 2024

We have the log of 'exec states' for each position of program counter, so we can compare current exec state with previous exec states to check if any previous state is identical to the current exec state, to detect effect-less code fragments.

We can also look for 'too small' differences in exec states, like when a big code fragment only resulted in small amount of shuffling the same values on the stack. We can have a table for 'small shuffles', like (a, b) -> (a, a): SWAP DROP DUP. If the code fragment is longer than the simple code for the same shuffle, we can give a note

@dgpv
Copy link
Owner Author

dgpv commented Jul 2, 2024

The vfExec array should be identical for the exec states

We should also check differences in the altstack. It will complicate the 'shuffles table', though, if we consider shuffles with changes to altstack. But may be still manageable to build the shuffles table manually for small shuffles

for longer shuffles some 'optimizer' have to be built that can output a shortest fragment for certain stack permutation. Given that it will only concern shuffles, and not value computation, it should not bee too complex, though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant