Store num args instead of offset in prologue and func entry SrcKeys
commit23b884956b050f23d9e1bc2740585eb17e494bc2
authorJan Oravec <jan@fb.com>
Mon, 15 Aug 2022 18:30:43 +0000 (15 11:30 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Mon, 15 Aug 2022 18:30:43 +0000 (15 11:30 -0700)
tree0c76f2251c4d3d2f5b677a8a79298e10e0252961
parent6523d687d848042a7cd10888c59661ad890ad466
Store num args instead of offset in prologue and func entry SrcKeys

Summary:
If some default value arguments are not used, hhbbc optimizations may merge
multiple DV initializers together. This is problematic for prologues and func
entries, as SrcKeys for different number of arguments have the same offset and
thus become equal.

This did not cause any real issues yet, but it affects the next diff, which
performs argument type checks in prologues and assert expected types in func
entries.

Fix this by storing the number of passed args in prologue and func entry
SrcKeys instead of using the entry offset.

Kill the ambiguous Func::getEntryNumParams() API to prevent future issues.

Since tc-print may not have access to Func data, it may not be able to resolve
offsets for prologue and func entry SrcKeys. This affects all SrcKeys if repo
file is not available and all TransRec::src SrcKeys, as their func id is not
patched (and couldn't because the original func id is used elsewhere). Address
this by defaulting to the main entry offset of 0 and including additional data
about the number of passed arguments. The DV funclets are on their way out
anyway so the offset 0 will eventually become correct.

Reviewed By: mofarrell

Differential Revision: D38685176

fbshipit-source-id: f9f572295a6d2610c9f2f977b112b4d669ba58be
21 files changed:
hphp/runtime/vm/func.cpp
hphp/runtime/vm/func.h
hphp/runtime/vm/jit/irgen-call.cpp
hphp/runtime/vm/jit/irgen-func-prologue.cpp
hphp/runtime/vm/jit/irlower-branch.cpp
hphp/runtime/vm/jit/mcgen-prologue.cpp
hphp/runtime/vm/jit/mcgen-translate.cpp
hphp/runtime/vm/jit/service-request-handlers.cpp
hphp/runtime/vm/jit/service-request-handlers.h
hphp/runtime/vm/jit/service-requests.cpp
hphp/runtime/vm/jit/tc-prologue.cpp
hphp/runtime/vm/jit/tc-prologue.h
hphp/runtime/vm/jit/tc-region.cpp
hphp/runtime/vm/jit/translate-region.cpp
hphp/runtime/vm/jit/unique-stubs.cpp
hphp/runtime/vm/srckey-inl.h
hphp/runtime/vm/srckey.h
hphp/tools/tc-print/offline-code.cpp
hphp/tools/tc-print/offline-code.h
hphp/tools/tc-print/offline-trans-data.cpp
hphp/tools/tc-print/tc-print.cpp