Remove ZEND_ACC_INTERACTIVE and CG(interactive)

As far as I can discern these are leftovers of the interactive
shell implementation that was used before PHP 5.4. Now the readline
ext makes use of normal eval calls for this.

So, dropping these until there is evidence to the contrary, as they
currently wouldn't work anyway.
This commit is contained in:
Nikita Popov 2014-08-25 23:45:02 +02:00
parent 4ea19a682e
commit 59848e3fbb
18 changed files with 359 additions and 521 deletions

View File

@ -503,8 +503,6 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS
zend_set_default_compile_time_values(TSRMLS_C);
CG(interactive) = 0;
compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, NULL, 1, 0);
zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, NULL /* empty element */);
@ -1281,7 +1279,6 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
int i;
zend_file_handle *file_handle;
zend_op_array *op_array;
zend_long orig_interactive = CG(interactive);
va_start(files, file_count);
for (i = 0; i < file_count; i++) {
@ -1289,14 +1286,6 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
if (!file_handle) {
continue;
}
if (orig_interactive) {
if (file_handle->filename[0] != '-' || file_handle->filename[1]) {
CG(interactive) = 0;
} else {
CG(interactive) = 1;
}
}
op_array = zend_compile_file(file_handle, type TSRMLS_CC);
if (file_handle->opened_path) {
@ -1335,12 +1324,10 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
efree(op_array);
} else if (type==ZEND_REQUIRE) {
va_end(files);
CG(interactive) = orig_interactive;
return FAILURE;
}
}
va_end(files);
CG(interactive) = orig_interactive;
return SUCCESS;
}

View File

@ -63,11 +63,6 @@
static inline void zend_alloc_cache_slot(uint32_t literal TSRMLS_DC) {
zend_op_array *op_array = CG(active_op_array);
Z_CACHE_SLOT(op_array->literals[literal]) = op_array->last_cache_slot++;
if ((op_array->fn_flags & ZEND_ACC_INTERACTIVE) && op_array->run_time_cache) {
op_array->run_time_cache = erealloc(op_array->run_time_cache,
op_array->last_cache_slot * sizeof(void*));
op_array->run_time_cache[CG(active_op_array)->last_cache_slot - 1] = NULL;
}
}
#define POLYMORPHIC_CACHE_SLOT_SIZE 2
@ -76,12 +71,6 @@ static inline void zend_alloc_polymorphic_cache_slot(uint32_t literal TSRMLS_DC)
zend_op_array *op_array = CG(active_op_array);
Z_CACHE_SLOT(op_array->literals[literal]) = op_array->last_cache_slot;
op_array->last_cache_slot += POLYMORPHIC_CACHE_SLOT_SIZE;
if ((op_array->fn_flags & ZEND_ACC_INTERACTIVE) && op_array->run_time_cache) {
op_array->run_time_cache = erealloc(
op_array->run_time_cache, op_array->last_cache_slot * sizeof(void *));
op_array->run_time_cache[op_array->last_cache_slot - 1] = NULL;
op_array->run_time_cache[op_array->last_cache_slot - 2] = NULL;
}
}
ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
@ -178,7 +167,7 @@ static void init_compiler_declarables(TSRMLS_D) /* {{{ */
void zend_init_compiler_context(TSRMLS_D) /* {{{ */
{
CG(context).opcodes_size = (CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE) ? INITIAL_INTERACTIVE_OP_ARRAY_SIZE : INITIAL_OP_ARRAY_SIZE;
CG(context).opcodes_size = INITIAL_OP_ARRAY_SIZE;
CG(context).vars_size = 0;
CG(context).literals_size = 0;
CG(context).current_brk_cont = -1;
@ -837,7 +826,6 @@ void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2
zend_error_noreturn(E_COMPILE_ERROR, "'goto' to undefined label '%s'", Z_STRVAL_P(label));
} else {
/* Label is not defined. Delay to pass 2. */
INC_BPC(op_array);
return;
}
}
@ -869,10 +857,6 @@ void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2
/* Set real break distance */
ZVAL_LONG(label, distance);
}
if (pass2) {
DEC_BPC(op_array);
}
}
/* }}} */

View File

@ -35,10 +35,6 @@
#define SET_UNUSED(op) op ## _type = IS_UNUSED
#define INC_BPC(op_array) if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { (CG(context).backpatch_count++); }
#define DEC_BPC(op_array) if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { (CG(context).backpatch_count--); }
#define HANDLE_INTERACTIVE() if (CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE) { execute_new_code(TSRMLS_C); }
#define RESET_DOC_COMMENT() do { \
if (CG(doc_comment)) { \
zend_string_release(CG(doc_comment)); \
@ -173,9 +169,6 @@ typedef struct _zend_try_catch_element {
#define ZEND_ACC_INTERFACE 0x80
#define ZEND_ACC_TRAIT 0x120
/* op_array flags */
#define ZEND_ACC_INTERACTIVE 0x10
/* method flags (visibility) */
/* The order of those must be kept - public < protected < private */
#define ZEND_ACC_PUBLIC 0x100
@ -491,7 +484,6 @@ void zend_release_labels(int temporary TSRMLS_DC);
ZEND_API void function_add_ref(zend_function *function);
#define INITIAL_OP_ARRAY_SIZE 64
#define INITIAL_INTERACTIVE_OP_ARRAY_SIZE 8192
/* helper functions in zend_language_scanner.l */

View File

@ -1625,7 +1625,7 @@ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execu
EX(delayed_exception) = NULL;
EX(call) = NULL;
EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes;
EX(opline) = op_array->opcodes;
EX(scope) = EG(scope);
zend_attach_symbol_table(execute_data);
@ -1654,7 +1654,7 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da
EX(delayed_exception) = NULL;
EX(call) = NULL;
EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes;
EX(opline) = op_array->opcodes;
EX(scope) = EG(scope);
if (UNEXPECTED(EX(symbol_table) != NULL)) {

View File

@ -269,9 +269,6 @@ static zend_always_inline void zend_vm_stack_free_call_frame(zend_execute_data *
}
}
void execute_new_code(TSRMLS_D);
/* services */
ZEND_API const char *get_active_class_name(const char **space TSRMLS_DC);
ZEND_API const char *get_active_function_name(TSRMLS_D);

View File

@ -1084,10 +1084,8 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s
if (new_op_array) {
zval local_retval;
int orig_interactive = CG(interactive);
EG(no_extensions)=1;
CG(interactive) = 0;
zend_try {
ZVAL_UNDEF(&local_retval);
@ -1098,7 +1096,6 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s
zend_bailout();
} zend_end_try();
CG(interactive) = orig_interactive;
if (Z_TYPE(local_retval) != IS_UNDEF) {
if (retval_ptr) {
ZVAL_COPY_VALUE(retval_ptr, &local_retval);
@ -1148,84 +1145,6 @@ ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name,
}
/* }}} */
void execute_new_code(TSRMLS_D) /* {{{ */
{
zend_op *opline, *end;
zend_op *ret_opline;
int orig_interactive;
if (!(CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE)
|| CG(context).backpatch_count>0
|| CG(active_op_array)->function_name
|| CG(active_op_array)->type!=ZEND_USER_FUNCTION) {
return;
}
ret_opline = get_next_op(CG(active_op_array) TSRMLS_CC);
ret_opline->opcode = ZEND_RETURN;
ret_opline->op1_type = IS_CONST;
ret_opline->op1.constant = zend_add_literal(CG(active_op_array), &EG(uninitialized_zval) TSRMLS_CC);
SET_UNUSED(ret_opline->op2);
if (!EG(start_op)) {
EG(start_op) = CG(active_op_array)->opcodes;
}
opline=EG(start_op);
end=CG(active_op_array)->opcodes+CG(active_op_array)->last;
while (opline<end) {
if (opline->op1_type == IS_CONST) {
opline->op1.zv = &CG(active_op_array)->literals[opline->op1.constant];
}
if (opline->op2_type == IS_CONST) {
opline->op2.zv = &CG(active_op_array)->literals[opline->op2.constant];
}
switch (opline->opcode) {
case ZEND_GOTO:
if (Z_TYPE_P(opline->op2.zv) != IS_LONG) {
zend_resolve_goto_label(CG(active_op_array), opline, 1 TSRMLS_CC);
}
/* break omitted intentionally */
case ZEND_JMP:
opline->op1.jmp_addr = &CG(active_op_array)->opcodes[opline->op1.opline_num];
break;
case ZEND_JMPZNZ:
/* absolute index to relative offset */
opline->extended_value = (char*)(CG(active_op_array)->opcodes + opline->extended_value) - (char*)opline;
/* break omitted intentionally */
case ZEND_JMPZ:
case ZEND_JMPNZ:
case ZEND_JMPZ_EX:
case ZEND_JMPNZ_EX:
case ZEND_JMP_SET:
case ZEND_JMP_SET_VAR:
case ZEND_NEW:
case ZEND_FE_RESET:
case ZEND_FE_FETCH:
opline->op2.jmp_addr = &CG(active_op_array)->opcodes[opline->op2.opline_num];
break;
}
ZEND_VM_SET_OPCODE_HANDLER(opline);
opline++;
}
zend_release_labels(1 TSRMLS_CC);
orig_interactive = CG(interactive);
CG(interactive) = 0;
zend_execute(CG(active_op_array), NULL TSRMLS_CC);
CG(interactive) = orig_interactive;
if (EG(exception)) {
zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
}
CG(active_op_array)->last -= 1; /* get rid of that ZEND_RETURN */
EG(start_op) = CG(active_op_array)->opcodes+CG(active_op_array)->last;
}
/* }}} */
ZEND_API void zend_timeout(int dummy) /* {{{ */
{
TSRMLS_FETCH();

View File

@ -104,8 +104,6 @@ struct _zend_compiler_globals {
struct _zend_ini_parser_param *ini_parser_param;
int interactive;
uint32_t start_lineno;
zend_bool increment_lineno;

File diff suppressed because it is too large Load Diff

View File

@ -745,11 +745,7 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
efree(op_array);
retval = NULL;
} else {
zend_bool orig_interactive = CG(interactive);
CG(interactive) = 0;
init_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE TSRMLS_CC);
CG(interactive) = orig_interactive;
CG(active_op_array) = op_array;
zend_stack_push(&CG(context_stack), (void *) &CG(context));
zend_init_compiler_context(TSRMLS_C);

View File

@ -52,13 +52,6 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz
{
op_array->type = type;
if (CG(interactive)) {
/* We must avoid a realloc() on the op_array in interactive mode, since pointers to constants
* will become invalid
*/
initial_ops_size = INITIAL_INTERACTIVE_OP_ARRAY_SIZE;
}
op_array->refcount = (uint32_t *) emalloc(sizeof(uint32_t));
*op_array->refcount = 1;
op_array->last = 0;
@ -91,7 +84,7 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz
op_array->this_var = -1;
op_array->fn_flags = CG(interactive)?ZEND_ACC_INTERACTIVE:0;
op_array->fn_flags = 0;
op_array->early_binding = -1;
@ -397,12 +390,6 @@ zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC)
zend_op *next_op;
if (next_op_num >= CG(context).opcodes_size) {
if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) {
/* we messed up */
zend_printf("Ran out of opcode space!\n"
"You should probably consider writing this huge script into a file!\n");
zend_bailout();
}
CG(context).opcodes_size *= 4;
op_array_alloc_ops(op_array, CG(context).opcodes_size);
}
@ -701,15 +688,15 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC)
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_handler, op_array TSRMLS_CC);
}
if (!(op_array->fn_flags & ZEND_ACC_INTERACTIVE) && CG(context).vars_size != op_array->last_var) {
if (CG(context).vars_size != op_array->last_var) {
op_array->vars = (zend_string**) erealloc(op_array->vars, sizeof(zend_string*)*op_array->last_var);
CG(context).vars_size = op_array->last_var;
}
if (!(op_array->fn_flags & ZEND_ACC_INTERACTIVE) && CG(context).opcodes_size != op_array->last) {
if (CG(context).opcodes_size != op_array->last) {
op_array->opcodes = (zend_op *) erealloc(op_array->opcodes, sizeof(zend_op)*op_array->last);
CG(context).opcodes_size = op_array->last;
}
if (!(op_array->fn_flags & ZEND_ACC_INTERACTIVE) && CG(context).literals_size != op_array->last_literal) {
if (CG(context).literals_size != op_array->last_literal) {
op_array->literals = (zval*)erealloc(op_array->literals, sizeof(zval) * op_array->last_literal);
CG(context).literals_size = op_array->last_literal;
}

View File

@ -400,8 +400,7 @@ static void replace_tmp_by_const(zend_op_array *op_array,
static void zend_optimize(zend_op_array *op_array,
zend_optimizer_ctx *ctx TSRMLS_DC)
{
if (op_array->type == ZEND_EVAL_CODE ||
(op_array->fn_flags & ZEND_ACC_INTERACTIVE)) {
if (op_array->type == ZEND_EVAL_CODE) {
return;
}

View File

@ -1448,7 +1448,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T
if (!file_handle->filename ||
!ZCG(enabled) || !accel_startup_ok ||
(!ZCG(counted) && !ZCSG(accelerator_enabled)) ||
CG(interactive) ||
(ZCSG(restart_in_progress) && accel_restart_is_active(TSRMLS_C)) ||
(is_stream_path(file_handle->filename) &&
!is_cacheable_stream_path(file_handle->filename))) {
@ -1667,7 +1666,6 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl
{
if (ZCG(enabled) && accel_startup_ok &&
(ZCG(counted) || ZCSG(accelerator_enabled)) &&
!CG(interactive) &&
!ZCSG(restart_in_progress)) {
/* check if callback is called from include_once or it's a main request */
@ -1727,7 +1725,6 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len
{
if (ZCG(enabled) && accel_startup_ok &&
(ZCG(counted) || ZCSG(accelerator_enabled)) &&
!CG(interactive) &&
!ZCSG(restart_in_progress)) {
/* check if callback is called from include_once or it's a main request */

View File

@ -2130,7 +2130,6 @@ consult the installation file that came with this distribution, or visit \n\
while (!fastcgi || fcgi_accept_request(request) >= 0) {
SG(server_context) = fastcgi ? (void *) request : (void *) 1;
init_request_info(request TSRMLS_CC);
CG(interactive) = 0;
if (!cgi && !fastcgi) {
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
@ -2138,7 +2137,6 @@ consult the installation file that came with this distribution, or visit \n\
case 'a': /* interactive mode */
printf("Interactive mode enabled\n\n");
CG(interactive) = 1;
break;
case 'C': /* don't chdir to the script directory */

View File

@ -902,8 +902,6 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
fflush(stdout);
}
CG(interactive) = interactive;
/* only set script_file if not set already and not in direct mode and not at end of parameter list */
if (argc > php_optind
&& !script_file

View File

@ -1866,7 +1866,6 @@ consult the installation file that came with this distribution, or visit \n\
request_body_fd = -1;
SG(server_context) = (void *) &request;
init_request_info(TSRMLS_C);
CG(interactive) = 0;
char *primary_script = NULL;
fpm_request_info();

View File

@ -1134,8 +1134,6 @@ int main(int argc, char *argv[])
exit(1);
}
CG(interactive) = interactive;
/* only set script_file if not set already and not in direct mode and not at end of parameter list */
if (argc > ap_php_optind && !filename) {
filename=argv[ap_php_optind];

View File

@ -970,7 +970,6 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut
zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], (void*)&bp, &position) == SUCCESS;
zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) {
zval *retval = NULL;
int orig_interactive = CG(interactive);
zval **orig_retval = EG(return_value_ptr_ptr);
zend_op_array *orig_ops = EG(active_op_array);
zend_op **orig_opline = EG(opline_ptr);
@ -995,8 +994,6 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut
zend_rebuild_symbol_table(TSRMLS_C);
}
CG(interactive) = 0;
zend_try {
PHPDBG_G(flags) |= PHPDBG_IN_COND_BP;
zend_execute(EG(active_op_array) TSRMLS_CC);
@ -1008,8 +1005,6 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut
breakpoint = SUCCESS;
}
} zend_catch {
CG(interactive) = orig_interactive;
EG(no_extensions)=1;
EG(return_value_ptr_ptr) = orig_retval;
EG(active_op_array) = orig_ops;
@ -1017,8 +1012,6 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut
PHPDBG_G(flags) &= ~PHPDBG_IN_COND_BP;
} zend_end_try();
CG(interactive) = orig_interactive;
EG(no_extensions)=1;
EG(return_value_ptr_ptr) = orig_retval;
EG(active_op_array) = orig_ops;

View File

@ -1134,7 +1134,7 @@ static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_ar
}
}
EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes;
EX(opline) = op_array->opcodes;
EG(opline_ptr) = &EX(opline);
EX(function_state).function = (zend_function *) op_array;