Browse Source

Reorder fields for better nenory consumtion and data locality on 64-bit systems

pull/382/merge
Dmitry Stogov 12 years ago
parent
commit
ee552b628c
  1. 12
      Zend/zend.h
  2. 2
      Zend/zend_compile.c
  3. 31
      Zend/zend_compile.h
  4. 2
      Zend/zend_execute.c
  5. 2
      Zend/zend_generators.c
  6. 3
      Zend/zend_opcode.c
  7. 2
      ext/opcache/Optimizer/block_pass.c
  8. 10
      ext/opcache/Optimizer/pass3.c

12
Zend/zend.h

@ -476,14 +476,14 @@ struct _zend_class_entry {
int refcount; int refcount;
uint32_t ce_flags; uint32_t ce_flags;
HashTable function_table;
HashTable properties_info;
int default_properties_count;
int default_static_members_count;
zval *default_properties_table; zval *default_properties_table;
zval *default_static_members_table; zval *default_static_members_table;
zval *static_members_table; zval *static_members_table;
HashTable function_table;
HashTable properties_info;
HashTable constants_table; HashTable constants_table;
int default_properties_count;
int default_static_members_count;
union _zend_function *constructor; union _zend_function *constructor;
union _zend_function *destructor; union _zend_function *destructor;
@ -511,11 +511,11 @@ struct _zend_class_entry {
int (*serialize)(zval *object, unsigned char **buffer, uint32_t *buf_len, zend_serialize_data *data TSRMLS_DC); int (*serialize)(zval *object, unsigned char **buffer, uint32_t *buf_len, zend_serialize_data *data TSRMLS_DC);
int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, uint32_t buf_len, zend_unserialize_data *data TSRMLS_DC); int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, uint32_t buf_len, zend_unserialize_data *data TSRMLS_DC);
zend_class_entry **interfaces;
uint32_t num_interfaces; uint32_t num_interfaces;
uint32_t num_traits;
zend_class_entry **interfaces;
zend_class_entry **traits; zend_class_entry **traits;
uint32_t num_traits;
zend_trait_alias **trait_aliases; zend_trait_alias **trait_aliases;
zend_trait_precedence **trait_precedences; zend_trait_precedence **trait_precedences;

2
Zend/zend_compile.c

@ -5095,7 +5095,7 @@ void zend_compile_try(zend_ast *ast TSRMLS_DC) {
CG(active_op_array)->try_catch_array[try_catch_offset].finally_op = opnum_jmp + 1; CG(active_op_array)->try_catch_array[try_catch_offset].finally_op = opnum_jmp + 1;
CG(active_op_array)->try_catch_array[try_catch_offset].finally_end CG(active_op_array)->try_catch_array[try_catch_offset].finally_end
= get_next_op_number(CG(active_op_array)); = get_next_op_number(CG(active_op_array));
CG(active_op_array)->has_finally_block = 1;
CG(active_op_array)->fn_flags |= ZEND_ACC_HAS_FINALLY_BLOCK;
zend_emit_op(NULL, ZEND_FAST_RET, NULL, NULL TSRMLS_CC); zend_emit_op(NULL, ZEND_FAST_RET, NULL, NULL TSRMLS_CC);

31
Zend/zend_compile.h

@ -221,15 +221,17 @@ typedef struct _zend_try_catch_element {
/* function has arguments with type hinting */ /* function has arguments with type hinting */
#define ZEND_ACC_HAS_TYPE_HINTS 0x10000000 #define ZEND_ACC_HAS_TYPE_HINTS 0x10000000
/* op_array has finally blocks */
#define ZEND_ACC_HAS_FINALLY_BLOCK 0x20000000
#define ZEND_CE_IS_TRAIT(ce) (((ce)->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) #define ZEND_CE_IS_TRAIT(ce) (((ce)->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT)
char *zend_visibility_string(uint32_t fn_flags); char *zend_visibility_string(uint32_t fn_flags);
typedef struct _zend_property_info { typedef struct _zend_property_info {
uint32_t flags; uint32_t flags;
zend_string *name;
zend_ulong h;
int offset; int offset;
zend_string *name;
zend_string *doc_comment; zend_string *doc_comment;
zend_class_entry *ce; zend_class_entry *ce;
} zend_property_info; } zend_property_info;
@ -263,9 +265,9 @@ typedef struct _zend_internal_function_info {
struct _zend_op_array { struct _zend_op_array {
/* Common elements */ /* Common elements */
zend_uchar type; zend_uchar type;
uint32_t fn_flags;
zend_string *function_name; zend_string *function_name;
zend_class_entry *scope; zend_class_entry *scope;
uint32_t fn_flags;
zend_function *prototype; zend_function *prototype;
uint32_t num_args; uint32_t num_args;
uint32_t required_num_args; uint32_t required_num_args;
@ -274,37 +276,34 @@ struct _zend_op_array {
uint32_t *refcount; uint32_t *refcount;
zend_op *opcodes;
uint32_t this_var;
uint32_t last; uint32_t last;
zend_op *opcodes;
zend_string **vars;
int last_var; int last_var;
uint32_t T; uint32_t T;
zend_string **vars;
zend_brk_cont_element *brk_cont_array;
int last_brk_cont; int last_brk_cont;
zend_try_catch_element *try_catch_array;
int last_try_catch; int last_try_catch;
zend_bool has_finally_block;
zend_brk_cont_element *brk_cont_array;
zend_try_catch_element *try_catch_array;
/* static variables support */ /* static variables support */
HashTable *static_variables; HashTable *static_variables;
uint32_t this_var;
zend_string *filename; zend_string *filename;
uint32_t line_start; uint32_t line_start;
uint32_t line_end; uint32_t line_end;
zend_string *doc_comment; zend_string *doc_comment;
uint32_t early_binding; /* the linked list of delayed declarations */ uint32_t early_binding; /* the linked list of delayed declarations */
zval *literals;
int last_literal; int last_literal;
zval *literals;
void **run_time_cache;
int last_cache_slot; int last_cache_slot;
void **run_time_cache;
void *reserved[ZEND_MAX_RESERVED_RESOURCES]; void *reserved[ZEND_MAX_RESERVED_RESOURCES];
}; };
@ -316,9 +315,9 @@ struct _zend_op_array {
typedef struct _zend_internal_function { typedef struct _zend_internal_function {
/* Common elements */ /* Common elements */
zend_uchar type; zend_uchar type;
uint32_t fn_flags;
zend_string* function_name; zend_string* function_name;
zend_class_entry *scope; zend_class_entry *scope;
uint32_t fn_flags;
zend_function *prototype; zend_function *prototype;
uint32_t num_args; uint32_t num_args;
uint32_t required_num_args; uint32_t required_num_args;
@ -336,9 +335,9 @@ union _zend_function {
struct { struct {
zend_uchar type; /* never used */ zend_uchar type; /* never used */
uint32_t fn_flags;
zend_string *function_name; zend_string *function_name;
zend_class_entry *scope; zend_class_entry *scope;
uint32_t fn_flags;
union _zend_function *prototype; union _zend_function *prototype;
uint32_t num_args; uint32_t num_args;
uint32_t required_num_args; uint32_t required_num_args;

2
Zend/zend_execute.c

@ -70,9 +70,9 @@ static ZEND_FUNCTION(pass)
static const zend_internal_function zend_pass_function = { static const zend_internal_function zend_pass_function = {
ZEND_INTERNAL_FUNCTION, /* type */ ZEND_INTERNAL_FUNCTION, /* type */
0, /* fn_flags */
NULL, /* name */ NULL, /* name */
NULL, /* scope */ NULL, /* scope */
0, /* fn_flags */
NULL, /* prototype */ NULL, /* prototype */
0, /* num_args */ 0, /* num_args */
0, /* required_num_args */ 0, /* required_num_args */

2
Zend/zend_generators.c

@ -146,7 +146,7 @@ static void zend_generator_dtor_storage(zend_object *object TSRMLS_DC) /* {{{ */
uint32_t op_num, finally_op_num; uint32_t op_num, finally_op_num;
int i; int i;
if (!ex || !ex->func->op_array.has_finally_block) {
if (!ex || !(ex->func->op_array.fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK)) {
return; return;
} }

3
Zend/zend_opcode.c

@ -80,7 +80,6 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz
op_array->static_variables = NULL; op_array->static_variables = NULL;
op_array->last_try_catch = 0; op_array->last_try_catch = 0;
op_array->has_finally_block = 0;
op_array->this_var = -1; op_array->this_var = -1;
@ -678,7 +677,7 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC)
if (!ZEND_USER_CODE(op_array->type)) { if (!ZEND_USER_CODE(op_array->type)) {
return 0; return 0;
} }
if (op_array->has_finally_block) {
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
zend_resolve_finally_calls(op_array TSRMLS_CC); zend_resolve_finally_calls(op_array TSRMLS_CC);
} }
if (CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO) { if (CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO) {

2
ext/opcache/Optimizer/block_pass.c

@ -1952,7 +1952,7 @@ static void zend_block_optimization(zend_op_array *op_array, zend_optimizer_ctx
fflush(stderr); fflush(stderr);
#endif #endif
if (op_array->has_finally_block) {
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
return; return;
} }

10
ext/opcache/Optimizer/pass3.c

@ -153,7 +153,7 @@ if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) {
break; break;
case ZEND_JMP: case ZEND_JMP:
if (op_array->has_finally_block) {
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
break; break;
} }
@ -174,7 +174,7 @@ if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) {
case ZEND_JMP_SET: case ZEND_JMP_SET:
case ZEND_JMP_SET_VAR: case ZEND_JMP_SET_VAR:
if (op_array->has_finally_block) {
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
break; break;
} }
@ -189,7 +189,7 @@ if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) {
break; break;
case ZEND_JMPZ: case ZEND_JMPZ:
case ZEND_JMPNZ: case ZEND_JMPNZ:
if (op_array->has_finally_block) {
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
break; break;
} }
@ -245,7 +245,7 @@ if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) {
zend_uchar T_type = opline->result_type; zend_uchar T_type = opline->result_type;
znode_op T = opline->result; znode_op T = opline->result;
if (op_array->has_finally_block) {
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
break; break;
} }
@ -379,7 +379,7 @@ continue_jmp_ex_optimization:
break; break;
case ZEND_JMPZNZ: case ZEND_JMPZNZ:
if (op_array->has_finally_block) {
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
break; break;
} }

Loading…
Cancel
Save