-
Notifications
You must be signed in to change notification settings - Fork 5
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
Re-visit codegen from Erlang compiler files #48
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this would be a really fun project for anyone interested in BEAM internals. It would make this library more future-proof and eliminate sneaky bugs. I don't have time to do it myself though, so please continue the conversation if you'd want to help out!
The general idea
Codec.Beam.Instructions is a manually curated list of functions that mirrors the BEAM instruction set. However, this entire file could be generated from canonical files in the Erlang compiler. Specifically genop.tab and ops.tab. I think we can do this and maintain type safety, which would allow us to easily update the library with new OTP releases.
EDIT: This section of the documentation a most comprehensive overview of these tab files.
Prior attempt
I actually tried this before, but ran into issues. I backed out in this commit. Specifically, the
ops.tab
file was not complete — some type annotations were missing, so I could not complete the inference graph.However, I met @jhogberg at CodeBeam STO, and they went through and added the missing type information. Apparently it will prevent bugs in the Erlang compiler too! Their work can be found on this branch.
Open questions
Source
,Register
,SourceF
, andRegisterF
. I think this makes things easy to remember, but I'm not 100% certain that it's truthful. I'm interested to know how often things don't fit into this model. Can we do comprehensive codegen without an explosion of types or classes (I would call my previous attempt "an explosion")?Codec.Beam.Bifs
by parsing bif.tab?The text was updated successfully, but these errors were encountered: