Eliminate plain PackedArrays
commitb2be969db5a21d496071554722e6bb175bb92281
authorShaunak Kishore <kshaunak@fb.com>
Fri, 22 May 2020 21:51:16 +0000 (22 14:51 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 22 May 2020 21:53:57 +0000 (22 14:53 -0700)
treef4af1ac09832c64b17c3339b391714346c5638d3
parent99e3cb9b04d223e5b1f2a65b2c6957d77d870882
Eliminate plain PackedArrays

Summary:
On the continuing quest to eliminate EmptyArray and plain PackedArrays...

In this diff, we eliminate the four PackedArray constructor methods that produce plain PackedArrays. These methods are still used to implement the NewArray, NewLikeArrayL, and NewPackedArray bytecodes, which we handle as follows:
- **NewArray:** Simply create a MixedArray with the given capacity instead of a PackedArray.
- **NewLikeArrayL:** Ignore the hinted local, and create a MixedArray with the given capacity.
- **NewPackedArray:** Create a vec, and cast it to a PHP array (which now results in a plain MixedArray).

NewArray, NewLikeArrayL, and NewMixedArray are all exactly equivalent now! I'll admit that the implementation of NewPackedArray is...inefficient, but it just doesn't matter; we've been using the type-checker to eliminate usages of this bytecode, and we're in the process of removing parser support.

One other change we have to make is to have EmptyArray escalate straight to MixedArray. That's easy.

We know we're done with this change because of the stricter rules in PackedArray::checkInvariants. If the array is a varray, it must have PackedKind; otherwise, it must have VecKind.

Reviewed By: dneiter

Differential Revision: D21693490

fbshipit-source-id: 49f10f8940bdb756f0ff4b85dc4b95f7a34b8df0
18 files changed:
hphp/doc/ir.specification
hphp/runtime/base/empty-array.cpp
hphp/runtime/base/empty-array.h
hphp/runtime/base/mixed-array.cpp
hphp/runtime/base/mixed-array.h
hphp/runtime/base/packed-array.cpp
hphp/runtime/base/packed-array.h
hphp/runtime/ext/soap/ext_soap.cpp
hphp/runtime/ext/std/ext_std_classobj.cpp
hphp/runtime/vm/bytecode.cpp
hphp/runtime/vm/jit/dce.cpp
hphp/runtime/vm/jit/extra-data.h
hphp/runtime/vm/jit/ir-opcode.cpp
hphp/runtime/vm/jit/irgen-create.cpp
hphp/runtime/vm/jit/irlower-array.cpp
hphp/runtime/vm/jit/memory-effects.cpp
hphp/runtime/vm/jit/minstr-effects.cpp
hphp/runtime/vm/jit/type-inl.h