Do some cleanup around constants
Summary:
Do some cleanup around how the JIT deals with constants. Looking over
this code I noticied some issues.
- We weren't quite consistent about when we did or didn't need to
manipulate ref-counts. Some of the code assumed that constants were
always uncounted, which hasn't been the case for a long time.
- When resolving a constant's value via the 86cinit, we weren't
clearing the recursion marker along all the return/exception paths,
meaning it would just stay there.
- We had a DCns special type for types which can be in constants, but
such a union gives us very little (its most of the types anyways)
and is easy to get out of data. Just use InitCell instead.
- We side exited when a class constant was not initialized, but
there's little reason for this. I think the intention originally was
to avoid the IncRef for this miss case, but we've added an IncRef
for the hit case anyways. Instead of side-exiting, branch back to
main path (just a diamond).
- The code to use profiled constant slots for unknown classes failed
to check if the slot was a type constant. As a result, it was
possible to profile a particular slot (not a type constant), but
later happen to hit a class that had a type constant in that slot,
and return it as a regular constant. Add a check for the type bit.
- Centralize some logic to turn scalar TypedValues to constant
types. Instead of doing it in irgen-cns.cpp, add a function in
type.cc for it.
- Just general cleanup/modernization
Reviewed By: oulgen
Differential Revision:
D23835899
fbshipit-source-id:
ffd609d7137b7a13eb9be809716afc65bae7df5d