PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - lcov_data/ext/opcache/Optimizer - optimize_func_calls.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 42 74 56.8 %
Date: 2014-07-21 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* pass 4
       2             :  * - optimize INIT_FCALL_BY_NAME to DO_FCALL
       3             :  */
       4             : #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
       5             : 
       6             : typedef struct _optimizer_call_info {
       7             :         zend_function *func;
       8             :         zend_op       *opline;
       9             : } optimizer_call_info;
      10             : 
      11         451 : static void optimize_func_calls(zend_op_array *op_array, zend_persistent_script *script TSRMLS_DC) {
      12         451 :         zend_op *opline = op_array->opcodes;
      13         451 :         zend_op *end = opline + op_array->last;
      14         451 :         int call = 0;
      15             : #if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO
      16         451 :         optimizer_call_info *call_stack = ecalloc(op_array->nested_calls + 1, sizeof(optimizer_call_info));
      17             : #else
      18             :         int stack_size = 4;
      19             :         optimizer_call_info *call_stack = ecalloc(stack_size, sizeof(optimizer_call_info));
      20             : #endif
      21             : 
      22        7766 :         while (opline < end) {
      23        6864 :                 switch (opline->opcode) {
      24             :                         case ZEND_INIT_FCALL_BY_NAME:
      25             :                         case ZEND_INIT_NS_FCALL_BY_NAME:
      26          18 :                                 if (ZEND_OP2_TYPE(opline) == IS_CONST) {
      27             :                                         zend_function *func;
      28          18 :                                         zval *function_name = &op_array->literals[opline->op2.constant + 1].constant;
      29          72 :                                         if ((zend_hash_quick_find(&script->function_table,
      30          36 :                                                         Z_STRVAL_P(function_name), Z_STRLEN_P(function_name) + 1,
      31          18 :                                                         Z_HASH_P(function_name), (void **)&func) == SUCCESS)) {
      32           0 :                                                 call_stack[call].func = func;
      33             :                                         }
      34             :                                 }
      35             :                                 /* break missing intentionally */
      36             :                         case ZEND_NEW:
      37             :                         case ZEND_INIT_METHOD_CALL:
      38             :                         case ZEND_INIT_STATIC_METHOD_CALL:
      39         163 :                                 call_stack[call].opline = opline;
      40         163 :                                 call++;
      41             : #if ZEND_EXTENSION_API_NO < PHP_5_5_X_API_NO
      42             :                                 if (call == stack_size) {
      43             :                                         stack_size += 4;
      44             :                                         call_stack = erealloc(call_stack, sizeof(optimizer_call_info) * stack_size);
      45             :                                         memset(call_stack + 4, 0, 4 * sizeof(optimizer_call_info));
      46             :                                 }
      47             : #endif
      48         163 :                                 break;
      49             :                         case ZEND_DO_FCALL_BY_NAME:
      50         163 :                                 call--;
      51         163 :                                 if (call_stack[call].func && call_stack[call].opline) {
      52           0 :                                         zend_op *fcall = call_stack[call].opline;
      53             : 
      54           0 :                                         opline->opcode = ZEND_DO_FCALL;
      55           0 :                                         ZEND_OP1_TYPE(opline) = IS_CONST;
      56           0 :                                         opline->op1.constant = fcall->op2.constant + 1;
      57           0 :                                         op_array->literals[fcall->op2.constant + 1].cache_slot = op_array->literals[fcall->op2.constant].cache_slot;
      58           0 :                                         literal_dtor(&ZEND_OP2_LITERAL(fcall));
      59           0 :                                         if (fcall->opcode == ZEND_INIT_NS_FCALL_BY_NAME) {
      60           0 :                                                 literal_dtor(&op_array->literals[fcall->op2.constant + 2].constant);
      61             :                                         }
      62           0 :                                         MAKE_NOP(fcall);
      63         284 :                                 } else if (opline->extended_value == 0 &&
      64          59 :                                            call_stack[call].opline &&
      65          59 :                                            call_stack[call].opline->opcode == ZEND_INIT_FCALL_BY_NAME &&
      66           3 :                                            ZEND_OP2_TYPE(call_stack[call].opline) == IS_CONST) {
      67             : 
      68           3 :                                         zend_op *fcall = call_stack[call].opline;
      69             : 
      70           3 :                                         opline->opcode = ZEND_DO_FCALL;
      71           3 :                                         ZEND_OP1_TYPE(opline) = IS_CONST;
      72           3 :                                         opline->op1.constant = fcall->op2.constant + 1;
      73           3 :                                         op_array->literals[fcall->op2.constant + 1].cache_slot = op_array->literals[fcall->op2.constant].cache_slot;
      74           6 :                                         literal_dtor(&ZEND_OP2_LITERAL(fcall));
      75           3 :                                         MAKE_NOP(fcall);
      76             :                                 }
      77         163 :                                 call_stack[call].func = NULL;
      78         163 :                                 call_stack[call].opline = NULL;
      79         163 :                                 break;
      80             :                         case ZEND_FETCH_FUNC_ARG:
      81             :                         case ZEND_FETCH_OBJ_FUNC_ARG:
      82             :                         case ZEND_FETCH_DIM_FUNC_ARG:
      83           0 :                                 if (call_stack[call - 1].func) {
      84           0 :                                         if (ARG_SHOULD_BE_SENT_BY_REF(call_stack[call - 1].func, (opline->extended_value & ZEND_FETCH_ARG_MASK))) {
      85           0 :                                                 opline->extended_value = 0;
      86           0 :                                                 opline->opcode -= 9;
      87             :                                         } else {
      88           0 :                                                 opline->extended_value = 0;
      89           0 :                                                 opline->opcode -= 12;
      90             :                                         }
      91             :                                 }
      92           0 :                                 break;
      93             :                         case ZEND_SEND_VAL:
      94         830 :                                 if (opline->extended_value == ZEND_DO_FCALL_BY_NAME && call_stack[call - 1].func) {
      95           0 :                                         if (ARG_MUST_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) {
      96             :                                                 /* We won't convert it into_DO_FCALL to emit error at run-time */
      97           0 :                                                 call_stack[call - 1].opline = NULL;
      98             :                                         } else {
      99           0 :                                                 opline->extended_value = ZEND_DO_FCALL;
     100             :                                         }
     101             :                                 }
     102         830 :                                 break;
     103             :                         case ZEND_SEND_VAR:
     104         517 :                                 if (opline->extended_value == ZEND_DO_FCALL_BY_NAME && call_stack[call - 1].func) {
     105           0 :                                         if (ARG_SHOULD_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) {
     106           0 :                                                 opline->opcode = ZEND_SEND_REF;
     107             :                                         }
     108           0 :                                         opline->extended_value = ZEND_DO_FCALL;
     109             :                                 }
     110         517 :                                 break;
     111             :                         case ZEND_SEND_VAR_NO_REF:
     112         136 :                                 if (!(opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) && call_stack[call - 1].func) {
     113           0 :                                         if (ARG_SHOULD_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) {
     114           0 :                                                 opline->extended_value |= ZEND_ARG_COMPILE_TIME_BOUND | ZEND_ARG_SEND_BY_REF;
     115           0 :                                         } else if (opline->extended_value) {
     116           0 :                                                 opline->extended_value |= ZEND_ARG_COMPILE_TIME_BOUND;
     117             :                                         } else {
     118           0 :                                                 opline->opcode = ZEND_SEND_VAR;
     119           0 :                                                 opline->extended_value = ZEND_DO_FCALL;
     120             :                                         }
     121             :                                 }
     122         136 :                                 break;
     123             :                         case ZEND_SEND_REF:
     124           7 :                                 if (opline->extended_value == ZEND_DO_FCALL_BY_NAME && call_stack[call - 1].func) {
     125             :                                         /* We won't handle run-time pass by reference */
     126           0 :                                         call_stack[call - 1].opline = NULL;
     127             :                                 }
     128           7 :                                 break;
     129             : #if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
     130             :                         case ZEND_SEND_UNPACK:
     131           0 :                                 call_stack[call - 1].func = NULL;
     132           0 :                                 call_stack[call - 1].opline = NULL;
     133             :                                 break;
     134             : #endif
     135             :                         default:
     136             :                                 break;
     137             :                 }
     138        6864 :                 opline++;
     139             :         }
     140             : 
     141         451 :         efree(call_stack);
     142         451 : }
     143             : #endif

Generated by: LCOV version 1.10

Generated at Tue, 22 Jul 2014 01:33:24 +0000 (7 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.