Skip to content

Commit 59848e3

Browse files
committed
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.
1 parent 4ea19a6 commit 59848e3

18 files changed

+359
-521
lines changed

Zend/zend.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,6 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS
503503

504504
zend_set_default_compile_time_values(TSRMLS_C);
505505

506-
CG(interactive) = 0;
507-
508506
compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable));
509507
zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, NULL, 1, 0);
510508
zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, NULL /* empty element */);
@@ -1281,22 +1279,13 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
12811279
int i;
12821280
zend_file_handle *file_handle;
12831281
zend_op_array *op_array;
1284-
zend_long orig_interactive = CG(interactive);
12851282

12861283
va_start(files, file_count);
12871284
for (i = 0; i < file_count; i++) {
12881285
file_handle = va_arg(files, zend_file_handle *);
12891286
if (!file_handle) {
12901287
continue;
12911288
}
1292-
1293-
if (orig_interactive) {
1294-
if (file_handle->filename[0] != '-' || file_handle->filename[1]) {
1295-
CG(interactive) = 0;
1296-
} else {
1297-
CG(interactive) = 1;
1298-
}
1299-
}
13001289

13011290
op_array = zend_compile_file(file_handle, type TSRMLS_CC);
13021291
if (file_handle->opened_path) {
@@ -1335,12 +1324,10 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
13351324
efree(op_array);
13361325
} else if (type==ZEND_REQUIRE) {
13371326
va_end(files);
1338-
CG(interactive) = orig_interactive;
13391327
return FAILURE;
13401328
}
13411329
}
13421330
va_end(files);
1343-
CG(interactive) = orig_interactive;
13441331

13451332
return SUCCESS;
13461333
}

Zend/zend_compile.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@
6363
static inline void zend_alloc_cache_slot(uint32_t literal TSRMLS_DC) {
6464
zend_op_array *op_array = CG(active_op_array);
6565
Z_CACHE_SLOT(op_array->literals[literal]) = op_array->last_cache_slot++;
66-
if ((op_array->fn_flags & ZEND_ACC_INTERACTIVE) && op_array->run_time_cache) {
67-
op_array->run_time_cache = erealloc(op_array->run_time_cache,
68-
op_array->last_cache_slot * sizeof(void*));
69-
op_array->run_time_cache[CG(active_op_array)->last_cache_slot - 1] = NULL;
70-
}
7166
}
7267

7368
#define POLYMORPHIC_CACHE_SLOT_SIZE 2
@@ -76,12 +71,6 @@ static inline void zend_alloc_polymorphic_cache_slot(uint32_t literal TSRMLS_DC)
7671
zend_op_array *op_array = CG(active_op_array);
7772
Z_CACHE_SLOT(op_array->literals[literal]) = op_array->last_cache_slot;
7873
op_array->last_cache_slot += POLYMORPHIC_CACHE_SLOT_SIZE;
79-
if ((op_array->fn_flags & ZEND_ACC_INTERACTIVE) && op_array->run_time_cache) {
80-
op_array->run_time_cache = erealloc(
81-
op_array->run_time_cache, op_array->last_cache_slot * sizeof(void *));
82-
op_array->run_time_cache[op_array->last_cache_slot - 1] = NULL;
83-
op_array->run_time_cache[op_array->last_cache_slot - 2] = NULL;
84-
}
8574
}
8675

8776
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) /* {{{ */
178167

179168
void zend_init_compiler_context(TSRMLS_D) /* {{{ */
180169
{
181-
CG(context).opcodes_size = (CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE) ? INITIAL_INTERACTIVE_OP_ARRAY_SIZE : INITIAL_OP_ARRAY_SIZE;
170+
CG(context).opcodes_size = INITIAL_OP_ARRAY_SIZE;
182171
CG(context).vars_size = 0;
183172
CG(context).literals_size = 0;
184173
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
837826
zend_error_noreturn(E_COMPILE_ERROR, "'goto' to undefined label '%s'", Z_STRVAL_P(label));
838827
} else {
839828
/* Label is not defined. Delay to pass 2. */
840-
INC_BPC(op_array);
841829
return;
842830
}
843831
}
@@ -869,10 +857,6 @@ void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2
869857
/* Set real break distance */
870858
ZVAL_LONG(label, distance);
871859
}
872-
873-
if (pass2) {
874-
DEC_BPC(op_array);
875-
}
876860
}
877861
/* }}} */
878862

Zend/zend_compile.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535

3636
#define SET_UNUSED(op) op ## _type = IS_UNUSED
3737

38-
#define INC_BPC(op_array) if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { (CG(context).backpatch_count++); }
39-
#define DEC_BPC(op_array) if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { (CG(context).backpatch_count--); }
40-
#define HANDLE_INTERACTIVE() if (CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE) { execute_new_code(TSRMLS_C); }
41-
4238
#define RESET_DOC_COMMENT() do { \
4339
if (CG(doc_comment)) { \
4440
zend_string_release(CG(doc_comment)); \
@@ -173,9 +169,6 @@ typedef struct _zend_try_catch_element {
173169
#define ZEND_ACC_INTERFACE 0x80
174170
#define ZEND_ACC_TRAIT 0x120
175171

176-
/* op_array flags */
177-
#define ZEND_ACC_INTERACTIVE 0x10
178-
179172
/* method flags (visibility) */
180173
/* The order of those must be kept - public < protected < private */
181174
#define ZEND_ACC_PUBLIC 0x100
@@ -491,7 +484,6 @@ void zend_release_labels(int temporary TSRMLS_DC);
491484
ZEND_API void function_add_ref(zend_function *function);
492485

493486
#define INITIAL_OP_ARRAY_SIZE 64
494-
#define INITIAL_INTERACTIVE_OP_ARRAY_SIZE 8192
495487

496488

497489
/* helper functions in zend_language_scanner.l */

Zend/zend_execute.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execu
16251625
EX(delayed_exception) = NULL;
16261626
EX(call) = NULL;
16271627

1628-
EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes;
1628+
EX(opline) = op_array->opcodes;
16291629
EX(scope) = EG(scope);
16301630

16311631
zend_attach_symbol_table(execute_data);
@@ -1654,7 +1654,7 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da
16541654
EX(delayed_exception) = NULL;
16551655
EX(call) = NULL;
16561656

1657-
EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes;
1657+
EX(opline) = op_array->opcodes;
16581658
EX(scope) = EG(scope);
16591659

16601660
if (UNEXPECTED(EX(symbol_table) != NULL)) {

Zend/zend_execute.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,6 @@ static zend_always_inline void zend_vm_stack_free_call_frame(zend_execute_data *
269269
}
270270
}
271271

272-
void execute_new_code(TSRMLS_D);
273-
274-
275272
/* services */
276273
ZEND_API const char *get_active_class_name(const char **space TSRMLS_DC);
277274
ZEND_API const char *get_active_function_name(TSRMLS_D);

Zend/zend_execute_API.c

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,10 +1084,8 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s
10841084

10851085
if (new_op_array) {
10861086
zval local_retval;
1087-
int orig_interactive = CG(interactive);
10881087

10891088
EG(no_extensions)=1;
1090-
CG(interactive) = 0;
10911089

10921090
zend_try {
10931091
ZVAL_UNDEF(&local_retval);
@@ -1098,7 +1096,6 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s
10981096
zend_bailout();
10991097
} zend_end_try();
11001098

1101-
CG(interactive) = orig_interactive;
11021099
if (Z_TYPE(local_retval) != IS_UNDEF) {
11031100
if (retval_ptr) {
11041101
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,
11481145
}
11491146
/* }}} */
11501147

1151-
void execute_new_code(TSRMLS_D) /* {{{ */
1152-
{
1153-
zend_op *opline, *end;
1154-
zend_op *ret_opline;
1155-
int orig_interactive;
1156-
1157-
if (!(CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE)
1158-
|| CG(context).backpatch_count>0
1159-
|| CG(active_op_array)->function_name
1160-
|| CG(active_op_array)->type!=ZEND_USER_FUNCTION) {
1161-
return;
1162-
}
1163-
1164-
ret_opline = get_next_op(CG(active_op_array) TSRMLS_CC);
1165-
ret_opline->opcode = ZEND_RETURN;
1166-
ret_opline->op1_type = IS_CONST;
1167-
ret_opline->op1.constant = zend_add_literal(CG(active_op_array), &EG(uninitialized_zval) TSRMLS_CC);
1168-
SET_UNUSED(ret_opline->op2);
1169-
1170-
if (!EG(start_op)) {
1171-
EG(start_op) = CG(active_op_array)->opcodes;
1172-
}
1173-
1174-
opline=EG(start_op);
1175-
end=CG(active_op_array)->opcodes+CG(active_op_array)->last;
1176-
1177-
while (opline<end) {
1178-
if (opline->op1_type == IS_CONST) {
1179-
opline->op1.zv = &CG(active_op_array)->literals[opline->op1.constant];
1180-
}
1181-
if (opline->op2_type == IS_CONST) {
1182-
opline->op2.zv = &CG(active_op_array)->literals[opline->op2.constant];
1183-
}
1184-
switch (opline->opcode) {
1185-
case ZEND_GOTO:
1186-
if (Z_TYPE_P(opline->op2.zv) != IS_LONG) {
1187-
zend_resolve_goto_label(CG(active_op_array), opline, 1 TSRMLS_CC);
1188-
}
1189-
/* break omitted intentionally */
1190-
case ZEND_JMP:
1191-
opline->op1.jmp_addr = &CG(active_op_array)->opcodes[opline->op1.opline_num];
1192-
break;
1193-
case ZEND_JMPZNZ:
1194-
/* absolute index to relative offset */
1195-
opline->extended_value = (char*)(CG(active_op_array)->opcodes + opline->extended_value) - (char*)opline;
1196-
/* break omitted intentionally */
1197-
case ZEND_JMPZ:
1198-
case ZEND_JMPNZ:
1199-
case ZEND_JMPZ_EX:
1200-
case ZEND_JMPNZ_EX:
1201-
case ZEND_JMP_SET:
1202-
case ZEND_JMP_SET_VAR:
1203-
case ZEND_NEW:
1204-
case ZEND_FE_RESET:
1205-
case ZEND_FE_FETCH:
1206-
opline->op2.jmp_addr = &CG(active_op_array)->opcodes[opline->op2.opline_num];
1207-
break;
1208-
}
1209-
ZEND_VM_SET_OPCODE_HANDLER(opline);
1210-
opline++;
1211-
}
1212-
1213-
zend_release_labels(1 TSRMLS_CC);
1214-
1215-
orig_interactive = CG(interactive);
1216-
CG(interactive) = 0;
1217-
zend_execute(CG(active_op_array), NULL TSRMLS_CC);
1218-
CG(interactive) = orig_interactive;
1219-
1220-
if (EG(exception)) {
1221-
zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
1222-
}
1223-
1224-
CG(active_op_array)->last -= 1; /* get rid of that ZEND_RETURN */
1225-
EG(start_op) = CG(active_op_array)->opcodes+CG(active_op_array)->last;
1226-
}
1227-
/* }}} */
1228-
12291148
ZEND_API void zend_timeout(int dummy) /* {{{ */
12301149
{
12311150
TSRMLS_FETCH();

Zend/zend_globals.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ struct _zend_compiler_globals {
104104

105105
struct _zend_ini_parser_param *ini_parser_param;
106106

107-
int interactive;
108-
109107
uint32_t start_lineno;
110108
zend_bool increment_lineno;
111109

0 commit comments

Comments
 (0)