Use closure names, not ids for CreateCl
Summary:
All classes have an id, which is their index into their unit's
pre-class table. The only real use of this id is to represent a
closure in the CreateCl bytecode. This works because closures are always
stored in the same unit from which they're used.
However, the id is problematic because it's global to the unit, so
anything which wants to process things on a class level (like
distributed trait flattening) need to coordinate somehow.
Instead, change CreateCl to store the closure's name instead. Unlike
the id, the name is globally unique, so does not require
coordination. With this, we no longer need to store the id in the
pre-class anymore (which saves some space), and also simplifies some
logic during trait flattening and bytecode emission.
Note: this changes the logic for renaming closures a bit. We don't
bother with the hash of the unit name anymore, as simply appending the
destination class is enough to guarantee uniqueness.
Add some sanity check around the CreateCl bytecode to avoid invalid
things, like referring to non-closures, or closures outside of the
unit. This includes improved verifier logic.
I had to modify the Rust code to have it emit the name instead of the
id, but this lead to a rabbit-hole of "unused parameter" and like
errors, which required me to change way more than I really wanted.
Reviewed By: jano, edwinsmith
Differential Revision:
D38890884
fbshipit-source-id:
03b86032b161abf866f801e3976f04168842a4e1