Browse Source

Fix opcache support

pull/1392/head
Bob Weinand 11 years ago
parent
commit
6538269bfa
  1. 5
      Zend/zend_opcode.c
  2. 22
      ext/opcache/Optimizer/zend_optimizer.c
  3. 2
      ext/opcache/zend_file_cache.c
  4. 4
      ext/opcache/zend_persist.c
  5. 4
      ext/opcache/zend_persist_calc.c

5
Zend/zend_opcode.c

@ -65,6 +65,7 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz
op_array->vars = NULL;
op_array->T = 0;
op_array->T_liveliness = NULL;
op_array->function_name = NULL;
op_array->filename = zend_get_compiled_filename();
@ -389,9 +390,11 @@ ZEND_API void destroy_op_array(zend_op_array *op_array)
if (op_array->try_catch_array) {
efree(op_array->try_catch_array);
}
if (op_array->T_liveliness) {
efree(op_array->T_liveliness);
}
if (op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO) {
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_dtor_handler, op_array);
efree(op_array->T_liveliness);
}
if (op_array->arg_info) {
int32_t num_args = op_array->num_args;

22
ext/opcache/Optimizer/zend_optimizer.c

@ -529,6 +529,21 @@ static void zend_accel_optimize(zend_op_array *op_array,
/* Do actual optimizations */
zend_optimize(op_array, ctx);
opline = op_array->opcodes;
end = opline + op_array->last;
while (opline < end) {
if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
opline->op1.var = EX_VAR_TO_NUM(opline->op1.var) - op_array->last_var;
}
if (opline->op2_type & (IS_VAR|IS_TMP_VAR)) {
opline->op2.var = EX_VAR_TO_NUM(opline->op2.var) - op_array->last_var;
}
if (opline->result_type & (IS_VAR|IS_TMP_VAR)) {
opline->result.var = EX_VAR_TO_NUM(opline->result.var) - op_array->last_var;
}
opline++;
}
op_array->T_liveliness = generate_var_liveliness_info(op_array);
/* Redo pass_two() */
@ -537,9 +552,16 @@ static void zend_accel_optimize(zend_op_array *op_array,
while (opline < end) {
if (opline->op1_type == IS_CONST) {
ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline->op1);
} else if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
opline->op1.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, opline->op1.var + op_array->last_var);
}
if (opline->op2_type == IS_CONST) {
ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline->op2);
} else if (opline->op2_type & (IS_VAR|IS_TMP_VAR)) {
opline->op2.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, opline->op2.var + op_array->last_var);
}
if (opline->result_type & (IS_VAR|IS_TMP_VAR)) {
opline->result.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, opline->result.var + op_array->last_var);
}
switch (opline->opcode) {
case ZEND_JMP:

2
ext/opcache/zend_file_cache.c

@ -464,6 +464,7 @@ static void zend_file_cache_serialize_op_array(zend_op_array *op_arra
SERIALIZE_STR(op_array->doc_comment);
SERIALIZE_PTR(op_array->try_catch_array);
SERIALIZE_PTR(op_array->prototype);
SERIALIZE_PTR(op_array->T_liveliness);
}
}
@ -987,6 +988,7 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
UNSERIALIZE_STR(op_array->doc_comment);
UNSERIALIZE_PTR(op_array->try_catch_array);
UNSERIALIZE_PTR(op_array->prototype);
UNSERIALIZE_PTR(op_array->T_liveliness);
}
}

4
ext/opcache/zend_persist.c

@ -618,6 +618,10 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc
zend_accel_store(op_array->try_catch_array, sizeof(zend_try_catch_element) * op_array->last_try_catch);
}
if (op_array->T_liveliness) {
zend_accel_store(op_array->T_liveliness, sizeof(uint32_t) * op_array->T_liveliness[op_array->last - 1]);
}
if (op_array->vars) {
if (already_stored) {
persist_ptr = zend_shared_alloc_get_xlat_entry(op_array->vars);

4
ext/opcache/zend_persist_calc.c

@ -241,6 +241,10 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
ADD_DUP_SIZE(op_array->try_catch_array, sizeof(zend_try_catch_element) * op_array->last_try_catch);
}
if (op_array->T_liveliness) {
ADD_DUP_SIZE(op_array->T_liveliness, sizeof(uint32_t) * op_array->T_liveliness[op_array->last - 1]);
}
if (op_array->vars) {
int i;

Loading…
Cancel
Save