unsigned char *arg_types;
int original_op=op;
zend_function **function_ptr_ptr, *function_ptr;
+ int send_by_reference;
zend_stack_top(&CG(function_call_stack), (void **) &function_ptr_ptr);
arg_types = NULL;
}
- if (op==ZEND_SEND_VAL) {
- switch (param->op_type) {
- case IS_CONST: /* constants behave like variables when passed to functions,
- * as far as reference counting is concerned. Treat them
- * as if they were variables here.
- */
- break;
- case IS_VAR:
- op = ZEND_SEND_VAR_NO_REF;
- break;
- }
+ send_by_reference = ARG_SHOULD_BE_SENT_BY_REF(offset, 1, arg_types)?ZEND_ARG_SEND_BY_REF:0;
+
+ if (op == ZEND_SEND_VAL && param->op_type == IS_VAR) {
+ op = ZEND_SEND_VAR_NO_REF;
}
- if (op!=ZEND_SEND_VAR_NO_REF
- && ARG_SHOULD_BE_SENT_BY_REF(offset, 1, arg_types)) {
+
+ if (op!=ZEND_SEND_VAR_NO_REF && send_by_reference == ZEND_ARG_SEND_BY_REF) {
/* change to passing by reference */
switch (param->op_type) {
case IS_VAR:
}
}
- if (original_op==ZEND_SEND_VAR) {
+ if (original_op == ZEND_SEND_VAR) {
switch(op) {
case ZEND_SEND_VAR_NO_REF:
+ zend_do_end_variable_parse(BP_VAR_R, 0 CLS_CC);
+ break;
case ZEND_SEND_VAR:
if (function_ptr) {
zend_do_end_variable_parse(BP_VAR_R, 0 CLS_CC);
}
opline = get_next_op(CG(active_op_array) CLS_CC);
- if (function_ptr) {
- opline->extended_value = ZEND_DO_FCALL;
+
+ if (op == ZEND_SEND_VAR_NO_REF) {
+ if (function_ptr) {
+ opline->extended_value = ZEND_ARG_COMPILE_TIME_BOUND | send_by_reference;
+ } else {
+ opline->extended_value = 0;
+ }
} else {
- opline->extended_value = ZEND_DO_FCALL_BY_NAME;
+ if (function_ptr) {
+ opline->extended_value = ZEND_DO_FCALL;
+ } else {
+ opline->extended_value = ZEND_DO_FCALL_BY_NAME;
+ }
}
opline->opcode = op;
opline->op1 = *param;
zend_ptr_stack_push(&EG(argument_stack), valptr);
}
NEXT_OPCODE();
- case ZEND_SEND_VAR:
case ZEND_SEND_VAR_NO_REF:
- if (opline->extended_value==ZEND_DO_FCALL_BY_NAME
- && ARG_SHOULD_BE_SENT_BY_REF(opline->op2.u.opline_num, fbc, fbc->common.arg_types)) {
- if (opline->opcode==ZEND_SEND_VAR_NO_REF) {
- zend_error(E_ERROR, "Only variables can be passed by reference");
+ if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */
+ if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) {
+ goto send_by_var;
}
- goto send_by_ref;
+ } else if (!ARG_SHOULD_BE_SENT_BY_REF(opline->op2.u.opline_num, fbc, fbc->common.arg_types)) {
+ goto send_by_var;
}
{
zval *varptr;
varptr = get_zval_ptr(&opline->op1, Ts, &EG(free_op1), BP_VAR_R);
- if (varptr == &EG(uninitialized_zval)) {
- ALLOC_ZVAL(varptr);
- INIT_ZVAL(*varptr);
- varptr->refcount = 0;
- } else if (PZVAL_IS_REF(varptr)) {
- zval *original_var = varptr;
-
- ALLOC_ZVAL(varptr);
- *varptr = *original_var;
- varptr->is_ref = 0;
- varptr->refcount = 0;
- zval_copy_ctor(varptr);
+ if (varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) {
+ varptr->is_ref = 1;
+ varptr->refcount++;
+ zend_ptr_stack_push(&EG(argument_stack), varptr);
+ NEXT_OPCODE();
}
- varptr->refcount++;
- zend_ptr_stack_push(&EG(argument_stack), varptr);
- FREE_OP(&opline->op1, EG(free_op1)); /* for string offsets */
+ zend_error(E_ERROR, "Only variables can be passed by reference");
}
NEXT_OPCODE();
+ case ZEND_SEND_VAR:
+ if ((opline->extended_value == ZEND_DO_FCALL_BY_NAME)
+ && ARG_SHOULD_BE_SENT_BY_REF(opline->op2.u.opline_num, fbc, fbc->common.arg_types)) {
+ goto send_by_ref;
+ }
+send_by_var:
+ {
+ zval *varptr;
+ varptr = get_zval_ptr(&opline->op1, Ts, &EG(free_op1), BP_VAR_R);
+
+ if (varptr == &EG(uninitialized_zval)) {
+ ALLOC_ZVAL(varptr);
+ INIT_ZVAL(*varptr);
+ varptr->refcount = 0;
+ } else if (PZVAL_IS_REF(varptr)) {
+ zval *original_var = varptr;
+
+ ALLOC_ZVAL(varptr);
+ *varptr = *original_var;
+ varptr->is_ref = 0;
+ varptr->refcount = 0;
+ zval_copy_ctor(varptr);
+ }
+ varptr->refcount++;
+ zend_ptr_stack_push(&EG(argument_stack), varptr);
+ FREE_OP(&opline->op1, EG(free_op1)); /* for string offsets */
+ }
+ NEXT_OPCODE();
send_by_ref:
case ZEND_SEND_REF: {
zval **varptr_ptr;