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
19 changes: 14 additions & 5 deletions docs/bootstrap-profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@
"lib/Lint/UnsupportedRegistry.php",
"lib/Module.php",
"lib/ModuleAbstract.php",
"lib/NullSafeLivenessDetector.php",
"lib/OpCode.php",
"lib/Printer.php",
"lib/Runtime.php",
Expand Down Expand Up @@ -330,27 +331,35 @@
],
"aot_lint_targets": [
"examples/000-HelloWorld/example.php",
"test/bootstrap-aot/class_const_fetch.php",
"test/bootstrap-aot/class_constants.php",
"test/bootstrap-aot/class_nullable_property.php",
"test/bootstrap-aot/echo_hello.php",
"test/bootstrap-aot/instanceof_check.php",
"test/bootstrap-aot/minimal_class.php",
"test/bootstrap-aot/namespace_hello.php",
"test/bootstrap-aot/nullable_types.php",
"test/bootstrap-aot/require_chain/main.php",
"test/bootstrap-aot/throw_logic.php"
],
"aot_link_targets": [
"examples/000-HelloWorld/example.php",
"test/bootstrap-aot/class_const_fetch.php",
"test/bootstrap-aot/class_constants.php",
"test/bootstrap-aot/class_nullable_property.php",
"test/bootstrap-aot/echo_hello.php",
"test/bootstrap-aot/instanceof_check.php",
"test/bootstrap-aot/minimal_class.php",
"test/bootstrap-aot/namespace_hello.php",
"test/bootstrap-aot/nullable_types.php"
"test/bootstrap-aot/nullable_types.php",
"test/bootstrap-aot/require_chain/main.php",
"test/bootstrap-aot/throw_logic.php"
],
"totals": {
"inventory_files": 299,
"inventory_files": 300,
"excluded": 2,
"eligible": 297,
"aot_lint_targets": 8,
"aot_link_targets": 8
"eligible": 298,
"aot_lint_targets": 11,
"aot_link_targets": 11
}
}
5 changes: 3 additions & 2 deletions docs/bootstrap-selfhost.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ Regenerate: `make bootstrap-profile` (inventory + profile + optional `bootstrap-

## Bootstrap AOT lint ladder

Add scripts under `test/bootstrap-aot/*.php` — picked up automatically by `script/bootstrap-profile.php` ([#514](https://github.com/PurHur/php-compiler/issues/514)):
Add scripts under `test/bootstrap-aot/*.php` — picked up automatically by `script/bootstrap-profile.php` ([#514](https://github.com/PurHur/php-compiler/issues/514)). Multi-file `require_once` chains: `test/bootstrap-aot/<name>/main.php` (helpers alongside; issue [#120](https://github.com/PurHur/php-compiler/issues/120)):

- `echo_hello.php` — baseline procedural
- `nullable_types.php` — `?string` parameters (self-host typing)
- `namespace_hello.php` — single-file `namespace` + unqualified calls ([#513](https://github.com/PurHur/php-compiler/issues/513), [#84](https://github.com/PurHur/php-compiler/issues/84))
- `minimal_class.php` — one public method (ClassMethod lowering)
- `class_nullable_property.php` — nullable property with `= null` default
- `class_constants.php` — class `Const_` declarations (issue #84)
- `require_chain/main.php` — `require_once` helper with shared functions (issue #120)

`php bin/compile.php -l lib/OpCode.php` passes after `TYPE_DECLARE_CLASS_CONST` lowering; `lib/Frame.php` still needs namespaces. Next: `require_once` chain ([#120](https://github.com/PurHur/php-compiler/issues/120)).
`php bin/compile.php -l lib/OpCode.php` passes after `TYPE_DECLARE_CLASS_CONST` lowering; `lib/Frame.php` still needs namespaces.

## Non-goals (initial bootstrap)

Expand Down
4 changes: 4 additions & 0 deletions script/bootstrap-lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ function bootstrapDefaultAotLintTargets(string $root): array
foreach (glob($root.'/test/bootstrap-aot/*.php') ?: [] as $path) {
$targets[] = substr($path, strlen($root) + 1);
}
// Multi-file chains: test/bootstrap-aot/<name>/main.php (issue #120).
foreach (glob($root.'/test/bootstrap-aot/*/main.php') ?: [] as $path) {
$targets[] = substr($path, strlen($root) + 1);
}
sort($targets, SORT_STRING);

return array_values(array_unique($targets));
Expand Down
13 changes: 13 additions & 0 deletions test/bootstrap-aot/require_chain/helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

function greet(string $name): string
{
return 'Hello, '.$name;
}

function add(int $a, int $b): int
{
return $a + $b;
}
8 changes: 8 additions & 0 deletions test/bootstrap-aot/require_chain/main.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

declare(strict_types=1);

require_once __DIR__.'/helper.php';

echo greet('Bootstrap')."\n";
echo (string) add(2, 3)."\n";
1 change: 1 addition & 0 deletions test/unit/BootstrapProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function testProfileScriptBuildsValidJson(): void
$this->assertContains('test/bootstrap-aot/class_nullable_property.php', $profile['aot_lint_targets']);
$this->assertContains('test/bootstrap-aot/class_constants.php', $profile['aot_lint_targets']);
$this->assertContains('test/bootstrap-aot/throw_logic.php', $profile['aot_lint_targets']);
$this->assertContains('test/bootstrap-aot/require_chain/main.php', $profile['aot_lint_targets']);
$this->assertContains('lib/AOT/Linker.php', $profile['excluded_files']);
}

Expand Down