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
1 change: 1 addition & 0 deletions docs/bootstrap-selfhost.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Native self-host bundles include `lib/JIT/Result.php` for type closure only. Whe
| string | `strtolower`, `strtoupper`, `strcmp`, `strncmp`, `strcasecmp`, `strncasecmp`, `strlen`, `count`/`sizeof` | required |
| hash | `hash`, `hash_hmac` | required |
| preg | `preg_match`, `preg_quote` | required |
| filter | `filter_var`, `filter_input` | required |
| json | `json_encode` (minimal) | required |
| echo/print | opcode lowering in `lib/JIT.php` | n/a |
| other stdlib | — | `ExternalMethod` stub when not required |
Expand Down
9 changes: 6 additions & 3 deletions docs/stdlib-jit-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Auto-generated by `script/audit-stdlib-jit.php`. Regenerate: `php script/audit-s

| Metric | Count |
|--------|------:|
| `call()` implementations | 183 |
| With JitStringArg/JitLongArg (or zero-arg LLVM) | 177 |
| `call()` implementations | 186 |
| With JitStringArg/JitLongArg (or zero-arg LLVM) | 180 |
| Missing arg helpers (actionable for JIT) | 0 |
| Deferred (VM-only) | 6 |
| Self-host auto-stub batch | 31 |
| Self-host auto-stub batch | 32 |

## Missing (sorted)

Expand Down Expand Up @@ -47,6 +47,7 @@ _None — all JIT `call()` builtins are lowered or deferred._
- `array_unique` — `ext/standard/array_unique.php`
- `array_unshift` — `ext/standard/array_unshift.php`
- `array_values` — `ext/standard/array_values.php`
- `atan2` — `ext/standard/atan2.php`
- `base64_decode` — `ext/standard/base64_decode.php`
- `base64_encode` — `ext/standard/base64_encode.php`
- `basename` — `ext/standard/basename.php`
Expand All @@ -60,6 +61,7 @@ _None — all JIT `call()` builtins are lowered or deferred._
- `compact` — `ext/standard/compact_.php`
- `copy` — `ext/standard/copy_.php`
- `cos` — `ext/standard/cos.php`
- `crc32` — `ext/standard/crc32.php`
- `date` — `ext/standard/date.php`
- `decbin` — `ext/standard/decbin.php`
- `dechex` — `ext/standard/dechex.php`
Expand Down Expand Up @@ -185,6 +187,7 @@ _None — all JIT `call()` builtins are lowered or deferred._
- `strstr` — `ext/standard/strstr.php`
- `strtolower` — `ext/standard/strtolower.php`
- `strtoupper` — `ext/standard/strtoupper.php`
- `strtr` — `ext/standard/strtr.php`
- `strval` — `ext/standard/strval.php`
- `substr` — `ext/standard/substr.php`
- `substr_count` — `ext/standard/substr_count.php`
Expand Down
4 changes: 4 additions & 0 deletions lib/JIT/SelfHostBuiltinPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ final class SelfHostBuiltinPolicy
+ self::CATEGORY_ARRAY
+ self::CATEGORY_HASH
+ self::CATEGORY_PREG
+ self::CATEGORY_FILTER
+ self::CATEGORY_JSON
+ self::CATEGORY_NUMERIC;

Expand Down Expand Up @@ -83,6 +84,9 @@ final class SelfHostBuiltinPolicy
/** @var array<string, string> */
private const CATEGORY_PREG = ['preg_match' => 'preg', 'preg_quote' => 'preg'];

/** @var array<string, string> */
private const CATEGORY_FILTER = ['filter_var' => 'filter', 'filter_input' => 'filter'];

/** @var array<string, string> */
private const CATEGORY_JSON = ['json_encode' => 'json'];

Expand Down
2 changes: 1 addition & 1 deletion script/audit-stdlib-jit.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
$hasJitLowering = static function (string $source): bool {
return (bool) preg_match(
'/JitStringArg|JitLongArg|JitBoolArg|->jitString\s*\(|->jitLong\s*\(|->jitBool\s*\(|'
.'ArrayBuiltinHelper::|pow::toJitDouble|JitDate::|JitGetallheaders::|JitPendingHeaders::|constReal\s*\(/',
.'ArrayBuiltinHelper::|pow::toJitDouble|JitDate::|JitFilter::|JitGetallheaders::|JitPendingHeaders::|constReal\s*\(/',
$source
);
};
Expand Down
5 changes: 5 additions & 0 deletions test/unit/SelfHostBuiltinPolicyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public function testRequiredBundleCategories(): void
$this->assertFalse(SelfHostBuiltinPolicy::shouldExternalStub('mkdir'));
$this->assertFalse(SelfHostBuiltinPolicy::shouldExternalStub('file_put_contents'));
$this->assertFalse(SelfHostBuiltinPolicy::shouldExternalStub('fopen'));
$this->assertTrue(SelfHostBuiltinPolicy::isRequiredForBundle('filter_var'));
$this->assertSame('filter', SelfHostBuiltinPolicy::categoryFor('filter_input'));
$this->assertFalse(SelfHostBuiltinPolicy::shouldExternalStub('filter_var'));
$this->assertFalse(SelfHostBuiltinPolicy::shouldExternalStub('hash'));
$this->assertFalse(SelfHostBuiltinPolicy::shouldExternalStub('preg_match'));
}

public function testCompileFuncRegistersExternalMethodStub(): void
Expand Down
Loading