diff options
Diffstat (limited to 'ext/opcache/zend_file_cache.c')
-rw-r--r-- | ext/opcache/zend_file_cache.c | 111 |
1 files changed, 74 insertions, 37 deletions
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index b8e9b1800b..6d34851352 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -373,7 +373,6 @@ static void zend_file_cache_serialize_op_array(zend_op_array *op_arra } if (!IS_SERIALIZED(op_array->opcodes)) { -#if ZEND_USE_ABS_CONST_ADDR || ZEND_USE_ABS_JMP_ADDR zend_op *opline, *end; SERIALIZE_PTR(op_array->opcodes); @@ -381,20 +380,18 @@ static void zend_file_cache_serialize_op_array(zend_op_array *op_arra UNSERIALIZE_PTR(opline); end = opline + op_array->last; while (opline < end) { -# if ZEND_USE_ABS_CONST_ADDR - if (ZEND_OP1_TYPE(opline) == IS_CONST) { +#if ZEND_USE_ABS_CONST_ADDR + if (opline->op1_type == IS_CONST) { SERIALIZE_PTR(opline->op1.zv); } - if (ZEND_OP2_TYPE(opline) == IS_CONST) { + if (opline->op2_type == IS_CONST) { SERIALIZE_PTR(opline->op2.zv); } -# endif -# if ZEND_USE_ABS_JMP_ADDR +#endif +#if ZEND_USE_ABS_JMP_ADDR switch (opline->opcode) { case ZEND_JMP: case ZEND_FAST_CALL: - case ZEND_DECLARE_ANON_CLASS: - case ZEND_DECLARE_ANON_INHERITED_CLASS: SERIALIZE_PTR(opline->op1.jmp_addr); break; case ZEND_JMPZNZ: @@ -406,23 +403,22 @@ static void zend_file_cache_serialize_op_array(zend_op_array *op_arra case ZEND_JMPNZ_EX: case ZEND_JMP_SET: case ZEND_COALESCE: - case ZEND_NEW: case ZEND_FE_RESET_R: case ZEND_FE_RESET_RW: case ZEND_ASSERT_CHECK: SERIALIZE_PTR(opline->op2.jmp_addr); break; + case ZEND_DECLARE_ANON_CLASS: + case ZEND_DECLARE_ANON_INHERITED_CLASS: case ZEND_FE_FETCH_R: case ZEND_FE_FETCH_RW: /* relative extended_value don't have to be changed */ break; } -# endif +#endif + zend_serialize_opcode_handler(opline); opline++; } -#else - SERIALIZE_PTR(op_array->opcodes); -#endif if (op_array->arg_info) { zend_arg_info *p, *end; @@ -464,7 +460,7 @@ static void zend_file_cache_serialize_op_array(zend_op_array *op_arra SERIALIZE_STR(op_array->function_name); SERIALIZE_STR(op_array->filename); - SERIALIZE_PTR(op_array->brk_cont_array); + SERIALIZE_PTR(op_array->live_range); SERIALIZE_PTR(op_array->scope); SERIALIZE_STR(op_array->doc_comment); SERIALIZE_PTR(op_array->try_catch_array); @@ -509,6 +505,28 @@ static void zend_file_cache_serialize_prop_info(zval *zv, } } +static void zend_file_cache_serialize_class_constant(zval *zv, + zend_persistent_script *script, + zend_file_cache_metainfo *info, + void *buf) +{ + if (!IS_SERIALIZED(Z_PTR_P(zv))) { + zend_class_constant *c; + + SERIALIZE_PTR(Z_PTR_P(zv)); + c = Z_PTR_P(zv); + UNSERIALIZE_PTR(c); + + zend_file_cache_serialize_zval(&c->value, script, info, buf); + if (c->ce && !IS_SERIALIZED(c->ce)) { + SERIALIZE_PTR(c->ce); + } + if (c->doc_comment && !IS_SERIALIZED(c->doc_comment)) { + SERIALIZE_STR(c->doc_comment); + } + } +} + static void zend_file_cache_serialize_class(zval *zv, zend_persistent_script *script, zend_file_cache_metainfo *info, @@ -546,9 +564,9 @@ static void zend_file_cache_serialize_class(zval *zv, p++; } } - zend_file_cache_serialize_hash(&ce->constants_table, script, info, buf, zend_file_cache_serialize_zval); - SERIALIZE_STR(ZEND_CE_FILENAME(ce)); - SERIALIZE_STR(ZEND_CE_DOC_COMMENT(ce)); + zend_file_cache_serialize_hash(&ce->constants_table, script, info, buf, zend_file_cache_serialize_class_constant); + SERIALIZE_STR(ce->info.user.filename); + SERIALIZE_STR(ce->info.user.doc_comment); zend_file_cache_serialize_hash(&ce->properties_info, script, info, buf, zend_file_cache_serialize_prop_info); if (ce->trait_aliases) { @@ -660,11 +678,11 @@ static void zend_file_cache_serialize(zend_persistent_script *script, memcpy(buf, script->mem, script->size); new_script = (zend_persistent_script*)((char*)buf + info->script_offset); - SERIALIZE_STR(new_script->full_path); + SERIALIZE_STR(new_script->script.filename); - zend_file_cache_serialize_hash(&new_script->class_table, script, info, buf, zend_file_cache_serialize_class); - zend_file_cache_serialize_hash(&new_script->function_table, script, info, buf, zend_file_cache_serialize_func); - zend_file_cache_serialize_op_array(&new_script->main_op_array, script, info, buf); + zend_file_cache_serialize_hash(&new_script->script.class_table, script, info, buf, zend_file_cache_serialize_class); + zend_file_cache_serialize_hash(&new_script->script.function_table, script, info, buf, zend_file_cache_serialize_func); + zend_file_cache_serialize_op_array(&new_script->script.main_op_array, script, info, buf); SERIALIZE_PTR(new_script->arena_mem); new_script->mem = NULL; @@ -712,7 +730,7 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm) #endif void *mem, *buf; - filename = zend_file_cache_get_bin_file_path(script->full_path); + filename = zend_file_cache_get_bin_file_path(script->script.filename); if (zend_file_cache_mkdir(filename, strlen(ZCG(accel_directives).file_cache)) != SUCCESS) { zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot create directory for file '%s'\n", filename); @@ -939,10 +957,10 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr end = opline + op_array->last; while (opline < end) { # if ZEND_USE_ABS_CONST_ADDR - if (ZEND_OP1_TYPE(opline) == IS_CONST) { + if (opline->op1_type == IS_CONST) { UNSERIALIZE_PTR(opline->op1.zv); } - if (ZEND_OP2_TYPE(opline) == IS_CONST) { + if (opline->op2_type == IS_CONST) { UNSERIALIZE_PTR(opline->op2.zv); } # endif @@ -950,8 +968,6 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr switch (opline->opcode) { case ZEND_JMP: case ZEND_FAST_CALL: - case ZEND_DECLARE_ANON_CLASS: - case ZEND_DECLARE_ANON_INHERITED_CLASS: UNSERIALIZE_PTR(opline->op1.jmp_addr); break; case ZEND_JMPZNZ: @@ -963,19 +979,20 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr case ZEND_JMPNZ_EX: case ZEND_JMP_SET: case ZEND_COALESCE: - case ZEND_NEW: case ZEND_FE_RESET_R: case ZEND_FE_RESET_RW: case ZEND_ASSERT_CHECK: UNSERIALIZE_PTR(opline->op2.jmp_addr); break; + case ZEND_DECLARE_ANON_CLASS: + case ZEND_DECLARE_ANON_INHERITED_CLASS: case ZEND_FE_FETCH_R: case ZEND_FE_FETCH_RW: /* relative extended_value don't have to be changed */ break; } # endif - ZEND_VM_SET_OPCODE_HANDLER(opline); + zend_deserialize_opcode_handler(opline); opline++; } @@ -1017,7 +1034,7 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr UNSERIALIZE_STR(op_array->function_name); UNSERIALIZE_STR(op_array->filename); - UNSERIALIZE_PTR(op_array->brk_cont_array); + UNSERIALIZE_PTR(op_array->live_range); UNSERIALIZE_PTR(op_array->scope); UNSERIALIZE_STR(op_array->doc_comment); UNSERIALIZE_PTR(op_array->try_catch_array); @@ -1058,6 +1075,26 @@ static void zend_file_cache_unserialize_prop_info(zval *zv, } } +static void zend_file_cache_unserialize_class_constant(zval *zv, + zend_persistent_script *script, + void *buf) +{ + if (!IS_UNSERIALIZED(Z_PTR_P(zv))) { + zend_class_constant *c; + + UNSERIALIZE_PTR(Z_PTR_P(zv)); + c = Z_PTR_P(zv); + + zend_file_cache_unserialize_zval(&c->value, script, buf); + if (c->ce && !IS_UNSERIALIZED(c->ce)) { + UNSERIALIZE_PTR(c->ce); + } + if (c->doc_comment && !IS_UNSERIALIZED(c->doc_comment)) { + UNSERIALIZE_STR(c->doc_comment); + } + } +} + static void zend_file_cache_unserialize_class(zval *zv, zend_persistent_script *script, void *buf) @@ -1093,9 +1130,9 @@ static void zend_file_cache_unserialize_class(zval *zv, } } zend_file_cache_unserialize_hash(&ce->constants_table, - script, buf, zend_file_cache_unserialize_zval, NULL); - UNSERIALIZE_STR(ZEND_CE_FILENAME(ce)); - UNSERIALIZE_STR(ZEND_CE_DOC_COMMENT(ce)); + script, buf, zend_file_cache_unserialize_class_constant, NULL); + UNSERIALIZE_STR(ce->info.user.filename); + UNSERIALIZE_STR(ce->info.user.doc_comment); zend_file_cache_unserialize_hash(&ce->properties_info, script, buf, zend_file_cache_unserialize_prop_info, ZVAL_PTR_DTOR); @@ -1195,13 +1232,13 @@ static void zend_file_cache_unserialize(zend_persistent_script *script, { script->mem = buf; - UNSERIALIZE_STR(script->full_path); + UNSERIALIZE_STR(script->script.filename); - zend_file_cache_unserialize_hash(&script->class_table, + zend_file_cache_unserialize_hash(&script->script.class_table, script, buf, zend_file_cache_unserialize_class, ZEND_CLASS_DTOR); - zend_file_cache_unserialize_hash(&script->function_table, + zend_file_cache_unserialize_hash(&script->script.function_table, script, buf, zend_file_cache_unserialize_func, ZEND_FUNCTION_DTOR); - zend_file_cache_unserialize_op_array(&script->main_op_array, script, buf); + zend_file_cache_unserialize_op_array(&script->script.main_op_array, script, buf); UNSERIALIZE_PTR(script->arena_mem); } @@ -1364,7 +1401,7 @@ use_process_mem: script->dynamic_members.checksum = zend_accel_script_checksum(script); script->dynamic_members.last_used = ZCG(request_time); - zend_accel_hash_update(&ZCSG(hash), ZSTR_VAL(script->full_path), ZSTR_LEN(script->full_path), 0, script); + zend_accel_hash_update(&ZCSG(hash), ZSTR_VAL(script->script.filename), ZSTR_LEN(script->script.filename), 0, script); zend_shared_alloc_unlock(); zend_arena_release(&CG(arena), checkpoint); |