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: 0 74 0.0 %
Date: 2014-04-16 Functions: 0 1 0.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           0 : static void optimize_func_calls(zend_op_array *op_array, zend_persistent_script *script TSRMLS_DC) {
      12           0 :         zend_op *opline = op_array->opcodes;
      13           0 :         zend_op *end = opline + op_array->last;
      14           0 :         int call = 0;
      15             : #if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO
      16           0 :         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           0 :         while (opline < end) {
      23           0 :                 switch (opline->opcode) {
      24             :                         case ZEND_INIT_FCALL_BY_NAME:
      25             :                         case ZEND_INIT_NS_FCALL_BY_NAME:
      26           0 :                                 if (ZEND_OP2_TYPE(opline) == IS_CONST) {
      27             :                                         zend_function *func;
      28           0 :                                         zval *function_name = &op_array->literals[opline->op2.constant + 1].constant;
      29           0 :                                         if ((zend_hash_quick_find(&script->function_table,
      30           0 :                                                         Z_STRVAL_P(function_name), Z_STRLEN_P(function_name) + 1,
      31           0 :                                                         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           0 :                                 call_stack[call].opline = opline;
      40           0 :                                 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           0 :                                 break;
      49             :                         case ZEND_DO_FCALL_BY_NAME:
      50           0 :                                 call--;
      51           0 :                                 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           0 :                                 } else if (opline->extended_value == 0 &&
      64           0 :                                            call_stack[call].opline &&
      65           0 :                                            call_stack[call].opline->opcode == ZEND_INIT_FCALL_BY_NAME &&
      66           0 :                                            ZEND_OP2_TYPE(call_stack[call].opline) == IS_CONST) {
      67             : 
      68           0 :                                         zend_op *fcall = call_stack[call].opline;
      69             : 
      70           0 :                                         opline->opcode = ZEND_DO_FCALL;
      71           0 :                                         ZEND_OP1_TYPE(opline) = IS_CONST;
      72           0 :                                         opline->op1.constant = fcall->op2.constant + 1;
      73           0 :                                         op_array->literals[fcall->op2.constant + 1].cache_slot = op_array->literals[fcall->op2.constant].cache_slot;
      74           0 :                                         literal_dtor(&ZEND_OP2_LITERAL(fcall));
      75           0 :                                         MAKE_NOP(fcall);
      76             :                                 }
      77           0 :                                 call_stack[call].func = NULL;
      78           0 :                                 call_stack[call].opline = NULL;
      79           0 :                                 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           0 :                                 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           0 :                                 break;
     103             :                         case ZEND_SEND_VAR:
     104           0 :                                 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           0 :                                 break;
     111             :                         case ZEND_SEND_VAR_NO_REF:
     112           0 :                                 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           0 :                                 break;
     123             :                         case ZEND_SEND_REF:
     124           0 :                                 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           0 :                                 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           0 :                 opline++;
     139             :         }
     140             : 
     141           0 :         efree(call_stack);
     142           0 : }
     143             : #endif

Generated by: LCOV version 1.10

Generated at Wed, 16 Apr 2014 12:48:02 +0000 (2 days ago)

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