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
2 changes: 1 addition & 1 deletion lib/JIT/Builtin/SuperglobalNameRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Owns `__compiler_is_superglobal_name` ABI module-locally: {@see getNamedFunction} first, then
* {@see implementBridge}. Do not re-add empty always-on shells in {@see Type} — leftover decls
* mint is_superglobal_name.1 (#31894 / #32122 / #33235). Context ensureMinimalUserStandaloneBodies
* must not NestedJIT this during thin hello-world init (#34812) — call sites
* and ensureFullStandaloneBodies must not NestedJIT this during init (#34812 / #35035) — call sites
* {@see StringSuperglobalName::ensureLinked} / {@see \PHPCompiler\ext\standard\JitSuperglobalName}
* already ensureLinked before lookup. Call-site ensureLinked restores the caller insert block
* after bridge emit (thin AOT: parentless call / module verify — peer MetaTagsRuntime #27317).
Expand Down
14 changes: 9 additions & 5 deletions lib/JIT/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -2485,15 +2485,19 @@ private function ensureFullStandaloneBodies(): void
Builtin\RewriteVarsRuntime::ensureStandaloneBodies($this);
Builtin\DefineRuntime::ensureStandaloneBodies($this);
Builtin\SuperglobalRefreshRuntime::ensureStandaloneBodies($this);
Builtin\SuperglobalNameRuntime::ensureLinked($this);
// SuperglobalName always-on removed (#35035): JitSuperglobalName / JIT.php
// StringSuperglobalName::ensureLinked before lookup (peer ensureMinimal #34812 /
// #33235). Full standalone must not NestedJIT is_superglobal_name during init —
// leftover Context NestedJIT vs Runtime ABI drift mints is_superglobal_name.1
// (#31894 / #32122).
Builtin\StringStrspn::ensureStandaloneBodies($this);
// BootstrapCompileSmokeM3Emit / inventory argv {main} calls __compiler_file_get_contents (#15604).
Builtin\StringFileGetContents::ensureStandaloneBodies($this);
Builtin\StringReadfile::ensureStandaloneBodies($this);
Builtin\TokenGetAll::ensureStandaloneBodies($this);
Builtin\Highlight::ensureStandaloneBodies($this);
Builtin\Hebrev::ensureStandaloneBodies($this);
Builtin\Hebrevc::ensureStandaloneBodies($this);
// TokenGetAll / Highlight / Hebrev / Hebrevc always-on removed (#35035): each
// ensureStandaloneBodies is a no-op — helper LLVM compiles on first lowering
// (TokenGetAll::helperFunction / JitHighlight / JitHebrev). Do not re-add eager
// NestedJIT here (#31894 / #32122 .1 mint class).
\PHPCompiler\ext\standard\JitStreamBucketKernel::ensureStandaloneBodies($this);
} finally {
Builtin\StreamIoRuntime::endStandaloneInitPhase();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

declare(strict_types=1);

namespace PHPCompiler\Test\Unit;

use PHPUnit\Framework\TestCase;

/**
* Drop Context::ensureFullStandaloneBodies always-on TokenGetAll/Highlight/Hebrev/Hebrevc
* no-ops + SuperglobalNameRuntime NestedJIT (#35035 / peer #34812).
*
* Full standalone must not NestedJIT is_superglobal_name during init (#32122 .1 mint class).
* TokenGetAll/Highlight/Hebrev/Hebrevc ensureStandaloneBodies are no-ops — helpers compile
* on first lowering.
*/
final class ContextFullStandaloneLazyTokenHebrevSuperglobalShrinkTest extends TestCase
{
public function testEnsureFullDropsEagerTokenHighlightHebrevAndSuperglobalName(): void
{
$context = (string) file_get_contents(__DIR__.'/../../lib/JIT/Context.php');
$this->assertStringContainsString('#35035', $context);
$fullPos = strpos($context, 'private function ensureFullStandaloneBodies');
$this->assertNotFalse($fullPos);
$fullEnd = strpos($context, 'public function compileToFile', $fullPos);
$this->assertNotFalse($fullEnd);
$fullBody = substr($context, $fullPos, $fullEnd - $fullPos);

foreach ([
'TokenGetAll::ensureStandaloneBodies($this)',
'Highlight::ensureStandaloneBodies($this)',
'Hebrev::ensureStandaloneBodies($this)',
'Hebrevc::ensureStandaloneBodies($this)',
'SuperglobalNameRuntime::ensureLinked($this)',
] as $forbidden) {
$this->assertStringNotContainsString(
$forbidden,
$fullBody,
'ensureFullStandaloneBodies must not eagerly '.$forbidden.' (#35035)'
);
}

// Still links refresh + strspn / file helpers used by inventory / standalone main.
$this->assertStringContainsString('SuperglobalRefreshRuntime::ensureStandaloneBodies($this)', $fullBody);
$this->assertStringContainsString('StringStrspn::ensureStandaloneBodies($this)', $fullBody);
}

public function testCallSitesStillEnsureBeforeLookup(): void
{
$jit = (string) file_get_contents(__DIR__.'/../../ext/standard/JitSuperglobalName.php');
$this->assertStringContainsString('StringSuperglobalName::ensureLinked($context)', $jit);

$hebrev = (string) file_get_contents(__DIR__.'/../../ext/standard/JitHebrev.php');
$this->assertStringContainsString('Hebrev::ensureLinked($context)', $hebrev);

$hebrevc = (string) file_get_contents(__DIR__.'/../../ext/standard/JitHebrevc.php');
$this->assertStringContainsString('HebrevcBuiltin::ensureLinked($context)', $hebrevc);

$highlight = (string) file_get_contents(__DIR__.'/../../ext/standard/JitHighlight.php');
$this->assertStringContainsString('Highlight::ensureLinked($context)', $highlight);

$token = (string) file_get_contents(__DIR__.'/../../ext/tokenizer/JitTokenGetAll.php');
$this->assertStringContainsString('TokenGetAll::helperFunction($context)', $token);
}

public function testSuperglobalNameRuntimeDocumentsLazyFull(): void
{
$source = (string) file_get_contents(__DIR__.'/../../lib/JIT/Builtin/SuperglobalNameRuntime.php');
$this->assertStringContainsString('#35035', $source);
$this->assertStringContainsString('ensureFullStandaloneBodies', $source);
}

public function testNoNewRuntimeCForFullStandaloneLazy(): void
{
$runtimeDir = dirname(__DIR__, 2).'/lib/AOT/runtime';
$this->assertFileDoesNotExist(
$runtimeDir.'/token_get_all.c',
'must not add token_get_all.c for #35035 — PHP JIT bridges only'
);
$this->assertFileDoesNotExist(
$runtimeDir.'/is_superglobal_name.c',
'must not re-add is_superglobal_name.c for #35035'
);
}
}
Loading