From 0f9e81197be31d91c52a86ef2c399da041a9c380 Mon Sep 17 00:00:00 2001 From: mwilliams Date: Thu, 18 Apr 2013 17:01:36 -0700 Subject: [PATCH] Prevent some repo mode optimizations Since its seen the whole program, it optimizes class_exists to false if there's no definition anywhere. Replace local variables with globals so that assignments can't be optimized away (since we're gathering coverage information). --- hphp/test/quick/class_interface_trait_exists.php | 2 +- hphp/test/quick/coverage.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hphp/test/quick/class_interface_trait_exists.php b/hphp/test/quick/class_interface_trait_exists.php index 18671fa7f..ff111b41d 100644 --- a/hphp/test/quick/class_interface_trait_exists.php +++ b/hphp/test/quick/class_interface_trait_exists.php @@ -8,7 +8,7 @@ function __autoload($n) { trait tttt {} class cccc {} interface iiii {} - +if (0) { class zzzz {} interface zzzz {} } function main() { var_dump(class_exists('fooo', false)); var_dump(class_exists('fooo')); diff --git a/hphp/test/quick/coverage.php b/hphp/test/quick/coverage.php index 383b1c24a..da6cbbebf 100644 --- a/hphp/test/quick/coverage.php +++ b/hphp/test/quick/coverage.php @@ -4,7 +4,7 @@ function b($s) { if (strlen($s) == 4) { return 12; } - $z = 234; + $GLOBALS['z'] = 234; return 8; } @@ -20,8 +20,8 @@ function a($b) { function f() { for ($i = 0; $i < 4; ++$i) { a($i < 3); - $tmp = $i; - $i = $tmp; + $GLOBALS['tmp'] = $i; + $i = $GLOBALS['tmp']; } } @@ -29,11 +29,11 @@ function enable() { echo "Going to enable\n"; fb_enable_code_coverage(); echo "Enabled\n"; - $z = 3; + $GLOBALS['z'] = 3; } function doenable() { - $y = 2; + global $y; enable(); $y += 43; }