Skip to content

Commit cb8f39f

Browse files
committed
Add zend_get_opcode_id() to get opcode id from name
1 parent 4af6679 commit cb8f39f

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

UPGRADING.INTERNALS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ PHP 8.1 INTERNALS UPGRADE NOTES
33
1. Internal API changes
44
a. Removed Zend APIs
55
b. Zend Stream API
6+
c. zend_get_opcode_id()
67

78
2. Build system changes
89

910
3. Module changes
1011
a. ext/hash
12+
b. ext/pdo
13+
c. ext/standard
1114

1215
========================
1316
1. Internal API changes
@@ -31,6 +34,7 @@ PHP 8.1 INTERNALS UPGRADE NOTES
3134
the same function where they were created by zend_stream_init_*()). Previously there were two different
3235
destructors zend_destroy_file_handle() and zend_file_handle_dtor().
3336
- zend_ini_scanner_globals.filename now is zend_string*
37+
c. Added the zend_get_opcode_id() function, which is intended to get opcode id from name.
3438

3539
========================
3640
2. Build system changes

Zend/zend_vm_opcodes.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,12 @@ ZEND_API uint32_t ZEND_FASTCALL zend_get_opcode_flags(zend_uchar opcode) {
442442
}
443443
return zend_vm_opcodes_flags[opcode];
444444
}
445+
ZEND_API zend_uchar zend_get_opcode_id(const char *name, size_t length) {
446+
zend_uchar opcode;
447+
for (opcode = 0; opcode < (sizeof(zend_vm_opcodes_names) / sizeof(zend_vm_opcodes_names[0])) - 1; opcode++) {
448+
if (strncmp(zend_vm_opcodes_names[opcode], name, length) == 0) {
449+
return opcode;
450+
}
451+
}
452+
return ZEND_VM_LAST_OPCODE + 1;
453+
}

Zend/zend_vm_opcodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ BEGIN_EXTERN_C()
7979

8080
ZEND_API const char* ZEND_FASTCALL zend_get_opcode_name(zend_uchar opcode);
8181
ZEND_API uint32_t ZEND_FASTCALL zend_get_opcode_flags(zend_uchar opcode);
82+
ZEND_API zend_uchar zend_get_opcode_id(const char *name, size_t length);
8283

8384
END_EXTERN_C()
8485

0 commit comments

Comments
 (0)