Skip to content

Commit

Permalink
- Interned string related callbacks moved turned from compiler_global…
Browse files Browse the repository at this point in the history
…s into real globals

- Updated API version number
  • Loading branch information
dstogov committed May 25, 2010
1 parent a389c77 commit f7ce695
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 31 deletions.
6 changes: 3 additions & 3 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
}
}
fname_len = strlen(ptr->fname);
lowercase_name = CG(new_interned_string)(zend_str_tolower_dup(ptr->fname, fname_len), fname_len + 1, 1 TSRMLS_CC);
lowercase_name = zend_new_interned_string(zend_str_tolower_dup(ptr->fname, fname_len), fname_len + 1, 1 TSRMLS_CC);
if (zend_hash_add(target_function_table, lowercase_name, fname_len+1, &function, sizeof(zend_function), (void**)&reg_function) == FAILURE) {
unload=1;
str_efree(lowercase_name);
Expand Down Expand Up @@ -2205,7 +2205,7 @@ static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class
}

zend_str_tolower_copy(lowercase_name, orig_class_entry->name, class_entry->name_length);
lowercase_name = CG(new_interned_string)(lowercase_name, class_entry->name_length + 1, 1 TSRMLS_CC);
lowercase_name = zend_new_interned_string(lowercase_name, class_entry->name_length + 1, 1 TSRMLS_CC);
zend_hash_update(CG(class_table), lowercase_name, class_entry->name_length+1, &class_entry, sizeof(zend_class_entry *), NULL);
str_efree(lowercase_name);
return class_entry;
Expand Down Expand Up @@ -3165,7 +3165,7 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, const char *name, in
break;
}

interned_name = CG(new_interned_string)(property_info.name, property_info.name_length+1, 0 TSRMLS_CC);
interned_name = zend_new_interned_string(property_info.name, property_info.name_length+1, 0 TSRMLS_CC);
if (interned_name != property_info.name) {
if (ce->type == ZEND_USER_CLASS) {
efree(property_info.name);
Expand Down
14 changes: 7 additions & 7 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static int lookup_cv(zend_op_array *op_array, char* name, int name_len TSRMLS_DC
op_array->size_var += 16; /* FIXME */
op_array->vars = erealloc(op_array->vars, op_array->size_var*sizeof(zend_compiled_variable));
}
op_array->vars[i].name = CG(new_interned_string)(name, name_len + 1, 1 TSRMLS_CC);
op_array->vars[i].name = zend_new_interned_string(name, name_len + 1, 1 TSRMLS_CC);
op_array->vars[i].name_len = name_len;
op_array->vars[i].hash_value = hash_value;
return i;
Expand Down Expand Up @@ -374,7 +374,7 @@ int zend_add_literal(zend_op_array *op_array, const zval *zv) /* {{{ */
TSRMLS_FETCH();

Z_STRVAL_P(z) =
CG(new_interned_string)(Z_STRVAL_P(zv), Z_STRLEN_P(zv) + 1, 1 TSRMLS_CC);
zend_new_interned_string(Z_STRVAL_P(zv), Z_STRLEN_P(zv) + 1, 1 TSRMLS_CC);
}
CONSTANT_EX(op_array, i) = *zv;
Z_SET_REFCOUNT(CONSTANT_EX(op_array, i), 2);
Expand Down Expand Up @@ -1540,7 +1540,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
op_array.line_start = zend_get_compiled_lineno(TSRMLS_C);

if (is_method) {
lcname = CG(new_interned_string)(zend_str_tolower_dup(name, name_len), name_len + 1, 1 TSRMLS_CC);
lcname = zend_new_interned_string(zend_str_tolower_dup(name, name_len), name_len + 1, 1 TSRMLS_CC);

if (zend_hash_add(&CG(active_class_entry)->function_table, lcname, name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array)) == FAILURE) {
zend_error(E_COMPILE_ERROR, "Cannot redeclare %s::%s()", CG(active_class_entry)->name, name);
Expand Down Expand Up @@ -1836,7 +1836,7 @@ void zend_do_receive_arg(zend_uchar op, znode *varname, const znode *offset, con
}
CG(active_op_array)->arg_info = erealloc(CG(active_op_array)->arg_info, sizeof(zend_arg_info)*(CG(active_op_array)->num_args));
cur_arg_info = &CG(active_op_array)->arg_info[CG(active_op_array)->num_args-1];
cur_arg_info->name = CG(new_interned_string)(estrndup(varname->u.constant.value.str.val, varname->u.constant.value.str.len), varname->u.constant.value.str.len + 1, 1 TSRMLS_CC);
cur_arg_info->name = zend_new_interned_string(estrndup(varname->u.constant.value.str.val, varname->u.constant.value.str.len), varname->u.constant.value.str.len + 1, 1 TSRMLS_CC);
cur_arg_info->name_len = varname->u.constant.value.str.len;
cur_arg_info->type_hint = 0;
cur_arg_info->allow_null = 1;
Expand All @@ -1853,7 +1853,7 @@ void zend_do_receive_arg(zend_uchar op, znode *varname, const znode *offset, con
if (ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(class_type->u.constant), Z_STRLEN(class_type->u.constant))) {
zend_resolve_class_name(class_type, &opline->extended_value, 1 TSRMLS_CC);
}
class_type->u.constant.value.str.val = CG(new_interned_string)(class_type->u.constant.value.str.val, class_type->u.constant.value.str.len + 1, 1 TSRMLS_CC);
class_type->u.constant.value.str.val = zend_new_interned_string(class_type->u.constant.value.str.val, class_type->u.constant.value.str.len + 1, 1 TSRMLS_CC);
cur_arg_info->class_name = class_type->u.constant.value.str.val;
cur_arg_info->class_name_len = class_type->u.constant.value.str.len;
if (op == ZEND_RECV_INIT) {
Expand Down Expand Up @@ -4766,7 +4766,7 @@ void zend_do_declare_property(const znode *var_name, const znode *value, zend_ui
CG(doc_comment_len) = 0;
}

zend_declare_property_ex(CG(active_class_entry), CG(new_interned_string)(var_name->u.constant.value.str.val, var_name->u.constant.value.str.len + 1, 0 TSRMLS_CC), var_name->u.constant.value.str.len, property, access_type, comment, comment_len TSRMLS_CC);
zend_declare_property_ex(CG(active_class_entry), zend_new_interned_string(var_name->u.constant.value.str.val, var_name->u.constant.value.str.len + 1, 0 TSRMLS_CC), var_name->u.constant.value.str.len, property, access_type, comment, comment_len TSRMLS_CC);
efree(var_name->u.constant.value.str.val);
}
/* }}} */
Expand All @@ -4787,7 +4787,7 @@ void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_D
ALLOC_ZVAL(property);
*property = value->u.constant;

if (zend_hash_add(&CG(active_class_entry)->constants_table, CG(new_interned_string)(var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, 0 TSRMLS_CC), var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL)==FAILURE) {
if (zend_hash_add(&CG(active_class_entry)->constants_table, zend_new_interned_string(var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, 0 TSRMLS_CC), var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL)==FAILURE) {
FREE_ZVAL(property);
zend_error(E_COMPILE_ERROR, "Cannot redefine class constant %s::%s", CG(active_class_entry)->name, var_name->u.constant.value.str.val);
}
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,14 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC)
/* keep in mind that c->name_len already contains the '\0' */
lowercase_name = estrndup(c->name, c->name_len-1);
zend_str_tolower(lowercase_name, c->name_len-1);
lowercase_name = CG(new_interned_string)(lowercase_name, c->name_len, 1 TSRMLS_CC);
lowercase_name = zend_new_interned_string(lowercase_name, c->name_len, 1 TSRMLS_CC);
name = lowercase_name;
} else {
char *slash = strrchr(c->name, '\\');
if(slash) {
lowercase_name = estrndup(c->name, c->name_len-1);
zend_str_tolower(lowercase_name, slash-c->name);
lowercase_name = CG(new_interned_string)(lowercase_name, c->name_len, 1 TSRMLS_CC);
lowercase_name = zend_new_interned_string(lowercase_name, c->name_len, 1 TSRMLS_CC);
name = lowercase_name;
} else {
name = c->name;
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/* The first number is the engine version and the rest is the date.
* This way engine 2/3 API no. is always greater than engine 1 API no..
*/
#define ZEND_EXTENSION_API_NO 220100409
#define ZEND_EXTENSION_API_NO 220100525

typedef struct _zend_extension_version_info {
int zend_extension_api_no;
Expand Down
4 changes: 0 additions & 4 deletions Zend/zend_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ struct _zend_compiler_globals {

HashTable interned_strings;

char *(*new_interned_string)(char *str, int len, int free_src TSRMLS_DC);
void (*interned_strings_snapshot)(TSRMLS_D);
void (*interned_strings_restore)(TSRMLS_D);

#ifdef ZEND_MULTIBYTE
zend_encoding **script_encoding_list;
size_t script_encoding_list_size;
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *zend_module TSRMLS_DC
#define ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU zend_module TSRMLS_CC

#define ZEND_MODULE_API_NO 20100409
#define ZEND_MODULE_API_NO 20100525
#ifdef ZTS
#define USING_ZTS 1
#else
Expand Down
22 changes: 13 additions & 9 deletions Zend/zend_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
# include <sys/mman.h>
#endif

static char *zend_new_interned_string(char *str, int len, int free_src TSRMLS_DC);
static void zend_interned_strings_snapshot(TSRMLS_D);
static void zend_interned_strings_restore(TSRMLS_D);
ZEND_API char *(*zend_new_interned_string)(char *str, int len, int free_src TSRMLS_DC);
ZEND_API void (*zend_interned_strings_snapshot)(TSRMLS_D);
ZEND_API void (*zend_interned_strings_restore)(TSRMLS_D);

static char *zend_new_interned_string_int(char *str, int len, int free_src TSRMLS_DC);
static void zend_interned_strings_snapshot_int(TSRMLS_D);
static void zend_interned_strings_restore_int(TSRMLS_D);

void zend_interned_strings_init(TSRMLS_D)
{
Expand Down Expand Up @@ -59,9 +63,9 @@ void zend_interned_strings_init(TSRMLS_D)

#endif

CG(new_interned_string) = zend_new_interned_string;
CG(interned_strings_snapshot) = zend_interned_strings_snapshot;
CG(interned_strings_restore) = zend_interned_strings_restore;
zend_new_interned_string = zend_new_interned_string_int;
zend_interned_strings_snapshot = zend_interned_strings_snapshot_int;
zend_interned_strings_restore = zend_interned_strings_restore_int;
}

void zend_interned_strings_dtor(TSRMLS_D)
Expand All @@ -75,7 +79,7 @@ void zend_interned_strings_dtor(TSRMLS_D)
#endif
}

static char *zend_new_interned_string(char *arKey, int nKeyLength, int free_src TSRMLS_DC)
static char *zend_new_interned_string_int(char *arKey, int nKeyLength, int free_src TSRMLS_DC)
{
#ifndef ZTS
ulong h;
Expand Down Expand Up @@ -173,12 +177,12 @@ static char *zend_new_interned_string(char *arKey, int nKeyLength, int free_src
#endif
}

static void zend_interned_strings_snapshot(TSRMLS_D)
static void zend_interned_strings_snapshot_int(TSRMLS_D)
{
CG(interned_strings_snapshot_top) = CG(interned_strings_top);
}

static void zend_interned_strings_restore(TSRMLS_D)
static void zend_interned_strings_restore_int(TSRMLS_D)
{
#ifndef ZTS
Bucket *p;
Expand Down
4 changes: 4 additions & 0 deletions Zend/zend_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

#include "zend.h"

ZEND_API extern char *(*zend_new_interned_string)(char *str, int len, int free_src TSRMLS_DC);
ZEND_API extern void (*zend_interned_strings_snapshot)(TSRMLS_D);
ZEND_API extern void (*zend_interned_strings_restore)(TSRMLS_D);

void zend_interned_strings_init(TSRMLS_D);
void zend_interned_strings_dtor(TSRMLS_D);

Expand Down
8 changes: 4 additions & 4 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ void php_request_shutdown_for_exec(void *dummy)
/* used to close fd's in the 3..255 range here, but it's problematic
*/
shutdown_memory_manager(1, 1 TSRMLS_CC);
CG(interned_strings_restore)(TSRMLS_C);
zend_interned_strings_restore(TSRMLS_C);
}
/* }}} */

Expand Down Expand Up @@ -1587,7 +1587,7 @@ void php_request_shutdown_for_hook(void *dummy)
shutdown_memory_manager(CG(unclean_shutdown), 0 TSRMLS_CC);
} zend_end_try();

CG(interned_strings_restore)(TSRMLS_C);
zend_interned_strings_restore(TSRMLS_C);

zend_try {
zend_unset_timeout(TSRMLS_C);
Expand Down Expand Up @@ -1687,7 +1687,7 @@ void php_request_shutdown(void *dummy)
zend_try {
shutdown_memory_manager(CG(unclean_shutdown) || !report_memleaks, 0 TSRMLS_CC);
} zend_end_try();
CG(interned_strings_restore)(TSRMLS_C);
zend_interned_strings_restore(TSRMLS_C);

/* 12. Reset max_execution_time */
zend_try {
Expand Down Expand Up @@ -2154,7 +2154,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
module_startup = 0;

shutdown_memory_manager(1, 0 TSRMLS_CC);
CG(interned_strings_snapshot)(TSRMLS_C);
zend_interned_strings_snapshot(TSRMLS_C);

/* we're done */
return SUCCESS;
Expand Down

0 comments on commit f7ce695

Please sign in to comment.