Store weak pointers by hash
Summary:
Currently, a Conser stores a map from T -> Weak<T>. This means that there's one copy of T stored in the map as a key, and a second, ref-counted copy stored on the heap (which will be destroyed if its strong refcount drops to 0, and freed on the next Conser::gc invocation). Ideally, we should just store a single copy on the heap! Having an owned version inside the map also makes it impossible for us to reclaim some unused memory: if we hashcons a value containing other hashconsed values, those other values will be strongly referenced by the value we store as the map's key.
If we key the table by value hashes instead, we avoid these problems at the cost of needing to handle collisions. I've punted on collision handling in this diff (u64 is a pretty big space). Additionally, since we no longer need to store an owned copy of the value in the map, we're able to hashcons unsized types like `str`. The next diff removes an indirection in `Symbol` by switching its representation from `Hc<Box<str>>` to `Hc<str>` now that this is possible.
Reviewed By: edwinsmith
Differential Revision:
D33698451
fbshipit-source-id:
4e74f97ddd64af32fb5a3ec006c40d94ebfc1f36