Skip to content

Commit

Permalink
Improve the way auto-globals JIT works, and add the ability to turn i…
Browse files Browse the repository at this point in the history
…t off
  • Loading branch information
zsuraski committed Mar 16, 2004
1 parent e2a5ebf commit 02344b1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions main/main.c
Expand Up @@ -273,6 +273,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("register_globals", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_globals, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("register_long_arrays", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_long_arrays, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("auto_globals_jit", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, auto_globals_jit, php_core_globals, core_globals)
#if PHP_SAFE_MODE
STD_PHP_INI_BOOLEAN("safe_mode", "1", PHP_INI_SYSTEM, OnUpdateBool, safe_mode, php_core_globals, core_globals)
#else
Expand Down
1 change: 1 addition & 0 deletions main/php_globals.h
Expand Up @@ -121,6 +121,7 @@ struct _php_core_globals {
zend_bool register_globals;
zend_bool register_long_arrays;
zend_bool register_argc_argv;
zend_bool auto_globals_jit;

zend_bool y2k_compliance;

Expand Down
15 changes: 8 additions & 7 deletions main/php_variables.c
Expand Up @@ -543,6 +543,7 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS
static zend_bool php_auto_globals_create_env(char *name, uint name_len TSRMLS_DC);
static zend_bool php_auto_globals_create_request(char *name, uint name_len TSRMLS_DC);


/* {{{ php_hash_environment
*/
int php_hash_environment(TSRMLS_D)
Expand All @@ -551,7 +552,7 @@ int php_hash_environment(TSRMLS_D)
unsigned char _gpc_flags[5] = {0, 0, 0, 0, 0};
zval *dummy_track_vars_array = NULL;
zend_bool initialized_dummy_track_vars_array=0;
zend_bool jit_initialization = (!PG(register_globals) && !PG(register_long_arrays));
zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays) && !PG(register_argc_argv));
struct auto_global_record {
char *name;
uint name_len;
Expand Down Expand Up @@ -609,6 +610,7 @@ int php_hash_environment(TSRMLS_D)
case 'e':
case 'E':
if (!jit_initialization && !_gpc_flags[3]) {
zend_auto_global_disable_jit("_ENV", sizeof("_ENV")-1 TSRMLS_CC);
php_auto_globals_create_env("_ENV", sizeof("_ENV")-1 TSRMLS_CC);
_gpc_flags[3]=1;
if (PG(register_globals)) {
Expand All @@ -619,6 +621,7 @@ int php_hash_environment(TSRMLS_D)
case 's':
case 'S':
if (!jit_initialization && !_gpc_flags[4]) {
zend_auto_global_disable_jit("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
php_register_server_variables(TSRMLS_C);
_gpc_flags[4]=1;
if (PG(register_globals)) {
Expand Down Expand Up @@ -660,6 +663,7 @@ int php_hash_environment(TSRMLS_D)

/* Create _REQUEST */
if (!jit_initialization) {
zend_auto_global_disable_jit("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC);
php_auto_globals_create_request("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC);
}

Expand Down Expand Up @@ -746,15 +750,12 @@ static zend_bool php_auto_globals_create_request(char *name, uint name_len TSRML

void php_startup_auto_globals(TSRMLS_D)
{
zend_bool cb = (!PG(register_globals) && !PG(register_long_arrays));

/*cb = 0;*/
zend_register_auto_global("_GET", sizeof("_GET")-1, NULL TSRMLS_CC);
zend_register_auto_global("_POST", sizeof("_POST")-1, NULL TSRMLS_CC);
zend_register_auto_global("_COOKIE", sizeof("_COOKIE")-1, NULL TSRMLS_CC);
zend_register_auto_global("_SERVER", sizeof("_SERVER")-1, cb?php_auto_globals_create_server:NULL TSRMLS_CC);
zend_register_auto_global("_ENV", sizeof("_ENV")-1, cb?php_auto_globals_create_env:NULL TSRMLS_CC);
zend_register_auto_global("_REQUEST", sizeof("_REQUEST")-1, cb?php_auto_globals_create_request:NULL TSRMLS_CC);
zend_register_auto_global("_SERVER", sizeof("_SERVER")-1, php_auto_globals_create_server TSRMLS_CC);
zend_register_auto_global("_ENV", sizeof("_ENV")-1, php_auto_globals_create_env TSRMLS_CC);
zend_register_auto_global("_REQUEST", sizeof("_REQUEST")-1, php_auto_globals_create_request TSRMLS_CC);
zend_register_auto_global("_FILES", sizeof("_FILES")-1, NULL TSRMLS_CC);
}

Expand Down

0 comments on commit 02344b1

Please sign in to comment.