Skip to content

Commit

Permalink
Add --force-jit flag
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Nov 24, 2024
1 parent 8ae7e88 commit af5f5ae
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Psalm/Internal/Cli/Psalm.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ final class Psalm
'memory-limit:',
'monochrome',
'no-diff',
'force-jit',
'no-cache',
'no-reflection-cache',
'no-file-cache',
Expand Down Expand Up @@ -924,8 +925,10 @@ private static function restart(array $options, int $threads, Progress $progress
// If Xdebug is enabled, restart without it
$ini_handler->check();

$hasJit = false;
if (function_exists('opcache_get_status')) {
if (true === (opcache_get_status()['jit']['on'] ?? false)) {
$hasJit = true;
$progress->write(PHP_EOL
. 'JIT acceleration: ON'
. PHP_EOL . PHP_EOL);
Expand All @@ -943,11 +946,15 @@ private static function restart(array $options, int $threads, Progress $progress
. PHP_EOL . PHP_EOL);
} else {
$progress->write(PHP_EOL
. 'JIT acceleration: OFF (opcache not installed)' . PHP_EOL
. 'Install the opcache extension to make use of JIT for a 20%+ performance boost!'
. 'JIT acceleration: OFF (opcache not installed or not enabled)' . PHP_EOL
. 'Install and enable the opcache extension to make use of JIT for a 20%+ performance boost!'
. PHP_EOL . PHP_EOL);
}
}
if (isset($options['force-jit']) && !$hasJit) {
$progress->write('Exiting because JIT was requested but is not available.' . PHP_EOL . PHP_EOL);
exit(1);
}
}

private static function detectThreads(array $options, Config $config, bool $in_ci): int
Expand Down Expand Up @@ -1291,6 +1298,9 @@ private static function getHelpText(): string
--disable-extension=[extension]
Used to disable certain extensions while Psalm is running.
--force-jit
If set, requires JIT acceleration to be available in order to run Psalm, exiting immediately if it cannot be enabled.
--threads=INT
If greater than one, Psalm will run analysis on multiple threads, speeding things up.
Expand Down

0 comments on commit af5f5ae

Please sign in to comment.