void do_fetch_globals(znode *varname CLS_DC)
{
- if (!CG(active_op_array)->initialized_globals
+ if (!CG(active_op_array)->uses_globals
&& varname->op_type == IS_CONST
&& varname->u.constant.type == IS_STRING
&& varname->u.constant.value.str.len == (sizeof("GLOBALS")-1)
&& !memcmp(varname->u.constant.value.str.val, "GLOBALS", sizeof("GLOBALS")-1)) {
- zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
-
- opline->opcode = ZEND_INIT_GLOBALS;
- SET_UNUSED(opline->op1);
- SET_UNUSED(opline->op2);
- CG(active_op_array)->initialized_globals = 1;
+ CG(active_op_array)->uses_globals = 1;
}
}
zend_brk_cont_element *brk_cont_array;
int last_brk_cont;
int current_brk_cont;
- unsigned char initialized_globals;
+ unsigned char uses_globals;
/* static variables support */
HashTable *static_variables;
#define ZEND_DECLARE_FUNCTION_OR_CLASS 91
-#define ZEND_INIT_GLOBALS 92
-
-#define ZEND_EXT_STMT 93
-#define ZEND_EXT_FCALL_BEGIN 94
-#define ZEND_EXT_FCALL_END 95
-#define ZEND_EXT_NOP 96
+#define ZEND_EXT_STMT 92
+#define ZEND_EXT_FCALL_BEGIN 93
+#define ZEND_EXT_FCALL_END 94
+#define ZEND_EXT_NOP 95
/* end of block */
*/
function_state.function_symbol_table = NULL;
#endif
+
+ if (op_array->uses_globals) {
+ zval *globals = (zval *) emalloc(sizeof(zval));
+
+ globals->refcount=1;
+ globals->is_ref=1;
+ globals->type = IS_ARRAY;
+ globals->value.ht = &EG(symbol_table);
+ if (zend_hash_add(EG(active_symbol_table), "GLOBALS", sizeof("GLOBALS"), &globals, sizeof(zval *), NULL)==FAILURE) {
+ efree(globals);
+ }
+ }
while (opline<end) {
switch(opline->opcode) {
case ZEND_DECLARE_FUNCTION_OR_CLASS:
do_bind_function_or_class(opline, EG(function_table), EG(class_table));
break;
- case ZEND_INIT_GLOBALS: {
- zval *globals = (zval *) emalloc(sizeof(zval));
-
- globals->refcount=1;
- globals->is_ref=1;
- globals->type = IS_ARRAY;
- globals->value.ht = &EG(symbol_table);
- zend_hash_add(EG(active_symbol_table), "GLOBALS", sizeof("GLOBALS"), &globals, sizeof(zval *), NULL);
- }
- break;
case ZEND_EXT_NOP:
case ZEND_NOP:
break;
op_array->static_variables = NULL;
- op_array->initialized_globals = 0;
+ op_array->uses_globals = 0;
zend_llist_apply_with_argument(&zend_extensions, (void (*)(void *, void *)) zend_extension_op_array_ctor_handler, op_array);
}