Changeset 246


Ignore:
Timestamp:
07/27/06 11:38:27 (4 years ago)
Author:
bart
Message:

Killing the very broken encoder. Once when eAccelerator is in full

shape an encoder may return.

Location:
eaccelerator/trunk
Files:
8 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • eaccelerator/trunk/ChangeLog

    r245 r246  
    33        * Branched 0.9.5, development for 0.9.6 will start in trunk 
    44        * Bumped up version to 0.9.6-dev 
     5        * Killing the very broken encoder. Once when eAccelerator is in full 
     6          shape an encoder may return. 
    57 
    682006-07-25  Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 
  • eaccelerator/trunk/Makefile.in

    r237 r246  
    11LTLIBRARY_NAME        = libeaccelerator.la 
    2 LTLIBRARY_SOURCES     = eaccelerator.c optimize.c encoder.c loader.c opcodes.c content.c mm.c session.c shm.c debug.c cache.c ea_restore.c ea_store.c ea_info.c ea_dasm.c 
     2LTLIBRARY_SOURCES     = eaccelerator.c optimize.c opcodes.c content.c mm.c session.c shm.c debug.c cache.c ea_restore.c ea_store.c ea_info.c ea_dasm.c 
    33LTLIBRARY_SHARED_NAME = eaccelerator.la 
    44 
  • eaccelerator/trunk/README

    r211 r246  
    1919by several engines. Files that can't fit in shared memory are cached  on  disk 
    2020only. 
    21  
    22 eAccelerator contains a PHP encoder and loader. You  can  encode  PHP  scripts 
    23 using encoder.php in order to distribute them without sources.  Encoded  files  
    24 can be run on any site which  runs  PHP  with  eAccelerator.  The  sources  of 
    25 encoded scripts can't be restored because they are stored in a  compiled  form 
    26 and the encoded version doesn't contain the source. Of course, some  internals 
    27 of the scripts can  be  restored  with  different  reverse  engineering  tools 
    28 (disassemblers, debuggers, etc), but it is not trivial. 
    2921 
    3022eAccelerator is compatible with Zend Optimizer's loader. Zend  Optimizer  must 
  • eaccelerator/trunk/config.m4

    r207 r246  
    3030]) 
    3131 
    32 AC_ARG_WITH(eaccelerator-encoder, 
    33 [  --without-eaccelerator-encoder           Do not include eaccelerator encoder],[ 
    34   eaccelerator_encoder=$withval 
    35 ],[ 
    36   eaccelerator_encoder=yes 
    37 ]) 
    38  
    39 AC_ARG_WITH(eaccelerator-loader, 
    40 [  --without-eaccelerator-loader            Do not include eaccelerator loader],[ 
    41   eaccelerator_loader=$withval 
    42 ],[ 
    43   eaccelerator_loader=yes 
    44 ]) 
    45  
    4632AC_ARG_WITH(eaccelerator-shared-memory, 
    4733[  --with-eaccelerator-shared-memory        Include eaccelerator shared memory functions],[ 
     
    114100  if test "$eaccelerator_optimizer" = "yes"; then 
    115101    AC_DEFINE(WITH_EACCELERATOR_OPTIMIZER, 1, [Define if you like to use peephole opcode optimization]) 
    116   fi 
    117   if test "$eaccelerator_encoder" = "yes"; then 
    118     AC_DEFINE(WITH_EACCELERATOR_ENCODER, 1, [Define if you like to use eAccelerator enoder]) 
    119   fi 
    120   if test "$eaccelerator_loader" = "yes"; then 
    121     AC_DEFINE(WITH_EACCELERATOR_LOADER, 1, [Define if you like to load files encoded by eAccelerator encoder]) 
    122102  fi 
    123103  if test "$eaccelerator_shm" = "yes"; then 
  • eaccelerator/trunk/ea_store.c

    r231 r246  
    4343static void calc_string(char *str, int len TSRMLS_DC) 
    4444{ 
    45         if (len > MAX_DUP_STR_LEN || zend_hash_add(&EAG(strings), str, len, 
    46                                                                                            &str, sizeof(char *), 
    47                                                                                            NULL) == SUCCESS) { 
     45        if (len > MAX_DUP_STR_LEN ||  
     46            zend_hash_add(&EAG(strings), str, len, &str, sizeof(char *), NULL) == SUCCESS) { 
    4847                EACCELERATOR_ALIGN(EAG(mem)); 
    4948                EAG(mem) += len; 
     
    344343} 
    345344 
    346 /** Functions to store a script **/ 
    347345static inline char *store_string(char *str, int len TSRMLS_DC) 
    348346{ 
  • eaccelerator/trunk/eaccelerator.c

    r237 r246  
    14091409      DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: storing in cache (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start))); 
    14101410      DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: storing in cache\n", getpid())); 
    1411 #ifdef WITH_EACCELERATOR_LOADER 
    1412       if (t->last >= 3 && 
    1413           t->opcodes[0].opcode == ZEND_SEND_VAL && 
    1414           t->opcodes[1].opcode == ZEND_DO_FCALL && 
    1415           t->opcodes[2].opcode == ZEND_RETURN && 
    1416           t->opcodes[1].op1.op_type == IS_CONST && 
    1417           t->opcodes[1].op1.u.constant.type == IS_STRING && 
    1418           t->opcodes[1].op1.u.constant.value.str.len == sizeof("eaccelerator_load")-1 && 
    1419           (memcmp(t->opcodes[1].op1.u.constant.value.str.val, "eaccelerator_load", sizeof("eaccelerator_load")-1) == 0) && 
    1420           t->opcodes[0].op1.op_type == IS_CONST && 
    1421           t->opcodes[0].op1.u.constant.type == IS_STRING) { 
    1422         zend_op_array* new_t = NULL; 
    1423         zend_bool old_in_compilation = CG(in_compilation); 
    1424         char* old_filename = CG(compiled_filename); 
    1425         int old_lineno = CG(zend_lineno); 
    1426  
    1427         CG(in_compilation) = 1; 
    1428         zend_set_compiled_filename(t->filename TSRMLS_CC); 
    1429         CG(zend_lineno) = t->opcodes[1].lineno; 
    1430  
    1431         zend_try { 
    1432           new_t = eaccelerator_load( 
    1433             t->opcodes[0].op1.u.constant.value.str.val, 
    1434             t->opcodes[0].op1.u.constant.value.str.len TSRMLS_CC); 
    1435         } zend_catch { 
    1436             CG(function_table)  = orig_function_table; 
    1437             CG(class_table)             = orig_class_table; 
    1438             ea_bailout                          = 1; 
    1439         } zend_end_try(); 
    1440         if (ea_bailout) { 
    1441           zend_bailout (); 
    1442         } 
    1443         CG(in_compilation) = old_in_compilation; 
    1444         CG(compiled_filename) = old_filename; 
    1445         CG(zend_lineno) = old_lineno; 
    1446         if (new_t != NULL) { 
    1447 #ifdef ZEND_ENGINE_2 
    1448           destroy_op_array(t TSRMLS_CC); 
    1449 #else 
    1450           destroy_op_array(t); 
    1451 #endif 
    1452           efree(t); 
    1453           t = new_t; 
    1454         } 
    1455       } 
    1456 #endif 
    14571411      function_table_tail = function_table_tail?function_table_tail->pListNext:CG(function_table)->pListHead; 
    14581412      class_table_tail = class_table_tail?class_table_tail->pListNext:CG(class_table)->pListHead; 
     
    19091863  eaccelerator_globals->optimizer_enabled = 1; 
    19101864  eaccelerator_globals->compiler          = 0; 
    1911   eaccelerator_globals->encoder           = 0; 
    19121865  eaccelerator_globals->cond_list         = NULL; 
    19131866  eaccelerator_globals->content_headers   = NULL; 
     
    19881941    } 
    19891942#endif 
    1990 #ifdef WITH_EACCELERATOR_LOADER 
    1991     if (zend_hash_exists(&module_registry, EACCELERATOR_LOADER_EXTENSION_NAME,  
    1992                 sizeof(EACCELERATOR_LOADER_EXTENSION_NAME))) { 
    1993       zend_error(E_CORE_WARNING,"Extension \"%s\" is not need with \"%s\". Remove it from php.ini\n",  
    1994               EACCELERATOR_LOADER_EXTENSION_NAME, EACCELERATOR_EXTENSION_NAME); 
    1995       zend_hash_del(&module_registry, EACCELERATOR_LOADER_EXTENSION_NAME,  
    1996               sizeof(EACCELERATOR_LOADER_EXTENSION_NAME)); 
    1997     } 
    1998 #endif 
    19991943  } 
    20001944  if (!eaccelerator_check_php_version(TSRMLS_C)) { 
     
    21152059        EAG(used_entries) = NULL; 
    21162060        EAG(compiler) = 0; 
    2117         EAG(encoder) = 0; 
    21182061        EAG(refcount_helper) = 1; 
    21192062        EAG(compress_content) = 1; 
     
    22412184  PHP_FE(eaccelerator_removed_scripts, NULL) 
    22422185  PHP_FE(eaccelerator_list_keys, NULL) 
    2243 #endif 
    2244 #ifdef WITH_EACCELERATOR_ENCODER 
    2245   PHP_FE(eaccelerator_encode, eaccelerator_second_arg_force_ref) 
    2246 #endif 
    2247 #ifdef WITH_EACCELERATOR_LOADER 
    2248   PHP_FE(eaccelerator_load, NULL) 
    2249   PHP_FE(_eaccelerator_loader_file, NULL) 
    2250   PHP_FE(_eaccelerator_loader_line, NULL) 
    22512186#endif 
    22522187#ifdef WITH_EACCELERATOR_SESSIONS 
  • eaccelerator/trunk/eaccelerator.h

    r237 r246  
    109109 
    110110#ifdef HAVE_EACCELERATOR 
    111 #ifndef HAVE_EACCELERATOR_STANDALONE_LOADER  
    112111 
    113112#include "mm.h" 
     
    177176/******************************************************************************/ 
    178177 
    179 #endif /* HAVE_EACCELERATOR_STANDALONE_LOADER */ 
    180178 
    181179#ifndef offsetof 
     
    259257} mm_fc_entry; 
    260258 
    261 #ifndef HAVE_EACCELERATOR_STANDALONE_LOADER 
    262259 
    263260/* 
     
    399396#  endif 
    400397 
    401 #ifdef WITH_EACCELERATOR_ENCODER 
    402 PHP_FUNCTION (eaccelerator_encode); 
    403 #endif 
    404 #endif /* HAVE_EACCELERATOR_STANDALONE_LOADER */ 
    405  
    406398#ifdef ZTS 
    407399#  define EAG(v) TSRMG(eaccelerator_globals_id, zend_eaccelerator_globals*, v) 
     
    419411        struct _mm_cond_entry *next; 
    420412} mm_cond_entry; 
    421  
    422 #ifdef WITH_EACCELERATOR_LOADER 
    423 zend_op_array *eaccelerator_load (char *src, int src_len TSRMLS_DC); 
    424 PHP_FUNCTION (eaccelerator_load); 
    425 PHP_FUNCTION (_eaccelerator_loader_file); 
    426 PHP_FUNCTION (_eaccelerator_loader_line); 
    427 #endif 
    428413 
    429414/* 
     
    437422zend_bool compression_enabled; 
    438423zend_bool compiler; 
    439 zend_bool encoder; 
    440424zend_bool compress; 
    441425zend_bool compress_content; 
     
    484468 
    485469#define EACCELERATOR_EXTENSION_NAME "eAccelerator" 
    486 #define EACCELERATOR_LOADER_EXTENSION_NAME "eLoader" 
    487470 
    488471#define EA_MAGIC "EACCELERATOR" 
    489  
    490 #define EA_ENCODER_VERSION   0x00000004 
    491 #define EA_ENCODER_END       0x00 
    492 #define EA_ENCODER_NAMESPACE 0x01 
    493 #define EA_ENCODER_CLASS     0x02 
    494 #define EA_ENCODER_FUNCTION  0x03 
    495472 
    496473#define EACCELERATOR_VERSION_GUID   "PHPE8EDA1B6-806A-4851-B1C8-A6B4712F44FB" 
  • eaccelerator/trunk/optimize.c

    r201 r246  
    14971497 
    14981498static int opt_get_constant(const char* name, int name_len, zend_constant** result TSRMLS_DC) { 
    1499   if (!EAG(encoder) || 
    1500       (name_len == sizeof("false")-1 && strcmp(name,"false") == 0) || 
    1501       (name_len == sizeof("true")-1 && strcmp(name,"true") == 0)) { 
    1502     union { 
    1503       zend_constant *v; 
    1504       void *ptr; 
    1505     } c; 
    1506     int retval; 
    1507     char *lookup_name = do_alloca(name_len+1); 
    1508     memcpy(lookup_name, name, name_len); 
    1509     lookup_name[name_len] = '\0'; 
     1499  union { 
     1500    zend_constant *v; 
     1501    void *ptr; 
     1502  } c; 
     1503  int retval; 
     1504  char *lookup_name = do_alloca(name_len+1); 
     1505  memcpy(lookup_name, name, name_len); 
     1506  lookup_name[name_len] = '\0'; 
     1507 
     1508  if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, &c.ptr)==SUCCESS) { 
     1509    *result = c.v; 
     1510    retval=1; 
     1511  } else { 
     1512    zend_str_tolower(lookup_name, name_len); 
    15101513 
    15111514    if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, &c.ptr)==SUCCESS) { 
    1512       *result = c.v; 
    1513       retval=1; 
     1515      if ((c.v->flags & CONST_CS) && (memcmp(c.v->name, name, name_len)!=0)) { 
     1516        retval=0; 
     1517      } else { 
     1518        *result = c.v; 
     1519        retval=1; 
     1520      } 
    15141521    } else { 
    1515       zend_str_tolower(lookup_name, name_len); 
    1516  
    1517       if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, &c.ptr)==SUCCESS) { 
    1518         if ((c.v->flags & CONST_CS) && (memcmp(c.v->name, name, name_len)!=0)) { 
    1519           retval=0; 
    1520         } else { 
    1521           *result = c.v; 
    1522           retval=1; 
    1523         } 
    1524       } else { 
    1525         retval=0; 
    1526       } 
    1527     } 
    1528     free_alloca(lookup_name); 
    1529     return retval; 
    1530   } else { 
    1531     return 0; 
    1532   } 
     1522      retval=0; 
     1523    } 
     1524  } 
     1525  free_alloca(lookup_name); 
     1526  return retval; 
    15331527} 
    15341528 
    15351529static int opt_function_exists(const char* name, int name_len TSRMLS_DC) { 
    1536   if (!EAG(encoder)) { 
    1537     char *lcname; 
    1538     char *lcfname; 
    1539     Bucket *p; 
    1540  
    1541     lcname = estrndup(name,name_len+1); 
    1542     zend_str_tolower(lcname, name_len); 
    1543     p = module_registry.pListHead; 
    1544     while (p != NULL) { 
    1545       zend_module_entry *m = (zend_module_entry*)p->pData; 
    1546       if (m->type == MODULE_PERSISTENT) { 
    1547         zend_function_entry* f = m->functions; 
    1548         if (f != NULL) { 
    1549           while (f->fname) { 
    1550             lcfname = estrdup(f->fname); 
    1551             zend_str_tolower(lcfname, strlen(lcfname)); 
    1552             if (strcmp(lcname,lcfname) == 0) { 
    1553               efree(lcfname); 
    1554               efree(lcname); 
    1555               return 1; 
    1556             } 
    1557             efree(lcfname); 
    1558             f++; 
    1559           } 
    1560         } 
    1561       } 
    1562       p = p->pListNext; 
    1563     } 
    1564     efree(lcname); 
    1565   } 
     1530  char *lcname; 
     1531  char *lcfname; 
     1532  Bucket *p; 
     1533 
     1534  lcname = estrndup(name,name_len+1); 
     1535  zend_str_tolower(lcname, name_len); 
     1536  p = module_registry.pListHead; 
     1537  while (p != NULL) { 
     1538    zend_module_entry *m = (zend_module_entry*)p->pData; 
     1539    if (m->type == MODULE_PERSISTENT) { 
     1540      zend_function_entry* f = m->functions; 
     1541      if (f != NULL) { 
     1542        while (f->fname) { 
     1543        lcfname = estrdup(f->fname); 
     1544        zend_str_tolower(lcfname, strlen(lcfname)); 
     1545        if (strcmp(lcname,lcfname) == 0) { 
     1546          efree(lcfname); 
     1547          efree(lcname); 
     1548          return 1; 
     1549        } 
     1550          efree(lcfname); 
     1551          f++; 
     1552        } 
     1553      } 
     1554    } 
     1555    p = p->pListNext; 
     1556  } 
     1557  efree(lcname); 
    15661558  return 0; 
    15671559} 
    15681560 
    15691561static int opt_extension_loaded(const char* name, int name_len TSRMLS_DC) { 
    1570   if (!EAG(encoder)) { 
    1571     Bucket *p = module_registry.pListHead; 
    1572     while (p != NULL) { 
    1573       zend_module_entry *m = (zend_module_entry*)p->pData; 
    1574       if (m->type == MODULE_PERSISTENT && strcmp(m->name,name) == 0) { 
    1575         return 1; 
    1576       } 
    1577       p = p->pListNext; 
    1578     } 
    1579   } 
    1580   return 0; 
     1562  Bucket *p = module_registry.pListHead; 
     1563  while (p != NULL) { 
     1564    zend_module_entry *m = (zend_module_entry*)p->pData; 
     1565    if (m->type == MODULE_PERSISTENT && strcmp(m->name,name) == 0) { 
     1566      return 1; 
     1567    } 
     1568    p = p->pListNext; 
     1569  } 
    15811570} 
    15821571 
Note: See TracChangeset for help on using the changeset viewer.