From af5f5aef72ee97f49dcaa444c39811303ec176f2 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 24 Nov 2024 10:58:14 +0000 Subject: [PATCH] Add --force-jit flag --- src/Psalm/Internal/Cli/Psalm.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index bd43a169100..e0ac61bcfef 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -132,6 +132,7 @@ final class Psalm 'memory-limit:', 'monochrome', 'no-diff', + 'force-jit', 'no-cache', 'no-reflection-cache', 'no-file-cache', @@ -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); @@ -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 @@ -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.