zval结构体
PHP5的zval的定义:结构体的大小是(在64位系统)24个字节
struct _zval_struct {
union {
long lval;
double dval;
struct {
char *val;
int len;
} str;
HashTable *ht;
zend_object_value obj;
zend_ast *ast;
} value;
zend_uint refcount__gc;
zend_uchar type;
zend_uchar is_ref__gc;
};
PHP7的zval的定义: 全部都是联合体, 这个新的zval在64位环境下,现在只需要16个字节(2个指针size)
struct _zval_struct {
zend_value value; /* value 根据u1de type来决定使用哪个类型*/
union {
struct {
ZEND_ENDIAN_LOHI_3(
zend_uchar type, /* active type 代表数据的类型*/
zend_uchar type_flags,
union {
uint16_t extra; /* not further specified */
} u)
} v;
uint32_t type_info;
} u1;
union {
uint32_t next; /* hash collision chain 数组中hash冲突使用*/
uint32_t cache_slot; /* cache slot (for RECV_INIT) */
uint32_t opline_num; /* opline number (for FAST_CALL) */
uint32_t lineno; /* line number (for ast nodes) */
uint32_t num_args; /* arguments number for EX(This) */
uint32_t fe_pos; /* foreach position */
uint32_t fe_iter_idx; /* foreach iterator index */
uint32_t access_flags; /* class constant access flags */
uint32_t property_guard; /* single property guard */
uint32_t constant_flags