Disallow null {class, func, record, ...}-constant types
commit28ab023ed279cd45bcf67548c3facdacc68c062b
authorShaunak Kishore <kshaunak@fb.com>
Sat, 28 Dec 2019 02:37:15 +0000 (27 18:37 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sat, 28 Dec 2019 02:39:15 +0000 (27 18:39 -0800)
tree083ecbad49acda80d202f31b96065b6797749beb
parent9170d0a7ab2e2672555c0dedcdc955e315a36b60
Disallow null {class, func, record, ...}-constant types

Summary:
We sometimes create null class-constant types in the JIT, for the class context of certain ops. There's no reason to do this! Instead, we should correctly type these ops as taking Cls|Nullptr as input, and we should validate that constant types never have a null value. To do this validation, we can just extend the existing Type::checkValid logic, but we need to call it in one more place (the return type of Type::cns).

The ops that now take Cls|Nullptr are all implemented via native calls that check the type of the SSATmp at JIT time and then pass only the value. However, pointer | null unions are explicitly allowed by our JIT -> Native ABI bindings (see CallSpec::verifySignature), so expanding the type of these ops' inputs is safe.

We also need to adjust the type-check logic for constant inputs to check admitsSingleVal instead of hasConstVal for TNullptr (which I still maintain is weird).

Reviewed By: jjgriego

Differential Revision: D19209543

fbshipit-source-id: 220f8013586939a8b00fcf24549aa1cf64877294
hphp/doc/ir.specification
hphp/runtime/vm/jit/check.cpp
hphp/runtime/vm/jit/irgen-internal.h
hphp/runtime/vm/jit/irgen-sprop-global.cpp
hphp/runtime/vm/jit/type-inl.h
hphp/runtime/vm/jit/type.cpp