SOURCES: php-eaccelerator-php51.patch - makes eaccelerator work on...

adamg adamg at pld-linux.org
Fri Jan 6 18:11:02 CET 2006


Author: adamg                        Date: Fri Jan  6 17:11:02 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- makes eaccelerator work on php5.1 (patch by Hans Rakers)

---- Files affected:
SOURCES:
   php-eaccelerator-php51.patch (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/php-eaccelerator-php51.patch
diff -u SOURCES/php-eaccelerator-php51.patch:1.1 SOURCES/php-eaccelerator-php51.patch:1.2
--- SOURCES/php-eaccelerator-php51.patch:1.1	Sat Dec 24 16:44:30 2005
+++ SOURCES/php-eaccelerator-php51.patch	Fri Jan  6 18:10:57 2006
@@ -1,12 +1,12 @@
-hopefully fix build on php5.1 (though I am not sure about the content.c part)
-
---- eaccelerator-0.9.3/content.c~	2005-04-27 22:39:18.000000000 +0200
-+++ eaccelerator-0.9.3/content.c	2005-12-24 16:37:03.468541456 +0100
-@@ -593,10 +593,12 @@
+diff -urN --exclude=CVS eaccelerator-cvs-05012005/content.c eaccelerator/content.c
+--- eaccelerator-cvs-05012005/content.c	2005-07-10 10:12:33.000000000 +0200
++++ eaccelerator/content.c	2005-12-27 16:52:41.000000000 +0100
+@@ -593,10 +593,13 @@
      if (zend_eval_string(code, return_value, eval_name TSRMLS_CC) == SUCCESS &&
          eaccelerator_content_cache_place != eaccelerator_none) {
  
-+#if 0
++#ifndef ZEND_ENGINE_2_1
++/* No worko on php >= 5.1.0 */
        /* clean garbage */
        while (EG(garbage_ptr)) {
          zval_ptr_dtor(&EG(garbage)[--EG(garbage_ptr)]);
@@ -15,74 +15,858 @@
  
        eaccelerator_put(key, key_len, return_value, ttl, eaccelerator_content_cache_place TSRMLS_CC);
      }
---- eaccelerator-0.9.3/optimize.c~	2005-04-26 17:04:34.000000000 +0200
-+++ eaccelerator-0.9.3/optimize.c	2005-12-24 16:40:37.332029264 +0100
-@@ -250,14 +250,18 @@
+diff -urN --exclude=CVS eaccelerator-cvs-05012005/ea_restore.c eaccelerator/ea_restore.c
+--- eaccelerator-cvs-05012005/ea_restore.c	2005-08-03 20:54:32.000000000 +0200
++++ eaccelerator/ea_restore.c	2005-12-27 17:14:48.000000000 +0100
+@@ -39,6 +39,9 @@
+ #include "zend.h"
+ #include "zend_API.h"
+ #include "zend_extensions.h"
++#ifdef ZEND_ENGINE_2_1
++#include "zend_vm.h"
++#endif
+ 
+ #ifndef INCOMPLETE_CLASS
+ #  define INCOMPLETE_CLASS "__PHP_Incomplete_Class"
+@@ -69,11 +72,18 @@
+ 	property_dtor = dummy_class_entry.properties_info.pDestructor;
+ 
+ 	zend_hash_destroy(&dummy_class_entry.default_properties);
+-	zend_hash_destroy(&dummy_class_entry.properties_info);
+-	zend_hash_destroy(dummy_class_entry.static_members);
+ 	zend_hash_destroy(&dummy_class_entry.function_table);
+-	FREE_HASHTABLE(dummy_class_entry.static_members);
++#ifdef ZEND_ENGINE_2
+ 	zend_hash_destroy(&dummy_class_entry.constants_table);
++	zend_hash_destroy(&dummy_class_entry.properties_info);
++#endif
++#if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_1)
++	zend_hash_destroy(dummy_class_entry.static_members);
++        FREE_HASHTABLE(dummy_class_entry.static_members);
++#endif
++#ifdef ZEND_ENGINE_2_1
++	zend_hash_destroy(&dummy_class_entry.default_static_members);
++#endif
+ 
+ 	return property_dtor;
+ }
+@@ -92,6 +102,9 @@
+ static void fixup_property_info(zend_property_info * from TSRMLS_DC)
+ {
+ 	FIXUP(from->name);
++#ifdef ZEND_ENGINE_2_1
++	FIXUP(from->doc_comment);
++#endif
+ }
+ #endif
+ 
+@@ -221,7 +234,12 @@
+ 				FIXUP(opline->op2.u.jmp_addr);
+ 				break;
+ 			}
++#  ifdef ZEND_ENGINE_2_1
++			ZEND_VM_SET_OPCODE_HANDLER(opline);
++#  else
+ 			opline->handler = get_opcode_handler(opline->opcode TSRMLS_CC);
++#  endif
++
+ #endif
+ 		}
+ 		EAG(compress) = 1;
+@@ -234,6 +252,15 @@
+ 		FIXUP(from->static_variables);
+ 		fixup_zval_hash(from->static_variables);
+ 	}
++#ifdef ZEND_ENGINE_2_1
++	if (from->vars != NULL) {
++		zend_uint i;
++		FIXUP(from->vars);
++		for (i = 0; i < from->last_var; i++) {
++			FIXUP(from->vars[i].name);
++		}
++	}
++#endif
+ 	FIXUP(from->filename);
+ #ifdef ZEND_ENGINE_2
+ 	FIXUP(from->doc_comment);
+@@ -570,12 +597,12 @@
+ 	to->T = from->T;
+ 	to->brk_cont_array = from->brk_cont_array;
+ 	to->last_brk_cont = from->last_brk_cont;
+-	/*
++	
+ 	   to->current_brk_cont = -1;
+ 	   to->static_variables = from->static_variables;
+-	   to->start_op         = to->opcodes;
++//	   to->start_op         = to->opcodes;
+ 	   to->backpatch_count  = 0;
+-	 */
++	
+ 	to->return_reference = from->return_reference;
+ 	to->done_pass_two = 1;
+ 	to->filename = from->filename;
+@@ -612,6 +639,20 @@
+ #endif
+ 	}
+ 
++#ifdef ZEND_ENGINE_2_1
++	to->vars             = from->vars;
++	to->last_var         = from->last_var;
++	to->size_var         = 0;
++	if (to->vars) {		
++		zend_uint i;
++		to->vars = (zend_compiled_variable*)emalloc(from->last_var*sizeof(zend_compiled_variable));		
++		memcpy(to->vars, from->vars, sizeof(zend_compiled_variable) * from->last_var);
++		for (i = 0; i < from->last_var; i ++) {
++			to->vars[i].name = estrndup(from->vars[i].name, from->vars[i].name_len);
++		}
++	}
++#endif
++
+ 	/* disable deletion in destroy_op_array */
+ 	++EAG(refcount_helper);
+ 	to->refcount = &EAG(refcount_helper);
+@@ -633,6 +674,12 @@
+ 	memcpy(to, from, sizeof(zend_property_info));
+ 	to->name = emalloc(from->name_length + 1);
+ 	memcpy(to->name, from->name, from->name_length + 1);
++#ifdef ZEND_ENGINE_2_1
++	if (from->doc_comment != NULL) {
++		to->doc_comment = emalloc(from->doc_comment_len+1);
++		memcpy(to->doc_comment, from->doc_comment, from->doc_comment_len+1);
++	}
++#endif
+ 	return to;
+ }
+ #endif
+@@ -813,6 +860,11 @@
+             (restore_bucket_t) restore_property_info TSRMLS_CC);
+ 	to->properties_info.pDestructor = properties_info_dtor;
+ 
++#ifdef ZEND_ENGINE_2_1
++	restore_zval_hash(&to->default_static_members, &from->default_static_members);
++#endif
++	
++
+ 	if (from->static_members != NULL) {
+ 		ALLOC_HASHTABLE(to->static_members);
+ 		restore_zval_hash(to->static_members, from->static_members);
+diff -urN --exclude=CVS eaccelerator-cvs-05012005/ea_restore.h eaccelerator/ea_restore.h
+--- eaccelerator-cvs-05012005/ea_restore.h	2005-07-11 19:25:38.000000000 +0200
++++ eaccelerator/ea_restore.h	2005-12-27 16:53:02.000000000 +0100
+@@ -34,6 +34,7 @@
+ void fixup_op_array (eaccelerator_op_array * from TSRMLS_DC);
+ void fixup_class_entry (eaccelerator_class_entry * from TSRMLS_DC);
+ 
++void restore_zval(zval * zv TSRMLS_DC);
+ void restore_class(mm_fc_entry *p TSRMLS_DC);
+ void restore_function(mm_fc_entry *p TSRMLS_DC);
+ zend_op_array* restore_op_array(zend_op_array *to, eaccelerator_op_array *from TSRMLS_DC);
+diff -urN --exclude=CVS eaccelerator-cvs-05012005/ea_store.c eaccelerator/ea_store.c
+--- eaccelerator-cvs-05012005/ea_store.c	2005-07-11 19:25:38.000000000 +0200
++++ eaccelerator/ea_store.c	2005-12-27 16:53:04.000000000 +0100
+@@ -82,6 +82,11 @@
+ 	EACCELERATOR_ALIGN(EAG(mem));
+ 	EAG(mem) += sizeof(zend_property_info);
+ 	calc_string(from->name, from->name_length + 1 TSRMLS_CC);
++#ifdef ZEND_ENGINE_2_1
++	if (from->doc_comment != NULL) {
++		calc_string(from->doc_comment, from->doc_comment_len + 1 TSRMLS_CC);
++	}
++#endif
+ }
+ 
+ /* Calculate the size of a point to a class entry */
+@@ -246,6 +251,16 @@
+ 		EAG(mem) += sizeof(HashTable);
+ 		calc_zval_hash(from->static_variables);
+ 	}
++#ifdef ZEND_ENGINE_2_1
++	if (from->vars != NULL) {
++		zend_uint i;
++		EACCELERATOR_ALIGN(EAG(mem));
++		EAG(mem) += sizeof(zend_compiled_variable) * from->last_var;
++		for (i = 0; i < from->last_var; i ++) {
++			calc_string(from->vars[i].name, from->vars[i].name_len+1 TSRMLS_CC);
++		}
++	}
++#endif
+ 	if (from->filename != NULL)
+ 		calc_string(from->filename, strlen(from->filename) + 1 TSRMLS_CC);
+ #ifdef ZEND_ENGINE_2
+@@ -285,6 +300,11 @@
+ 
+ 	calc_zval_hash(&from->constants_table);
+ 	calc_zval_hash(&from->default_properties);
++
++#ifdef ZEND_ENGINE_2_1
++	calc_zval_hash(&from->default_static_members);
++#endif
++	
+ 	calc_hash(&from->properties_info, (calc_bucket_t) calc_property_info);
+ 	if (from->static_members != NULL) {
+ 		EACCELERATOR_ALIGN(EAG(mem));
+@@ -610,6 +630,10 @@
+ 	to->uses_globals = from->uses_globals;
+ #endif
+ 	to->static_variables = from->static_variables;
++#ifdef ZEND_ENGINE_2_1
++	to->vars             = from->vars;
++	to->last_var         = from->last_var;
++#endif
+ 	to->return_reference = from->return_reference;
+ 	to->filename = from->filename;
+ 
+@@ -671,6 +695,22 @@
+ 		EAG(mem) += sizeof(HashTable);
+ 		store_zval_hash(to->static_variables, from->static_variables);
+ 	}
++#ifdef ZEND_ENGINE_2_1
++	if (from->vars != NULL) {
++        	zend_uint i;
++	        EACCELERATOR_ALIGN(EAG(mem));
++	        to->last_var = from->last_var;
++	        to->vars = (zend_compiled_variable*)EAG(mem);
++	        EAG(mem) += sizeof(zend_compiled_variable) * from->last_var;
++			memcpy(to->vars, from->vars, sizeof(zend_compiled_variable) * from->last_var);	        
++	        for (i = 0; i < from->last_var; i ++) {
++	        	to->vars[i].name = store_string(from->vars[i].name, from->vars[i].name_len+1 TSRMLS_CC);
++			}
++	} else {
++		to->last_var = 0;
++	        //to->vars = 0;
++	}
++#endif
+ 	if (from->filename != NULL) {
+ 		to->filename = store_string(to->filename, strlen(from->filename) + 1 TSRMLS_CC);
+ 	}
+@@ -693,6 +733,12 @@
+ 	EAG(mem) += sizeof(zend_property_info);
+ 	memcpy(to, from, sizeof(zend_property_info));
+ 	to->name = store_string(from->name, from->name_length + 1 TSRMLS_CC);
++#ifdef ZEND_ENGINE_2_1
++	to->doc_comment_len = from->doc_comment_len;
++	if (from->doc_comment != NULL) {
++		to->doc_comment = store_string(from->doc_comment, from->doc_comment_len + 1 TSRMLS_CC);
++	}
++#endif
+ 	return to;
+ }
+ #endif
+@@ -771,6 +817,11 @@
+ #else
+ 	store_zval_hash(&to->default_properties, &from->default_properties);
+ #endif
++
++#ifdef ZEND_ENGINE_2_1
++	store_zval_hash(&to->default_static_members, &from->default_static_members); //LYLE
++#endif
++
+ 	store_hash(&to->function_table, &from->function_table, (store_bucket_t) store_op_array);
+ 
+ #ifdef DEBUG
+diff -urN --exclude=CVS eaccelerator-cvs-05012005/eaccelerator.c eaccelerator/eaccelerator.c
+--- eaccelerator-cvs-05012005/eaccelerator.c	2005-11-29 18:19:18.000000000 +0100
++++ eaccelerator/eaccelerator.c	2005-12-27 16:53:08.000000000 +0100
+@@ -110,6 +110,10 @@
+ /* saved original functions */
+ static zend_op_array *(*mm_saved_zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
+ 
++#ifdef DEBUG
++static void (*mm_saved_zend_execute)(zend_op_array *op_array TSRMLS_DC);
++#endif
++
+ /* external declarations */
+ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC);
+ 
+@@ -842,7 +846,7 @@
+   q = p->c_head;
+   while (q != NULL) {
+ #ifdef ZEND_ENGINE_2
+-      q->fc = store_class_entry ((zend_class_entry *) q->fc TSRMLS_CC);
++      q->fc = store_class_entry ((zend_class_entry *) q->fc TSRMLS_CC);  // hra: exactly the same?!
+ #else
+       q->fc = store_class_entry ((zend_class_entry *) q->fc TSRMLS_CC);
+ #endif
+@@ -1561,18 +1565,20 @@
+ 
+   for (i=0;i<EAG(profile_level);i++)
+     ea_debug_put(EA_PROFILE_OPCODES, "  ");
+-  ea_debug_printf(EA_PROFILE_OPCODES, "enter: %s:%s\n", op_array->filename, op_array->function_name);
++  ea_debug_printf(EA_PROFILE_OPCODES, "enter profile_execute: %s:%s\n", op_array->filename, op_array->function_name);
+   ea_debug_start_time(&tv_start);
+   EAG(self_time)[EAG(profile_level)] = 0;
+   EAG(profile_level)++;
++  ea_debug_printf(EA_PROFILE_OPCODES, "About to enter zend_execute...\n");
+   mm_saved_zend_execute(op_array TSRMLS_CC);
++  ea_debug_printf(EA_PROFILE_OPCODES, "Finished zend_execute...\n");
+   usec = ea_debug_elapsed_time(&tv_start);
+   EAG(profile_level)--;
+   if (EAG(profile_level) > 0)
+     EAG(self_time)[EAG(profile_level)-1] += usec;
+   for (i=0;i<EAG(profile_level);i++)
+     ea_debug_put(EA_PROFILE_OPCODES, "  ");
+-  ea_debug_printf(EA_PROFILE_OPCODES, "leave: %s:%s (%ld,%ld)\n", op_array->filename, op_array->function_name, usec, usec-EAG(self_time)[EAG(profile_level)]);
++  ea_debug_printf(EA_PROFILE_OPCODES, "leave profile_execute: %s:%s (%ld,%ld)\n", op_array->filename, op_array->function_name, usec, usec-EAG(self_time)[EAG(profile_level)]);
+ }
+ 
+ ZEND_DLEXPORT zend_op_array* profile_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) {
+@@ -1589,7 +1595,7 @@
+     EAG(self_time)[EAG(profile_level)-1] += usec;
+   for (i=0;i<EAG(profile_level);i++)
+     ea_debug_put(EA_PROFILE_OPCODES, "  ");
+-  ea_debug_printf(EA_DEBUG, "compile: %s (%ld)\n", file_handle->filename, usec);
++  ea_debug_printf(EA_DEBUG, "zend_op_array compile: %s (%ld)\n", file_handle->filename, usec);
+   return t;
+ }
+ 
+diff -urN --exclude=CVS eaccelerator-cvs-05012005/eaccelerator.h eaccelerator/eaccelerator.h
+--- eaccelerator-cvs-05012005/eaccelerator.h	2005-11-29 18:19:18.000000000 +0100
++++ eaccelerator/eaccelerator.h	2005-12-27 16:53:11.000000000 +0100
+@@ -44,6 +44,10 @@
+ #  endif
+ #endif
+ 
++#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1
++#   define ZEND_ENGINE_2_1
++#endif
++
+ /* fixes compile errors on php5.1 */
+ #ifdef STR_EMPTY_ALLOC
+ #define empty_string STR_EMPTY_ALLOC()
+@@ -199,6 +203,10 @@
+ #endif
+ 	zend_op *opcodes;
+ 	zend_uint last;
++#ifdef ZEND_ENGINE_2_1
++	zend_compiled_variable *vars;
++    int last_var;
++#endif
+ 	zend_uint T;
+ 	zend_brk_cont_element *brk_cont_array;
+ 	zend_uint last_brk_cont;
+@@ -224,12 +232,16 @@
+ 	char *parent;
+ 	HashTable function_table;
+ 	HashTable default_properties;
++#ifdef ZEND_ENGINE_2_1
++	HashTable default_static_members;
++#endif
+ #ifdef ZEND_ENGINE_2
+ 	zend_uint ce_flags;
+ 	HashTable *static_members;
+ 	HashTable properties_info;
+ 	HashTable constants_table;
+ 	zend_uint num_interfaces;
++
+ 	char **interfaces;
+ 	zend_class_iterator_funcs iterator_funcs;
+ 
+diff -urN --exclude=CVS eaccelerator-cvs-05012005/loader.c eaccelerator/loader.c
+--- eaccelerator-cvs-05012005/loader.c	2005-08-03 20:54:32.000000000 +0200
++++ eaccelerator/loader.c	2005-12-27 16:53:14.000000000 +0100
+@@ -40,6 +40,10 @@
+ #include "ea_restore.h"
+ #include <math.h>
+ 
++#ifdef HAVE_EACCELERATOR_STANDALONE_LOADER
++zend_extension* ZendOptimizer = NULL;
++#endif
++
+ typedef struct loader_data {
+   long  version;
+   char* filename;
+diff -urN --exclude=CVS eaccelerator-cvs-05012005/opcodes.c eaccelerator/opcodes.c
+--- eaccelerator-cvs-05012005/opcodes.c	2005-05-16 11:56:42.000000000 +0200
++++ eaccelerator/opcodes.c	2005-12-28 00:26:38.000000000 +0100
+@@ -43,11 +43,7 @@
+ #  define OP1_VAR_2 OP1_VAR
+ #endif
+ 
+-#ifdef ZEND_ENGINE_2
+-#  define LAST_OPCODE 149
+-#else
+-#  define LAST_OPCODE 106
+-#endif
++#define LAST_OPCODE (sizeof(opcodes)/sizeof(opcodes[0]))
+ 
+ static const opcode_dsc opcodes[] = {
+   OPDEF("NOP",                       EXT_UNUSED | OP1_UNUSED | OP2_UNUSED | RES_UNUSED), /* 0 */
+@@ -158,16 +154,20 @@
+   OPDEF("INIT_ARRAY",                EXT_BIT    | OP1_STD    | OP2_STD    | RES_TMP), /* 71 */
+   OPDEF("ADD_ARRAY_ELEMENT",         EXT_BIT    | OP1_STD    | OP2_STD    | RES_TMP), /* 72 */
+   OPDEF("INCLUDE_OR_EVAL",           EXT_UNUSED | OP1_STD    | OP2_INCLUDE| RES_VAR), /* 73 */
+-#ifdef ZEND_ENGINE_2
++#ifdef ZEND_ENGINE_2_1
++  /* php 5.1 and up */
+   OPDEF("UNSET_VAR",                 EXT_UNUSED | OP1_STD    | OP2_FETCH  | RES_UNUSED), /* 74 */
+-  OPDEF("UNSET_DIM_OBJ",             EXT_STD    | OP1_STD    | OP2_STD    | RES_UNUSED), /* 75 */
+-  OPDEF("ISSET_ISEMPTY",             EXT_ISSET  | OP1_VAR    | OP2_UNUSED | RES_TMP), /* 76 */
++  OPDEF("UNSET_DIM",                 EXT_STD    | OP1_STD    | OP2_STD    | RES_UNUSED), /* 75 */
++  OPDEF("UNSET_OBJ",                 EXT_STD    | OP1_STD    | OP2_STD    | RES_UNUSED), /* 76 */
++  OPDEF("FE_RESET",                  EXT_BIT    | OP1_STD    | OP2_OPLINE | RES_VAR), /* 77 */
+ #else
++  /* <= php 5.0 */
++  /* though there is no ISSET_ISEMPTY in php 5.0 it's better to leave it here i guess */
+   OPDEF("UNSET_VAR",                 EXT_UNUSED | OP1_STD    | OP2_UNUSED | RES_UNUSED), /* 74 */
+   OPDEF("UNSET_DIM_OBJ",             EXT_UNUSED | OP1_VAR    | OP2_STD    | RES_UNUSED), /* 75 */
+   OPDEF("ISSET_ISEMPTY",             EXT_UNUSED | OP1_VAR    | OP2_ISSET  | RES_TMP), /* 76 */
+-#endif
+   OPDEF("FE_RESET",                  EXT_BIT    | OP1_STD    | OP2_UNUSED | RES_VAR), /* 77 */
++#endif
+   OPDEF("FE_FETCH",                  EXT_FE     | OP1_STD    | OP2_OPLINE | RES_TMP), /* 78 */
+   OPDEF("EXIT",                      EXT_UNUSED | OP1_STD    | OP2_UNUSED | RES_UNUSED), /* 79 */
+   OPDEF("FETCH_R",                   EXT_UNUSED | OP1_STD    | OP2_FETCH  | RES_VAR), /* 80 */
+@@ -245,14 +245,17 @@
+   OPDEF("VERIFY_INSTANCEOF",         EXT_UNUSED | OP1_CLASS  | OP2_STD    | RES_UNUSED), /* 145 */
+   OPDEF("VERIFY_ABSTRACT_CLASS",     EXT_UNUSED | OP1_CLASS  | OP2_UNUSED | RES_UNUSED), /* 146 */
+   OPDEF("ASSIGN_DIM",                EXT_UNUSED | OP1_STD    | OP2_STD    | RES_VAR),  /* 147 */
+-
+   OPDEF("ISSET_ISEMPTY_PROP_OBJ",    EXT_ISSET  | OP1_STD    | OP2_STD    | RES_TMP), /* 148 */
+   OPDEF("HANDLE_EXCEPTION",          EXT_STD    | OP1_UNUSED | OP2_UNUSED | RES_STD)  /* 149 */
++# ifdef ZEND_ENGINE_2_1
++  ,
++  OPDEF("USER_OPCODE",               EXT_STD    | OP1_UNUSED | OP2_UNUSED | RES_STD)  /* 150 */
++# endif    
+ #endif
+ };
+ 
+ const opcode_dsc* get_opcode_dsc(unsigned int n) {
+-  if (n <= LAST_OPCODE) {
++  if (n < LAST_OPCODE) {
+     return &opcodes[n];
+   } else {
+     return NULL;
+@@ -261,17 +264,17 @@
+ #endif
+ 
+ #ifdef ZEND_ENGINE_2
+-static opcode_handler_t eaccelerator_opcode_handlers[LAST_OPCODE+1];
++static opcode_handler_t eaccelerator_opcode_handlers[LAST_OPCODE];
+ static int handlers_retrived = 0;
+ 
+ ZEND_DLEXPORT void retrive_opcode_handlers_handler(zend_op_array *op_array) {
+   unsigned char i;
+   efree(op_array->opcodes);
+-  op_array->opcodes = (zend_op*)emalloc(sizeof(zend_op)*(LAST_OPCODE+1));
+-  op_array->last = LAST_OPCODE+1;
+-  op_array->size = LAST_OPCODE+1;
++  op_array->opcodes = (zend_op*)emalloc(sizeof(zend_op)*(LAST_OPCODE));
++  op_array->last = LAST_OPCODE;
++  op_array->size = LAST_OPCODE;
+   op_array->T    = 0;
+-  for (i=0; i<=LAST_OPCODE; i++) {
++  for (i=0; i<LAST_OPCODE; i++) {
+     op_array->opcodes[i].opcode = i;
+     op_array->opcodes[i].op1.op_type = IS_UNUSED;
+     op_array->opcodes[i].op1.u.opline_num = i;
+@@ -298,9 +301,9 @@
+     ext->op_array_handler = retrive_opcode_handlers_handler;
+     p = compile_string(&str, empty_string TSRMLS_CC);
+     ext->op_array_handler = old;
+-    if (p != NULL && p->last == LAST_OPCODE+1) {
++    if (p != NULL && p->last == (LAST_OPCODE - 1)) {
+       int i = 0;
+-      while (i <= LAST_OPCODE) {
++      while (i < LAST_OPCODE) {
+          eaccelerator_opcode_handlers[p->opcodes[i].opcode] = p->opcodes[i].handler;
+          ++i;
+       }
+@@ -318,7 +321,7 @@
+       return NULL;
+     }
+   }
+-  if (opcode <= LAST_OPCODE) {
++  if (opcode < LAST_OPCODE) {
+     return eaccelerator_opcode_handlers[opcode];
+   } else {
+     return (opcode_handler_t) NULL;
+diff -urN --exclude=CVS eaccelerator-cvs-05012005/optimize.c eaccelerator/optimize.c
+--- eaccelerator-cvs-05012005/optimize.c	2005-11-17 21:25:11.000000000 +0100
++++ eaccelerator/optimize.c	2005-12-29 14:52:11.000000000 +0100
+@@ -250,14 +250,27 @@
                 }
                 break;
               case ZEND_UNSET_VAR:
-+#ifdef ZEND_UNSET_DIM_OBJ
++#ifndef ZEND_ENGINE_2_1
++/* Pre-PHP 5.1 only */
               case ZEND_UNSET_DIM_OBJ:
-+#endif
                 end->result.op_type = IS_UNUSED;
                 break;
++#else
++             case ZEND_UNSET_DIM:
++             case ZEND_UNSET_OBJ:
++               end->result.op_type = IS_UNUSED;
++               break;
++#endif
               case ZEND_RECV:
               case ZEND_RECV_INIT:
               /*case ZEND_ADD_ARRAY_ELEMENT:*/
               case ZEND_INCLUDE_OR_EVAL:
-+#ifdef ZEND_JMP_NO_CTOR
++#ifndef ZEND_ENGINE_2_1
++/* Pre-PHP 5.1 only */
               case ZEND_JMP_NO_CTOR:
++#else
++             case ZEND_NEW:
 +#endif
               case ZEND_FE_FETCH:
  #ifdef ZEND_ENGINE_2
               case ZEND_ASSIGN_DIM:
-@@ -1279,7 +1283,9 @@
+@@ -1279,7 +1292,12 @@
                goto jmp_nz;
              }
              goto jmp_2;
-+#ifdef ZEND_JMP_NO_CTOR
++#ifndef ZEND_ENGINE_2_1
++/* Pre-PHP 5.1 only */
            case ZEND_JMP_NO_CTOR:
++#else
++          case ZEND_NEW:
 +#endif
            case ZEND_FE_FETCH:
  jmp_2:
              while (p->jmp_2->len == 1 && p->jmp_2->start->opcode == ZEND_JMP) {
-@@ -2437,7 +2443,9 @@
+@@ -1714,6 +1732,7 @@
+       }
+     } else 
+ #endif
++
+     if ((op->opcode == ZEND_ADD ||
+                 op->opcode == ZEND_SUB ||
+                 op->opcode == ZEND_MUL ||
+@@ -2443,7 +2462,13 @@
            op->opcode == ZEND_DO_FCALL_BY_NAME ||
            op->opcode == ZEND_POST_INC ||
            op->opcode == ZEND_POST_DEC ||
-+#ifdef ZEND_UNSET_DIM_OBJ
++#ifndef ZEND_ENGINE_2_1
++/* Pre-PHP 5.1 only */
            op->opcode == ZEND_UNSET_DIM_OBJ ||
++#else
++          op->opcode == ZEND_UNSET_DIM ||
++          op->opcode == ZEND_UNSET_OBJ ||
 +#endif
            op->opcode == ZEND_INCLUDE_OR_EVAL
  #ifdef ZEND_ENGINE_2
            || op->opcode == ZEND_ASSIGN_DIM
-@@ -2715,7 +2723,9 @@
+@@ -2705,7 +2730,7 @@
+ 		switch(op->opcode)
+ 		{
+ 			case ZEND_RETURN:
+-			case ZEND_EXIT:
++			case ZEND_EXIT:			
+ 				bb[line_num+1].start = op+1;
+ 				break;
+ 			case ZEND_JMP:
+@@ -2721,7 +2746,13 @@
  			case ZEND_JMPNZ:
  			case ZEND_JMPZ_EX:
  			case ZEND_JMPNZ_EX:
-+#ifdef ZEND_JMP_NO_CTOR
++#ifndef ZEND_ENGINE_2_1
++/* Pre-PHP 5.1 only */
  			case ZEND_JMP_NO_CTOR:
++#else
++			case ZEND_NEW:
++			case ZEND_FE_RESET:
 +#endif
  			case ZEND_FE_FETCH:
  				bb[line_num+1].start = op+1;
  				bb[op->op2.u.opline_num].start = &op_array->opcodes[op->op2.u.opline_num];
-@@ -2834,7 +2844,9 @@
+@@ -2840,9 +2871,19 @@
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/php-eaccelerator-php51.patch?r1=1.1&r2=1.2&f=u



More information about the pld-cvs-commit mailing list