Changeset 256

Show
Ignore:
Timestamp:
07/29/06 14:28:19 (2 years ago)
Author:
bart
Message:

Remove some leftovers from restoring encoded scripts which only create

overhead without the loader.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • eaccelerator/trunk/ChangeLog

    r255 r256  
    77        * Move some functions around to make more of them static, this reduces 
    88          the binary size and load times. 
    9  
     9                * Remove some leftovers from restoring encoded scripts which only create 
     10                  overhead without the loader. 
     11                   
    10122006-07-29  Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 
    1113 
  • eaccelerator/trunk/eaccelerator.c

    r255 r256  
    44   +----------------------------------------------------------------------+ 
    55   | Copyright (c) 2004 - 2006 eAccelerator                               | 
    6    | http://eaccelerator.net                                                                                                           
     6   | http://eaccelerator.net                                                                                     
    77   +----------------------------------------------------------------------+ 
    88   | This program is free software; you can redistribute it and/or        | 
     
    920920#ifndef ZEND_WIN32 
    921921  if (file_handle->type == ZEND_HANDLE_FP && file_handle->handle.fp != NULL) { 
    922     if (fstat(fileno(file_handle->handle.fp), buf) == 0 && 
    923        S_ISREG(buf->st_mode)) { 
     922    if (fstat(fileno(file_handle->handle.fp), buf) == 0 && S_ISREG(buf->st_mode)) { 
    924923      if (file_handle->opened_path != NULL) { 
    925         strcpy(realname,file_handle->opened_path); 
     924        strcpy(realname, file_handle->opened_path); 
    926925      } 
    927926      return 0; 
     
    930929#endif 
    931930  if (file_handle->opened_path != NULL) { 
    932     if (stat(file_handle->opened_path, buf) == 0 && 
    933         S_ISREG(buf->st_mode)) { 
     931    if (stat(file_handle->opened_path, buf) == 0 && S_ISREG(buf->st_mode)) { 
    934932       strcpy(realname,file_handle->opened_path); 
    935933       return 0; 
    936934    } 
    937   } else if (PG(include_path) == NULL || 
    938             file_handle->filename[0] == '.' || 
     935  } else if (PG(include_path) == NULL ||  
     936                        file_handle->filename[0] == '.' || 
    939937             IS_SLASH(file_handle->filename[0]) || 
    940938             IS_ABSOLUTE_PATH(file_handle->filename,strlen(file_handle->filename))) { 
    941     if (stat(file_handle->filename, buf) == 0 && 
    942         S_ISREG(buf->st_mode)) { 
     939    if (stat(file_handle->filename, buf) == 0 && S_ISREG(buf->st_mode)) { 
    943940       return 0; 
    944941    } 
     
    953950      end = strchr(ptr, DEFAULT_DIR_SEPARATOR); 
    954951      if (end != NULL) { 
    955         len = end-ptr; 
     952        len = end - ptr; 
    956953        end++; 
    957954      } else { 
    958955        len = strlen(ptr); 
    959         end = ptr+len; 
    960       } 
    961       if (len+filename_len+2 < MAXPATHLEN) { 
     956        end = ptr + len; 
     957      } 
     958      if (len + filename_len + 2 < MAXPATHLEN) { 
    962959        memcpy(tryname, ptr, len); 
    963960        tryname[len] = '/'; 
    964         memcpy(tryname+len+1, file_handle->filename, filename_len); 
    965         tryname[len+filename_len+1] = '\0'; 
    966         if (stat(tryname, buf) == 0 && 
    967             S_ISREG(buf->st_mode)) { 
     961        memcpy(tryname + len + 1, file_handle->filename, filename_len); 
     962        tryname[len + filename_len + 1] = '\0'; 
     963        if (stat(tryname, buf) == 0 && S_ISREG(buf->st_mode)) { 
    968964          return 0; 
    969965        } 
     
    978974                tryname_length = strlen(tryname); 
    979975 
    980                 while (tryname_length >= 0 && !IS_SLASH(tryname[tryname_length])) 
     976                while (tryname_length >= 0 && !IS_SLASH(tryname[tryname_length])) { 
    981977                        tryname_length--; 
     978                } 
    982979                if (tryname_length > 0 && tryname[0] != '[' // [no active file] 
    983980                        && tryname_length + filename_len + 1 < MAXPATHLEN) 
    984981                { 
    985982                        strncpy(tryname + tryname_length + 1, file_handle->filename, filename_len + 1); 
    986                         if (stat(tryname, buf) == 0 && S_ISREG(buf->st_mode)) 
     983                        if (stat(tryname, buf) == 0 && S_ISREG(buf->st_mode)) { 
    987984                                return 0; 
     985                        } 
    988986                } 
    989987        } 
     
    997995      if (!eaccelerator_check_mtime) { 
    998996        return 0; 
    999       } else if (fstat(fileno(file_handle->handle.fp), buf) == 0 && 
    1000                  S_ISREG(buf->st_mode)) { 
     997      } else if (fstat(fileno(file_handle->handle.fp), buf) == 0 && S_ISREG(buf->st_mode)) { 
    1001998        return 0; 
    1002999      } else { 
     
    10061003      if (!eaccelerator_check_mtime) { 
    10071004        return 0; 
    1008       } else if (stat(realname, buf) == 0 && 
    1009                  S_ISREG(buf->st_mode)) { 
     1005      } else if (stat(realname, buf) == 0 && S_ISREG(buf->st_mode)) { 
    10101006        return 0; 
    10111007      } else { 
     
    10161012    if (!eaccelerator_check_mtime) { 
    10171013      return 0; 
    1018     } else if (stat(realname, buf) == 0 && 
    1019                S_ISREG(buf->st_mode)) { 
     1014    } else if (stat(realname, buf) == 0 && S_ISREG(buf->st_mode)) { 
    10201015      return 0; 
    10211016    } else { 
     
    10251020  } else if (file_handle->filename == NULL) { 
    10261021    return -1; 
    1027   } else if (PG(include_path) == NULL || 
     1022  } else if (PG(include_path) == NULL ||  
    10281023             file_handle->filename[0] == '.' || 
    10291024             IS_SLASH(file_handle->filename[0]) || 
     
    10321027      if (!eaccelerator_check_mtime) { 
    10331028        return 0; 
    1034       } else if (stat(realname, buf) == 0 && 
    1035                  S_ISREG(buf->st_mode)) { 
     1029      } else if (stat(realname, buf) == 0 && S_ISREG(buf->st_mode)) { 
    10361030        return 0; 
    10371031      } else { 
     
    10491043      end = strchr(ptr, DEFAULT_DIR_SEPARATOR); 
    10501044      if (end != NULL) { 
    1051         len = end-ptr; 
     1045        len = end - ptr; 
    10521046        end++; 
    10531047      } else { 
    10541048        len = strlen(ptr); 
    1055         end = ptr+len; 
     1049        end = ptr + len; 
    10561050      } 
    10571051      if (len+filename_len+2 < MAXPATHLEN) { 
    10581052        memcpy(tryname, ptr, len); 
    10591053        tryname[len] = '/'; 
    1060         memcpy(tryname+len+1, file_handle->filename, filename_len); 
    1061         tryname[len+filename_len+1] = '\0'; 
     1054        memcpy(tryname + len + 1, file_handle->filename, filename_len); 
     1055        tryname[len + filename_len + 1] = '\0'; 
    10621056        if (VCWD_REALPATH(tryname, realname)) { 
    10631057#ifdef ZEND_WIN32 
    1064           if (stat(realname, buf) == 0 && 
    1065               S_ISREG(buf->st_mode)) { 
     1058          if (stat(realname, buf) == 0 && S_ISREG(buf->st_mode)) { 
    10661059            return 0; 
    10671060          } 
     
    10691062          if (!eaccelerator_check_mtime) { 
    10701063            return 0; 
    1071           } else if (stat(realname, buf) == 0 && 
    1072                      S_ISREG(buf->st_mode)) { 
     1064          } else if (stat(realname, buf) == 0 && S_ISREG(buf->st_mode)) { 
    10731065            return 0; 
    10741066          } else { 
     
    11071099  realname[0] = '\000'; 
    11081100#endif 
     1101 
    11091102  DBG(ea_debug_start_time, (&tv_start)); 
    11101103  DBG(ea_debug_printf, (EA_DEBUG, "[%d] Enter COMPILE\n",getpid())); 
     
    11951188    int ea_bailout; 
    11961189 
    1197     DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: marking\n", getpid())); 
     1190#ifdef DEBUG 
     1191    ea_debug_printf(EA_DEBUG, "\t[%d] compile_file: marking\n", getpid()); 
    11981192    if (CG(class_table) != EG(class_table)) { 
    1199       DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] oops, CG(class_table)[%08x] != EG(class_table)[%08x]\n",  
    1200                                                 getpid(), CG(class_table), EG(class_table))); 
    1201       DBG(ea_debug_log_hashkeys, ("CG(class_table)\n", CG(class_table))); 
    1202       DBG(ea_debug_log_hashkeys, ("EG(class_table)\n", EG(class_table))); 
     1193      ea_debug_printf(EA_DEBUG, "\t[%d] oops, CG(class_table)[%08x] != EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table)); 
     1194      ea_debug_log_hashkeys("CG(class_table)\n", CG(class_table)); 
     1195      ea_debug_log_hashkeys("EG(class_table)\n", EG(class_table)); 
    12031196    } else { 
    1204       DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] OKAY. That what I thought, CG(class_table)[%08x] == EG(class_table)[%08x]\n",  
    1205                                                 getpid(), CG(class_table), EG(class_table))); 
    1206       DBG(ea_debug_log_hashkeys, ("CG(class_table)\n", CG(class_table))); 
    1207     } 
    1208  
    1209     zend_hash_init_ex(&tmp_function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0); 
    1210     zend_hash_copy(&tmp_function_table, &eaccelerator_global_function_table, NULL, &tmp_func, sizeof(zend_function)); 
    1211     orig_function_table = CG(function_table); 
    1212     CG(function_table) = &tmp_function_table; 
    1213  
    1214     zend_hash_init_ex(&tmp_class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0); 
    1215     zend_hash_copy(&tmp_class_table, &eaccelerator_global_class_table, NULL, &tmp_class, sizeof(zend_class_entry)); 
    1216  
    1217     orig_class_table = CG(class_table);; 
    1218     CG(class_table) = &tmp_class_table; 
    1219 #ifdef ZEND_ENGINE_2 
    1220     orig_eg_class_table = EG(class_table);; 
    1221     EG(class_table) = &tmp_class_table; 
     1197      ea_debug_printf(EA_DEBUG, "\t[%d] OKAY. That what I thought, CG(class_table)[%08x] == EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table)); 
     1198      ea_debug_log_hashkeys("CG(class_table)\n", CG(class_table)); 
     1199    } 
    12221200#endif 
    12231201 
     
    12261204    class_table_tail = CG(class_table)->pListTail; 
    12271205 
    1228     DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: compiling (%ld)\n",getpid(),ea_debug_elapsed_time(&tv_start))); 
    1229     DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: compiling tmp_class_table=%d class_table=%d\n",  
    1230           getpid(), tmp_class_table.nNumOfElements, orig_class_table->nNumOfElements)); 
     1206    DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: compiling (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start))); 
     1207     
    12311208    if (EAG(optimizer_enabled) && eaccelerator_mm_instance->optimizer_enabled) { 
    12321209      EAG(compiler) = 1; 
    12331210    } 
    12341211 
     1212        /* try to compile the script */ 
    12351213    ea_bailout = 0; 
    12361214    zend_try { 
    12371215      t = mm_saved_zend_compile_file(file_handle, type TSRMLS_CC); 
    12381216    } zend_catch { 
    1239       CG(function_table) = orig_function_table; 
    1240       CG(class_table) = orig_class_table; 
    1241 #ifdef ZEND_ENGINE_2 
    1242       EG(class_table) = orig_eg_class_table; 
    1243 #endif 
    12441217      ea_bailout = 1; 
    12451218    } zend_end_try(); 
     
    12491222    DBG(ea_debug_log_hashkeys, ("class_table\n", CG(class_table))); 
    12501223 
    1251 /*??? 
    1252     if (file_handle->opened_path == NULL && t != NULL) { 
    1253       file_handle->opened_path = t->filename; 
    1254     } 
    1255 */ 
    12561224    EAG(compiler) = 0; 
    12571225    if (t != NULL && file_handle->opened_path != NULL && (eaccelerator_check_mtime || 
     
    12591227      DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: storing in cache (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start))); 
    12601228      DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: storing in cache\n", getpid())); 
    1261       function_table_tail = function_table_tail?function_table_tail->pListNext:CG(function_table)->pListHead; 
    1262       class_table_tail = class_table_tail?class_table_tail->pListNext:CG(class_table)->pListHead; 
     1229      function_table_tail = function_table_tail ? function_table_tail->pListNext : CG(function_table)->pListHead; 
     1230      class_table_tail = class_table_tail ? class_table_tail->pListNext : CG(class_table)->pListHead; 
    12631231      if (eaccelerator_store(file_handle->opened_path, &buf, nreloads, t, function_table_tail, class_table_tail TSRMLS_CC)) { 
    12641232#ifdef DEBUG 
     
    12751243      } 
    12761244    } else { 
    1277       function_table_tail = function_table_tail?function_table_tail->pListNext:CG(function_table)->pListHead; 
    1278       class_table_tail = class_table_tail?class_table_tail->pListNext:CG(class_table)->pListHead; 
    1279     } 
    1280     CG(function_table) = orig_function_table; 
    1281     CG(class_table) = orig_class_table; 
    1282 #ifdef ZEND_ENGINE_2 
    1283     EG(class_table) = orig_eg_class_table; 
    1284     DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] restoring CG(class_table)[%08x] != EG(class_table)[%08x]\n",  
    1285                 getpid(), CG(class_table), EG(class_table))); 
    1286 #endif 
    1287     while (function_table_tail != NULL) { 
    1288       zend_op_array *op_array = (zend_op_array*)function_table_tail->pData; 
    1289       if (op_array->type == ZEND_USER_FUNCTION) { 
    1290         if (zend_hash_add(CG(function_table), function_table_tail->arKey, function_table_tail->nKeyLength, op_array,  
    1291                     sizeof(zend_op_array), NULL) == FAILURE && function_table_tail->arKey[0] != '\000') { 
    1292           CG(in_compilation) = 1; 
    1293           CG(compiled_filename) = file_handle->opened_path; 
    1294 #ifdef ZEND_ENGINE_2 
    1295           CG(zend_lineno) = op_array->line_start; 
    1296 #else 
    1297           CG(zend_lineno) = op_array->opcodes[0].lineno; 
    1298 #endif 
    1299           zend_error(E_ERROR, "Cannot redeclare %s()", function_table_tail->arKey); 
    1300         } 
    1301       } 
    1302       function_table_tail = function_table_tail->pListNext; 
    1303     } 
    1304     while (class_table_tail != NULL) { 
    1305 #ifdef ZEND_ENGINE_2 
    1306       zend_class_entry **ce = (zend_class_entry**)class_table_tail->pData; 
    1307       if ((*ce)->type == ZEND_USER_CLASS) { 
    1308         if (zend_hash_add(CG(class_table), class_table_tail->arKey, class_table_tail->nKeyLength,  
    1309                     ce, sizeof(zend_class_entry*), NULL) == FAILURE && class_table_tail->arKey[0] != '\000') { 
    1310           CG(in_compilation) = 1; 
    1311           CG(compiled_filename) = file_handle->opened_path; 
    1312           CG(zend_lineno) = (*ce)->line_start; 
    1313 #else 
    1314       zend_class_entry *ce = (zend_class_entry*)class_table_tail->pData; 
    1315       if (ce->type == ZEND_USER_CLASS) { 
    1316         if (ce->parent != NULL) { 
    1317           if (zend_hash_find(CG(class_table), (void*)ce->parent->name, ce->parent->name_length+1, (void **)&ce->parent) != SUCCESS) { 
    1318             ce->parent = NULL; 
    1319           } 
    1320         } 
    1321         if (zend_hash_add(CG(class_table), class_table_tail->arKey, class_table_tail->nKeyLength, ce,  
    1322                     sizeof(zend_class_entry), NULL) == FAILURE && class_table_tail->arKey[0] != '\000') { 
    1323           CG(in_compilation) = 1; 
    1324           CG(compiled_filename) = file_handle->opened_path; 
    1325           CG(zend_lineno) = 0; 
    1326 #endif 
    1327           zend_error(E_ERROR, "Cannot redeclare class %s", class_table_tail->arKey); 
    1328         } 
    1329       } 
    1330       class_table_tail = class_table_tail->pListNext; 
    1331     } 
    1332     tmp_function_table.pDestructor = NULL; 
    1333     tmp_class_table.pDestructor = NULL; 
    1334     zend_hash_destroy(&tmp_function_table); 
    1335     zend_hash_destroy(&tmp_class_table); 
     1245      function_table_tail = function_table_tail ? function_table_tail->pListNext : CG(function_table)->pListHead; 
     1246      class_table_tail = class_table_tail ? class_table_tail->pListNext : CG(class_table)->pListHead; 
     1247    } 
    13361248  } 
    13371249  DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: end (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start)));