Make memoize caches be agnostic to frame layout
commit5eef7ee66a4a6357a27e225781949e7edde18170
authorRick Lavoie <rlavoie@fb.com>
Tue, 7 Apr 2020 02:09:27 +0000 (6 19:09 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 7 Apr 2020 02:13:42 +0000 (6 19:13 -0700)
tree0a9800d3075834f7434b8fb1d57fe0179f4aef51
parentaae65293d5f138c3fece3d7b4999f2523d7277c0
Make memoize caches be agnostic to frame layout

Summary:
The memoize cache get/set functions receive a TypedValue* representing
the keys to perform the lookup. This works right now because both the
frame and the stack are just an array of TypedValue, so the functions
work on both. This will no longer be the case soon.  It will no longer
be possible to use the same functions to read keys from the locals
versus the stack, so split them into two variations. One that receives
the frame pointer and a start index, and one that receives a stack
pointer (similar to before). Add the necessary template abstractions
to support both cases.

For the stack case, we'll continue to just index into the given
pointer (though backwards to match the locals ordering). However, for
the frame pointer case, we'll call frame_local with the frame pointer
and index. This works right now because frame_local is cheap. If
frame_local becomes more complicated due to a more complicated layout,
this may become too expensive. In that case we can experiment with
further specializing the functions based on start offset (which would
allow us to const fold away all the offset calculations).

Adding the frame pointer and stack pointer variations caused yet a
further increase in the number of possible instantiations we need to
deal with in memo-cache.cpp. Its getting too big to deal with
manually, so use some ugly macro-ology to automate the various
instantiations. This also makes it less onerous to make future
changes. Likewise do some cleanup in irlower-intrinsics.cpp, which had
a lot of duplicated logic.

Reviewed By: mxw

Differential Revision: D20788765

fbshipit-source-id: 5224cc54df8f72a39b80cbe2b521748501839207
hphp/runtime/vm/bytecode.cpp
hphp/runtime/vm/jit/code-gen-helpers.h
hphp/runtime/vm/jit/irgen-builtin.cpp
hphp/runtime/vm/jit/irlower-intrinsic.cpp
hphp/runtime/vm/memo-cache.cpp
hphp/runtime/vm/memo-cache.h