Problem
The VM already has helpers such as allocArray(), but some code still directly allocates runtime objects and manually adds them to tracking collections.
For example:
const arr = try self.allocator.create(PhpArray);
try self.arrays.append(self.allocator, arr);
This can bypass pooling, duplicate ownership logic, and make allocation-failure cleanup inconsistent.
The same should be audited for arrays, objects, strings, reference cells, generators, fibers, etc.
Changes
Route runtime heap allocations through centralized helpers such as:
allocArray()
allocObject()
allocOwnedString()
allocPersistentString()
allocRefCell()
Each helper should handle initialization, tracking, pooling, lifetime, and failure cleanup.
Acceptance criteria
- Runtime heap objects use centralized allocation paths.
- Pooling/tracking cannot be accidentally bypassed.
- Tracking allocation failures clean up correctly.
- No meaningful performance regression.
Problem
The VM already has helpers such as
allocArray(), but some code still directly allocates runtime objects and manually adds them to tracking collections.For example:
This can bypass pooling, duplicate ownership logic, and make allocation-failure cleanup inconsistent.
The same should be audited for arrays, objects, strings, reference cells, generators, fibers, etc.
Changes
Route runtime heap allocations through centralized helpers such as:
allocArray()allocObject()allocOwnedString()allocPersistentString()allocRefCell()Each helper should handle initialization, tracking, pooling, lifetime, and failure cleanup.
Acceptance criteria