mirror of
https://github.com/php/php-src.git
synced 2024-10-01 06:46:08 +00:00
Merge branch 'master' of git.php.net:php-src
This commit is contained in:
commit
bbc37e78e8
@ -1909,7 +1909,9 @@ static void zend_t_usage(zend_code_block *block, zend_op_array *op_array, char *
|
||||
if (RESULT_USED(opline)) {
|
||||
if (!defined_here[VAR_NUM(ZEND_RESULT(opline).var)] && !used_ext[VAR_NUM(ZEND_RESULT(opline).var)] &&
|
||||
(opline->opcode == ZEND_RECV || opline->opcode == ZEND_RECV_INIT ||
|
||||
#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
|
||||
opline->opcode == ZEND_RECV_VARIADIC ||
|
||||
#endif
|
||||
(opline->opcode == ZEND_OP_DATA && ZEND_RESULT_TYPE(opline) == IS_TMP_VAR) ||
|
||||
opline->opcode == ZEND_ADD_ARRAY_ELEMENT)) {
|
||||
/* these opcodes use the result as argument */
|
||||
@ -1994,7 +1996,9 @@ static void zend_t_usage(zend_code_block *block, zend_op_array *op_array, char *
|
||||
|
||||
if (opline->opcode == ZEND_RECV ||
|
||||
opline->opcode == ZEND_RECV_INIT ||
|
||||
#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
|
||||
opline->opcode == ZEND_RECV_VARIADIC ||
|
||||
#endif
|
||||
opline->opcode == ZEND_ADD_ARRAY_ELEMENT) {
|
||||
if (ZEND_OP1_TYPE(opline) == IS_VAR || ZEND_OP1_TYPE(opline) == IS_TMP_VAR) {
|
||||
usage[VAR_NUM(ZEND_RESULT(opline).var)] = 1;
|
||||
|
@ -433,7 +433,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
|
||||
zval t;
|
||||
|
||||
if (zend_get_persistent_constant(Z_STRVAL(ZEND_OP1_LITERAL(opline - 1)),
|
||||
Z_STRLEN(ZEND_OP1_LITERAL(opline - 1)), &t, 0 TSRMLS_CC)) {
|
||||
Z_STRLEN(ZEND_OP1_LITERAL(opline - 1)), &t, 1 TSRMLS_CC)) {
|
||||
if (replace_var_by_const(op_array, opline + 1, ZEND_RESULT(opline).var, &t TSRMLS_CC)) {
|
||||
literal_dtor(&ZEND_OP1_LITERAL(opline - 1));
|
||||
MAKE_NOP((opline - 1));
|
||||
|
@ -36,7 +36,11 @@
|
||||
#include "main/php_open_temporary_file.h"
|
||||
#include "zend_API.h"
|
||||
#include "zend_ini.h"
|
||||
#include "zend_virtual_cwd.h"
|
||||
#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
|
||||
# include "zend_virtual_cwd.h"
|
||||
#else
|
||||
# include "TSRM/tsrm_virtual_cwd.h"
|
||||
#endif
|
||||
#include "zend_accelerator_util_funcs.h"
|
||||
#include "zend_accelerator_hash.h"
|
||||
|
||||
@ -387,8 +391,10 @@ static void accel_use_shm_interned_strings(TSRMLS_D)
|
||||
{
|
||||
Bucket *p, *q;
|
||||
|
||||
#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
|
||||
/* empty string */
|
||||
CG(interned_empty_string) = accel_new_interned_string("", sizeof(""), 0 TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
/* function table hash keys */
|
||||
p = CG(function_table)->pListHead;
|
||||
@ -2135,7 +2141,9 @@ static void accel_activate(void)
|
||||
}
|
||||
|
||||
#if (ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO) && !defined(ZTS)
|
||||
accel_interned_strings_restore_state(TSRMLS_C);
|
||||
if (ZCG(accel_directives).interned_strings_buffer) {
|
||||
accel_interned_strings_restore_state(TSRMLS_C);
|
||||
}
|
||||
#endif
|
||||
|
||||
zend_shared_alloc_restore_state();
|
||||
@ -2453,36 +2461,39 @@ static int zend_accel_init_shm(TSRMLS_D)
|
||||
|
||||
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
|
||||
|
||||
ZCSG(interned_strings_start) = ZCSG(interned_strings_end) = NULL;
|
||||
# ifndef ZTS
|
||||
zend_hash_init(&ZCSG(interned_strings), (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024) / (sizeof(Bucket) + sizeof(Bucket*) + 8 /* average string length */), NULL, NULL, 1);
|
||||
ZCSG(interned_strings).nTableMask = ZCSG(interned_strings).nTableSize - 1;
|
||||
ZCSG(interned_strings).arBuckets = zend_shared_alloc(ZCSG(interned_strings).nTableSize * sizeof(Bucket *));
|
||||
ZCSG(interned_strings_start) = zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * 1024));
|
||||
if (!ZCSG(interned_strings).arBuckets || !ZCSG(interned_strings_start)) {
|
||||
zend_accel_error(ACCEL_LOG_FATAL, ACCELERATOR_PRODUCT_NAME " cannot allocate buffer for interned strings");
|
||||
return FAILURE;
|
||||
if (ZCG(accel_directives).interned_strings_buffer) {
|
||||
ZCSG(interned_strings).nTableMask = ZCSG(interned_strings).nTableSize - 1;
|
||||
ZCSG(interned_strings).arBuckets = zend_shared_alloc(ZCSG(interned_strings).nTableSize * sizeof(Bucket *));
|
||||
ZCSG(interned_strings_start) = zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * 1024));
|
||||
if (!ZCSG(interned_strings).arBuckets || !ZCSG(interned_strings_start)) {
|
||||
zend_accel_error(ACCEL_LOG_FATAL, ACCELERATOR_PRODUCT_NAME " cannot allocate buffer for interned strings");
|
||||
return FAILURE;
|
||||
}
|
||||
ZCSG(interned_strings_end) = ZCSG(interned_strings_start) + (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024);
|
||||
ZCSG(interned_strings_top) = ZCSG(interned_strings_start);
|
||||
|
||||
orig_interned_strings_start = CG(interned_strings_start);
|
||||
orig_interned_strings_end = CG(interned_strings_end);
|
||||
CG(interned_strings_start) = ZCSG(interned_strings_start);
|
||||
CG(interned_strings_end) = ZCSG(interned_strings_end);
|
||||
}
|
||||
ZCSG(interned_strings_end) = ZCSG(interned_strings_start) + (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024);
|
||||
ZCSG(interned_strings_top) = ZCSG(interned_strings_start);
|
||||
# else
|
||||
ZCSG(interned_strings_start) = ZCSG(interned_strings_end) = NULL;
|
||||
# endif
|
||||
|
||||
orig_interned_strings_start = CG(interned_strings_start);
|
||||
orig_interned_strings_end = CG(interned_strings_end);
|
||||
orig_new_interned_string = zend_new_interned_string;
|
||||
orig_interned_strings_snapshot = zend_interned_strings_snapshot;
|
||||
orig_interned_strings_restore = zend_interned_strings_restore;
|
||||
|
||||
CG(interned_strings_start) = ZCSG(interned_strings_start);
|
||||
CG(interned_strings_end) = ZCSG(interned_strings_end);
|
||||
zend_new_interned_string = accel_new_interned_string_for_php;
|
||||
zend_interned_strings_snapshot = accel_interned_strings_snapshot_for_php;
|
||||
zend_interned_strings_restore = accel_interned_strings_restore_for_php;
|
||||
|
||||
# ifndef ZTS
|
||||
accel_use_shm_interned_strings(TSRMLS_C);
|
||||
accel_interned_strings_save_state(TSRMLS_C);
|
||||
if (ZCG(accel_directives).interned_strings_buffer) {
|
||||
accel_use_shm_interned_strings(TSRMLS_C);
|
||||
accel_interned_strings_save_state(TSRMLS_C);
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif
|
||||
@ -2711,6 +2722,21 @@ void accel_shutdown(TSRMLS_D)
|
||||
return;
|
||||
}
|
||||
|
||||
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
|
||||
if (ZCG(accel_directives).interned_strings_buffer) {
|
||||
# ifndef ZTS
|
||||
zend_hash_clean(CG(function_table));
|
||||
zend_hash_clean(CG(class_table));
|
||||
zend_hash_clean(EG(zend_constants));
|
||||
# endif
|
||||
CG(interned_strings_start) = orig_interned_strings_start;
|
||||
CG(interned_strings_end) = orig_interned_strings_end;
|
||||
}
|
||||
zend_new_interned_string = orig_new_interned_string;
|
||||
zend_interned_strings_snapshot = orig_interned_strings_snapshot;
|
||||
zend_interned_strings_restore = orig_interned_strings_restore;
|
||||
#endif
|
||||
|
||||
accel_free_ts_resources();
|
||||
zend_shared_alloc_shutdown();
|
||||
zend_compile_file = accelerator_orig_compile_file;
|
||||
@ -2718,20 +2744,6 @@ void accel_shutdown(TSRMLS_D)
|
||||
if (zend_hash_find(EG(ini_directives), "include_path", sizeof("include_path"), (void **) &ini_entry) == SUCCESS) {
|
||||
ini_entry->on_modify = orig_include_path_on_modify;
|
||||
}
|
||||
|
||||
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
|
||||
# ifndef ZTS
|
||||
zend_hash_clean(CG(function_table));
|
||||
zend_hash_clean(CG(class_table));
|
||||
zend_hash_clean(EG(zend_constants));
|
||||
# endif
|
||||
CG(interned_strings_start) = orig_interned_strings_start;
|
||||
CG(interned_strings_end) = orig_interned_strings_end;
|
||||
zend_new_interned_string = orig_new_interned_string;
|
||||
zend_interned_strings_snapshot = orig_interned_strings_snapshot;
|
||||
zend_interned_strings_restore = orig_interned_strings_restore;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void zend_accel_schedule_restart(zend_accel_restart_reason reason TSRMLS_DC)
|
||||
|
@ -362,7 +362,7 @@ AC_TRY_RUN([
|
||||
if test "$flock_type" == "unknown"; then
|
||||
AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no])
|
||||
fi
|
||||
|
||||
|
||||
PHP_NEW_EXTENSION(opcache,
|
||||
ZendAccelerator.c \
|
||||
zend_accelerator_blacklist.c \
|
||||
|
34
ext/opcache/tests/blacklist-win32.phpt
Normal file
34
ext/opcache/tests/blacklist-win32.phpt
Normal file
@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
Blacklist (with glob, quote and comments)
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.blacklist_filename={PWD}/opcache-*.blacklist
|
||||
opcache.file_update_protection=0
|
||||
--SKIPIF--
|
||||
<?php require_once('skipif.inc'); ?>
|
||||
<?php if (substr(PHP_OS, 0, 3) != 'WIN') { die('skip only for Windows'); } ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$conf = opcache_get_configuration();
|
||||
$conf = $conf['blacklist'];
|
||||
$conf[3] = preg_replace("!^\\Q".dirname(__FILE__)."\\E!", "__DIR__", $conf[3]);
|
||||
$conf[4] = preg_replace("!^\\Q".dirname(__FILE__)."\\E!", "__DIR__", $conf[4]);
|
||||
print_r($conf);
|
||||
include("blacklist.inc");
|
||||
$status = opcache_get_status();
|
||||
print_r(count($status['scripts']));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Array
|
||||
(
|
||||
[0] => C:\path\to\foo
|
||||
[1] => C:\path\to\foo2
|
||||
[2] => C:\path\to\bar
|
||||
[3] => __DIR__\blacklist.inc
|
||||
[4] => __DIR__\current.php
|
||||
[5] => %scurrent.php
|
||||
[6] => %scurrent.php
|
||||
)
|
||||
ok
|
||||
1
|
@ -7,6 +7,7 @@ opcache.blacklist_filename={PWD}/opcache-*.blacklist
|
||||
opcache.file_update_protection=0
|
||||
--SKIPIF--
|
||||
<?php require_once('skipif.inc'); ?>
|
||||
<?php if (substr(PHP_OS, 0, 3) == 'WIN') { die('skip not for Windows'); } ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$conf = opcache_get_configuration();
|
||||
|
16
ext/opcache/tests/bug66440.phpt
Normal file
16
ext/opcache/tests/bug66440.phpt
Normal file
@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
Bug #66440 (Optimisation of conditional JMPs based on pre-evaluate constant function calls)
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.optimization_level=-1
|
||||
opcache.file_update_protection=0
|
||||
--SKIPIF--
|
||||
<?php require_once('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
if(constant('PHP_BINARY')) {
|
||||
echo "OK\n";
|
||||
}
|
||||
--EXPECT--
|
||||
OK
|
15
ext/opcache/tests/bug66461.phpt
Normal file
15
ext/opcache/tests/bug66461.phpt
Normal file
@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #66461 (PHP crashes if opcache.interned_strings_buffer=0)
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.optimization_level=-1
|
||||
opcache.file_update_protection=0
|
||||
opcache.interned_strings_buffer=0
|
||||
--SKIPIF--
|
||||
<?php require_once('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
echo "ok\n";
|
||||
--EXPECT--
|
||||
ok
|
@ -28,7 +28,11 @@
|
||||
#include "zend_accelerator_blacklist.h"
|
||||
#include "php_ini.h"
|
||||
#include "SAPI.h"
|
||||
#include "zend_virtual_cwd.h"
|
||||
#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
|
||||
# include "zend_virtual_cwd.h"
|
||||
#else
|
||||
# include "TSRM/tsrm_virtual_cwd.h"
|
||||
#endif
|
||||
#include "ext/standard/info.h"
|
||||
#include "ext/standard/php_filestat.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user