Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions docs/bootstrap-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Regenerate: `php script/bootstrap-inventory.php`

| Metric | Count |
|--------|------:|
| PHP files on vm.php path | 3028 |
| Phase A inventory files (M2 ratio SSOT) | 3028 |
| PHP files on vm.php path | 3027 |
| Phase A inventory files (M2 ratio SSOT) | 3027 |
| Phase A ratio-deferred paths | 0 |
| Source constructs flagged (blockers) | 0 |
| Source constructs flagged (warnings) | 8157 |
| Source constructs flagged (warnings) | 8156 |

## Compiler CFG gaps (`lib/Compiler.php`)

Expand Down Expand Up @@ -2261,8 +2261,7 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
| `lib/JIT/Builtin/StringParseStrJit.php` | 0 | 1 |
| `lib/JIT/Builtin/StringPasswordCrypto.php` | 0 | 1 |
| `lib/JIT/Builtin/StringPasswordCryptoJit.php` | 0 | 1 |
| `lib/JIT/Builtin/StringPhpinfoRuntime.php` | 0 | 2 |
| `lib/JIT/Builtin/StringPhpinfoRuntimeLlvm.php` | 0 | 2 |
| `lib/JIT/Builtin/StringPhpinfoRuntime.php` | 0 | 3 |
| `lib/JIT/Builtin/StringPregMatch.php` | 0 | 1 |
| `lib/JIT/Builtin/StringPregMatchJit.php` | 0 | 2 |
| `lib/JIT/Builtin/StringPregQuote.php` | 0 | 1 |
Expand Down Expand Up @@ -17661,13 +17660,8 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
### `lib/JIT/Builtin/StringPhpinfoRuntime.php`

**Warnings** (review for bootstrap subset):
- new JIT (line 160)
- 7 class method(s)

### `lib/JIT/Builtin/StringPhpinfoRuntimeLlvm.php`

**Warnings** (review for bootstrap subset):
- 21 class method(s)
- new JIT (line 158)
- 8 class method(s)
- 1 closure(s)

### `lib/JIT/Builtin/StringPregMatch.php`
Expand Down
53 changes: 26 additions & 27 deletions lib/JIT/Builtin/StringPhpinfoRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
namespace PHPCompiler\JIT\Builtin;

use PHPCompiler\JIT;
use PHPCompiler\JIT\Builtin;
use PHPCompiler\JIT\Context;
use PHPCompiler\JIT\NestedJitCompileScope;
use PHPLLVM\Value\Function_ as LlvmFunction;

/**
* JIT/AOT link for __compiler_phpinfo / __compiler_phpcredits via PhpinfoJitHelper PHP (#9256).
*
* JIT uses compiled {@see \PHPCompiler\ext\standard\PhpinfoJitHelper}; AOT standalone keeps
* {@see StringPhpinfoRuntimeLlvm} until VmInfo HTML compiles in native link (#9256).
* php-src: ext/standard/info.c
* JIT embed and AOT standalone compile {@see \PHPCompiler\ext\standard\PhpinfoJitHelper}; thin LLVM bridges
* forward the ABI. php-src: ext/standard/info.c
*/
final class StringPhpinfoRuntime
{
Expand All @@ -41,6 +40,11 @@ public static function ensureLinked(Context $context): void
self::implement($context);
}

public static function ensureStandaloneBodies(Context $context): void
{
self::implement($context);
}

public static function implement(Context $context): void
{
$probe = $context->module->getNamedFunction('__compiler_phpinfo');
Expand All @@ -50,13 +54,6 @@ public static function implement(Context $context): void
return;
}

if (Builtin::LOAD_TYPE_STANDALONE === $context->loadType) {
StringPhpinfoRuntimeLlvm::implement($context);
self::registerLinkedRuntime($context);

return;
}

ObOutput::registerExternals($context);
ObOutputRuntime::ensureLinked($context);
self::ensureJitHelperCompiled($context);
Expand Down Expand Up @@ -149,25 +146,27 @@ private static function ensureJitHelperCompiled(Context $context): void
$runtime = $context->runtime;
$path = \dirname(__DIR__, 3).self::HELPER_PATH;
$prevSelfHostAot = \getenv('PHP_COMPILER_SELFHOST_AOT');
if (\function_exists('putenv')) {
\putenv('PHP_COMPILER_SELFHOST_AOT=0');
}
try {
$block = $runtime->parseAndCompile((string) \file_get_contents($path), 'PhpinfoJitHelper.php');
if (null === $block) {
throw new \LogicException('PhpinfoJitHelper.php parseAndCompile failed (#9256)');
}
$jit = new JIT($context);
$jit->compile($block);
} finally {
NestedJitCompileScope::run($context, static function () use ($context, $runtime, $path, $prevSelfHostAot): void {
if (\function_exists('putenv')) {
if (false === $prevSelfHostAot || null === $prevSelfHostAot) {
\putenv('PHP_COMPILER_SELFHOST_AOT=');
} else {
\putenv('PHP_COMPILER_SELFHOST_AOT='.$prevSelfHostAot);
\putenv('PHP_COMPILER_SELFHOST_AOT=0');
}
try {
$block = $runtime->parseAndCompile((string) \file_get_contents($path), 'PhpinfoJitHelper.php');
if (null === $block) {
throw new \LogicException('PhpinfoJitHelper.php parseAndCompile failed (#9256)');
}
$jit = new JIT($context);
$jit->compile($block);
} finally {
if (\function_exists('putenv')) {
if (false === $prevSelfHostAot || null === $prevSelfHostAot) {
\putenv('PHP_COMPILER_SELFHOST_AOT=');
} else {
\putenv('PHP_COMPILER_SELFHOST_AOT='.$prevSelfHostAot);
}
}
}
}
});
foreach (self::COMPILED_HELPERS as $logical) {
if (!isset($context->functions[\strtolower($logical)])) {
throw new \LogicException($logical.' was not compiled for JIT (#9256)');
Expand Down
Loading