diff --git a/run-tests.php b/run-tests.php index d9019f04..99771d4e 100755 --- a/run-tests.php +++ b/run-tests.php @@ -4204,7 +4204,7 @@ function compile_php_file(string $file): string file_put_contents($file, "parseBeforeStmtLines() . PHP_EOL; - $code .= 'zend_try {'; + $code .= 'try {'; $stmts = $v->stmts; $code .= PHP_EOL; @@ -2639,7 +2639,7 @@ class CompilerBase extends \PhpAot\Core\Translator $exVar = $this->genTmpVarName(); $this->addLocalVar($exVar, self::TYPE_OBJECT); - $code .= 'zend_catch {' . PHP_EOL; + $code .= 'catch(zend_object *_ex) {' . PHP_EOL; if ($catches) { $code .= $this->getIndent() . $exVar . ' = php::catchException();' . PHP_EOL; $this->indentLevel++; @@ -2648,7 +2648,7 @@ class CompilerBase extends \PhpAot\Core\Translator } $this->indentLevel--; } - $code .= '}' . PHP_EOL . 'zend_end_try();' . PHP_EOL; + $code .= '}' . PHP_EOL; if ($finally) { $code .= $this->parseStmts($finally->stmts); $code .= PHP_EOL; diff --git a/src/cpp/main.cc b/src/cpp/main.cc index 56c81119..30450089 100644 --- a/src/cpp/main.cc +++ b/src/cpp/main.cc @@ -11,13 +11,9 @@ extern void php_app_init(); extern void php_app_clean(); extern zend_module_entry *php_embed_get_module(); -static void throw_exception(zend_object *ex) { - zend_bailout(); -} - int main(int cpp_argc, char **cpp_argv) { php_embed_init(cpp_argc, cpp_argv); - zend_throw_exception_hook = throw_exception; + php::throw_impl = [](zend_object *ex) { throw ex; }; zend_module_entry *module = php_embed_get_module(); if (zend_register_module_ex(module, MODULE_PERSISTENT) == NULL) { @@ -34,19 +30,14 @@ int main(int cpp_argc, char **cpp_argv) { #if PPROF_ON ProfilerStart("profile.out"); #endif - zend_first_try { + try { php::request_init(); php_app_init(); php::eval("main();"); - } - zend_catch { + } catch (zend_object *e) { rc = EG(exit_status); - if (EG(exception)) { - zend_exception_error(EG(exception), E_ERROR); - zend_clear_exception(); - } + zend_exception_error(e, E_ERROR); } - zend_end_try(); #if PPROF_ON ProfilerStop(); #endif