Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always enable JIT #9237

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/Psalm/Internal/Fork/PsalmRestarter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
use Composer\XdebugHandler\XdebugHandler;

use function array_filter;
use function array_splice;
use function extension_loaded;
use function file_get_contents;
use function file_put_contents;
use function implode;
use function in_array;
use function ini_get;
use function preg_replace;

/**
Expand Down Expand Up @@ -40,16 +43,28 @@ protected function requiresRestart($default): bool
$this->disabledExtensions,
static fn(string $extension): bool => extension_loaded($extension)
);
if (!extension_loaded('opcache')) {
return true;
}
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;
}

/**
* No type hint to allow xdebug-handler v1 and v2 usage
*
* @param string|string[] $command
* @param string[] $command
*/
protected function restart($command): void
protected function restart(array $command): void
{
if ($this->required && $this->tmpIni) {
$regex = '/^\s*(extension\s*=.*(' . implode('|', $this->disabledExtensions) . ').*)$/mi';
Expand All @@ -59,8 +74,18 @@ protected function restart($command): void

file_put_contents($this->tmpIni, $content);
}
array_splice(
$command,
1,
0,
[
'-dzend_extension=opcache',
'-dopcache.enable_cli=true',
'-dopcache.jit_buffer_size=512M',
'-dopcache.jit=1205',
],
);

/** @psalm-suppress PossiblyInvalidArgument */
parent::restart($command);
}
}