PHP7系列:对zval的优化(三)

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
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值