PageRenderTime 49ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/slow/ir_inlining/try_catch_call_002.php

http://github.com/facebook/hiphop-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
  1. <?hh
  2. function thrower() {
  3. for ($i = 0; $i < 10; ++$i) mt_rand(); // make it not-inlinable
  4. // Make hhbbc not prove it's going to throw:
  5. for ($i = 0; $i < 10 + mt_rand() ? 1 : 0; ++$i) {
  6. mt_rand();
  7. }
  8. if ($i >= 10) throw new Exception('heh');
  9. return false;
  10. }
  11. function better_handle_retbcoff_if_you_inline() {
  12. thrower();
  13. }
  14. function main() {
  15. // Generate a prologue for thrower:
  16. try { thrower(); } catch (Exception $x) {}
  17. // Push down bytecode offsets
  18. for ($i = 0; $i < 10; ++$i) mt_rand();
  19. for ($i = 0; $i < 10; ++$i) mt_rand();
  20. for ($i = 0; $i < 10; ++$i) mt_rand();
  21. for ($i = 0; $i < 10; ++$i) mt_rand();
  22. for ($i = 0; $i < 10; ++$i) mt_rand();
  23. for ($i = 0; $i < 10; ++$i) mt_rand();
  24. for ($i = 0; $i < 10; ++$i) mt_rand();
  25. for ($i = 0; $i < 10; ++$i) mt_rand();
  26. try {
  27. $z = better_handle_retbcoff_if_you_inline();
  28. var_dump($z);
  29. } catch (exception $e) {
  30. echo "got it\n";
  31. }
  32. }
  33. <<__EntryPoint>>
  34. function main_try_catch_call_002() {
  35. main();
  36. }