Do some cleanup around constants
commitd6173b7f8a8fd8514fe28106d07356fe8889980f
authorRick Lavoie <rlavoie@fb.com>
Tue, 22 Sep 2020 20:17:37 +0000 (22 13:17 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 22 Sep 2020 20:21:23 +0000 (22 13:21 -0700)
treebb4f10d30972a4243f9778f93c3b29df0a8d24e3
parent5d68cfe2e7c9c7da6556bd90522beff31764b58a
Do some cleanup around constants

Summary:
Do some cleanup around how the JIT deals with constants. Looking over
this code I noticied some issues.

- We weren't quite consistent about when we did or didn't need to
  manipulate ref-counts. Some of the code assumed that constants were
  always uncounted, which hasn't been the case for a long time.

- When resolving a constant's value via the 86cinit, we weren't
  clearing the recursion marker along all the return/exception paths,
  meaning it would just stay there.

- We had a DCns special type for types which can be in constants, but
  such a union gives us very little (its most of the types anyways)
  and is easy to get out of data. Just use InitCell instead.

- We side exited when a class constant was not initialized, but
  there's little reason for this. I think the intention originally was
  to avoid the IncRef for this miss case, but we've added an IncRef
  for the hit case anyways. Instead of side-exiting, branch back to
  main path (just a diamond).

- The code to use profiled constant slots for unknown classes failed
  to check if the slot was a type constant. As a result, it was
  possible to profile a particular slot (not a type constant), but
  later happen to hit a class that had a type constant in that slot,
  and return it as a regular constant. Add a check for the type bit.

- Centralize some logic to turn scalar TypedValues to constant
  types. Instead of doing it in irgen-cns.cpp, add a function in
  type.cc for it.

- Just general cleanup/modernization

Reviewed By: oulgen

Differential Revision: D23835899

fbshipit-source-id: ffd609d7137b7a13eb9be809716afc65bae7df5d
20 files changed:
hphp/doc/ir.specification
hphp/runtime/base/typed-value.h
hphp/runtime/vm/class.cpp
hphp/runtime/vm/class.h
hphp/runtime/vm/jit/check.cpp
hphp/runtime/vm/jit/cls-cns-profile.cpp
hphp/runtime/vm/jit/cls-cns-profile.h
hphp/runtime/vm/jit/dce.cpp
hphp/runtime/vm/jit/extra-data.h
hphp/runtime/vm/jit/ir-instruction.cpp
hphp/runtime/vm/jit/ir-opcode.cpp
hphp/runtime/vm/jit/ir-opcode.h
hphp/runtime/vm/jit/irgen-builtin.cpp
hphp/runtime/vm/jit/irgen-cns.cpp
hphp/runtime/vm/jit/irlower-cns.cpp
hphp/runtime/vm/jit/irlower-internal-inl.h
hphp/runtime/vm/jit/memory-effects.cpp
hphp/runtime/vm/jit/reg-alloc.cpp
hphp/runtime/vm/jit/type-inl.h
hphp/runtime/vm/jit/type.h