zend_optimizer_internal.h 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend OPcache |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1998-2016 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Andi Gutmans <andi@zend.com> |
  16. | Zeev Suraski <zeev@zend.com> |
  17. | Stanislav Malyshev <stas@zend.com> |
  18. | Dmitry Stogov <dmitry@zend.com> |
  19. +----------------------------------------------------------------------+
  20. */
  21. #ifndef ZEND_OPTIMIZER_INTERNAL_H
  22. #define ZEND_OPTIMIZER_INTERNAL_H
  23. #include "ZendAccelerator.h"
  24. #if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO
  25. # define VAR_NUM(v) ((zend_uint)(EX_TMP_VAR_NUM(0, 0) - EX_TMP_VAR(0, v)))
  26. # define NUM_VAR(v) ((zend_uint)(zend_uintptr_t)EX_TMP_VAR_NUM(0, v))
  27. #elif ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO
  28. # define VAR_NUM(v) ((v)/ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)))
  29. # define NUM_VAR(v) ((v)*ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)))
  30. #else
  31. # define VAR_NUM(v) ((v)/(sizeof(temp_variable)))
  32. # define NUM_VAR(v) ((v)*(sizeof(temp_variable)))
  33. #endif
  34. #define INV_COND(op) ((op) == ZEND_JMPZ ? ZEND_JMPNZ : ZEND_JMPZ)
  35. #define INV_EX_COND(op) ((op) == ZEND_JMPZ_EX ? ZEND_JMPNZ : ZEND_JMPZ)
  36. #define INV_COND_EX(op) ((op) == ZEND_JMPZ ? ZEND_JMPNZ_EX : ZEND_JMPZ_EX)
  37. #define INV_EX_COND_EX(op) ((op) == ZEND_JMPZ_EX ? ZEND_JMPNZ_EX : ZEND_JMPZ_EX)
  38. #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
  39. # define MAKE_NOP(opline) { opline->opcode = ZEND_NOP; memset(&opline->result,0,sizeof(opline->result)); memset(&opline->op1,0,sizeof(opline->op1)); memset(&opline->op2,0,sizeof(opline->op2)); opline->result_type=opline->op1_type=opline->op2_type=IS_UNUSED; opline->handler = zend_opcode_handlers[ZEND_NOP]; }
  40. # define RESULT_USED(op) (((op->result_type & IS_VAR) && !(op->result_type & EXT_TYPE_UNUSED)) || op->result_type == IS_TMP_VAR)
  41. # define RESULT_UNUSED(op) ((op->result_type & EXT_TYPE_UNUSED) != 0)
  42. # define SAME_VAR(op1, op2) ((((op1 ## _type & IS_VAR) && (op2 ## _type & IS_VAR)) || (op1 ## _type == IS_TMP_VAR && op2 ## _type == IS_TMP_VAR)) && op1.var == op2.var)
  43. #else
  44. # define MAKE_NOP(opline) { opline->opcode = ZEND_NOP; memset(&opline->result,0,sizeof(znode)); memset(&opline->op1,0,sizeof(znode)); memset(&opline->op2,0,sizeof(znode)); opline->result.op_type=opline->op1.op_type=opline->op2.op_type=IS_UNUSED; opline->handler = zend_opcode_handlers[ZEND_NOP]; }
  45. # define RESULT_USED(op) ((op->result.op_type == IS_VAR && (op->result.u.EA.type & EXT_TYPE_UNUSED) == 0) || (op->result.op_type == IS_TMP_VAR))
  46. # define RESULT_UNUSED(op) ((op->result.op_type == IS_VAR) && (op->result.u.EA.type == EXT_TYPE_UNUSED))
  47. # define SAME_VAR(op1, op2) (((op1.op_type == IS_VAR && op2.op_type == IS_VAR) || (op1.op_type == IS_TMP_VAR && op2.op_type == IS_TMP_VAR)) && op1.u.var == op2.u.var)
  48. #endif
  49. typedef struct _zend_code_block zend_code_block;
  50. typedef struct _zend_block_source zend_block_source;
  51. struct _zend_code_block {
  52. int access;
  53. zend_op *start_opline;
  54. int start_opline_no;
  55. int len;
  56. zend_code_block *op1_to;
  57. zend_code_block *op2_to;
  58. zend_code_block *ext_to;
  59. zend_code_block *follow_to;
  60. zend_code_block *next;
  61. zend_block_source *sources;
  62. zend_bool protected; /* don't merge this block with others */
  63. };
  64. typedef struct _zend_cfg {
  65. zend_code_block *blocks;
  66. zend_code_block **try;
  67. zend_code_block **catch;
  68. zend_code_block **loop_start;
  69. zend_code_block **loop_cont;
  70. zend_code_block **loop_brk;
  71. } zend_cfg;
  72. struct _zend_block_source {
  73. zend_code_block *from;
  74. zend_block_source *next;
  75. };
  76. #endif