/hphp/test/slow/ir_inlining/try_catch_call_002.php
PHP | 42 lines | 33 code | 6 blank | 3 comment | 11 complexity | 37834d9375b0038cfbe37f317c055e1a MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
- <?hh
- function thrower() {
- for ($i = 0; $i < 10; ++$i) mt_rand(); // make it not-inlinable
- // Make hhbbc not prove it's going to throw:
- for ($i = 0; $i < 10 + mt_rand() ? 1 : 0; ++$i) {
- mt_rand();
- }
- if ($i >= 10) throw new Exception('heh');
- return false;
- }
- function better_handle_retbcoff_if_you_inline() {
- thrower();
- }
- function main() {
- // Generate a prologue for thrower:
- try { thrower(); } catch (Exception $x) {}
- // Push down bytecode offsets
- for ($i = 0; $i < 10; ++$i) mt_rand();
- for ($i = 0; $i < 10; ++$i) mt_rand();
- for ($i = 0; $i < 10; ++$i) mt_rand();
- for ($i = 0; $i < 10; ++$i) mt_rand();
- for ($i = 0; $i < 10; ++$i) mt_rand();
- for ($i = 0; $i < 10; ++$i) mt_rand();
- for ($i = 0; $i < 10; ++$i) mt_rand();
- for ($i = 0; $i < 10; ++$i) mt_rand();
- try {
- $z = better_handle_retbcoff_if_you_inline();
- var_dump($z);
- } catch (exception $e) {
- echo "got it\n";
- }
- }
- <<__EntryPoint>>
- function main_try_catch_call_002() {
- main();
- }