Eliminate abstract "EmptyOrMonotype" layouts
commit0d1804667a1a21eac7777b7fb7516732f74ad82e
authorShaunak Kishore <kshaunak@fb.com>
Sat, 27 Feb 2021 03:17:02 +0000 (26 19:17 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Sat, 27 Feb 2021 03:19:12 +0000 (26 19:19 -0800)
tree63ffa0cef20a6c7733699ae7aa5ccfcb2c7c6c2d
parent4297b3e58cff3bdca1267d7b7e6996a2c2680088
Eliminate abstract "EmptyOrMonotype" layouts

Summary:
EmptyOrMonotypeVec<String> is an abstract bespoke::Layout with three concrete children:
- MonotypeVec<String>
- MonotypeVec<PersistentString>
- EmptyMonotypeVec

Now that colavitam has made it possible to use a MonotypeVec's methods on an EmptyMonotypeVec, we no longer need this abstract node. We can simply make EmptyMonotypeVec a child of MonotypeVec<T> for all DataTypes T. (We've long had the ability to have concrete layouts that are children of other concrete layouts; the difference now is that punning lets us have such relationships even when the exact native helpers of the parent and child don't match, as long as the parent's ones work on the child.)

Doing so cleans up some ugly types. It makes it easier to optimize layout tests, as the resulting type lattice is much more natural. We also do the same to dicts.

To get this change to work, we have to update a few implementation details:
- We make the type() of the empty vec and dict be kExtraInvalidDataType == 0. That's needed for the new unordered-code type tests.
- We update a few functions on MonotypeVec and MonotypeDict to work on empty inputs, notably: HeapSize, ToDVArray, ToHackArray, and SetLegacyArray.

Reviewed By: colavitam

Differential Revision: D26655996

fbshipit-source-id: d8c55ac681a4fd9dfc86eeaf2e366d1cede5ac1d
hphp/runtime/base/bespoke/layout-selection.cpp
hphp/runtime/base/bespoke/layout.cpp
hphp/runtime/base/bespoke/layout.h
hphp/runtime/base/bespoke/monotype-dict.cpp
hphp/runtime/base/bespoke/monotype-dict.h
hphp/runtime/base/bespoke/monotype-vec.cpp
hphp/runtime/base/bespoke/monotype-vec.h