-
Notifications
You must be signed in to change notification settings - Fork 700
Add explicit arities to calls, breaks, & return #595
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
Conversation
|
+1 for syntactic arity immediate. The opcodes-with-fixed-immediates extension (which I'll make a PR for once we finish convergence on the current binary format) should hopefully mitigate the size impact. |
Conflicts: BinaryEncoding.md
|
Ping. Now that GDC is over, this should be ready to land. |
|
lgtm |
|
Shouldn't this mention that arity mismatch is an error? |
|
lgtm too |
|
I support the parsing not depending on the context, but still see potential problems with the I believe that the appropriate solution would be for the While the 'arity' of the I ask that if this lands that the arity of the |
|
I can sympathize with the idea that parsing should not rely on its context, and I can kind of see how tooling might want to read ASTs without having to parse the whole module, but if I'm doing the work to parse the whole AST for function bodies... it is not much more work to read the signature and declaration sections. I debate the point @titzer made that "redundancy can catch encoding errors in mismatches". Redundancy can cause bugs where someone is validating one number and then using another, etc. It is much safer to have a value stored in a single place rather than multiple places. I place higher precedence on the elimination of these bugs (which can often be security vulnerabilities) than making this more context-free. |
|
@titzer If you believe that one byte per function for an end marker is significant then you might be interested to know that AngryBots has 195682 function calls and one extra byte each is about five times as much as the function end markers and 1.6% of the file size. This seems significant although I also see some benefit to being context-free. As noted above the operator table might help here with |
|
From the perspective of an expression-less encoding, the Also from this perspective the In an expression-less encoding blocks do not return values, so breaks need no arity. |
|
I did some measurements, this adds 1.3% to BB's binary size, or 0.4% after gzip. So noticeable, but quite small. @lukewagner is also optimistic that that would go away with an opcode table. I think he's probably right, and given the small downside here it seems not too worrying. But just noting these numbers here, it would be nice to measure later on after an opcode table as well, as technically speaking this information is redundant in the binary format. |
|
This PR needs to be rebased onto the binary_0xb branch. |
|
Thanks! |
(And while here, do a stylistic tweak to use
:for type annotations :) )