Add ArrLike type operand to IsType[C,L]
commit41f4c5f943304562d5e291c664e1d23e0a7d13d9
authorRick Lavoie <rlavoie@fb.com>
Fri, 2 Feb 2018 00:33:20 +0000 (1 16:33 -0800)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Fri, 2 Feb 2018 00:38:43 +0000 (1 16:38 -0800)
tree749ca841ccee397f9aa09da97c69cd18855acbc0
parent2201be03eca29296c72d6f9eeddf623cd5f7c70f
Add ArrLike type operand to IsType[C,L]

Summary:
Add a new type operand to the IsType[C,L] bytecode, called ArrLike. As the name
suggests, it checks if the value is "ArrLike" (array, vec, dict, or
keyset). This operand does not correspond to any is_* function in Hack, but is
meant to be used internally inside array_map, array_filter, and
array_reduce. This lets Hack arrays pass the array fast-path check, just like
normal arrays. It also suppresses extraneous Hack array compat notices from
those functions (because those are only triggered when testing for an array).

The JIT already had support for testing array-like types. It only required
modifying typeOpToDataType to return a Type instead of a DataType (which was
always cast into a Type anyways).

Reviewed By: paulbiss

Differential Revision: D6869739

fbshipit-source-id: 393cbdf891eab14e80f01e54b97e2e80f01c0bf2
16 files changed:
hphp/doc/bytecode.specification
hphp/hack/src/hhbc/Hhas_parser_actions.ml
hphp/hack/src/hhbc/hhbc_ast.ml
hphp/hack/src/hhbc/hhbc_hhas.ml
hphp/hhbbc/interp.cpp
hphp/hhbbc/type-system.cpp
hphp/runtime/vm/bytecode.cpp
hphp/runtime/vm/hhbc.h
hphp/runtime/vm/jit/irgen-types.cpp
hphp/system/php/array_filter.hhas
hphp/system/php/array_map.hhas
hphp/system/php/array_reduce.hhas
hphp/test/slow/hack_arr_compat/array_map_is_array.php [new file with mode: 0644]
hphp/test/slow/hack_arr_compat/array_map_is_array.php.expect [new file with mode: 0644]
hphp/test/slow/hack_arr_compat/array_map_is_array.php.hphp_opts [new file with mode: 0644]
hphp/test/slow/hack_arr_compat/array_map_is_array.php.opts [new file with mode: 0644]