Skip to content

Language: __COMPILER_HALT_OFFSET__ magic constant (phase 2 of #3479, zend_compile.c) #5455

Description

@PurHur

Category

language

Problem

__halt_compiler() lowering landed (#3479), but the companion magic constant __COMPILER_HALT_OFFSET__ is still undefined at runtime. PHAR stubs and codegen tools rely on the byte offset of the first halt instruction.

Verified 2026-06-04: halt stops execution, but reading the constant fatals.

php-src reference

Repro

<?php
echo __COMPILER_HALT_OFFSET__, "\n";
__halt_compiler();
TRAILING
./script/docker-exec.sh bash -lc 'php repro.php'          # prints int offset (e.g. 89)
./script/docker-exec.sh bash -lc 'php bin/vm.php repro.php' # Error: Undefined constant "__COMPILER_HALT_OFFSET__"
Engine Expected
Zend int(N) — byte offset of halt in compiled file
This compiler same int on VM and AOT

Scope (this repo)

Layer Path
Compiler lib/Compiler.php — record halt byte offset per compilation unit (extend existing #3479 trailing-bytes fields)
php-cfg / parse expose offset from Stmt\HaltCompiler site
VM lower as script magic constant like __LINE__ / __FILE__
JIT/AOT constexpr per module; no host \__COMPILER_HALT_OFFSET__
Tests test/compliance/cases/language/compiler_halt_offset.phpt

Done when

Related

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