Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improved interactive mode - it is now available in all builds, withou…

…t any significant slowdown
  • Loading branch information...
commit 85b4df53c0c7c538206244e9f7d0764380a909bb 1 parent 4e1c65b
@zsuraski zsuraski authored
View
8 NEWS
@@ -1,6 +1,8 @@
PHP 4.0 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-?? ??? 200?, Version 4.0.7-dev
+?? ??? 200?, Version 4.0.7-dev
+- Improved interactive mode - it is now available in all builds of PHP, without
+ any significant slowdown (Zeev, Zend Engine)
- Fixed crash in iptcparse() if the supplied data was bogus. (Thies)
- Fix return value for a failed snmpset() - now returns false (Rasmus)
- Add hostname:port support to snmp functions
@@ -9,8 +11,8 @@ PHP 4.0 NEWS
- Fixed return value for a failed snmpset() - now returns false (Rasmus)
- Added hostname:port support to snmp functions (nbougues@axialys.net, Rasmus)
- Added fdf_set_encoding() function (Masaki YATSU, Rasmus)
-- Reversed the destruction-order of resources. This fixes the reported OCI8
- "failed to rollback outstanding transactions!" message. (Thies Zend Engine)
+- Reversed the destruction-order of resources. This fixes the reported OCI8
+ "failed to rollback outstanding transactions!" message (Thies, Zend Engine)
- Added option for returning XMLRPC fault packets. (Matt Allen, Sascha
Schumann)
- Improved range() function to support range('a','z') and range(9,0) types of
View
3  Zend/zend.c
@@ -277,6 +277,8 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals)
zend_hash_copy(compiler_globals->class_table, global_class_table, (copy_ctor_func_t) zend_class_add_ref, &tmp_class, sizeof(zend_class_entry));
zend_set_default_compile_time_values(CLS_C);
+
+ CG(interactive) = 0;
}
@@ -302,7 +304,6 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals)
zend_init_rsrc_plist(ELS_C);
EG(lambda_count)=0;
EG(user_error_handler) = NULL;
- EG(interactive) = 0;
EG(in_execution) = 0;
}
View
4 Zend/zend_compile.c
@@ -770,10 +770,6 @@ void zend_do_end_function_declaration(znode *function_token CLS_DC)
zend_do_extended_info(CLS_C);
zend_do_return(NULL, 0 CLS_CC);
pass_two(CG(active_op_array));
-#if SUPPORT_INTERACTIVE
- CG(active_op_array)->start_op_number = 0;
- CG(active_op_array)->end_op_number = CG(active_op_array)->last;
-#endif
CG(active_op_array) = function_token->u.op_array;
/* Pop the switch and foreach seperators */
View
20 Zend/zend_compile.h
@@ -35,22 +35,14 @@
#define DEBUG_ZEND 0
-#define SUPPORT_INTERACTIVE 1
-
#define FREE_PNODE(znode) zval_dtor(&znode->u.constant);
#define FREE_OP(op, should_free) if (should_free) zval_dtor(&Ts[(op)->u.var].tmp_var);
#define SET_UNUSED(op) (op).op_type = IS_UNUSED
-#if SUPPORT_INTERACTIVE
-#define INC_BPC(op_array) ((op_array)->backpatch_count++)
-#define DEC_BPC(op_array) ((op_array)->backpatch_count--)
-#define HANDLE_INTERACTIVE() if (EG(interactive)) { execute_new_code(CLS_C); }
-#else
-#define INC_BPC(op_array)
-#define DEC_BPC(op_array)
-#define HANDLE_INTERACTIVE()
-#endif
+#define INC_BPC(op_array) if (CG(interactive)) { ((op_array)->backpatch_count++); }
+#define DEC_BPC(op_array) if (CG(interactive)) { ((op_array)->backpatch_count--); }
+#define HANDLE_INTERACTIVE() if (CG(interactive)) { execute_new_code(CLS_C); }
typedef struct _zend_op_array zend_op_array;
@@ -109,11 +101,9 @@ struct _zend_op_array {
/* static variables support */
HashTable *static_variables;
-#if SUPPORT_INTERACTIVE
- int start_op_number, end_op_number;
- int last_executed_op_number;
+ zend_op *start_op;
int backpatch_count;
-#endif
+
zend_bool return_reference;
zend_bool done_pass_two;
View
30 Zend/zend_execute.c
@@ -971,10 +971,7 @@ typedef struct _object_info {
ZEND_API void execute(zend_op_array *op_array ELS_DC)
{
- zend_op *opline = op_array->opcodes;
-#if SUPPORT_INTERACTIVE
- zend_op *end = op_array->opcodes + op_array->last;
-#endif
+ zend_op *opline;
zend_function_state function_state;
zend_function *fbc=NULL; /* Function Being Called */
object_info object = {NULL};
@@ -986,12 +983,11 @@ ZEND_API void execute(zend_op_array *op_array ELS_DC)
zend_bool original_in_execution=EG(in_execution);
EG(in_execution) = 1;
-#if SUPPORT_INTERACTIVE
- if (EG(interactive)) {
- opline = op_array->opcodes + op_array->start_op_number;
- end = op_array->opcodes + op_array->end_op_number;
+ if (op_array->start_op) {
+ opline = op_array->start_op;
+ } else {
+ opline = op_array->opcodes;
}
-#endif
EG(opline_ptr) = &opline;
@@ -1017,11 +1013,7 @@ ZEND_API void execute(zend_op_array *op_array ELS_DC)
}
}
-#if SUPPORT_INTERACTIVE
- while (opline<end) {
-#else
while (1) {
-#endif
#ifdef ZEND_WIN32
if (EG(timed_out)) {
zend_timeout(0);
@@ -1683,9 +1675,6 @@ binary_assign_op_addr: {
(*EG(return_value_ptr_ptr))->is_ref = 0;
}
}
-#if SUPPORT_INTERACTIVE
- op_array->last_executed_op_number = opline-op_array->opcodes;
-#endif
free_alloca(Ts);
EG(in_execution) = original_in_execution;
return;
@@ -2418,12 +2407,5 @@ binary_assign_op_addr: {
}
}
-#if SUPPORT_INTERACTIVE
- ALLOC_INIT_ZVAL(*(EG(return_value_ptr_ptr)));
- op_array->last_executed_op_number = opline-op_array->opcodes;
- EG(in_execution) = original_in_execution;
- free_alloca(Ts);
-#else
- zend_error(E_ERROR,"Arrived at end of main loop which shouldn't happen");
-#endif
+ zend_error(E_ERROR, "Arrived at end of main loop which shouldn't happen");
}
View
2  Zend/zend_execute.h
@@ -127,9 +127,7 @@ static inline int zend_ptr_stack_get_arg(int requested_arg, void **data ELS_DC)
return SUCCESS;
}
-#if SUPPORT_INTERACTIVE
void execute_new_code(CLS_D);
-#endif
/* services */
View
23 Zend/zend_execute_API.c
@@ -552,21 +552,30 @@ ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name CLS
}
-
-#if SUPPORT_INTERACTIVE
void execute_new_code(CLS_D)
{
zend_op *opline, *end;
+ zend_op *ret_opline;
ELS_FETCH();
- if (!EG(interactive)
+ if (!CG(interactive)
|| CG(active_op_array)->backpatch_count>0
|| CG(active_op_array)->function_name
|| CG(active_op_array)->type!=ZEND_USER_FUNCTION) {
return;
}
- opline=CG(active_op_array)->opcodes + CG(active_op_array)->start_op_number;
+ ret_opline = get_next_op(CG(active_op_array) CLS_CC);
+ ret_opline->opcode = ZEND_RETURN;
+ ret_opline->op1.op_type = IS_CONST;
+ INIT_ZVAL(ret_opline->op1.u.constant);
+ SET_UNUSED(ret_opline->op2);
+
+ if (!CG(active_op_array)->start_op) {
+ CG(active_op_array)->start_op = CG(active_op_array)->opcodes;
+ }
+
+ opline=CG(active_op_array)->start_op;
end=CG(active_op_array)->opcodes+CG(active_op_array)->last;
while (opline<end) {
@@ -581,14 +590,12 @@ void execute_new_code(CLS_D)
opline++;
}
- CG(active_op_array)->start_op_number = CG(active_op_array)->last_executed_op_number;
- CG(active_op_array)->end_op_number = CG(active_op_array)->last;
EG(active_op_array) = CG(active_op_array);
zend_execute(CG(active_op_array) ELS_CC);
zval_ptr_dtor(EG(return_value_ptr_ptr));
- CG(active_op_array)->start_op_number = CG(active_op_array)->last_executed_op_number;
+ CG(active_op_array)->last--; /* get rid of that ZEND_RETURN */
+ CG(active_op_array)->start_op = CG(active_op_array)->opcodes+CG(active_op_array)->last;
}
-#endif
ZEND_API void zend_timeout(int dummy)
View
6 Zend/zend_globals.h
@@ -111,6 +111,7 @@ struct _zend_compiler_globals {
zend_bool ini_parser_unbuffered_errors;
zend_llist open_files;
+
#if defined(ZTS) && defined(__cplusplus)
ZendFlexLexer *ZFL;
ZendIniFlexLexer *ini_scanner;
@@ -118,6 +119,8 @@ struct _zend_compiler_globals {
void *ZFL;
void *ini_parser;
#endif
+
+ int interactive;
};
@@ -195,9 +198,6 @@ struct _zend_executor_globals {
HashTable ini_directives;
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
-#if SUPPORT_INTERACTIVE
- int interactive;
-#endif
};
View
2  Zend/zend_language_scanner.l
@@ -78,9 +78,7 @@
#define YY_DECL int lex_scan(zval *zendlval CLS_DC)
#endif
-#if SUPPORT_INTERACTIVE
#define YY_INTERACTIVE
-#endif
#define ECHO { ZEND_WRITE( yytext, yyleng ); }
View
28 Zend/zend_opcode.c
@@ -53,20 +53,14 @@ static void op_array_alloc_ops(zend_op_array *op_array)
void init_op_array(zend_op_array *op_array, int type, int initial_ops_size CLS_DC)
{
op_array->type = type;
-#if SUPPORT_INTERACTIVE
- {
- ELS_FETCH();
-
- op_array->start_op_number = op_array->end_op_number = op_array->last_executed_op_number = 0;
- op_array->backpatch_count = 0;
- if (EG(interactive)) {
- /* We must avoid a realloc() on the op_array in interactive mode, since pointers to constants
- * will become invalid
- */
- initial_ops_size = 8192;
- }
+
+ op_array->backpatch_count = 0;
+ if (CG(interactive)) {
+ /* We must avoid a realloc() on the op_array in interactive mode, since pointers to constants
+ * will become invalid
+ */
+ initial_ops_size = 8192;
}
-#endif
op_array->refcount = (zend_uint *) emalloc(sizeof(zend_uint));
*op_array->refcount = 1;
@@ -93,6 +87,8 @@ void init_op_array(zend_op_array *op_array, int type, int initial_ops_size CLS_D
op_array->return_reference = 0;
op_array->done_pass_two = 0;
+ op_array->start_op = NULL;
+
zend_llist_apply_with_argument(&zend_extensions, (void (*)(void *, void *)) zend_extension_op_array_ctor_handler, op_array);
}
@@ -201,16 +197,12 @@ zend_op *get_next_op(zend_op_array *op_array CLS_DC)
zend_op *next_op;
if (next_op_num >= op_array->size) {
-#if SUPPORT_INTERACTIVE
- ELS_FETCH();
-
- if (EG(interactive)) {
+ if (CG(interactive)) {
/* we messed up */
zend_printf("Ran out of opcode space!\n"
"You should probably consider writing this huge script into a file!\n");
zend_bailout();
}
-#endif
op_array->size *= 4;
op_array_alloc_ops(op_array);
}
View
13 ext/com/COM.c
@@ -351,26 +351,21 @@ static PHP_INI_MH(OnTypelibFileChange)
FILE *typelib_file;
char *typelib_name_buffer;
char *strtok_buf = NULL;
-#if SUPPORT_INTERACTIVE
int interactive;
- ELS_FETCH();
-
- interactive = EG(interactive);
-#endif
+ CLS_FETCH();
+ interactive = CG(interactive);
if(!new_value || (typelib_file = VCWD_FOPEN(new_value, "r"))==NULL)
{
return FAILURE;
}
-#if SUPPORT_INTERACTIVE
if(interactive)
{
printf("Loading type libraries...");
fflush(stdout);
}
-#endif
typelib_name_buffer = (char *) emalloc(sizeof(char)*1024);
@@ -413,12 +408,10 @@ static PHP_INI_MH(OnTypelibFileChange)
}
-#if SUPPORT_INTERACTIVE
if(interactive)
{
printf("\rLoading %-60s\r", typelib_name);
}
-#endif
if((pTL = php_COM_find_typelib(typelib_name, mode)) != NULL)
{
php_COM_load_typelib(pTL, mode);
@@ -429,12 +422,10 @@ static PHP_INI_MH(OnTypelibFileChange)
efree(typelib_name_buffer);
fclose(typelib_file);
-#if SUPPORT_INTERACTIVE
if(interactive)
{
printf("\r%70s\r", "");
}
-#endif
return SUCCESS;
}
View
13 ext/rpc/com/com_wrapper.c
@@ -351,26 +351,21 @@ static PHP_INI_MH(OnTypelibFileChange)
FILE *typelib_file;
char *typelib_name_buffer;
char *strtok_buf = NULL;
-#if SUPPORT_INTERACTIVE
int interactive;
- ELS_FETCH();
-
- interactive = EG(interactive);
-#endif
+ CLS_FETCH();
+ interactive = CG(interactive);
if(!new_value || (typelib_file = VCWD_FOPEN(new_value, "r"))==NULL)
{
return FAILURE;
}
-#if SUPPORT_INTERACTIVE
if(interactive)
{
printf("Loading type libraries...");
fflush(stdout);
}
-#endif
typelib_name_buffer = (char *) emalloc(sizeof(char)*1024);
@@ -413,12 +408,10 @@ static PHP_INI_MH(OnTypelibFileChange)
}
-#if SUPPORT_INTERACTIVE
if(interactive)
{
printf("\rLoading %-60s\r", typelib_name);
}
-#endif
if((pTL = php_COM_find_typelib(typelib_name, mode)) != NULL)
{
php_COM_load_typelib(pTL, mode);
@@ -429,12 +422,10 @@ static PHP_INI_MH(OnTypelibFileChange)
efree(typelib_name_buffer);
fclose(typelib_file);
-#if SUPPORT_INTERACTIVE
if(interactive)
{
printf("\r%70s\r", "");
}
-#endif
return SUCCESS;
}
View
5 ext/standard/var.c
@@ -154,9 +154,8 @@ PHP_FUNCTION(var_dump)
/* }}} */
/* {{{ php_var_serialize */
-inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old);
-
-inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old) {
+static inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old)
+{
ulong var_no;
char id[sizeof(void *)*2+3];
View
12 sapi/cgi/cgi_main.c
@@ -253,9 +253,7 @@ static void php_cgi_usage(char *argv0)
" -v Version number\n"
" -C Do not chdir to the script's directory\n"
" -c <path> Look for php.ini file in this directory\n"
-#if SUPPORT_INTERACTIVE
" -a Run interactively\n"
-#endif
" -d foo[=bar] Define INI entry foo with value 'bar'\n"
" -e Generate extended information for debugger/profiler\n"
" -z <file> Load Zend extension <file>.\n"
@@ -379,9 +377,7 @@ int main(int argc, char *argv[])
char *argv0=NULL;
char *script_file=NULL;
zend_llist global_vars;
-#if SUPPORT_INTERACTIVE
int interactive=0;
-#endif
/* end of temporary locals */
#ifdef ZTS
zend_compiler_globals *compiler_globals;
@@ -531,12 +527,8 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
switch (c) {
case 'a': /* interactive mode */
-#if SUPPORT_INTERACTIVE
printf("Interactive mode enabled\n\n");
interactive=1;
-#else
- printf("Interactive mode not supported!\n\n");
-#endif
break;
case 'C': /* don't chdir to the script directory */
@@ -645,9 +637,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
}
} /* not cgi */
-#if SUPPORT_INTERACTIVE
- EG(interactive) = interactive;
-#endif
+ CG(interactive) = interactive;
if (!cgi) {
if (!SG(request_info).query_string) {
Please sign in to comment.
Something went wrong with that request. Please try again.