Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is OPCODE in the PHP kernel

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about what OPCODE is in the PHP kernel. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

OPCODE

What is OPCODE? It is an instruction that a virtual machine can recognize and process. The Zend virtual machine contains a series of OPCODE, and many things can be done through the OPCODE virtual machine. Here are a few examples of OPCODE:

ZEND_ADD adds two operands.

ZEND_NEW creates a PHP object.

ZEND_ECHO outputs the content to standard output.

ZEND_EXIT exits PHP.

For operations like this, PHP defines 186 (more kinds of OPCODE will certainly be supported as PHP is updated), and all OPCODE definitions and implementations can be found in the source zend/zend_vm_def.h file (the content of this file is not native C code, but a template, which will explain why).

Let's take a look at how PHP designs OPCODE data structures:

Struct _ zend_op {const void * handler;znode_op op1;znode_op op2;znode_op result;uint32_t extended_value;uint32_t lineno;zend_uchar opcode;zend_uchar op1_type;zend_uchar op2_type;zend_uchar result_type;}

Take a closer look at the data structure of OPCODE to see if you can find the feel of assembly language. Each OPCODE contains two operands, and the op1 and op2,handler pointers point to the function that performs the OPCODE operation. The result of the function is stored in the result.

Let's give a simple example:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report