Skip to content

Commit

Permalink
Do not try tweaking JIT if it's not available
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Feb 11, 2023
1 parent 542cc34 commit db1a382
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/Psalm/Internal/Fork/PsalmRestarter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@ protected function requiresRestart($default): bool
static fn(string $extension): bool => extension_loaded($extension)
);

if (!in_array(ini_get('opcache.enable_cli'), ['1', 'true', true, 1])) {
return true;
}

if (((int) ini_get('opcache.jit')) !== 1205) {
return true;
}

if (((int) ini_get('opcache.jit')) === 0) {
return true;
if (PHP_VERSION_ID >= 8_00_00 && (extension_loaded('opcache') || extension_loaded('Zend OPcache'))) {
// restart to enable JIT if it's not configured in the optimal way
if (!in_array(ini_get('opcache.enable_cli'), ['1', 'true', true, 1])) {
return true;
}

if (((int) ini_get('opcache.jit')) !== 1205) {
return true;
}

if (((int) ini_get('opcache.jit')) === 0) {
return true;
}
}

return $default || $this->required;
Expand All @@ -80,7 +83,8 @@ protected function restart(array $command): void
// executed in the parent process (before restart)
// if it wasn't loaded then we apparently don't have opcache installed and there's no point trying
// to tweak it
if (extension_loaded('opcache') || extension_loaded('Zend OPcache')) {
// If we're running on 7.4 there's no JIT available
if (PHP_VERSION_ID >= 8_00_00 && (extension_loaded('opcache') || extension_loaded('Zend OPcache'))) {
$additional_options = [
'-dopcache.enable_cli=true',
'-dopcache.jit_buffer_size=512M',
Expand Down

0 comments on commit db1a382

Please sign in to comment.