Fix DCE's processCatchBlock() logic
commit9bd08c97b62b1338fcf55c95be65558aac3a1263
authorJan Oravec <jan@fb.com>
Mon, 8 Mar 2021 17:35:10 +0000 (8 09:35 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Mon, 8 Mar 2021 17:37:24 +0000 (8 09:37 -0800)
treec6a644b9bd6c8cf78a71fd522ad97f01655d70a6
parenta55e4eaafaa6d9ae4a3e31fb410760f7760b4f39
Fix DCE's processCatchBlock() logic

Summary:
The logic of mapping AStack into a given range was wrong, as it assumed that
AStack goes from `offset()` to `offset() + size()`, while in real it goes from
`offset() - size() + 1` to `offset() + 1`.

The `stk->offset() < stackTop` check was always false, as it means `stk` was
outside of `stackRange`. The remaining logic would accidentally work most of
the time because of the above issue combined with an off by one issue
cancelling each other out when `size() == 1`, which it is for the operation we
care about the most (StStk). Operations with bigger AStacks are rare in catch
blocks.

Fix this by using AStack's new low/high bounds. Always track the top 64 stack
slots, as heuristics based on the FPRelOffset from the uppermost frame won't
work after the switch to IRSPRelOffset. It's actually faster, as AStackAny will
now set the whole range with one 64-bit write.

Also kills the last usage of AStack::offset().

Reviewed By: ricklavoie

Differential Revision: D26878330

fbshipit-source-id: 0b9bdf8e8f84a4ce156c5c3cce933af685eea588
hphp/runtime/vm/jit/alias-class.h
hphp/runtime/vm/jit/dce.cpp