UPGRADING.INTERNALS 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. $Id$
  2. PHP 5.6 INTERNALS UPGRADE NOTES
  3. 1. Internal API changes
  4. a. Addition of do_operation and compare object handlers
  5. b. return_value_ptr now always available, RETVAL_ZVAL_FAST macros
  6. c. POST data handling
  7. d. Arginfo changes
  8. e. tsrm_virtual_cwd.h moved to zend_virtual_cwd.h
  9. f. empty strings are interned
  10. g. Additional str_* APIs
  11. h. Addition of zend_hash_reindex
  12. i. Addition of zend_hash_splice
  13. j. Unserialization of manipulated object strings
  14. k. Removal of IS_CONSTANT_ARRAY and IS_CONSTANT_INDEX hack
  15. 2. Build system changes
  16. a. Unix build system changes
  17. b. Windows build system changes
  18. ========================
  19. 1. Internal API changes
  20. ========================
  21. a. Addition of do_operation and compare object handlers
  22. Two new object handlers have been added:
  23. do_operation:
  24. typedef int (*zend_object_do_operation_t)(
  25. zend_uchar opcode, zval *result, zval *op1, zval *op2 TSRMLS_DC
  26. );
  27. compare:
  28. typedef int (*zend_object_compare_zvals_t)(
  29. zval *result, zval *op1, zval *op2 TSRMLS_DC
  30. );
  31. The first handler is used to overload arithmetic operations. The first
  32. argument specifies the opcode of the operator, result is the target zval,
  33. op1 the first operand and op2 the second operand. For unary operations
  34. op2 is NULL. If the handler returns FAILURE PHP falls back to the default
  35. behavior for the operation.
  36. The second handler is used to perform comparison operations with
  37. non-objects. The value written into result must be an IS_LONG with value
  38. -1 (smaller), 0 (equal) or 1 (greater). The return value is a SUCCESS/FAILURE
  39. return code. The difference between this handler and compare_objects is
  40. that it will be triggered for comparisons with non-objects and objects of
  41. different types. It takes precedence over compare_objects.
  42. Further docs in the RFC: https://wiki.php.net/rfc/operator_overloading_gmp
  43. b. return_value_ptr now always available, RETVAL_ZVAL_FAST macros
  44. The return_value_ptr argument to internal functions is now always set.
  45. Previously it was only available for functions returning by-reference.
  46. return_value_ptr can now be used to return zvals without copying them.
  47. For this purpose two new macros are provided:
  48. RETVAL_ZVAL_FAST(zv); /* analog to RETVAL_ZVAL(zv, 1, 0) */
  49. RETURN_ZVAL_FAST(zv); /* analog to RETURN_ZVAL(zv, 1, 0) */
  50. The macros behave similarly to the non-FAST variants with copy=1 and
  51. dtor=0, but will try to return the zval without making a copy by utilizing
  52. return_value_ptr.
  53. c. POST data handling
  54. The sapi_request_info's members post_data, post_data_len and raw_post_data as
  55. well as raw_post_data_len have been replaced with a temp PHP stream
  56. request_body.
  57. The recommended way to access raw POST data is to open and use a php://input
  58. stream wrapper. It is safe to be used concurrently and more than once.
  59. d. Arginfo changes
  60. The pass_rest_by_reference argument of the ZEND_BEGIN_ARG_INFO and
  61. ZEND_BEGIN_ARG_INFO_EX() is no longer used. The value passed to it is ignored.
  62. Instead a variadic argument is created using ZEND_ARG_VARIADIC_INFO():
  63. ZEND_ARG_VARIADIC_INFO(0, name) /* pass rest by value */
  64. ZEND_ARG_VARIADIC_INFO(1, name) /* pass rest by reference */
  65. ZEND_ARG_VARIADIC_INFO(ZEND_SEND_PREFER_REF, name)
  66. /* pass rest by prefer-ref */
  67. ZEND_ARG_VARIADIC_INFO() should only be used for the last argument.
  68. The following changes were applied to the zend_arg_info struct:
  69. typedef struct _zend_arg_info {
  70. const char *class_name;
  71. zend_uint class_name_len;
  72. zend_uchar type_hint;
  73. + zend_uchar pass_by_reference;
  74. zend_bool allow_null;
  75. - zend_bool pass_by_reference;
  76. + zend_bool is_variadic;
  77. } zend_arg_info;
  78. The following changes were applied to the zend_internal_function_info struct:
  79. typedef struct _zend_internal_function_info {
  80. zend_uint required_num_args;
  81. zend_uchar _type_hint;
  82. zend_bool return_reference;
  83. - zend_bool pass_rest_by_reference;
  84. + zend_bool _allow_null;
  85. + zend_bool _is_variadic;
  86. } zend_internal_function_info;
  87. The CHECK_ARG_SEND_TYPE(), ARG_MUST_BE_SENT_BY_REF(),
  88. ARG_SHOULD_BE_SENT_BY_REF() and ARG_MAY_BE_SENT_BY_REF() macros now assume
  89. that the argument passed to them is a zend_function* and that it is non-NULL.
  90. e. tsrm_virtual_cwd.h moved to zend_virtual_cwd.h
  91. Memory allocation is now managed by emalloc/efree instead of malloc/free.
  92. f. empty strings are interned
  93. String created using STR_EMPTY_ALLOC() are now interned.
  94. convert_to_string use STR_EMPTY_ALLOC() for zval when IS_NULL.
  95. str_efree() shoud be preferred as efree() on such strings can cause memory
  96. corruption.
  97. g. Additional str_* APIs
  98. In addition to the previously existing str_free() and str_efree() macros, the
  99. following macros have been introduced to simplify dealing with potentially
  100. interned strings:
  101. str_efree_rel(str) - efree_rel() if not interned
  102. str_erealloc(str, new_len) - erealloc() or emalloc+memcpy if interned
  103. str_estrndup(str, len) - estrndup() if not interned
  104. str_strndup(str, len) - zend_strndup() if not interned
  105. str_hash(str, len) - INTERNED_HASH(str) if interned,
  106. zend_hash_func(str, len+1) otherwise
  107. h. Addition of zend_hash_reindex
  108. A zend_hash_reindex() function with the following prototype has been added:
  109. void zend_hash_reindex(HashTable *ht, zend_bool only_integer_keys);
  110. If only_integer_keys==0, this function will change all keys to be continuous,
  111. zero-based integers in hash order. If only_integer_keys==1 the same will be
  112. done only for keys that were already integers previously, while leaving
  113. string keys alone.
  114. i. Addition of zend_hash_splice
  115. A zend_hash_splice() macro with the following prototype has been added:
  116. void zend_hash_splice(
  117. HashTable *ht, uint nDataSize, copy_ctor_func_t pCopyConstructor,
  118. uint offset, uint length,
  119. void **list, uint list_count, HashTable *removed
  120. );
  121. This function performs an in-place splice operation on a hashtable:
  122. The elements between offset and offset+length are removed and the elements in
  123. list[list_count] are inserted in their place. The removed elements can be
  124. optionally collected into a hashtable.
  125. This operation reindexes the hashtable, i.e. integer keys will be zero-based
  126. and sequential, while string keys stay intact. The same applies to the
  127. elements inserted into the removed HT.
  128. As a side-effect of this addition the signature of the php_splice() function
  129. changed:
  130. void php_splice(
  131. HashTable *ht, zend_uint offset, zend_uint length,
  132. zval ***list, zend_uint list_count, HashTable *removed TSRMLS_DC
  133. )
  134. This function now directly forwards to zend_hash_splice(), resets the
  135. IAP of ht (for compatibility with the previous implementation) and resets
  136. CVs if the passed hashtable is the global symbol table.
  137. j. Unserialization of manipulated object strings
  138. Strings requiring unserialization of objects are now explicitly checked
  139. whether the object they contain implements the Serializable interface.
  140. This solves the situation where manipulated strings could be passed for
  141. objects using Serializable to disallow serialization. An object
  142. implementing Serializable will always start with "C:" in the serialized
  143. string, all other objects are represented with starting "O:". Objects
  144. implementing Serializable to disable serialization using
  145. zend_class_unserialize_deny and zend_class_serialize_deny, when
  146. instantiated from the serializer with a manipulated "O:" string at the
  147. start, will most likely be defectively initialized. This is now
  148. fixed at the appropriate place by checking for the presence of the
  149. serialize callback in the class entry.
  150. k. Removal of IS_CONSTANT_ARRAY and IS_CONSTANT_INDEX hack
  151. These two #defines disappeared. Instead we have now IS_CONSTANT_AST which
  152. covers also the functionality IS_CONSTANT_ARRAY bid and furthermore the
  153. hack for marking zvals as constant index with IS_CONSTANT_INDEX is now
  154. superfluous and so removed.
  155. Please note that IS_CONSTANT_AST now has the same value than
  156. IS_CONSTANT_ARRAY had.
  157. ========================
  158. 2. Build system changes
  159. ========================
  160. a. Unix build system changes
  161. - The bison version check is now a blacklist instead of a whitelist.
  162. - The bison binary can be specified through the YACC environment/configure
  163. variable. Previously `bison` was assumed to be in $PATH.
  164. b. Windows build system changes
  165. - The configure option --enable-static-analyze isn't available anymore.
  166. The new option was introduced --with-analyzer.
  167. - It is possible to disable PGO for single extensions, to do that
  168. define a global variable PHP_MYMODULE_PGO evaluating to false
  169. inside config.w32