Skip to content

Commit 6904407

Browse files
committed
Paired instuctions frequientiy used together (e.g. comparisons + conditional jumps)
1 parent c2ef8a9 commit 6904407

File tree

3 files changed

+1998
-1576
lines changed

3 files changed

+1998
-1576
lines changed

Zend/zend_execute.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,11 +2215,40 @@ static zend_always_inline zend_generator *zend_get_running_generator(zend_execut
22152215
#define ZEND_VM_INC_OPCODE() \
22162216
OPLINE++
22172217

2218-
#define ZEND_VM_REPEATABLE_OPCODE \
2219-
do {
22202218

2221-
#define ZEND_VM_REPEAT_OPCODE(_opcode) \
2219+
#ifndef VM_SMART_OPCODES
2220+
# define VM_SMART_OPCODES 1
2221+
#endif
2222+
2223+
#if VM_SMART_OPCODES
2224+
# define ZEND_VM_REPEATABLE_OPCODE \
2225+
do {
2226+
# define ZEND_VM_REPEAT_OPCODE(_opcode) \
22222227
} while (UNEXPECTED(OPLINE->opcode == _opcode))
2228+
# define ZEND_VM_SMART_BRANCH(_result, _check) do { \
2229+
int __result; \
2230+
if (EXPECTED((opline+1)->opcode == ZEND_JMPZ)) { \
2231+
__result = (_result); \
2232+
} else if (EXPECTED((opline+1)->opcode == ZEND_JMPNZ)) { \
2233+
__result = !(_result); \
2234+
} else { \
2235+
break; \
2236+
} \
2237+
if ((_check) && UNEXPECTED(EG(exception))) { \
2238+
HANDLE_EXCEPTION(); \
2239+
} \
2240+
if (__result) { \
2241+
ZEND_VM_SET_NEXT_OPCODE(opline + 2); \
2242+
} else { \
2243+
ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline + 1, (opline+1)->op2)); \
2244+
} \
2245+
ZEND_VM_CONTINUE(); \
2246+
} while (0)
2247+
#else
2248+
# define ZEND_VM_REPEATABLE_OPCODE
2249+
# define ZEND_VM_REPEAT_OPCODE(_opcode)
2250+
# define ZEND_VM_SMART_BRANCH(_result, _check)
2251+
#endif
22232252

22242253
#ifdef __GNUC__
22252254
# define ZEND_VM_GUARD(name) __asm__("#" #name)

0 commit comments

Comments
 (0)