Skip to content

Update internal ABI to zero/sign-extend where necessary only #87

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 10 commits into from
May 5, 2018
Merged

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Apr 28, 2018

Related issue: #38

Previous behaviour was:

  • When returning a small integer (i8, i16 etc.) from a function, make sure it is properly wrapped
  • When assigning a small integer to a variable, make sure it is properly wrapped
  • When performing an operation that might overflow, wrap after performing that operation

New behavior is:

  • When returning a small integer (i8, i16 etc.) from an exported function, make sure it is properly wrapped
  • When assigning a small integer to a global, make sure it is properly wrapped (see comment below).
  • When performing an operation that requires properly wrapped values, wrap before performing that operation if necessary
  • When an expression of a specific kind does not technically overflow, do not wrap its result
  • Remember wrap states of locals throughout flows, and use this for tagging their respective get_locals .

@dcodeIO
Copy link
Member Author

dcodeIO commented May 1, 2018

One more missing piece is remembering wrap status of locals thoughout flows. Without, occurences of get_local reset the wrap status to unwrapped, leading to quite a lot unnecessary re-wraps as can be seen in the fixtures.

This can't be done for globals because these are shared between functions, so I decided to wrap set_globals on assignments so code using globals can consider them properly wrapped. There are usually more gets than sets, so this should reduce more unnecessary wraps than it introduces.

dcodeIO added 7 commits May 2, 2018 02:02
…h flows; Create wrappers for binaryen functions that expect non-tagged pointers
Tagging has the disadvantage that it doesn't take the target type of an expresssion into account when converted. Also required applying and checking tags in a lot of places, which now all happens in the canOverflow check instead.
@dcodeIO
Copy link
Member Author

dcodeIO commented May 5, 2018

Ok, I think the most common cases should be handled now, but there are more opportunities along the road. Thinking of merging and adding an issue to track additional optimizations - maybe?

@MaxGraey
Copy link
Member

MaxGraey commented May 5, 2018

Great idea. Also Alan working on souper branch which could be cover other optimization scenarios when it landed

@dcodeIO dcodeIO merged commit 50f6c1c into master May 5, 2018
@dcodeIO dcodeIO changed the title WIP: Update internal ABI to zero/sign-extend where necessary only Update internal ABI to zero/sign-extend where necessary only May 5, 2018
@dcodeIO dcodeIO deleted the abi2 branch May 6, 2018 02:39
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