Rework interp-minstr logic in HHBBC
commitc11b57266b5313249676709c83c3e232956dc68c
authorRick Lavoie <rlavoie@fb.com>
Wed, 16 Dec 2020 07:37:04 +0000 (15 23:37 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 16 Dec 2020 07:41:06 +0000 (15 23:41 -0800)
tree86aac1b886ad1f1677b2fff48a099384d0a48d02
parent18e8c78d5ac1dfa70fa7806a4959780f5a53b57c
Rework interp-minstr logic in HHBBC

Summary:
The interp-minstr logic in HHBBC was quite old, had undergone a lot of
changes, and was quite confusing. In addition, it was dealing with a
number of cases which don't happen anymore (various array and stdclass
promotions). Rounds of edits to the logic also left a lot of
non-sensical code (loading values and never using them, calling empty
functions, etc etc).

I audited all of the interp-minstr logic related to elem accesses and
brought it all up to date with the current runtime behavior. This
allowed me to refine the analysis so now we can detect effect-free
minstr sequences a lot better and const fold then more
aggressively. In addition, previously we weren't accounting for a
number of corner cases (Uninit locals, base ClsMeth promotion,
etc). This is all dealt with now. I didn't touch logic related to
properties that much. It's less complicated anyways.

There are a number of improvements, but I'd like to single out that we
now have array_like_set, array_like_elem, and
array_like_newelem. Unlike the others, this can handle arbitrary
TOptArrLike types. If the type is a union of different array types, it
will automatically call the appropriate specific functions and union
together the results. This leads to better analysis because we no
longer need to give up if we have an union.

While I was at it, change a number of nothrow() calls in interp.cc to
effect_free() because they're actually effect-free. This makes const
prop more effective.

Differential Revision: D25510513

fbshipit-source-id: 67e3970ddacb75e678214158ec49297be01d93b3
39 files changed:
hphp/compiler/analysis/emitter.cpp
hphp/hhbbc/dce.cpp
hphp/hhbbc/interp-builtin.cpp
hphp/hhbbc/interp-internal.h
hphp/hhbbc/interp-minstr.cpp
hphp/hhbbc/interp-state.h
hphp/hhbbc/interp.cpp
hphp/hhbbc/main.cpp
hphp/hhbbc/type-system.cpp
hphp/hhbbc/type-system.h
hphp/runtime/vm/member-operations.h
hphp/runtime/vm/repo-global-data.cpp
hphp/runtime/vm/repo-global-data.h
hphp/runtime/vm/repo.cpp
hphp/test/slow/class-ptr/class-cmp-warn.php.hphp_opts [new file with mode: 0644]
hphp/test/slow/class-ptr/class-warn.php.hphp_opts
hphp/test/slow/class-ptr/lazyclass-cmp-warn.php.hphp_opts
hphp/test/slow/clsmeth-log.php.hphp_opts
hphp/test/slow/clsmeth/array-access-notice.php.hphp_opts
hphp/test/slow/clsmeth/compare-notice.php.hphp_opts
hphp/test/slow/clsmeth/convert-notice.php.hphp_opts
hphp/test/slow/clsmeth/elem-set-notice.php.hphp_opts
hphp/test/slow/clsmeth/elem-set-verbose.php.nohadva [new file with mode: 0644]
hphp/test/slow/clsmeth/elem-set.php.nohadva [new file with mode: 0644]
hphp/test/slow/clsmeth/elem-unset-notice.php.hphp_opts
hphp/test/slow/clsmeth/notices.php.hphp_opts
hphp/test/slow/clsmeth/primitive-cmp-notice.php.hphp_opts
hphp/test/slow/clsmeth/types-notice.php.hphp_opts
hphp/test/slow/global_func/class_meth/cast.php.hphp_opts
hphp/test/slow/global_func/class_meth/dv_arr/apc_store.php.hphp_opts
hphp/test/slow/global_func/class_meth/dv_arr/mutate.php.hphp_opts
hphp/test/slow/global_func/class_meth/dv_arr_hack_arr/apc_store.php.hphp_opts
hphp/test/slow/global_func/class_meth/dv_arr_hack_arr/call_user_func.php.hphp_opts
hphp/test/slow/global_func/class_meth/dv_arr_hack_arr/cmp_warn.php.hphp_opts
hphp/test/slow/global_func/class_meth/dv_arr_hack_arr/container_builtins_convert_and_warn.php.hphp_opts
hphp/test/slow/global_func/class_meth/dv_arr_hack_arr/container_builtins_warn.php.hphp_opts
hphp/test/slow/global_func/class_meth/dv_arr_hack_arr/mutate.php.hphp_opts
hphp/test/slow/global_func/class_meth/is_callable.php.hphp_opts
hphp/test/slow/memoize-ptr.php.hphp_opts