zend_call_graph.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend Engine, Call Graph |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 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. | https://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: Dmitry Stogov <dmitry@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #ifndef ZEND_CALL_GRAPH_H
  19. #define ZEND_CALL_GRAPH_H
  20. #include "zend_ssa.h"
  21. #include "zend_func_info.h"
  22. #include "zend_optimizer.h"
  23. typedef struct _zend_send_arg_info {
  24. zend_op *opline;
  25. } zend_send_arg_info;
  26. struct _zend_call_info {
  27. zend_op_array *caller_op_array;
  28. zend_op *caller_init_opline;
  29. zend_op *caller_call_opline;
  30. zend_function *callee_func;
  31. zend_call_info *next_caller;
  32. zend_call_info *next_callee;
  33. bool recursive;
  34. bool send_unpack; /* Parameters passed by SEND_UNPACK or SEND_ARRAY */
  35. bool named_args; /* Function has named arguments */
  36. bool is_prototype; /* An overridden child method may be called */
  37. int num_args;
  38. zend_send_arg_info arg_info[1];
  39. };
  40. struct _zend_func_info {
  41. int num;
  42. uint32_t flags;
  43. zend_ssa ssa; /* Static Single Assignment Form */
  44. zend_call_info *caller_info; /* where this function is called from */
  45. zend_call_info *callee_info; /* which functions are called from this one */
  46. zend_call_info **call_map; /* Call info associated with init/call/send opnum */
  47. zend_ssa_var_info return_info;
  48. };
  49. typedef struct _zend_call_graph {
  50. int op_arrays_count;
  51. zend_op_array **op_arrays;
  52. zend_func_info *func_infos;
  53. } zend_call_graph;
  54. BEGIN_EXTERN_C()
  55. ZEND_API int zend_build_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph);
  56. ZEND_API void zend_analyze_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph);
  57. ZEND_API zend_call_info **zend_build_call_map(zend_arena **arena, zend_func_info *info, const zend_op_array *op_array);
  58. ZEND_API int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_flags, zend_op_array *op_array, zend_func_info *func_info);
  59. END_EXTERN_C()
  60. #endif /* ZEND_CALL_GRAPH_H */