Fix HHBBC constprop during inline interpretationnightly-2020.11.09
commit03f070e2f632ed547c44a85b4b717a964e5f711c
authorRick Lavoie <rlavoie@fb.com>
Mon, 9 Nov 2020 01:02:01 +0000 (8 17:02 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Mon, 9 Nov 2020 01:23:47 +0000 (8 17:23 -0800)
tree3656a70f089666c95101e204bc8c70c9a59ad1a6
parent2c1b7214ad480f0bce8052f817264c4bdc131781
Fix HHBBC constprop during inline interpretation

Summary:
If HHBBC performs a constprop during inline function interpretation,
we can derive incorrect results. The analysis assumes that if we
perform a constprop, the bytecode will actually be replaced, and
therefore we can use the inferred type afterwards (usually a static
array). However, if we're in inline interp, the bytecode won't
actually be changed (the types are contextual), which means the actual
runtime type won't be static.

For example, suppose we have NewKeysetArray with constant inputs,
coming from the function's parameters. Normally we would constprop
this to a static keyset using the Keyset bytecode. However since we're
in inline interp, and the constant inputs are coming from the
function's parameters, the inputs to NewKeysetArray won't actually be
constant at runtime. So it is not correct to derive a static type.

Fix this by not performing constprop if we're in inline interp. We'll
still push a constant type, but it won't be converted to a static
array.

Reviewed By: jano

Differential Revision: D24821589

fbshipit-source-id: e3ccf21e55d417c8ec1e126acceb2c09896635f7
hphp/hhbbc/interp.cpp
hphp/test/slow/hhbbc/inline-const-prop.php [new file with mode: 0644]
hphp/test/slow/hhbbc/inline-const-prop.php.expect [new file with mode: 0644]