Skip to content

Commit 285bfb9

Browse files
committed
Optimize "backup" functions of inlined opcode handlers for size
1 parent 3778abf commit 285bfb9

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Zend/zend_portability.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,19 @@ char *alloca();
221221
# define ZEND_ATTRIBUTE_UNUSED __attribute__((unused))
222222
# define ZEND_COLD __attribute__((cold))
223223
# define ZEND_HOT __attribute__((hot))
224+
# ifdef __OPTIMIZE__
225+
# define ZEND_OPT_SIZE __attribute__((optimize("Os")))
226+
# define ZEND_OPT_SPEED __attribute__((optimize("Ofast")))
227+
# else
228+
# define ZEND_OPT_SIZE
229+
# define ZEND_OPT_SPEED
230+
# endif
224231
#else
225232
# define ZEND_ATTRIBUTE_UNUSED
226233
# define ZEND_COLD
227234
# define ZEND_HOT
235+
# define ZEND_OPT_SIZE
236+
# define ZEND_OPT_SPEED
228237
#endif
229238

230239
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 5000

Zend/zend_vm_execute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ static const void *zend_vm_get_opcode_handler_func(zend_uchar opcode, const zend
366366
# endif
367367
# if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID)
368368
# define ZEND_VM_RETURN() opline = &hybrid_halt_op; return
369-
# define ZEND_VM_HOT zend_always_inline
369+
# define ZEND_VM_HOT zend_always_inline ZEND_OPT_SIZE
370370
# else
371371
# define ZEND_VM_RETURN() opline = NULL; return
372372
# define ZEND_VM_HOT

Zend/zend_vm_gen.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
17451745
if ($kind == ZEND_VM_KIND_HYBRID) {
17461746
out($f,"# if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID)\n");
17471747
out($f,"# define ZEND_VM_RETURN() opline = &hybrid_halt_op; return\n");
1748-
out($f,"# define ZEND_VM_HOT zend_always_inline\n");
1748+
out($f,"# define ZEND_VM_HOT zend_always_inline ZEND_OPT_SIZE\n");
17491749
out($f,"# else\n");
17501750
out($f,"# define ZEND_VM_RETURN() opline = NULL; return\n");
17511751
out($f,"# define ZEND_VM_HOT\n");

0 commit comments

Comments
 (0)