UPGRADING.INTERNALS 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. PHP 7.3 INTERNALS UPGRADE NOTES
  2. 1. Internal API changes
  3. a. array_init() and array_init_size()
  4. b. Run-time constant operand addressing
  5. c. Array/Object recursion protection
  6. d. HASH_FLAG_PERSISTENT
  7. e. AST and IS_CONSTANT
  8. f. GC_REFCOUNT()
  9. g. zend_get_parameters()
  10. h. zend_register_persistent_resource()
  11. i. RAND_RANGE()
  12. j. cast_object() with _IS_NUMBER
  13. k. zend_fcall_info_cache.initialized
  14. l. php_hrtime_current()
  15. m. zend_cpu_supports()
  16. n. IS_TYPE_COPYABLE
  17. o. IS_UNUSED
  18. p. VM instruction operands (FETCH_CLASS, FETCH_CONSTANT, CATCH)
  19. q. sapi_cli_single_write()
  20. r. php_url
  21. s. zend_function.reserved[]
  22. t. zif_handler
  23. u. GC_G
  24. v. php_add[c]slashes
  25. w. zend_class_entry.iterator_funcs
  26. x. Class declaration opcodes (DECLARE_INHERITED_CLASS ...)
  27. y. zend_constant
  28. z. HAVE_ST_BLKSIZE and HAVE_ST_RDEV
  29. aa. RETSIGTYPE
  30. bb. php_setcookie
  31. 2. Build system changes
  32. a. Unix build system changes
  33. b. Windows build system changes
  34. 3. Module changes
  35. ========================
  36. 1. Internal API changes
  37. ========================
  38. a. array_init() and array_init_size() are not functions anymore.
  39. They don't return any values.
  40. b. In 64-bit builds PHP-7.2 and below used relative run-time constant operand
  41. addressing. E.g. opline->op1.constant kept an offset from start of literals
  42. table - op_array->literals. To speedup access op_array->literals was cached
  43. in execute_data->literals. So the resulting address calculated as
  44. EX(literals) + opline->op1.constant.
  45. Now at run-time literals allocated close to opcodes, and addressed
  46. relatively from current opline. This eliminates load of EX(literals) on
  47. each constant access as well as EX(literals) initialization on each call.
  48. As result some related macros were removed (ZEND_EX_USE_LITERALS,
  49. EX_LOAD_LITERALS, EX_LITERALS, RT_CONSTANT_EX, EX_CONSTANT) or changed
  50. (RT_CONSTANT, ZEND_PASS_TWO_UPDATE_CONSTANT, ZEND_PASS_TWO_UNDO_CONSTANT).
  51. This change may affect only some "system" extensions. EX_LITERALS,
  52. RT_CONSTANT_EX, EX_CONSTANT should be substituted by RT_CONSTANT, and now
  53. use "opline" (instead of "op_array") as first argument.
  54. c. Protection from recursion during processing circular data structures was
  55. refactored. HashTable.nApplyCount and IS_OBJ_APPLY_COUNT are replaced by
  56. single flag GC_PROTECTED. Corresponding macros Z_OBJ_APPLY_COUNT,
  57. Z_OBJ_INC_APPLY_COUNT, Z_OBJ_DEC_APPLY_COUNT, ZEND_HASH_GET_APPLY_COUNT,
  58. ZEND_HASH_INC_APPLY_COUNT, ZEND_HASH_DEC_APPLY_COUNT are replaced with
  59. GC_IS_RECURSIVE, GC_PROTECT_RECURSION, GC_UNPROTECT_RECURSION,
  60. Z_IS_RECURSIVE, Z_PROTECT_RECURSION, Z_UNPROTECT_RECURSION.
  61. HASH_FLAG_APPLY_PROTECTION flag and ZEND_HASH_APPLY_PROTECTION() macro
  62. are removed. All mutable arrays should use recursion protection.
  63. Corresponding checks should be replaced by Z_REFCOUNTED() or
  64. !(GC_FLAGS(p) & GC_IMMUTABLE).
  65. d. HASH_FLAG_PERSISTENT renamed into IS_ARRAY_PERSISTENT and moved into
  66. GC_FLAGS (to be consistent with IS_STR_PERSISTENT).
  67. e. zend_ast_ref structure is changed to use only one allocation.
  68. zend_ast_copy() now returns zend_ast_ref (instead of zend_asr).
  69. zend_ast_destroy_and_free() is removed. ZVAL_NEW_AST() is replaced
  70. by ZVAL_AST().
  71. IS_CONSTANT type and Z_CONST_FLAGS() are removed. Now constants are always
  72. represented using IS_CONSTANT_AST (ZEND_AST_CONSTANT kind). AST node
  73. attributes are used instead of constant flags. IS_TYPE_CONSTANT flag is
  74. removed, but Z_CONSTANT() macro is kept for compatibility.
  75. f. GC_REFCOUNT() is turned into inline function and can't be modified direcly.
  76. All reference-counting operations should be done through corresponding
  77. macros GC_SET_REFCOUNT(), GC_ADDREF() and GC_DELREF().
  78. GC_REFCOUNT(p)++ should be changed into GC_ADDREF(p),
  79. GC_REFCOUNT(p)-- into GC_DELREF(p),
  80. GC_REFCOUNT(p) = 1 into GC_SET_REFCOUNT(p, 1).
  81. g. The zend_get_parameters() and zend_get_parameters_ex() functions were
  82. removed. Instead zend_parse_parameters() should be used.
  83. h. New functions zend_register_persistent_resource() or
  84. zend_register_persistent_resource_ex() should beused to register
  85. persistent resources, instead of manual insertion into EG(persistent_list).
  86. i. The RAND_RANGE() macro has been removed. php_mt_rand_range() should be
  87. used instead.
  88. j. The cast_object() object handler now also accepts the _IS_NUMBER type. The
  89. handler should return either an integer or float value in this case,
  90. whichever is more appropriate.
  91. k. zend_fcall_info_cache.initialized is removed. zend_fcall_info_cache is
  92. initialized if zend_fcall_info_cache.function_handler is set.
  93. l. php_hrtime_current() delivers the number of nanoseconds since an uncertain
  94. point in the past.
  95. m. zend_cpu_supports() determines if a feature is supported by current cpu.
  96. Also serial inline zend_cpu_supports_xxx() are added, which is designed for
  97. ifunc resolver function, as resolver function should not depend on any
  98. external function.
  99. n. IS_TYPE_COPYABLE flag is removed. IS_STRING zvals didn't need to be
  100. duplication by zval_copy_ctor(), ZVAL_DUP() and SEPARATE_ZVAL*() macros.
  101. Interned strings didn't set IS_TYPE_COPYABLE, so they aren't affected at
  102. all. Now instead of checking for IS_TYPE_COPYABLE, engine checks for
  103. IS_ARRAY type (it may be IS_TYPE_REFCOUNTED or not). All the related
  104. macros: Z_COPYABLE..., Z_IMMUTABLE... are kept for compatibility.
  105. o. IS_UNUSED became zero and can't be used as a bitmask (there were no such
  106. usages in PHP sources).
  107. p. Operands of few VM instructions were changed
  108. - FETCH_CLASS op1<fetch-flags>, op2<name>, result<var>
  109. - FETCH_CONSTANT op1<fetch-flags>, op2<name>, result<tmp>
  110. - CATCH ext<last-flag>, op1<name>, op2<jump_addr>, result<cv>
  111. q. sapi_cli_single_write() now returns ssize_t instead of size_t.
  112. r. fields of php_url struct change from char * to zend_string *
  113. s. Special purpose zend_functions marked by ZEND_ACC_CALL_VIA_TRAMPOLINE or
  114. ZEND_ACC_FAKE_CLOSURE flags use reserved[0] for internal purpose.
  115. Third party extensions must not modify reserved[] fields of these functions.
  116. t. For internal functions the typedef zif_handler has been introduced. It is
  117. recommended to use this from now on, instead of defining own handler types.
  118. u. The GC globals (GC_G) are now private. Use the new zend_gc_get_status() to
  119. retrieve status information of the GC.
  120. v. The should_free argument of the php_add[c]slashes functions has been
  121. removed. It is now always the caller's responsibility to free the passed
  122. string.
  123. w. zend_class_entry.iterator_funcs have been replaced by iterator_funcs_ptr.
  124. You don't have to set its value, setting parent.funcs in the get_iterator
  125. function is enough.
  126. x. Class declaration opcode formats were changed
  127. - DECLARE_INHERITED_CLASS and DECLARE_ANON_INHERITED_CLASS now encode parent
  128. class name in second operand directly (as IS_CONST operand). Previously,
  129. parent class was fetched by the prior FETCH_CLASS opcode.
  130. - ADD_INTERFACE and ADD_TRAIT don't use run-time cache to keep interface or
  131. trait. These instructions are executed once, and caching is useless.
  132. y. zend_constant.flags and zend_constant.module_number are packed into
  133. reserved space inside zend_constant.value. They should be accessed using
  134. ZEND_CONSTANT_FLAGS(), ZEND_CONSTANT_MODULE_NUMBER() and
  135. ZEND_CONSTANT_SET_FLAGS() macros.
  136. z. HAVE_ST_BLKSIZE must be replaced with HAVE_STRUCT_STAT_ST_BLKSIZE and
  137. HAVE_ST_RDEV must be replaced with HAVE_STRUCT_STAT_ST_RDEV.
  138. aa. RETSIGTYPE has been removed from the generated php_config.h and should be
  139. replaced with void.
  140. bb. php_setcookie() now expects an additional samesite argument, and the
  141. url_encode parameter has been moved to the end. The signature is now:
  142. int php_setcookie(zend_string *name, zend_string *value, time_t expires,
  143. zend_string *path, zend_string *domain, int secure,
  144. int httponly, zend_string *samesite, int url_encode);
  145. ========================
  146. 2. Build system changes
  147. ========================
  148. a. Unix build system changes
  149. - PHP_PROG_LEX, TSRM_CHECK_GCC_ARG, and LIBZEND_CPLUSPLUS_CHECKS Autoconf
  150. macros have been removed.
  151. - Minimum Autoconf version is 2.68+ for generating the configure script.
  152. b. Windows build system changes
  153. - ZEND_WIN32_FORCE_INLINE doesn't affect C++ anymore. zend_always_inline is
  154. still usable in C++, but anything else inlining related is up to
  155. compiler.
  156. - ZEND_WIN32_KEEP_INLINE was removed, it was only needed for C++
  157. convenience and is now default behavior with C++.
  158. - New configure option --enable-native-intrinsics accepts a list of the
  159. intrinsic optimizations to enable. It affects both the code generation
  160. and the explicit optimizations guarded by preprocessor macros.
  161. - The configure option --with-codegen-arch accepts only ia32 as a value.
  162. Use it, to produce builds suitable for older processors without SSE2 or
  163. even SSE support.
  164. ========================
  165. 3. Module changes
  166. ========================