Eliminate ArrayData::LvalForceNew
commitcc994be4db142bfb74bc4d1911de703a03a73073
authorShaunak Kishore <kshaunak@fb.com>
Wed, 1 Apr 2020 07:07:01 +0000 (1 00:07 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 1 Apr 2020 07:19:52 +0000 (1 00:19 -0700)
tree4ec8fc91706ca180aad72935c9e6a8f23325fd57
parent918a38a7f1a437afcfae13e5d7fd2c7ce474f400
Eliminate ArrayData::LvalForceNew

Summary:
Now that false-y promote is dead, we don't support [] as an intermediate member op - only a final op. We can use this fact to eliminate LvalForceNew.

9 times out of 10, if you're calling "LvalForceNew", you really just want to append a value to the array. The 10th time, you're implementing register_variable, which has synthetic support for an implicit [] as an intermediate op. For this case, I did an awkward thing where I use iteration order to identify the key that was just added. We were already doing something similar in ext_xml and this function isn't hot.

We still have a few direct calls to PackedArray or MixedArray LvalForce methods in variable-serializer. Now that these methods aren't part of the general interface, we can simplify them, pushing assumptions onto the callers and optimizing them for this pre-sized use case.

Reviewed By: jjgriego

Differential Revision: D20759054

fbshipit-source-id: 8475a91f845911bb07fed0b0a3aaefd9987b1e53
24 files changed:
hphp/runtime/base/apc-local-array.cpp
hphp/runtime/base/apc-local-array.h
hphp/runtime/base/array-data-defs.h
hphp/runtime/base/array-data.cpp
hphp/runtime/base/array-data.h
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/base/program-functions.cpp
hphp/runtime/base/record-array.cpp
hphp/runtime/base/record-array.h
hphp/runtime/base/set-array.cpp
hphp/runtime/base/set-array.h
hphp/runtime/base/type-array.cpp
hphp/runtime/base/type-array.h
hphp/runtime/base/variable-unserializer.cpp
hphp/runtime/ext/collections/ext_collections-vector.h
hphp/runtime/ext/xml/ext_xml.cpp
hphp/runtime/test/array.cpp
hphp/runtime/vm/globals-array.cpp
hphp/runtime/vm/globals-array.h