Simplify array specialization logic
commit4c0e08960ce0a9a1505faf713d1de49e12aac77d
authorShaunak Kishore <kshaunak@fb.com>
Sun, 8 Mar 2020 00:15:23 +0000 (7 16:15 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sun, 8 Mar 2020 00:19:19 +0000 (7 16:19 -0800)
treecf44f0bd6ef1c56bd9a3a6efbab4afa4b70eb943
parentbaf4fe30beda3555c71636fe33b1cdf962b15e39
Simplify array specialization logic

Summary:
This change is mostly aesthetic: I'd like to avoid generating types like "Vec=Vanilla" when the AllowBespokeArrayLikes flag is off. The way to do that is to automatically set the vanilla bit on all specialized RAT ArraySpecs, and rely on typeFromRAT to widen these types to include bespoke array likes when the flag is off. The new logic for typeFromRAT is simple: HHBBC has no knowledge of hidden classes, so we simply widen all types when the flag is on. Specifically, consider the following cases for typeFromRAT:

| Input RAT | with flag off (before) | with flag off (after) | with flag on (both before and after)
| Vec | Vec=Vanilla | Vec | Vec
| Arr | Arr=Vanilla | Arr | Arr
| VArr | Arr=PackedKind | Arr=PackedKind | Arr={PackedKind I Bespoke}
| VecN([Str]) | Vec=N([Str]) | Vec=N([Str]) | Vec={N([Str]) I Bespoke}

As the table shows, we avoid constructing the (useless) specializations Vec=Vanilla and Arr=Vanilla with the flag off, while still keeping around useful specializations with array kinds or RAT info. This diff shouldn't change any generated code and should have no perf effects.

We'll still construct vanilla types with the flag off in a handful of cases - for example, the union Arr=PackedKind | Arr=MixedKind resolves to Arr=Vanilla. I don't care to deal with that, and I definitely don't want to change the core type operations based on this flag.

Reviewed By: ricklavoie

Differential Revision: D20295067

fbshipit-source-id: 57a77efa42e26eb37244bbc9403239dac7990060
hphp/runtime/test/type.cpp
hphp/runtime/vm/jit/type-specialization-inl.h
hphp/runtime/vm/jit/type-specialization.h
hphp/runtime/vm/jit/type.cpp
hphp/runtime/vm/jit/type.h