use TypeStructure in bespoke layout selection
commitc713e49ce137f5c1694ae6a8457f8a064b382e21
authorSally Zhou <sallyz@fb.com>
Fri, 10 Jun 2022 18:39:18 +0000 (10 11:39 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 10 Jun 2022 18:39:18 +0000 (10 11:39 -0700)
treee471f1d8c5a1135aafec4118a963d64f3668455f
parent5534d3f56fa51ef8e24c8abcc822451df908c634
use TypeStructure in bespoke layout selection

Summary:
This diff adds logic to profile arrays and decide when to use bespoke type structures. The layout is gated on the runtime-option `EmitBespokeTypeStructures` , which is set to `false`.

Current logic: the bespoke type structure layout will only be selected if the array source exactly matches the fields in a type structure and if the array is never modified.

In the future, we could consider more detailed conditions (e.g. we still select the bespoke layout if a user modifies some fields and the modified array is still a valid type structure) but for now, the current logic is sufficient.

Reviewed By: arnabde03

Differential Revision: D36901413

fbshipit-source-id: 1eb3856f389ec6ee13818bfadba815c995af372e
13 files changed:
hphp/runtime/base/bespoke/layout-selection.cpp
hphp/runtime/base/bespoke/layout.cpp
hphp/runtime/base/bespoke/logging-profile.cpp
hphp/runtime/base/bespoke/logging-profile.h
hphp/runtime/base/bespoke/type-structure.cpp
hphp/runtime/base/bespoke/type-structure.h
hphp/runtime/base/runtime-option.h
hphp/runtime/test/bespoke-type-structure.cpp
hphp/runtime/vm/jit/array-layout.cpp
hphp/runtime/vm/jit/array-layout.h
hphp/test/slow/type_structure/bespoke-type-structure.php [new file with mode: 0644]
hphp/test/slow/type_structure/bespoke-type-structure.php.expect [new file with mode: 0644]
hphp/test/slow/type_structure/bespoke-type-structure.php.opts [new file with mode: 0644]