diff --git a/examples/micro_bench.php b/examples/micro_bench.php index b20d0d53..a35288d7 100644 --- a/examples/micro_bench.php +++ b/examples/micro_bench.php @@ -16,9 +16,10 @@ function simpleudcall($n) { function hallo2() { } -function simpleicall($n) { - for ($i = 0; $i < $n; $i++) - $ret = function_exists('hallo'); +function simpleicall($n) +{ + for ($i = 0; $i < $n; $i++) + $ret = function_exists('hallo'); } class Foo { @@ -287,14 +288,14 @@ function main() empty_loop(N); $t = end_test($t, 'empty_loop'); $overhead = $last_time; -// simpleucall(N); -// $t = end_test($t, 'func()', $overhead); -// simpleudcall(N); -// $t = end_test($t, 'undef_func()', $overhead); + simpleucall(N); + $t = end_test($t, 'func()', $overhead); + simpleudcall(N); + $t = end_test($t, 'undef_func()', $overhead); simpleicall(N); $t = end_test($t, 'int_func()', $overhead); -// Foo::read_static(N); -// $t = end_test($t, '$x = self::$x', $overhead); + Foo::read_static(N); + $t = end_test($t, '$x = self::$x', $overhead); // Foo::write_static(N); // $t = end_test($t, 'self::$x = 0', $overhead); // Foo::isset_static(N); diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index d17b0ced..4c386efa 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -763,7 +763,6 @@ class CompilerBase extends \PhpAot\Core\Translator if (!$this->isVarExpr($expr->var)) { $this->fatalError($expr, 'When an assignment expression serves as an rvalue, it must be an assignment of a variable'); } - return $this->parseExpr($expr); default: return $this->parseExpr($expr); diff --git a/src/Php/FuncCallOptimizer.php b/src/Php/FuncCallOptimizer.php index f1f95807..68276547 100644 --- a/src/Php/FuncCallOptimizer.php +++ b/src/Php/FuncCallOptimizer.php @@ -45,7 +45,13 @@ trait FuncCallOptimizer return 'php::math::abs(' . $this->parseIdentifier($expr->args[0]->value) . ')'; } if ($name === 'function_exists') { - return 'php::fn::function_exists(' . $this->parseIdentifier($expr->args[0]->value) . ')'; + $funcName = $expr->args[0]->value; + if ($this->isScalarString($funcName)) { + $funcName = $this->getLiteralString(strtolower(trim($funcName->value, '\\'))); + return 'php::fn::function_exists(' . $funcName . ', true)'; + } else { + return 'php::fn::function_exists(' . $this->parseIdentifier($funcName) . ')'; + } } return false;