-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH-17715: Handle preloaded internal function runtime cache
This solely affects the builtin enum functions currently. Given that these are stored in SHM, we cannot simply hardwire a pointer into the internal function runtime cache on NTS too, but have to use a MAP_PTR (like on ZTS). Now, by design, the runtime cache of internal functions no longer is reset between requests, hence we need to store them explicitly as static runtime cache. On NTS builds we cannot trivially move the pointers into CG(internal_run_time_cache) as they're directly stored on the individual functions (on ZTS we could simply iterate the static map_ptrs). Hence, we have the choice between having opcache managing the internal run_time_cache for its preloaded functions itself or realloc CG(internal_run_time_cache) and iterate through all functions to assign the new address. We choose the latter for simplicity and initial speed. Note: map_ptr_static_last has been added as last element to zend_accel_shared_globals, so that accesses to it are compatible. We do not have to care about the ABI of creating new zend_accel_shared_globals structs. That's opcaches prerogative.
- Loading branch information
Showing
7 changed files
with
133 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--TEST-- | ||
Enum preloading with observers | ||
--EXTENSIONS-- | ||
opcache | ||
zend_test | ||
--INI-- | ||
opcache.enable=1 | ||
opcache.enable_cli=1 | ||
opcache.optimization_level=-1 | ||
opcache.preload={PWD}/preload_enum.inc | ||
zend_test.observer.enabled=1 | ||
zend_test.observer.observe_all=1 | ||
--SKIPIF-- | ||
<?php | ||
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows'); | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
spl_autoload_register(static function ($class) { | ||
if ($class === 'MyEnum') { | ||
require_once(__DIR__ . '/preload_enum.inc'); | ||
} | ||
}); | ||
|
||
var_dump(MyEnum::cases()); | ||
|
||
?> | ||
--EXPECTF-- | ||
<!-- init '%spreload_enum.inc' --> | ||
<file '%spreload_enum.inc'> | ||
<!-- init var_dump() --> | ||
<var_dump> | ||
enum(MyEnum::Bar) | ||
</var_dump> | ||
</file '%spreload_enum.inc'> | ||
<!-- init '%spreload_enum_observed.php' --> | ||
<file '%spreload_enum_observed.php'> | ||
<!-- init spl_autoload_register() --> | ||
<spl_autoload_register> | ||
</spl_autoload_register> | ||
<!-- init MyEnum::cases() --> | ||
<MyEnum::cases> | ||
</MyEnum::cases> | ||
<!-- init var_dump() --> | ||
<var_dump> | ||
array(2) { | ||
[0]=> | ||
enum(MyEnum::Foo) | ||
[1]=> | ||
enum(MyEnum::Bar) | ||
} | ||
</var_dump> | ||
</file '%spreload_enum_observed.php'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters