Browse Source

Use 'const' qualifier for pointrs to code used at run-time (the code must not be changed)

pull/382/merge
Dmitry Stogov 11 years ago
parent
commit
f2b0370193
  1. 2
      Zend/zend.c
  2. 2
      Zend/zend_compile.c
  3. 6
      Zend/zend_compile.h
  4. 4
      Zend/zend_execute.c
  5. 2
      Zend/zend_globals.h
  6. 2
      Zend/zend_vm_def.h
  7. 8
      Zend/zend_vm_execute.h
  8. 8
      Zend/zend_vm_gen.php
  9. 2
      ext/opcache/ZendAccelerator.h

2
Zend/zend.c

@ -1029,7 +1029,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
/* Report about uncaught exception in case of fatal errors */
if (EG(exception)) {
zend_execute_data *ex;
zend_op *opline;
const zend_op *opline;
switch (type) {
case E_CORE_ERROR:

2
Zend/zend_compile.c

@ -2475,7 +2475,7 @@ ZEND_API void zend_do_bind_traits(zend_class_entry *ce TSRMLS_DC) /* {{{ */
}
/* }}} */
ZEND_API int do_bind_function(const zend_op_array *op_array, zend_op *opline, HashTable *function_table, zend_bool compile_time TSRMLS_DC) /* {{{ */
ZEND_API int do_bind_function(const zend_op_array *op_array, const zend_op *opline, HashTable *function_table, zend_bool compile_time TSRMLS_DC) /* {{{ */
{
zend_function *function, *new_function;
zval *op1, *op2;

6
Zend/zend_compile.h

@ -362,7 +362,7 @@ typedef enum _vm_frame_kind {
} vm_frame_kind;
struct _zend_execute_data {
struct _zend_op *opline; /* executed opline */
const zend_op *opline; /* executed opline */
zend_execute_data *call; /* current call */
void **run_time_cache;
zend_function *func; /* executed op_array */
@ -376,7 +376,7 @@ struct _zend_execute_data {
zval *return_value;
zend_class_entry *scope; /* function scope (self) */
zend_array *symbol_table;
struct _zend_op *fast_ret; /* used by FAST_CALL/FAST_RET (finally keyword) */
const zend_op *fast_ret; /* used by FAST_CALL/FAST_RET (finally keyword) */
zend_object *delayed_exception;
zval old_error_reporting;
};
@ -453,7 +453,7 @@ void zend_handle_encoding_declaration(zend_ast_list *declares TSRMLS_DC);
/* parser-driven code generators */
void zend_do_free(znode *op1 TSRMLS_DC);
ZEND_API int do_bind_function(const zend_op_array *op_array, zend_op *opline, HashTable *function_table, zend_bool compile_time TSRMLS_DC);
ZEND_API int do_bind_function(const zend_op_array *op_array, const zend_op *opline, HashTable *function_table, zend_bool compile_time TSRMLS_DC);
ZEND_API zend_class_entry *do_bind_class(const zend_op_array *op_array, const zend_op *opline, HashTable *class_table, zend_bool compile_time TSRMLS_DC);
ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array, const zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time TSRMLS_DC);
ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface TSRMLS_DC);

4
Zend/zend_execute.c

@ -668,7 +668,7 @@ static void zend_verify_missing_arg(zend_execute_data *execute_data, uint32_t ar
}
}
static inline void zend_assign_to_object(zval *retval, zval *object_ptr, zval *property_name, int value_type, znode_op *value_op, const zend_execute_data *execute_data, int opcode, void **cache_slot TSRMLS_DC)
static inline void zend_assign_to_object(zval *retval, zval *object_ptr, zval *property_name, int value_type, const znode_op *value_op, const zend_execute_data *execute_data, int opcode, void **cache_slot TSRMLS_DC)
{
zend_free_op free_value;
zval *value = get_zval_ptr(value_type, value_op, execute_data, &free_value, BP_VAR_R);
@ -1751,7 +1751,7 @@ ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_ar
}
/* }}} */
static zend_always_inline zend_bool zend_is_by_ref_func_arg_fetch(zend_op *opline, zend_execute_data *call TSRMLS_DC) /* {{{ */
static zend_always_inline zend_bool zend_is_by_ref_func_arg_fetch(const zend_op *opline, zend_execute_data *call TSRMLS_DC) /* {{{ */
{
uint32_t arg_num = opline->extended_value & ZEND_FETCH_ARG_MASK;
return ARG_SHOULD_BE_SENT_BY_REF(call->func, arg_num);

2
Zend/zend_globals.h

@ -219,7 +219,7 @@ struct _zend_executor_globals {
zend_objects_store objects_store;
zend_object *exception, *prev_exception;
zend_op *opline_before_exception;
const zend_op *opline_before_exception;
zend_op exception_op[3];
struct _zend_execute_data *current_execute_data;

2
Zend/zend_vm_def.h

@ -1815,7 +1815,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
EG(scope) = EX(scope);
if (UNEXPECTED(EG(exception) != NULL)) {
zend_op *opline = EX(opline);
const zend_op *opline = EX(opline);
zend_throw_exception_internal(NULL TSRMLS_CC);
if (RETURN_VALUE_USED(opline)) {
zval_ptr_dtor(EX_VAR(opline->result.var));

8
Zend/zend_vm_execute.h

@ -306,7 +306,7 @@ static zend_uchar zend_user_opcodes[256] = {0,
241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
};
static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op);
static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, const zend_op* op);
#undef OPLINE
@ -316,7 +316,7 @@ static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* o
#undef SAVE_OPLINE
#define OPLINE EX(opline)
#define DCL_OPLINE
#define USE_OPLINE zend_op *opline = EX(opline);
#define USE_OPLINE const zend_op *opline = EX(opline);
#define LOAD_OPLINE()
#define SAVE_OPLINE()
#undef CHECK_EXCEPTION
@ -420,7 +420,7 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
EG(scope) = EX(scope);
if (UNEXPECTED(EG(exception) != NULL)) {
zend_op *opline = EX(opline);
const zend_op *opline = EX(opline);
zend_throw_exception_internal(NULL TSRMLS_CC);
if (RETURN_VALUE_USED(opline)) {
zval_ptr_dtor(EX_VAR(opline->result.var));
@ -47851,7 +47851,7 @@ void zend_init_opcodes_handlers(void)
};
zend_opcode_handlers = (opcode_handler_t*)labels;
}
static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op)
static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, const zend_op* op)
{
static const int zend_vm_decode[] = {
_UNUSED_CODE, /* 0 */

8
Zend/zend_vm_gen.php

@ -884,7 +884,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name,
if (ZEND_VM_OLD_EXECUTOR && $spec) {
out($f,"static int zend_vm_old_executor = 0;\n\n");
}
out($f,"static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op);\n\n");
out($f,"static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, const zend_op* op);\n\n");
switch ($kind) {
case ZEND_VM_KIND_CALL:
out($f,"\n");
@ -895,7 +895,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name,
out($f,"#undef SAVE_OPLINE\n");
out($f,"#define OPLINE EX(opline)\n");
out($f,"#define DCL_OPLINE\n");
out($f,"#define USE_OPLINE zend_op *opline = EX(opline);\n");
out($f,"#define USE_OPLINE const zend_op *opline = EX(opline);\n");
out($f,"#define LOAD_OPLINE()\n");
out($f,"#define SAVE_OPLINE()\n");
out($f,"#undef CHECK_EXCEPTION\n");
@ -1333,7 +1333,7 @@ function gen_vm($def, $skel) {
}
// Generate zend_vm_get_opcode_handler() function
out($f, "static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op)\n");
out($f, "static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, const zend_op* op)\n");
out($f, "{\n");
if (!ZEND_VM_SPEC) {
out($f, "\treturn zend_opcode_handlers[opcode];\n");
@ -1386,7 +1386,7 @@ function gen_vm($def, $skel) {
out($f,"#undef SAVE_OPLINE\n");
out($f,"#define OPLINE EX(opline)\n");
out($f,"#define DCL_OPLINE\n");
out($f,"#define USE_OPLINE zend_op *opline = EX(opline);\n");
out($f,"#define USE_OPLINE const zend_op *opline = EX(opline);\n");
out($f,"#define LOAD_OPLINE()\n");
out($f,"#define SAVE_OPLINE()\n");
out($f,"#undef CHECK_EXCEPTION\n");

2
ext/opcache/ZendAccelerator.h

@ -235,7 +235,7 @@ typedef struct _zend_accel_globals {
/* preallocated shared-memory block to save current script */
void *mem;
/* cache to save hash lookup on the same INCLUDE opcode */
zend_op *cache_opline;
const zend_op *cache_opline;
zend_persistent_script *cache_persistent_script;
/* preallocated buffer for keys */
int key_len;

Loading…
Cancel
Save