Changeset 214 in svn


Ignore:
Timestamp:
2006-10-05T02:37:39+02:00 (9 years ago)
Author:
Xuefer
Message:

cacher: fixed #41, don't early bind class that implement interface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils.c

    r213 r214  
    319319}
    320320/* }}} */
    321 int xc_do_early_binding(zend_op_array *op_array, HashTable *class_table, int oplineno TSRMLS_DC) /* {{{ */
     321static int xc_do_early_binding(zend_op_array *op_array, HashTable *class_table, int oplineno TSRMLS_DC) /* {{{ */
    322322{
    323323    zend_op *opline, *opcodes;
     
    337337            zval *parent_name;
    338338            zend_class_entry **pce;
     339
     340            /* don't early-bind classes that implement interfaces */
     341            if ((opline + 1)->opcode == ZEND_FETCH_CLASS && (opline + 2)->opcode == ZEND_ADD_INTERFACE) {
     342                return FAILURE;
     343            }
     344
    339345            parent_name = &(opline - 1)->op2.u.constant;
    340 #ifdef DEBUG
     346#   ifdef DEBUG
    341347            fprintf(stderr, "binding with parent %s\n", Z_STRVAL_P(parent_name));
    342 #endif
     348#   endif
    343349            if (zend_lookup_class(Z_STRVAL_P(parent_name), Z_STRLEN_P(parent_name), &pce TSRMLS_CC) == FAILURE) {
    344350                return FAILURE;
     
    349355            }
    350356        }
    351 #else
    352         if (do_bind_function_or_class(opline, NULL, class_table, 1) == FAILURE) {
    353             return FAILURE;
    354         }
    355 #endif
    356 
    357 #ifdef ZEND_FETCH_CLASS
     357
    358358        /* clear unnecessary ZEND_FETCH_CLASS opcode */
    359359        if (opline > op_array->opcodes
     
    361361            zend_op *fetch_class_opline = opline - 1;
    362362
    363 #ifdef DEBUG
     363#   ifdef DEBUG
    364364            fprintf(stderr, "%s %p\n", Z_STRVAL(fetch_class_opline->op2.u.constant), Z_STRVAL(fetch_class_opline->op2.u.constant));
    365 #endif
     365#   endif
    366366            OP_ZVAL_DTOR(fetch_class_opline->op2);
    367367            fetch_class_opline->opcode = ZEND_NOP;
     
    372372            SET_UNUSED(fetch_class_opline->op2);
    373373            SET_UNUSED(fetch_class_opline->result);
     374        }
     375
     376        /* clear unnecessary ZEND_VERIFY_ABSTRACT_CLASS opcode */
     377        if ((opline + 1)->opcode == ZEND_VERIFY_ABSTRACT_CLASS) {
     378            zend_op *abstract_op = opline + 1;
     379            memset(abstract_op, 0, sizeof(abstract_op[0]));
     380            abstract_op->lineno = 0;
     381            SET_UNUSED(abstract_op->op1);
     382            SET_UNUSED(abstract_op->op2);
     383            SET_UNUSED(abstract_op->result);
     384            abstract_op->opcode = ZEND_NOP;
     385            ZEND_VM_SET_OPCODE_HANDLER(abstract_op);
     386        }
     387#else
     388        if (do_bind_function_or_class(opline, NULL, class_table, 1) == FAILURE) {
     389            return FAILURE;
    374390        }
    375391#endif
Note: See TracChangeset for help on using the changeset viewer.