summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-06-04 13:09:24 +0000
committerZeev Suraski <zeev@php.net>1999-06-04 13:09:24 +0000
commit1b4b5c4a880bdd9646a06a8f8a8ab7dbbb8690c0 (patch)
treea59ee8907505bbba0707fe2b069ff2efd6c7c523
parent1ecca4b8e882165203b383fa91bb4fb57dac2c94 (diff)
downloadphp-git-1b4b5c4a880bdd9646a06a8f8a8ab7dbbb8690c0.tar.gz
New $GLOBALS init
-rw-r--r--Zend/zend_compile.c9
-rw-r--r--Zend/zend_compile.h12
-rw-r--r--Zend/zend_execute.c22
-rw-r--r--Zend/zend_opcode.c2
4 files changed, 20 insertions, 25 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index b9f5ef1276..c9f6841a32 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -159,17 +159,12 @@ void do_binary_assign_op(int op, znode *result, znode *op1, znode *op2 CLS_DC)
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;
}
}
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index 4439d16c17..7bc6193361 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -102,7 +102,7 @@ struct _zend_op_array {
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;
@@ -482,12 +482,10 @@ int zendlex(znode *zendlval CLS_DC);
#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 */
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 0cc01e898a..5f8660da20 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -849,6 +849,18 @@ void execute(zend_op_array *op_array ELS_DC)
*/
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) {
@@ -1889,16 +1901,6 @@ send_by_ref:
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;
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index 0d7ac819ac..96ff8687dc 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -93,7 +93,7 @@ void init_op_array(zend_op_array *op_array, int initial_ops_size)
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);
}