Skip to content

Language: throw expressions — JIT lowering (phase 2 of #3802) #4137

Description

@PurHur

Category

language

Problem

#3802 delivered VM + compile lowering for throw in expression context (?:, ??, short-circuit). docs/capabilities-syntax.md still marks JIT = no for throw expressions.

bin/jit.php / self-host native emit must compile throw-expression CFG (TYPE_THROW from expression slots, no duplicate TYPE_NEW) or fall back with a documented gate.

Related open: #4041 (AOT phase 2) — coordinate so JIT and AOT share the same throw-expression merge rules.

php-src reference

Repro

<?php
try {
    echo (false ? 1 : throw new LogicException('x'));
} catch (LogicException $e) {
    echo $e->getMessage(), "\n";
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro.php
php bin/jit.php repro.php 2>&1 | head -20
'
Driver Expected
VM x
JIT x (no VM fallback / no compile abort)

Scope (this repo)

Layer Files
Compiler lib/Compiler.phpcompileThrowExpression, fresh slots for ?: / ?? (already VM)
JIT lib/JIT.php, lib/JIT/TypeReconstructor.phpExpr_Throw / TYPE_THROW lowering
Policy lib/JIT/SelfHostBuiltinPolicy.php — remove throw-expression from MCJIT skip list if present
Tests test/compliance/cases/language/throw_expression.phpt (extend JIT execute), test/fixtures/aot/compile-only/throw_expression.php
Matrix script/capability-syntax-lib.php — set jit => true when green

Done when

  • Repro prints x under bin/jit.php without VM-only fallback
  • throw on RHS of && / || and nested ?? covered by compliance PHPT
  • docs/capabilities-syntax.md throw_expression row: JIT yes
  • ./script/ci-fast.sh --filter throw_expression green (VM + JIT groups)

Links

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions