-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHBBC shouldn't step through unreachable code while inserting RAT ass…
…ertions Summary: While inserting RAT type assertions at the end of the optimize phase, HHBBC shouldn't step through unreachable bytecode. There's an invariant that at this point, the analysis of the function should have reached a fixed point. Therefore, stepping through the bytecodes should not infer anything new about the program. We do assert this in a few places (related to function folding). However, unreachable parts of the function may not be analyzed fully, and therefore stepping through them might break that invariant. Instead, as soon as we hit an unreachable part of the program, just insert a static analysis error guard and stop processing that block (same as we do elsewhere). Include a test case which triggers an assertion without this. The root cause of why this test case triggers it is because of the lack of a pattern-match optimization for IsType[C/L]; Not; Jmp[N]Z during analysis. The peephole optimizer will remove the Not and flip the jump, but only during the optimization phase. Add a suitable pattern matching optimization as well. Reviewed By: markw65 Differential Revision: D6905679 fbshipit-source-id: f4e30540e589158216dc8117c742b340507f21f5
- Loading branch information
1 parent
b145d0a
commit edc1b48
Showing
4 changed files
with
165 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?hh | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
function byref(&$x) {} | ||
function build() { | ||
$d = dict[]; | ||
$k = __hhvm_intrinsics\launder_value('key'); | ||
while (__hhvm_intrinsics\launder_value(false)) { | ||
$d[$k] = $d[$k] ?? dict[]; | ||
$d[$k] = $d[$k] ?? dict[]; | ||
byref(&$d[$k]['k2']); | ||
} | ||
return $d; | ||
} | ||
|
||
var_dump(build()); |
2 changes: 2 additions & 0 deletions
2
hphp/test/slow/hhbbc/insert-assertions-unreachable.php.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dict(0) { | ||
} |