You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
Ergonomics — currently, the library makes some concessions by standardizing on Source, Register, SourceF, and RegisterF. 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")?
How would we document these functions? I think most of the current documentation is iffy since it just mirrors The Beam Book. Perhaps we forego the attempt to add inline documentation?
Can we similarly improve Codec.Beam.Bifs by parsing bif.tab?
The text was updated successfully, but these errors were encountered:
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: