mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
Separate unspecializeble code of INCLIDE_OR_EVAL into helper functions
This commit is contained in:
parent
f48b20721c
commit
85f35a8fc1
3 changed files with 118 additions and 314 deletions
|
@ -2846,6 +2846,90 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
#define ZEND_FAKE_OP_ARRAY ((zend_op_array*)(zend_intptr_t)-1)
|
||||||
|
|
||||||
|
static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(zval *inc_filename, int type) /* {{{ */
|
||||||
|
{
|
||||||
|
zend_op_array *new_op_array = NULL;
|
||||||
|
zval tmp_inc_filename;
|
||||||
|
|
||||||
|
ZVAL_UNDEF(&tmp_inc_filename);
|
||||||
|
if (Z_TYPE_P(inc_filename) != IS_STRING) {
|
||||||
|
ZVAL_STR(&tmp_inc_filename, zval_get_string(inc_filename));
|
||||||
|
inc_filename = &tmp_inc_filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
|
||||||
|
if (type == ZEND_INCLUDE_ONCE || type == ZEND_INCLUDE) {
|
||||||
|
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
|
||||||
|
} else {
|
||||||
|
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (type) {
|
||||||
|
case ZEND_INCLUDE_ONCE:
|
||||||
|
case ZEND_REQUIRE_ONCE: {
|
||||||
|
zend_file_handle file_handle;
|
||||||
|
zend_string *resolved_path;
|
||||||
|
|
||||||
|
resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename));
|
||||||
|
if (resolved_path) {
|
||||||
|
if (zend_hash_exists(&EG(included_files), resolved_path)) {
|
||||||
|
goto already_compiled;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolved_path = zend_string_copy(Z_STR_P(inc_filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SUCCESS == zend_stream_open(ZSTR_VAL(resolved_path), &file_handle)) {
|
||||||
|
|
||||||
|
if (!file_handle.opened_path) {
|
||||||
|
file_handle.opened_path = zend_string_copy(resolved_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path)) {
|
||||||
|
zend_op_array *op_array = zend_compile_file(&file_handle, (type==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE));
|
||||||
|
zend_destroy_file_handle(&file_handle);
|
||||||
|
zend_string_release(resolved_path);
|
||||||
|
if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) {
|
||||||
|
zend_string_release(Z_STR(tmp_inc_filename));
|
||||||
|
}
|
||||||
|
return op_array;
|
||||||
|
} else {
|
||||||
|
zend_file_handle_dtor(&file_handle);
|
||||||
|
already_compiled:
|
||||||
|
new_op_array = ZEND_FAKE_OP_ARRAY;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (type == ZEND_INCLUDE_ONCE) {
|
||||||
|
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
|
||||||
|
} else {
|
||||||
|
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zend_string_release(resolved_path);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ZEND_INCLUDE:
|
||||||
|
case ZEND_REQUIRE:
|
||||||
|
new_op_array = compile_filename(type, inc_filename);
|
||||||
|
break;
|
||||||
|
case ZEND_EVAL: {
|
||||||
|
char *eval_desc = zend_make_compiled_string_description("eval()'d code");
|
||||||
|
new_op_array = zend_compile_string(inc_filename, eval_desc);
|
||||||
|
efree(eval_desc);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
EMPTY_SWITCH_DEFAULT_CASE()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) {
|
||||||
|
zend_string_release(Z_STR(tmp_inc_filename));
|
||||||
|
}
|
||||||
|
return new_op_array;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
#ifdef HAVE_GCC_GLOBAL_REGS
|
#ifdef HAVE_GCC_GLOBAL_REGS
|
||||||
# if defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(i386)
|
# if defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(i386)
|
||||||
# define ZEND_VM_FP_GLOBAL_REG "%esi"
|
# define ZEND_VM_FP_GLOBAL_REG "%esi"
|
||||||
|
|
|
@ -5386,89 +5386,20 @@ ZEND_VM_HANDLER(21, ZEND_CAST, CONST|TMP|VAR|CV, ANY, TYPE)
|
||||||
ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMPVAR|CV, ANY, EVAL)
|
ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMPVAR|CV, ANY, EVAL)
|
||||||
{
|
{
|
||||||
USE_OPLINE
|
USE_OPLINE
|
||||||
zend_op_array *new_op_array=NULL;
|
zend_op_array *new_op_array;
|
||||||
zend_free_op free_op1;
|
zend_free_op free_op1;
|
||||||
zval *inc_filename;
|
zval *inc_filename;
|
||||||
zval tmp_inc_filename;
|
|
||||||
zend_bool failure_retval=0;
|
|
||||||
|
|
||||||
SAVE_OPLINE();
|
SAVE_OPLINE();
|
||||||
inc_filename = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
|
inc_filename = GET_OP1_ZVAL_PTR(BP_VAR_R);
|
||||||
|
new_op_array = zend_include_or_eval(inc_filename, opline->extended_value);
|
||||||
ZVAL_UNDEF(&tmp_inc_filename);
|
|
||||||
if (Z_TYPE_P(inc_filename) != IS_STRING) {
|
|
||||||
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(inc_filename) == IS_UNDEF)) {
|
|
||||||
inc_filename = GET_OP1_UNDEF_CV(inc_filename, BP_VAR_R);
|
|
||||||
}
|
|
||||||
ZVAL_STR(&tmp_inc_filename, zval_get_string(inc_filename));
|
|
||||||
inc_filename = &tmp_inc_filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
|
|
||||||
if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
} else {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (opline->extended_value) {
|
|
||||||
case ZEND_INCLUDE_ONCE:
|
|
||||||
case ZEND_REQUIRE_ONCE: {
|
|
||||||
zend_file_handle file_handle;
|
|
||||||
zend_string *resolved_path;
|
|
||||||
|
|
||||||
resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename));
|
|
||||||
if (resolved_path) {
|
|
||||||
failure_retval = zend_hash_exists(&EG(included_files), resolved_path);
|
|
||||||
} else {
|
|
||||||
resolved_path = zend_string_copy(Z_STR_P(inc_filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (failure_retval) {
|
|
||||||
/* do nothing, file already included */
|
|
||||||
} else if (SUCCESS == zend_stream_open(ZSTR_VAL(resolved_path), &file_handle)) {
|
|
||||||
|
|
||||||
if (!file_handle.opened_path) {
|
|
||||||
file_handle.opened_path = zend_string_copy(resolved_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path)) {
|
|
||||||
new_op_array = zend_compile_file(&file_handle, (opline->extended_value==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE));
|
|
||||||
zend_destroy_file_handle(&file_handle);
|
|
||||||
} else {
|
|
||||||
zend_file_handle_dtor(&file_handle);
|
|
||||||
failure_retval=1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (opline->extended_value == ZEND_INCLUDE_ONCE) {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
} else {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zend_string_release(resolved_path);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ZEND_INCLUDE:
|
|
||||||
case ZEND_REQUIRE:
|
|
||||||
new_op_array = compile_filename(opline->extended_value, inc_filename);
|
|
||||||
break;
|
|
||||||
case ZEND_EVAL: {
|
|
||||||
char *eval_desc = zend_make_compiled_string_description("eval()'d code");
|
|
||||||
|
|
||||||
new_op_array = zend_compile_string(inc_filename, eval_desc);
|
|
||||||
efree(eval_desc);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
EMPTY_SWITCH_DEFAULT_CASE()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) {
|
|
||||||
zend_string_release(Z_STR(tmp_inc_filename));
|
|
||||||
}
|
|
||||||
FREE_OP1();
|
FREE_OP1();
|
||||||
if (UNEXPECTED(EG(exception) != NULL)) {
|
if (UNEXPECTED(EG(exception) != NULL)) {
|
||||||
HANDLE_EXCEPTION();
|
HANDLE_EXCEPTION();
|
||||||
|
} else if (new_op_array == ZEND_FAKE_OP_ARRAY) {
|
||||||
|
if (RETURN_VALUE_USED(opline)) {
|
||||||
|
ZVAL_TRUE(EX_VAR(opline->result.var));
|
||||||
|
}
|
||||||
} else if (EXPECTED(new_op_array != NULL)) {
|
} else if (EXPECTED(new_op_array != NULL)) {
|
||||||
zval *return_value = NULL;
|
zval *return_value = NULL;
|
||||||
zend_execute_data *call;
|
zend_execute_data *call;
|
||||||
|
@ -5491,7 +5422,7 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMPVAR|CV, ANY, EVAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
call->prev_execute_data = execute_data;
|
call->prev_execute_data = execute_data;
|
||||||
i_init_code_execute_data(call, new_op_array, return_value);
|
i_init_code_execute_data(call, new_op_array, return_value);
|
||||||
if (EXPECTED(zend_execute_ex == execute_ex)) {
|
if (EXPECTED(zend_execute_ex == execute_ex)) {
|
||||||
ZEND_VM_ENTER();
|
ZEND_VM_ENTER();
|
||||||
} else {
|
} else {
|
||||||
|
@ -5506,9 +5437,8 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMPVAR|CV, ANY, EVAL)
|
||||||
zend_throw_exception_internal(NULL);
|
zend_throw_exception_internal(NULL);
|
||||||
HANDLE_EXCEPTION();
|
HANDLE_EXCEPTION();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (RETURN_VALUE_USED(opline)) {
|
} else if (RETURN_VALUE_USED(opline)) {
|
||||||
ZVAL_BOOL(EX_VAR(opline->result.var), failure_retval);
|
ZVAL_FALSE(EX_VAR(opline->result.var));
|
||||||
}
|
}
|
||||||
ZEND_VM_INTERRUPT_CHECK();
|
ZEND_VM_INTERRUPT_CHECK();
|
||||||
ZEND_VM_NEXT_OPCODE();
|
ZEND_VM_NEXT_OPCODE();
|
||||||
|
|
|
@ -3531,89 +3531,20 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_CONST_HANDLER(ZEND_O
|
||||||
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||||
{
|
{
|
||||||
USE_OPLINE
|
USE_OPLINE
|
||||||
zend_op_array *new_op_array=NULL;
|
zend_op_array *new_op_array;
|
||||||
|
|
||||||
zval *inc_filename;
|
zval *inc_filename;
|
||||||
zval tmp_inc_filename;
|
|
||||||
zend_bool failure_retval=0;
|
|
||||||
|
|
||||||
SAVE_OPLINE();
|
SAVE_OPLINE();
|
||||||
inc_filename = EX_CONSTANT(opline->op1);
|
inc_filename = EX_CONSTANT(opline->op1);
|
||||||
|
new_op_array = zend_include_or_eval(inc_filename, opline->extended_value);
|
||||||
ZVAL_UNDEF(&tmp_inc_filename);
|
|
||||||
if (Z_TYPE_P(inc_filename) != IS_STRING) {
|
|
||||||
if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(inc_filename) == IS_UNDEF)) {
|
|
||||||
inc_filename = GET_OP1_UNDEF_CV(inc_filename, BP_VAR_R);
|
|
||||||
}
|
|
||||||
ZVAL_STR(&tmp_inc_filename, zval_get_string(inc_filename));
|
|
||||||
inc_filename = &tmp_inc_filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
|
|
||||||
if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
} else {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (opline->extended_value) {
|
|
||||||
case ZEND_INCLUDE_ONCE:
|
|
||||||
case ZEND_REQUIRE_ONCE: {
|
|
||||||
zend_file_handle file_handle;
|
|
||||||
zend_string *resolved_path;
|
|
||||||
|
|
||||||
resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename));
|
|
||||||
if (resolved_path) {
|
|
||||||
failure_retval = zend_hash_exists(&EG(included_files), resolved_path);
|
|
||||||
} else {
|
|
||||||
resolved_path = zend_string_copy(Z_STR_P(inc_filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (failure_retval) {
|
|
||||||
/* do nothing, file already included */
|
|
||||||
} else if (SUCCESS == zend_stream_open(ZSTR_VAL(resolved_path), &file_handle)) {
|
|
||||||
|
|
||||||
if (!file_handle.opened_path) {
|
|
||||||
file_handle.opened_path = zend_string_copy(resolved_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path)) {
|
|
||||||
new_op_array = zend_compile_file(&file_handle, (opline->extended_value==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE));
|
|
||||||
zend_destroy_file_handle(&file_handle);
|
|
||||||
} else {
|
|
||||||
zend_file_handle_dtor(&file_handle);
|
|
||||||
failure_retval=1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (opline->extended_value == ZEND_INCLUDE_ONCE) {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
} else {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zend_string_release(resolved_path);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ZEND_INCLUDE:
|
|
||||||
case ZEND_REQUIRE:
|
|
||||||
new_op_array = compile_filename(opline->extended_value, inc_filename);
|
|
||||||
break;
|
|
||||||
case ZEND_EVAL: {
|
|
||||||
char *eval_desc = zend_make_compiled_string_description("eval()'d code");
|
|
||||||
|
|
||||||
new_op_array = zend_compile_string(inc_filename, eval_desc);
|
|
||||||
efree(eval_desc);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
EMPTY_SWITCH_DEFAULT_CASE()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) {
|
|
||||||
zend_string_release(Z_STR(tmp_inc_filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UNEXPECTED(EG(exception) != NULL)) {
|
if (UNEXPECTED(EG(exception) != NULL)) {
|
||||||
HANDLE_EXCEPTION();
|
HANDLE_EXCEPTION();
|
||||||
|
} else if (new_op_array == ZEND_FAKE_OP_ARRAY) {
|
||||||
|
if (RETURN_VALUE_USED(opline)) {
|
||||||
|
ZVAL_TRUE(EX_VAR(opline->result.var));
|
||||||
|
}
|
||||||
} else if (EXPECTED(new_op_array != NULL)) {
|
} else if (EXPECTED(new_op_array != NULL)) {
|
||||||
zval *return_value = NULL;
|
zval *return_value = NULL;
|
||||||
zend_execute_data *call;
|
zend_execute_data *call;
|
||||||
|
@ -3636,7 +3567,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HAN
|
||||||
}
|
}
|
||||||
|
|
||||||
call->prev_execute_data = execute_data;
|
call->prev_execute_data = execute_data;
|
||||||
i_init_code_execute_data(call, new_op_array, return_value);
|
i_init_code_execute_data(call, new_op_array, return_value);
|
||||||
if (EXPECTED(zend_execute_ex == execute_ex)) {
|
if (EXPECTED(zend_execute_ex == execute_ex)) {
|
||||||
ZEND_VM_ENTER();
|
ZEND_VM_ENTER();
|
||||||
} else {
|
} else {
|
||||||
|
@ -3651,9 +3582,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HAN
|
||||||
zend_throw_exception_internal(NULL);
|
zend_throw_exception_internal(NULL);
|
||||||
HANDLE_EXCEPTION();
|
HANDLE_EXCEPTION();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (RETURN_VALUE_USED(opline)) {
|
} else if (RETURN_VALUE_USED(opline)) {
|
||||||
ZVAL_BOOL(EX_VAR(opline->result.var), failure_retval);
|
ZVAL_FALSE(EX_VAR(opline->result.var));
|
||||||
}
|
}
|
||||||
ZEND_VM_INTERRUPT_CHECK();
|
ZEND_VM_INTERRUPT_CHECK();
|
||||||
ZEND_VM_NEXT_OPCODE();
|
ZEND_VM_NEXT_OPCODE();
|
||||||
|
@ -35340,89 +35270,20 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_CV_HANDLER(ZEND_OPCO
|
||||||
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||||
{
|
{
|
||||||
USE_OPLINE
|
USE_OPLINE
|
||||||
zend_op_array *new_op_array=NULL;
|
zend_op_array *new_op_array;
|
||||||
|
|
||||||
zval *inc_filename;
|
zval *inc_filename;
|
||||||
zval tmp_inc_filename;
|
|
||||||
zend_bool failure_retval=0;
|
|
||||||
|
|
||||||
SAVE_OPLINE();
|
SAVE_OPLINE();
|
||||||
inc_filename = _get_zval_ptr_cv_undef(execute_data, opline->op1.var);
|
inc_filename = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var);
|
||||||
|
new_op_array = zend_include_or_eval(inc_filename, opline->extended_value);
|
||||||
ZVAL_UNDEF(&tmp_inc_filename);
|
|
||||||
if (Z_TYPE_P(inc_filename) != IS_STRING) {
|
|
||||||
if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(inc_filename) == IS_UNDEF)) {
|
|
||||||
inc_filename = GET_OP1_UNDEF_CV(inc_filename, BP_VAR_R);
|
|
||||||
}
|
|
||||||
ZVAL_STR(&tmp_inc_filename, zval_get_string(inc_filename));
|
|
||||||
inc_filename = &tmp_inc_filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
|
|
||||||
if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
} else {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (opline->extended_value) {
|
|
||||||
case ZEND_INCLUDE_ONCE:
|
|
||||||
case ZEND_REQUIRE_ONCE: {
|
|
||||||
zend_file_handle file_handle;
|
|
||||||
zend_string *resolved_path;
|
|
||||||
|
|
||||||
resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename));
|
|
||||||
if (resolved_path) {
|
|
||||||
failure_retval = zend_hash_exists(&EG(included_files), resolved_path);
|
|
||||||
} else {
|
|
||||||
resolved_path = zend_string_copy(Z_STR_P(inc_filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (failure_retval) {
|
|
||||||
/* do nothing, file already included */
|
|
||||||
} else if (SUCCESS == zend_stream_open(ZSTR_VAL(resolved_path), &file_handle)) {
|
|
||||||
|
|
||||||
if (!file_handle.opened_path) {
|
|
||||||
file_handle.opened_path = zend_string_copy(resolved_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path)) {
|
|
||||||
new_op_array = zend_compile_file(&file_handle, (opline->extended_value==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE));
|
|
||||||
zend_destroy_file_handle(&file_handle);
|
|
||||||
} else {
|
|
||||||
zend_file_handle_dtor(&file_handle);
|
|
||||||
failure_retval=1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (opline->extended_value == ZEND_INCLUDE_ONCE) {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
} else {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zend_string_release(resolved_path);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ZEND_INCLUDE:
|
|
||||||
case ZEND_REQUIRE:
|
|
||||||
new_op_array = compile_filename(opline->extended_value, inc_filename);
|
|
||||||
break;
|
|
||||||
case ZEND_EVAL: {
|
|
||||||
char *eval_desc = zend_make_compiled_string_description("eval()'d code");
|
|
||||||
|
|
||||||
new_op_array = zend_compile_string(inc_filename, eval_desc);
|
|
||||||
efree(eval_desc);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
EMPTY_SWITCH_DEFAULT_CASE()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) {
|
|
||||||
zend_string_release(Z_STR(tmp_inc_filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UNEXPECTED(EG(exception) != NULL)) {
|
if (UNEXPECTED(EG(exception) != NULL)) {
|
||||||
HANDLE_EXCEPTION();
|
HANDLE_EXCEPTION();
|
||||||
|
} else if (new_op_array == ZEND_FAKE_OP_ARRAY) {
|
||||||
|
if (RETURN_VALUE_USED(opline)) {
|
||||||
|
ZVAL_TRUE(EX_VAR(opline->result.var));
|
||||||
|
}
|
||||||
} else if (EXPECTED(new_op_array != NULL)) {
|
} else if (EXPECTED(new_op_array != NULL)) {
|
||||||
zval *return_value = NULL;
|
zval *return_value = NULL;
|
||||||
zend_execute_data *call;
|
zend_execute_data *call;
|
||||||
|
@ -35445,7 +35306,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLE
|
||||||
}
|
}
|
||||||
|
|
||||||
call->prev_execute_data = execute_data;
|
call->prev_execute_data = execute_data;
|
||||||
i_init_code_execute_data(call, new_op_array, return_value);
|
i_init_code_execute_data(call, new_op_array, return_value);
|
||||||
if (EXPECTED(zend_execute_ex == execute_ex)) {
|
if (EXPECTED(zend_execute_ex == execute_ex)) {
|
||||||
ZEND_VM_ENTER();
|
ZEND_VM_ENTER();
|
||||||
} else {
|
} else {
|
||||||
|
@ -35460,9 +35321,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLE
|
||||||
zend_throw_exception_internal(NULL);
|
zend_throw_exception_internal(NULL);
|
||||||
HANDLE_EXCEPTION();
|
HANDLE_EXCEPTION();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (RETURN_VALUE_USED(opline)) {
|
} else if (RETURN_VALUE_USED(opline)) {
|
||||||
ZVAL_BOOL(EX_VAR(opline->result.var), failure_retval);
|
ZVAL_FALSE(EX_VAR(opline->result.var));
|
||||||
}
|
}
|
||||||
ZEND_VM_INTERRUPT_CHECK();
|
ZEND_VM_INTERRUPT_CHECK();
|
||||||
ZEND_VM_NEXT_OPCODE();
|
ZEND_VM_NEXT_OPCODE();
|
||||||
|
@ -49983,89 +49843,20 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_TMPVAR_HANDLER(ZEND
|
||||||
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||||
{
|
{
|
||||||
USE_OPLINE
|
USE_OPLINE
|
||||||
zend_op_array *new_op_array=NULL;
|
zend_op_array *new_op_array;
|
||||||
zend_free_op free_op1;
|
zend_free_op free_op1;
|
||||||
zval *inc_filename;
|
zval *inc_filename;
|
||||||
zval tmp_inc_filename;
|
|
||||||
zend_bool failure_retval=0;
|
|
||||||
|
|
||||||
SAVE_OPLINE();
|
SAVE_OPLINE();
|
||||||
inc_filename = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1);
|
inc_filename = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1);
|
||||||
|
new_op_array = zend_include_or_eval(inc_filename, opline->extended_value);
|
||||||
ZVAL_UNDEF(&tmp_inc_filename);
|
|
||||||
if (Z_TYPE_P(inc_filename) != IS_STRING) {
|
|
||||||
if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(inc_filename) == IS_UNDEF)) {
|
|
||||||
inc_filename = GET_OP1_UNDEF_CV(inc_filename, BP_VAR_R);
|
|
||||||
}
|
|
||||||
ZVAL_STR(&tmp_inc_filename, zval_get_string(inc_filename));
|
|
||||||
inc_filename = &tmp_inc_filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
|
|
||||||
if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
} else {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (opline->extended_value) {
|
|
||||||
case ZEND_INCLUDE_ONCE:
|
|
||||||
case ZEND_REQUIRE_ONCE: {
|
|
||||||
zend_file_handle file_handle;
|
|
||||||
zend_string *resolved_path;
|
|
||||||
|
|
||||||
resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename));
|
|
||||||
if (resolved_path) {
|
|
||||||
failure_retval = zend_hash_exists(&EG(included_files), resolved_path);
|
|
||||||
} else {
|
|
||||||
resolved_path = zend_string_copy(Z_STR_P(inc_filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (failure_retval) {
|
|
||||||
/* do nothing, file already included */
|
|
||||||
} else if (SUCCESS == zend_stream_open(ZSTR_VAL(resolved_path), &file_handle)) {
|
|
||||||
|
|
||||||
if (!file_handle.opened_path) {
|
|
||||||
file_handle.opened_path = zend_string_copy(resolved_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path)) {
|
|
||||||
new_op_array = zend_compile_file(&file_handle, (opline->extended_value==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE));
|
|
||||||
zend_destroy_file_handle(&file_handle);
|
|
||||||
} else {
|
|
||||||
zend_file_handle_dtor(&file_handle);
|
|
||||||
failure_retval=1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (opline->extended_value == ZEND_INCLUDE_ONCE) {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
} else {
|
|
||||||
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zend_string_release(resolved_path);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ZEND_INCLUDE:
|
|
||||||
case ZEND_REQUIRE:
|
|
||||||
new_op_array = compile_filename(opline->extended_value, inc_filename);
|
|
||||||
break;
|
|
||||||
case ZEND_EVAL: {
|
|
||||||
char *eval_desc = zend_make_compiled_string_description("eval()'d code");
|
|
||||||
|
|
||||||
new_op_array = zend_compile_string(inc_filename, eval_desc);
|
|
||||||
efree(eval_desc);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
EMPTY_SWITCH_DEFAULT_CASE()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) {
|
|
||||||
zend_string_release(Z_STR(tmp_inc_filename));
|
|
||||||
}
|
|
||||||
zval_ptr_dtor_nogc(free_op1);
|
zval_ptr_dtor_nogc(free_op1);
|
||||||
if (UNEXPECTED(EG(exception) != NULL)) {
|
if (UNEXPECTED(EG(exception) != NULL)) {
|
||||||
HANDLE_EXCEPTION();
|
HANDLE_EXCEPTION();
|
||||||
|
} else if (new_op_array == ZEND_FAKE_OP_ARRAY) {
|
||||||
|
if (RETURN_VALUE_USED(opline)) {
|
||||||
|
ZVAL_TRUE(EX_VAR(opline->result.var));
|
||||||
|
}
|
||||||
} else if (EXPECTED(new_op_array != NULL)) {
|
} else if (EXPECTED(new_op_array != NULL)) {
|
||||||
zval *return_value = NULL;
|
zval *return_value = NULL;
|
||||||
zend_execute_data *call;
|
zend_execute_data *call;
|
||||||
|
@ -50088,7 +49879,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HA
|
||||||
}
|
}
|
||||||
|
|
||||||
call->prev_execute_data = execute_data;
|
call->prev_execute_data = execute_data;
|
||||||
i_init_code_execute_data(call, new_op_array, return_value);
|
i_init_code_execute_data(call, new_op_array, return_value);
|
||||||
if (EXPECTED(zend_execute_ex == execute_ex)) {
|
if (EXPECTED(zend_execute_ex == execute_ex)) {
|
||||||
ZEND_VM_ENTER();
|
ZEND_VM_ENTER();
|
||||||
} else {
|
} else {
|
||||||
|
@ -50103,9 +49894,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HA
|
||||||
zend_throw_exception_internal(NULL);
|
zend_throw_exception_internal(NULL);
|
||||||
HANDLE_EXCEPTION();
|
HANDLE_EXCEPTION();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (RETURN_VALUE_USED(opline)) {
|
} else if (RETURN_VALUE_USED(opline)) {
|
||||||
ZVAL_BOOL(EX_VAR(opline->result.var), failure_retval);
|
ZVAL_FALSE(EX_VAR(opline->result.var));
|
||||||
}
|
}
|
||||||
ZEND_VM_INTERRUPT_CHECK();
|
ZEND_VM_INTERRUPT_CHECK();
|
||||||
ZEND_VM_NEXT_OPCODE();
|
ZEND_VM_NEXT_OPCODE();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue