grpc 1.37.1 → 1.38.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (544) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +64 -58
  3. data/include/grpc/event_engine/README.md +38 -0
  4. data/include/grpc/event_engine/channel_args.h +28 -0
  5. data/include/grpc/event_engine/event_engine.h +336 -0
  6. data/include/grpc/event_engine/port.h +39 -0
  7. data/include/grpc/event_engine/slice_allocator.h +81 -0
  8. data/include/grpc/grpc.h +2 -2
  9. data/include/grpc/grpc_security_constants.h +14 -0
  10. data/include/grpc/impl/codegen/grpc_types.h +11 -0
  11. data/include/grpc/impl/codegen/port_platform.h +5 -0
  12. data/include/grpc/module.modulemap +14 -14
  13. data/src/core/ext/filters/client_channel/backup_poller.cc +3 -3
  14. data/src/core/ext/filters/client_channel/channel_connectivity.cc +177 -202
  15. data/src/core/ext/filters/client_channel/client_channel.cc +628 -3101
  16. data/src/core/ext/filters/client_channel/client_channel.h +489 -55
  17. data/src/core/ext/filters/client_channel/client_channel_channelz.h +1 -1
  18. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +4 -1
  19. data/src/core/ext/filters/client_channel/config_selector.h +1 -1
  20. data/src/core/ext/filters/client_channel/connector.h +1 -1
  21. data/src/core/ext/filters/client_channel/dynamic_filters.cc +9 -10
  22. data/src/core/ext/filters/client_channel/dynamic_filters.h +3 -3
  23. data/src/core/ext/filters/client_channel/health/health_check_client.cc +26 -27
  24. data/src/core/ext/filters/client_channel/health/health_check_client.h +27 -26
  25. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +24 -21
  26. data/src/core/ext/filters/client_channel/lb_policy.cc +1 -1
  27. data/src/core/ext/filters/client_channel/lb_policy.h +4 -4
  28. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +6 -6
  29. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +46 -43
  30. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
  31. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -1
  32. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +5 -5
  33. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +14 -12
  34. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +4 -4
  35. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +1 -1
  36. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +15 -15
  37. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +36 -30
  38. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +23 -23
  39. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +31 -46
  40. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +84 -61
  41. data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
  42. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +4 -4
  43. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
  44. data/src/core/ext/filters/client_channel/resolver.h +2 -2
  45. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +23 -15
  46. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -1
  47. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +3 -3
  48. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
  49. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +14 -14
  50. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +33 -24
  51. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +1 -1
  52. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
  53. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  54. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +17 -9
  55. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +20 -28
  56. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +7 -5
  57. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +13 -11
  58. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -1
  59. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +43 -28
  60. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +32 -239
  61. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +20 -49
  62. data/src/core/ext/filters/client_channel/retry_filter.cc +2188 -0
  63. data/src/core/ext/filters/client_channel/retry_filter.h +30 -0
  64. data/src/core/ext/filters/client_channel/retry_service_config.cc +287 -0
  65. data/src/core/ext/filters/client_channel/retry_service_config.h +90 -0
  66. data/src/core/ext/filters/client_channel/server_address.cc +1 -1
  67. data/src/core/ext/filters/client_channel/service_config.cc +15 -14
  68. data/src/core/ext/filters/client_channel/service_config.h +7 -6
  69. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +5 -4
  70. data/src/core/ext/filters/client_channel/service_config_parser.cc +6 -6
  71. data/src/core/ext/filters/client_channel/service_config_parser.h +7 -4
  72. data/src/core/ext/filters/client_channel/subchannel.cc +17 -16
  73. data/src/core/ext/filters/client_channel/subchannel.h +7 -6
  74. data/src/core/ext/filters/client_idle/client_idle_filter.cc +16 -15
  75. data/src/core/ext/filters/deadline/deadline_filter.cc +10 -10
  76. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +19 -18
  77. data/src/core/ext/filters/fault_injection/service_config_parser.cc +5 -5
  78. data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
  79. data/src/core/ext/filters/http/client/http_client_filter.cc +28 -21
  80. data/src/core/ext/filters/http/client_authority_filter.cc +3 -3
  81. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +23 -22
  82. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +21 -21
  83. data/src/core/ext/filters/http/server/http_server_filter.cc +27 -23
  84. data/src/core/ext/filters/max_age/max_age_filter.cc +12 -10
  85. data/src/core/ext/filters/message_size/message_size_filter.cc +14 -11
  86. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  87. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +4 -3
  88. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +7 -7
  89. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +7 -7
  90. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +2 -2
  91. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +1 -1
  92. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +3 -3
  93. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +44 -45
  94. data/src/core/ext/transport/chttp2/server/chttp2_server.h +2 -2
  95. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +3 -4
  96. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +2 -2
  97. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +3 -4
  98. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +129 -116
  99. data/src/core/ext/transport/chttp2/transport/context_list.cc +4 -5
  100. data/src/core/ext/transport/chttp2/transport/context_list.h +4 -4
  101. data/src/core/ext/transport/chttp2/transport/flow_control.cc +3 -3
  102. data/src/core/ext/transport/chttp2/transport/flow_control.h +8 -8
  103. data/src/core/ext/transport/chttp2/transport/frame_data.cc +8 -8
  104. data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -10
  105. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +7 -8
  106. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +6 -6
  107. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +7 -8
  108. data/src/core/ext/transport/chttp2/transport/frame_ping.h +7 -6
  109. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +7 -7
  110. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +6 -6
  111. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +6 -5
  112. data/src/core/ext/transport/chttp2/transport/frame_settings.h +6 -6
  113. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -6
  114. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +4 -6
  115. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +237 -208
  116. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +10 -10
  117. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +4 -3
  118. data/src/core/ext/transport/chttp2/transport/hpack_table.h +4 -4
  119. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -2
  120. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +2 -2
  121. data/src/core/ext/transport/chttp2/transport/internal.h +31 -27
  122. data/src/core/ext/transport/chttp2/transport/parsing.cc +63 -56
  123. data/src/core/ext/transport/chttp2/transport/writing.cc +7 -3
  124. data/src/core/ext/transport/inproc/inproc_transport.cc +30 -29
  125. data/src/core/ext/xds/certificate_provider_factory.h +1 -1
  126. data/src/core/ext/xds/certificate_provider_store.h +3 -3
  127. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +3 -3
  128. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +2 -2
  129. data/src/core/ext/xds/xds_api.cc +101 -93
  130. data/src/core/ext/xds/xds_api.h +6 -6
  131. data/src/core/ext/xds/xds_bootstrap.cc +97 -159
  132. data/src/core/ext/xds/xds_bootstrap.h +19 -24
  133. data/src/core/ext/xds/xds_certificate_provider.cc +4 -4
  134. data/src/core/ext/xds/xds_certificate_provider.h +4 -4
  135. data/src/core/ext/xds/xds_channel_args.h +5 -2
  136. data/src/core/ext/xds/xds_client.cc +310 -178
  137. data/src/core/ext/xds/xds_client.h +41 -27
  138. data/src/core/ext/xds/xds_client_stats.h +3 -2
  139. data/src/core/ext/xds/xds_server_config_fetcher.cc +34 -20
  140. data/src/core/lib/{iomgr → address_utils}/parse_address.cc +17 -17
  141. data/src/core/lib/{iomgr → address_utils}/parse_address.h +7 -7
  142. data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.cc +3 -20
  143. data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.h +6 -11
  144. data/src/core/lib/channel/channel_stack.cc +10 -9
  145. data/src/core/lib/channel/channel_stack.h +10 -9
  146. data/src/core/lib/channel/channel_stack_builder.cc +2 -2
  147. data/src/core/lib/channel/channel_stack_builder.h +1 -1
  148. data/src/core/lib/channel/channelz.cc +21 -13
  149. data/src/core/lib/channel/connected_channel.cc +4 -4
  150. data/src/core/lib/channel/handshaker.cc +7 -6
  151. data/src/core/lib/channel/handshaker.h +5 -5
  152. data/src/core/lib/event_engine/slice_allocator.cc +59 -0
  153. data/src/core/lib/event_engine/sockaddr.cc +38 -0
  154. data/src/core/lib/gprpp/ref_counted.h +28 -14
  155. data/src/core/lib/gprpp/status_helper.cc +407 -0
  156. data/src/core/lib/gprpp/status_helper.h +180 -0
  157. data/src/core/lib/http/httpcli.cc +11 -11
  158. data/src/core/lib/http/httpcli_security_connector.cc +11 -7
  159. data/src/core/lib/http/parser.cc +16 -16
  160. data/src/core/lib/http/parser.h +4 -4
  161. data/src/core/lib/iomgr/buffer_list.cc +7 -9
  162. data/src/core/lib/iomgr/buffer_list.h +4 -5
  163. data/src/core/lib/iomgr/call_combiner.cc +15 -12
  164. data/src/core/lib/iomgr/call_combiner.h +12 -14
  165. data/src/core/lib/iomgr/cfstream_handle.cc +3 -3
  166. data/src/core/lib/iomgr/cfstream_handle.h +1 -1
  167. data/src/core/lib/iomgr/closure.h +7 -6
  168. data/src/core/lib/iomgr/combiner.cc +14 -12
  169. data/src/core/lib/iomgr/combiner.h +2 -2
  170. data/src/core/lib/iomgr/endpoint.cc +1 -1
  171. data/src/core/lib/iomgr/endpoint.h +2 -2
  172. data/src/core/lib/iomgr/endpoint_cfstream.cc +11 -13
  173. data/src/core/lib/iomgr/endpoint_pair_windows.cc +1 -1
  174. data/src/core/lib/iomgr/error.cc +167 -61
  175. data/src/core/lib/iomgr/error.h +217 -106
  176. data/src/core/lib/iomgr/error_cfstream.cc +3 -2
  177. data/src/core/lib/iomgr/error_cfstream.h +2 -2
  178. data/src/core/lib/iomgr/error_internal.h +5 -1
  179. data/src/core/lib/iomgr/ev_apple.cc +5 -5
  180. data/src/core/lib/iomgr/ev_epoll1_linux.cc +19 -19
  181. data/src/core/lib/iomgr/ev_epollex_linux.cc +48 -45
  182. data/src/core/lib/iomgr/ev_poll_posix.cc +26 -23
  183. data/src/core/lib/iomgr/ev_posix.cc +9 -8
  184. data/src/core/lib/iomgr/ev_posix.h +9 -9
  185. data/src/core/lib/iomgr/exec_ctx.cc +4 -4
  186. data/src/core/lib/iomgr/exec_ctx.h +1 -1
  187. data/src/core/lib/iomgr/executor.cc +8 -8
  188. data/src/core/lib/iomgr/executor.h +2 -2
  189. data/src/core/lib/iomgr/iomgr.cc +1 -1
  190. data/src/core/lib/iomgr/iomgr.h +1 -1
  191. data/src/core/lib/iomgr/iomgr_custom.cc +1 -1
  192. data/src/core/lib/iomgr/iomgr_internal.cc +2 -2
  193. data/src/core/lib/iomgr/iomgr_internal.h +3 -3
  194. data/src/core/lib/iomgr/iomgr_posix.cc +1 -1
  195. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +2 -2
  196. data/src/core/lib/iomgr/iomgr_windows.cc +1 -1
  197. data/src/core/lib/iomgr/load_file.cc +4 -4
  198. data/src/core/lib/iomgr/load_file.h +2 -2
  199. data/src/core/lib/iomgr/lockfree_event.cc +5 -5
  200. data/src/core/lib/iomgr/lockfree_event.h +1 -1
  201. data/src/core/lib/iomgr/pollset.cc +5 -5
  202. data/src/core/lib/iomgr/pollset.h +9 -9
  203. data/src/core/lib/iomgr/pollset_custom.cc +5 -5
  204. data/src/core/lib/iomgr/pollset_windows.cc +5 -5
  205. data/src/core/lib/iomgr/port.h +1 -1
  206. data/src/core/lib/iomgr/python_util.h +1 -1
  207. data/src/core/lib/iomgr/resolve_address.cc +3 -3
  208. data/src/core/lib/iomgr/resolve_address.h +6 -6
  209. data/src/core/lib/iomgr/resolve_address_custom.cc +10 -9
  210. data/src/core/lib/iomgr/resolve_address_custom.h +3 -3
  211. data/src/core/lib/iomgr/resolve_address_posix.cc +3 -3
  212. data/src/core/lib/iomgr/resolve_address_windows.cc +4 -4
  213. data/src/core/lib/iomgr/resource_quota.cc +11 -10
  214. data/src/core/lib/iomgr/socket_utils_common_posix.cc +22 -20
  215. data/src/core/lib/iomgr/socket_utils_posix.h +20 -20
  216. data/src/core/lib/iomgr/tcp_client_cfstream.cc +4 -4
  217. data/src/core/lib/iomgr/tcp_client_custom.cc +5 -6
  218. data/src/core/lib/iomgr/tcp_client_posix.cc +15 -17
  219. data/src/core/lib/iomgr/tcp_client_posix.h +3 -4
  220. data/src/core/lib/iomgr/tcp_client_windows.cc +5 -5
  221. data/src/core/lib/iomgr/tcp_custom.cc +14 -16
  222. data/src/core/lib/iomgr/tcp_custom.h +13 -12
  223. data/src/core/lib/iomgr/tcp_posix.cc +36 -34
  224. data/src/core/lib/iomgr/tcp_server.cc +6 -6
  225. data/src/core/lib/iomgr/tcp_server.h +12 -11
  226. data/src/core/lib/iomgr/tcp_server_custom.cc +23 -21
  227. data/src/core/lib/iomgr/tcp_server_posix.cc +22 -21
  228. data/src/core/lib/iomgr/tcp_server_utils_posix.h +13 -12
  229. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +19 -17
  230. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +9 -9
  231. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +4 -4
  232. data/src/core/lib/iomgr/tcp_server_windows.cc +26 -25
  233. data/src/core/lib/iomgr/tcp_uv.cc +25 -23
  234. data/src/core/lib/iomgr/tcp_windows.cc +13 -13
  235. data/src/core/lib/iomgr/tcp_windows.h +2 -2
  236. data/src/core/lib/iomgr/timer_custom.cc +2 -1
  237. data/src/core/lib/iomgr/timer_custom.h +1 -1
  238. data/src/core/lib/iomgr/timer_generic.cc +6 -6
  239. data/src/core/lib/iomgr/udp_server.cc +21 -20
  240. data/src/core/lib/iomgr/unix_sockets_posix.cc +3 -3
  241. data/src/core/lib/iomgr/unix_sockets_posix.h +2 -2
  242. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +10 -7
  243. data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +3 -3
  244. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +4 -4
  245. data/src/core/lib/iomgr/wakeup_fd_posix.cc +3 -3
  246. data/src/core/lib/iomgr/wakeup_fd_posix.h +8 -6
  247. data/src/core/lib/iomgr/work_serializer.h +17 -1
  248. data/src/core/lib/json/json.h +1 -1
  249. data/src/core/lib/json/json_reader.cc +4 -4
  250. data/src/core/lib/matchers/matchers.cc +39 -39
  251. data/src/core/lib/matchers/matchers.h +28 -28
  252. data/src/core/lib/security/credentials/composite/composite_credentials.cc +4 -4
  253. data/src/core/lib/security/credentials/composite/composite_credentials.h +2 -2
  254. data/src/core/lib/security/credentials/credentials.h +2 -2
  255. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +17 -13
  256. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +13 -11
  257. data/src/core/lib/security/credentials/external/aws_request_signer.cc +2 -1
  258. data/src/core/lib/security/credentials/external/aws_request_signer.h +1 -1
  259. data/src/core/lib/security/credentials/external/external_account_credentials.cc +15 -12
  260. data/src/core/lib/security/credentials/external/external_account_credentials.h +9 -8
  261. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +5 -4
  262. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +4 -3
  263. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +8 -8
  264. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +9 -7
  265. data/src/core/lib/security/credentials/fake/fake_credentials.cc +2 -2
  266. data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -2
  267. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +9 -9
  268. data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -2
  269. data/src/core/lib/security/credentials/iam/iam_credentials.h +2 -2
  270. data/src/core/lib/security/credentials/jwt/json_token.cc +2 -2
  271. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +3 -3
  272. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -2
  273. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +7 -5
  274. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +21 -19
  275. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +5 -5
  276. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +5 -5
  277. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -2
  278. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +8 -7
  279. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +9 -9
  280. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +19 -13
  281. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +4 -0
  282. data/src/core/lib/security/credentials/xds/xds_credentials.cc +3 -3
  283. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -3
  284. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +13 -3
  285. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +2 -2
  286. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +12 -2
  287. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +1 -1
  288. data/src/core/lib/security/security_connector/local/local_security_connector.cc +14 -4
  289. data/src/core/lib/security/security_connector/security_connector.h +9 -4
  290. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +16 -6
  291. data/src/core/lib/security/security_connector/ssl_utils.cc +22 -4
  292. data/src/core/lib/security/security_connector/ssl_utils.h +4 -4
  293. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +56 -60
  294. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +66 -48
  295. data/src/core/lib/security/transport/client_auth_filter.cc +18 -10
  296. data/src/core/lib/security/transport/secure_endpoint.cc +4 -4
  297. data/src/core/lib/security/transport/security_handshaker.cc +33 -32
  298. data/src/core/lib/security/transport/server_auth_filter.cc +19 -13
  299. data/src/core/lib/security/transport/tsi_error.cc +2 -1
  300. data/src/core/lib/security/transport/tsi_error.h +2 -1
  301. data/src/core/lib/security/util/json_util.cc +2 -2
  302. data/src/core/lib/security/util/json_util.h +1 -1
  303. data/src/core/lib/surface/call.cc +46 -45
  304. data/src/core/lib/surface/call.h +2 -2
  305. data/src/core/lib/surface/channel.cc +6 -6
  306. data/src/core/lib/surface/channel.h +3 -2
  307. data/src/core/lib/surface/channel_ping.cc +1 -1
  308. data/src/core/lib/surface/completion_queue.cc +46 -47
  309. data/src/core/lib/surface/completion_queue.h +2 -1
  310. data/src/core/lib/surface/lame_client.cc +11 -11
  311. data/src/core/lib/surface/lame_client.h +1 -1
  312. data/src/core/lib/surface/server.cc +28 -22
  313. data/src/core/lib/surface/server.h +16 -15
  314. data/src/core/lib/surface/validate_metadata.cc +7 -7
  315. data/src/core/lib/surface/validate_metadata.h +3 -2
  316. data/src/core/lib/surface/version.cc +4 -2
  317. data/src/core/lib/transport/byte_stream.cc +5 -5
  318. data/src/core/lib/transport/byte_stream.h +8 -8
  319. data/src/core/lib/transport/connectivity_state.cc +1 -1
  320. data/src/core/lib/transport/error_utils.cc +19 -8
  321. data/src/core/lib/transport/error_utils.h +11 -5
  322. data/src/core/lib/transport/metadata_batch.cc +37 -37
  323. data/src/core/lib/transport/metadata_batch.h +19 -18
  324. data/src/core/lib/transport/transport.cc +4 -3
  325. data/src/core/lib/transport/transport.h +4 -4
  326. data/src/core/lib/transport/transport_op_string.cc +5 -5
  327. data/src/core/tsi/alts/crypt/gsec.h +4 -0
  328. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +5 -4
  329. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +7 -6
  330. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +2 -1
  331. data/src/core/tsi/ssl_transport_security.cc +32 -14
  332. data/src/core/tsi/ssl_transport_security.h +3 -4
  333. data/src/ruby/bin/math_services_pb.rb +1 -1
  334. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
  335. data/src/ruby/lib/grpc/version.rb +1 -1
  336. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +1 -1
  337. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +6 -6
  338. data/third_party/abseil-cpp/absl/algorithm/container.h +3 -3
  339. data/third_party/abseil-cpp/absl/base/attributes.h +24 -4
  340. data/third_party/abseil-cpp/absl/base/call_once.h +2 -9
  341. data/third_party/abseil-cpp/absl/base/config.h +37 -9
  342. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +24 -10
  343. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +4 -1
  344. data/third_party/abseil-cpp/absl/base/internal/endian.h +61 -0
  345. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +2 -3
  346. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +34 -32
  347. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +16 -6
  348. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +11 -2
  349. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +14 -5
  350. data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +2 -2
  351. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +3 -3
  352. data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +2 -2
  353. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +11 -11
  354. data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +5 -5
  355. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +1 -1
  356. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +5 -2
  357. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +43 -42
  358. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +111 -7
  359. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +0 -76
  360. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +1 -3
  361. data/third_party/abseil-cpp/absl/base/log_severity.h +4 -4
  362. data/third_party/abseil-cpp/absl/base/macros.h +11 -0
  363. data/third_party/abseil-cpp/absl/base/optimization.h +10 -7
  364. data/third_party/abseil-cpp/absl/base/options.h +1 -1
  365. data/third_party/abseil-cpp/absl/base/port.h +0 -1
  366. data/third_party/abseil-cpp/absl/base/thread_annotations.h +1 -1
  367. data/third_party/abseil-cpp/absl/container/fixed_array.h +2 -2
  368. data/third_party/abseil-cpp/absl/container/inlined_vector.h +5 -3
  369. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +1 -1
  370. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +5 -1
  371. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +2 -1
  372. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +2 -1
  373. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +141 -66
  374. data/third_party/abseil-cpp/absl/container/internal/layout.h +4 -4
  375. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +14 -1
  376. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +136 -136
  377. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +16 -12
  378. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +5 -2
  379. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +3 -12
  380. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +6 -1
  381. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +3 -5
  382. data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +2 -2
  383. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +2 -2
  384. data/third_party/abseil-cpp/absl/hash/internal/city.cc +15 -12
  385. data/third_party/abseil-cpp/absl/hash/internal/city.h +1 -19
  386. data/third_party/abseil-cpp/absl/hash/internal/hash.cc +25 -10
  387. data/third_party/abseil-cpp/absl/hash/internal/hash.h +86 -37
  388. data/third_party/abseil-cpp/absl/hash/internal/wyhash.cc +111 -0
  389. data/third_party/abseil-cpp/absl/hash/internal/wyhash.h +48 -0
  390. data/third_party/abseil-cpp/absl/meta/type_traits.h +16 -2
  391. data/third_party/abseil-cpp/absl/numeric/bits.h +177 -0
  392. data/third_party/abseil-cpp/absl/numeric/int128.cc +3 -3
  393. data/third_party/abseil-cpp/absl/numeric/internal/bits.h +358 -0
  394. data/third_party/abseil-cpp/absl/numeric/internal/representation.h +55 -0
  395. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +18 -0
  396. data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +4 -7
  397. data/third_party/abseil-cpp/absl/status/status.cc +29 -22
  398. data/third_party/abseil-cpp/absl/status/status.h +81 -20
  399. data/third_party/abseil-cpp/absl/status/statusor.h +3 -3
  400. data/third_party/abseil-cpp/absl/strings/charconv.cc +5 -5
  401. data/third_party/abseil-cpp/absl/strings/cord.cc +326 -371
  402. data/third_party/abseil-cpp/absl/strings/cord.h +182 -64
  403. data/third_party/abseil-cpp/absl/strings/escaping.cc +4 -4
  404. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +6 -6
  405. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.cc +83 -0
  406. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +387 -17
  407. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_flat.h +146 -0
  408. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.cc +897 -0
  409. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.h +589 -0
  410. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring_reader.h +114 -0
  411. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +14 -0
  412. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +14 -0
  413. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +15 -1
  414. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +19 -4
  415. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +14 -0
  416. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +36 -18
  417. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +14 -0
  418. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +14 -0
  419. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +14 -0
  420. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +15 -40
  421. data/third_party/abseil-cpp/absl/strings/internal/string_constant.h +64 -0
  422. data/third_party/abseil-cpp/absl/strings/match.cc +6 -3
  423. data/third_party/abseil-cpp/absl/strings/match.h +16 -6
  424. data/third_party/abseil-cpp/absl/strings/numbers.cc +132 -4
  425. data/third_party/abseil-cpp/absl/strings/numbers.h +10 -10
  426. data/third_party/abseil-cpp/absl/strings/str_join.h +1 -1
  427. data/third_party/abseil-cpp/absl/strings/str_split.h +38 -4
  428. data/third_party/abseil-cpp/absl/synchronization/internal/futex.h +154 -0
  429. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -1
  430. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +2 -2
  431. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +4 -4
  432. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +1 -65
  433. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +2 -6
  434. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +71 -59
  435. data/third_party/abseil-cpp/absl/synchronization/mutex.h +79 -62
  436. data/third_party/abseil-cpp/absl/time/clock.cc +146 -130
  437. data/third_party/abseil-cpp/absl/time/clock.h +2 -2
  438. data/third_party/abseil-cpp/absl/time/duration.cc +3 -2
  439. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +7 -11
  440. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +7 -1
  441. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +4 -4
  442. data/third_party/abseil-cpp/absl/time/time.cc +4 -3
  443. data/third_party/abseil-cpp/absl/time/time.h +26 -24
  444. data/third_party/abseil-cpp/absl/types/internal/variant.h +1 -1
  445. data/third_party/abseil-cpp/absl/types/variant.h +9 -4
  446. data/third_party/boringssl-with-bazel/err_data.c +477 -461
  447. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +1 -1
  448. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +1 -1
  449. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +18 -8
  450. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +1 -2
  451. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_locl.h +5 -0
  452. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -1
  453. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +1 -1
  454. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +1 -88
  455. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +14 -3
  456. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +119 -273
  457. data/third_party/boringssl-with-bazel/src/crypto/err/err.c +87 -80
  458. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
  459. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +1 -1
  460. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +11 -3
  461. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +25 -2
  462. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +10 -2
  463. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +4 -43
  464. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +4 -0
  465. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +0 -1
  466. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +0 -4
  467. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +104 -93
  468. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/internal.h +39 -0
  469. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +43 -46
  470. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +43 -46
  471. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +33 -22
  472. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cfb.c +9 -8
  473. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +9 -8
  474. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +17 -13
  475. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +1 -22
  476. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +2 -1
  477. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +26 -7
  478. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/fips.c +79 -0
  479. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +14 -9
  480. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +45 -48
  481. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +38 -43
  482. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +37 -45
  483. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +103 -42
  484. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +58 -37
  485. data/third_party/boringssl-with-bazel/src/crypto/internal.h +65 -0
  486. data/third_party/boringssl-with-bazel/src/crypto/mem.c +14 -0
  487. data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +3 -3
  488. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +1 -1
  489. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +95 -48
  490. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c +1 -1
  491. data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +0 -28
  492. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +19 -0
  493. data/third_party/boringssl-with-bazel/src/crypto/x509/t_req.c +2 -0
  494. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +19 -25
  495. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +3 -2
  496. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +39 -89
  497. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +9 -16
  498. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +1 -1
  499. data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +21 -17
  500. data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +7 -25
  501. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +5 -0
  502. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +25 -22
  503. data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.c +2 -0
  504. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +2 -4
  505. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  506. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -0
  507. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +0 -3
  508. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +120 -41
  509. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +9 -0
  510. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +0 -8
  511. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +24 -4
  512. data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +5 -2
  513. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +19 -0
  514. data/third_party/boringssl-with-bazel/src/include/openssl/err.h +3 -2
  515. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +1 -38
  516. data/third_party/boringssl-with-bazel/src/{crypto/x509/x509_r2x.c → include/openssl/evp_errors.h} +41 -58
  517. data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +24 -5
  518. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +2 -0
  519. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +9 -1
  520. data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +2 -2
  521. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +185 -17
  522. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +1 -0
  523. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +416 -121
  524. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +2 -0
  525. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +5 -0
  526. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +444 -0
  527. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +244 -1
  528. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +43 -12
  529. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +149 -8
  530. data/third_party/boringssl-with-bazel/src/ssl/internal.h +220 -46
  531. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +7 -1
  532. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +4 -6
  533. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +23 -26
  534. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +74 -15
  535. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +98 -64
  536. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +34 -4
  537. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +205 -100
  538. data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +4 -2
  539. metadata +68 -45
  540. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +0 -88
  541. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +0 -88
  542. data/third_party/abseil-cpp/absl/base/internal/bits.h +0 -219
  543. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +0 -249
  544. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/is_fips.c +0 -29
@@ -257,7 +257,7 @@ class ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTuple
257
257
 
258
258
  template <int I>
259
259
  ElemT<I>& get() & {
260
- return internal_compressed_tuple::Storage<ElemT<I>, I>::get();
260
+ return StorageT<I>::get();
261
261
  }
262
262
 
263
263
  template <int I>
@@ -72,6 +72,7 @@ void HashtablezInfo::PrepareForSampling() {
72
72
  total_probe_length.store(0, std::memory_order_relaxed);
73
73
  hashes_bitwise_or.store(0, std::memory_order_relaxed);
74
74
  hashes_bitwise_and.store(~size_t{}, std::memory_order_relaxed);
75
+ hashes_bitwise_xor.store(0, std::memory_order_relaxed);
75
76
 
76
77
  create_time = absl::Now();
77
78
  // The inliner makes hardcoded skip_count difficult (especially when combined
@@ -180,7 +181,9 @@ static bool ShouldForceSampling() {
180
181
  if (ABSL_PREDICT_TRUE(state == kDontForce)) return false;
181
182
 
182
183
  if (state == kUninitialized) {
183
- state = AbslContainerInternalSampleEverything() ? kForce : kDontForce;
184
+ state = ABSL_INTERNAL_C_SYMBOL(AbslContainerInternalSampleEverything)()
185
+ ? kForce
186
+ : kDontForce;
184
187
  global_state.store(state, std::memory_order_relaxed);
185
188
  }
186
189
  return state == kForce;
@@ -235,6 +238,7 @@ void RecordInsertSlow(HashtablezInfo* info, size_t hash,
235
238
 
236
239
  info->hashes_bitwise_and.fetch_and(hash, std::memory_order_relaxed);
237
240
  info->hashes_bitwise_or.fetch_or(hash, std::memory_order_relaxed);
241
+ info->hashes_bitwise_xor.fetch_xor(hash, std::memory_order_relaxed);
238
242
  info->max_probe_length.store(
239
243
  std::max(info->max_probe_length.load(std::memory_order_relaxed),
240
244
  probe_length),
@@ -78,6 +78,7 @@ struct HashtablezInfo {
78
78
  std::atomic<size_t> total_probe_length;
79
79
  std::atomic<size_t> hashes_bitwise_or;
80
80
  std::atomic<size_t> hashes_bitwise_and;
81
+ std::atomic<size_t> hashes_bitwise_xor;
81
82
 
82
83
  // `HashtablezSampler` maintains intrusive linked lists for all samples. See
83
84
  // comments on `HashtablezSampler::all_` for details on these. `init_mu`
@@ -312,7 +313,7 @@ void SetHashtablezMaxSamples(int32_t max);
312
313
  // initialization of static storage duration objects.
313
314
  // The definition of this constant is weak, which allows us to inject a
314
315
  // different value for it at link time.
315
- extern "C" bool AbslContainerInternalSampleEverything();
316
+ extern "C" bool ABSL_INTERNAL_C_SYMBOL(AbslContainerInternalSampleEverything)();
316
317
 
317
318
  } // namespace container_internal
318
319
  ABSL_NAMESPACE_END
@@ -21,7 +21,8 @@ ABSL_NAMESPACE_BEGIN
21
21
  namespace container_internal {
22
22
 
23
23
  // See hashtablez_sampler.h for details.
24
- extern "C" ABSL_ATTRIBUTE_WEAK bool AbslContainerInternalSampleEverything() {
24
+ extern "C" ABSL_ATTRIBUTE_WEAK bool ABSL_INTERNAL_C_SYMBOL(
25
+ AbslContainerInternalSampleEverything)() {
25
26
  return false;
26
27
  }
27
28
 
@@ -33,6 +33,12 @@ namespace absl {
33
33
  ABSL_NAMESPACE_BEGIN
34
34
  namespace inlined_vector_internal {
35
35
 
36
+ // GCC does not deal very well with the below code
37
+ #if !defined(__clang__) && defined(__GNUC__)
38
+ #pragma GCC diagnostic push
39
+ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
40
+ #endif
41
+
36
42
  template <typename Iterator>
37
43
  using IsAtLeastForwardIterator = std::is_convertible<
38
44
  typename std::iterator_traits<Iterator>::iterator_category,
@@ -75,6 +81,23 @@ void DestroyElements(AllocatorType* alloc_ptr, Pointer destroy_first,
75
81
  }
76
82
  }
77
83
 
84
+ // If kUseMemcpy is true, memcpy(dst, src, n); else do nothing.
85
+ // Useful to avoid compiler warnings when memcpy() is used for T values
86
+ // that are not trivially copyable in non-reachable code.
87
+ template <bool kUseMemcpy>
88
+ inline void MemcpyIfAllowed(void* dst, const void* src, size_t n);
89
+
90
+ // memcpy when allowed.
91
+ template <>
92
+ inline void MemcpyIfAllowed<true>(void* dst, const void* src, size_t n) {
93
+ memcpy(dst, src, n);
94
+ }
95
+
96
+ // Do nothing for types that are not memcpy-able. This function is only
97
+ // called from non-reachable branches.
98
+ template <>
99
+ inline void MemcpyIfAllowed<false>(void*, const void*, size_t) {}
100
+
78
101
  template <typename AllocatorType, typename Pointer, typename ValueAdapter,
79
102
  typename SizeType>
80
103
  void ConstructElements(AllocatorType* alloc_ptr, Pointer construct_first,
@@ -298,14 +321,20 @@ class Storage {
298
321
  // Storage Constructors and Destructor
299
322
  // ---------------------------------------------------------------------------
300
323
 
301
- Storage() : metadata_() {}
324
+ Storage() : metadata_(allocator_type(), /* size and is_allocated */ 0) {}
302
325
 
303
- explicit Storage(const allocator_type& alloc) : metadata_(alloc, {}) {}
326
+ explicit Storage(const allocator_type& alloc)
327
+ : metadata_(alloc, /* size and is_allocated */ 0) {}
304
328
 
305
329
  ~Storage() {
306
- pointer data = GetIsAllocated() ? GetAllocatedData() : GetInlinedData();
307
- inlined_vector_internal::DestroyElements(GetAllocPtr(), data, GetSize());
308
- DeallocateIfAllocated();
330
+ if (GetSizeAndIsAllocated() == 0) {
331
+ // Empty and not allocated; nothing to do.
332
+ } else if (IsMemcpyOk::value) {
333
+ // No destructors need to be run; just deallocate if necessary.
334
+ DeallocateIfAllocated();
335
+ } else {
336
+ DestroyContents();
337
+ }
309
338
  }
310
339
 
311
340
  // ---------------------------------------------------------------------------
@@ -363,6 +392,8 @@ class Storage {
363
392
  // Storage Member Mutators
364
393
  // ---------------------------------------------------------------------------
365
394
 
395
+ ABSL_ATTRIBUTE_NOINLINE void InitFrom(const Storage& other);
396
+
366
397
  template <typename ValueAdapter>
367
398
  void Initialize(ValueAdapter values, size_type new_size);
368
399
 
@@ -445,6 +476,8 @@ class Storage {
445
476
  }
446
477
 
447
478
  private:
479
+ ABSL_ATTRIBUTE_NOINLINE void DestroyContents();
480
+
448
481
  using Metadata =
449
482
  container_internal::CompressedTuple<allocator_type, size_type>;
450
483
 
@@ -462,10 +495,47 @@ class Storage {
462
495
  Inlined inlined;
463
496
  };
464
497
 
498
+ template <typename... Args>
499
+ ABSL_ATTRIBUTE_NOINLINE reference EmplaceBackSlow(Args&&... args);
500
+
465
501
  Metadata metadata_;
466
502
  Data data_;
467
503
  };
468
504
 
505
+ template <typename T, size_t N, typename A>
506
+ void Storage<T, N, A>::DestroyContents() {
507
+ pointer data = GetIsAllocated() ? GetAllocatedData() : GetInlinedData();
508
+ inlined_vector_internal::DestroyElements(GetAllocPtr(), data, GetSize());
509
+ DeallocateIfAllocated();
510
+ }
511
+
512
+ template <typename T, size_t N, typename A>
513
+ void Storage<T, N, A>::InitFrom(const Storage& other) {
514
+ const auto n = other.GetSize();
515
+ assert(n > 0); // Empty sources handled handled in caller.
516
+ const_pointer src;
517
+ pointer dst;
518
+ if (!other.GetIsAllocated()) {
519
+ dst = GetInlinedData();
520
+ src = other.GetInlinedData();
521
+ } else {
522
+ // Because this is only called from the `InlinedVector` constructors, it's
523
+ // safe to take on the allocation with size `0`. If `ConstructElements(...)`
524
+ // throws, deallocation will be automatically handled by `~Storage()`.
525
+ size_type new_capacity = ComputeCapacity(GetInlinedCapacity(), n);
526
+ dst = AllocatorTraits::allocate(*GetAllocPtr(), new_capacity);
527
+ SetAllocatedData(dst, new_capacity);
528
+ src = other.GetAllocatedData();
529
+ }
530
+ if (IsMemcpyOk::value) {
531
+ MemcpyIfAllowed<IsMemcpyOk::value>(dst, src, sizeof(dst[0]) * n);
532
+ } else {
533
+ auto values = IteratorValueAdapter<const_pointer>(src);
534
+ inlined_vector_internal::ConstructElements(GetAllocPtr(), dst, &values, n);
535
+ }
536
+ GetSizeAndIsAllocated() = other.GetSizeAndIsAllocated();
537
+ }
538
+
469
539
  template <typename T, size_t N, typename A>
470
540
  template <typename ValueAdapter>
471
541
  auto Storage<T, N, A>::Initialize(ValueAdapter values, size_type new_size)
@@ -542,48 +612,42 @@ template <typename T, size_t N, typename A>
542
612
  template <typename ValueAdapter>
543
613
  auto Storage<T, N, A>::Resize(ValueAdapter values, size_type new_size) -> void {
544
614
  StorageView storage_view = MakeStorageView();
545
-
546
- IteratorValueAdapter<MoveIterator> move_values(
547
- MoveIterator(storage_view.data));
548
-
549
- AllocationTransaction allocation_tx(GetAllocPtr());
550
- ConstructionTransaction construction_tx(GetAllocPtr());
551
-
552
- absl::Span<value_type> construct_loop;
553
- absl::Span<value_type> move_construct_loop;
554
- absl::Span<value_type> destroy_loop;
555
-
556
- if (new_size > storage_view.capacity) {
615
+ auto* const base = storage_view.data;
616
+ const size_type size = storage_view.size;
617
+ auto* alloc = GetAllocPtr();
618
+ if (new_size <= size) {
619
+ // Destroy extra old elements.
620
+ inlined_vector_internal::DestroyElements(alloc, base + new_size,
621
+ size - new_size);
622
+ } else if (new_size <= storage_view.capacity) {
623
+ // Construct new elements in place.
624
+ inlined_vector_internal::ConstructElements(alloc, base + size, &values,
625
+ new_size - size);
626
+ } else {
627
+ // Steps:
628
+ // a. Allocate new backing store.
629
+ // b. Construct new elements in new backing store.
630
+ // c. Move existing elements from old backing store to now.
631
+ // d. Destroy all elements in old backing store.
632
+ // Use transactional wrappers for the first two steps so we can roll
633
+ // back if necessary due to exceptions.
634
+ AllocationTransaction allocation_tx(alloc);
557
635
  size_type new_capacity = ComputeCapacity(storage_view.capacity, new_size);
558
636
  pointer new_data = allocation_tx.Allocate(new_capacity);
559
- construct_loop = {new_data + storage_view.size,
560
- new_size - storage_view.size};
561
- move_construct_loop = {new_data, storage_view.size};
562
- destroy_loop = {storage_view.data, storage_view.size};
563
- } else if (new_size > storage_view.size) {
564
- construct_loop = {storage_view.data + storage_view.size,
565
- new_size - storage_view.size};
566
- } else {
567
- destroy_loop = {storage_view.data + new_size, storage_view.size - new_size};
568
- }
569
637
 
570
- construction_tx.Construct(construct_loop.data(), &values,
571
- construct_loop.size());
638
+ ConstructionTransaction construction_tx(alloc);
639
+ construction_tx.Construct(new_data + size, &values, new_size - size);
572
640
 
573
- inlined_vector_internal::ConstructElements(
574
- GetAllocPtr(), move_construct_loop.data(), &move_values,
575
- move_construct_loop.size());
576
-
577
- inlined_vector_internal::DestroyElements(GetAllocPtr(), destroy_loop.data(),
578
- destroy_loop.size());
641
+ IteratorValueAdapter<MoveIterator> move_values((MoveIterator(base)));
642
+ inlined_vector_internal::ConstructElements(alloc, new_data, &move_values,
643
+ size);
579
644
 
580
- construction_tx.Commit();
581
- if (allocation_tx.DidAllocate()) {
645
+ inlined_vector_internal::DestroyElements(alloc, base, size);
646
+ construction_tx.Commit();
582
647
  DeallocateIfAllocated();
583
648
  AcquireAllocatedData(&allocation_tx);
584
649
  SetIsAllocated();
585
650
  }
586
-
587
651
  SetSize(new_size);
588
652
  }
589
653
 
@@ -684,44 +748,50 @@ template <typename T, size_t N, typename A>
684
748
  template <typename... Args>
685
749
  auto Storage<T, N, A>::EmplaceBack(Args&&... args) -> reference {
686
750
  StorageView storage_view = MakeStorageView();
751
+ const auto n = storage_view.size;
752
+ if (ABSL_PREDICT_TRUE(n != storage_view.capacity)) {
753
+ // Fast path; new element fits.
754
+ pointer last_ptr = storage_view.data + n;
755
+ AllocatorTraits::construct(*GetAllocPtr(), last_ptr,
756
+ std::forward<Args>(args)...);
757
+ AddSize(1);
758
+ return *last_ptr;
759
+ }
760
+ // TODO(b/173712035): Annotate with musttail attribute to prevent regression.
761
+ return EmplaceBackSlow(std::forward<Args>(args)...);
762
+ }
687
763
 
764
+ template <typename T, size_t N, typename A>
765
+ template <typename... Args>
766
+ auto Storage<T, N, A>::EmplaceBackSlow(Args&&... args) -> reference {
767
+ StorageView storage_view = MakeStorageView();
688
768
  AllocationTransaction allocation_tx(GetAllocPtr());
689
-
690
769
  IteratorValueAdapter<MoveIterator> move_values(
691
770
  MoveIterator(storage_view.data));
692
-
693
- pointer construct_data;
694
- if (storage_view.size == storage_view.capacity) {
695
- size_type new_capacity = NextCapacity(storage_view.capacity);
696
- construct_data = allocation_tx.Allocate(new_capacity);
697
- } else {
698
- construct_data = storage_view.data;
699
- }
700
-
771
+ size_type new_capacity = NextCapacity(storage_view.capacity);
772
+ pointer construct_data = allocation_tx.Allocate(new_capacity);
701
773
  pointer last_ptr = construct_data + storage_view.size;
702
774
 
775
+ // Construct new element.
703
776
  AllocatorTraits::construct(*GetAllocPtr(), last_ptr,
704
777
  std::forward<Args>(args)...);
705
-
706
- if (allocation_tx.DidAllocate()) {
707
- ABSL_INTERNAL_TRY {
708
- inlined_vector_internal::ConstructElements(
709
- GetAllocPtr(), allocation_tx.GetData(), &move_values,
710
- storage_view.size);
711
- }
712
- ABSL_INTERNAL_CATCH_ANY {
713
- AllocatorTraits::destroy(*GetAllocPtr(), last_ptr);
714
- ABSL_INTERNAL_RETHROW;
715
- }
716
-
717
- inlined_vector_internal::DestroyElements(GetAllocPtr(), storage_view.data,
718
- storage_view.size);
719
-
720
- DeallocateIfAllocated();
721
- AcquireAllocatedData(&allocation_tx);
722
- SetIsAllocated();
778
+ // Move elements from old backing store to new backing store.
779
+ ABSL_INTERNAL_TRY {
780
+ inlined_vector_internal::ConstructElements(
781
+ GetAllocPtr(), allocation_tx.GetData(), &move_values,
782
+ storage_view.size);
783
+ }
784
+ ABSL_INTERNAL_CATCH_ANY {
785
+ AllocatorTraits::destroy(*GetAllocPtr(), last_ptr);
786
+ ABSL_INTERNAL_RETHROW;
723
787
  }
788
+ // Destroy elements in old backing store.
789
+ inlined_vector_internal::DestroyElements(GetAllocPtr(), storage_view.data,
790
+ storage_view.size);
724
791
 
792
+ DeallocateIfAllocated();
793
+ AcquireAllocatedData(&allocation_tx);
794
+ SetIsAllocated();
725
795
  AddSize(1);
726
796
  return *last_ptr;
727
797
  }
@@ -885,6 +955,11 @@ auto Storage<T, N, A>::Swap(Storage* other_storage_ptr) -> void {
885
955
  swap(*GetAllocPtr(), *other_storage_ptr->GetAllocPtr());
886
956
  }
887
957
 
958
+ // End ignore "maybe-uninitialized"
959
+ #if !defined(__clang__) && defined(__GNUC__)
960
+ #pragma GCC diagnostic pop
961
+ #endif
962
+
888
963
  } // namespace inlined_vector_internal
889
964
  ABSL_NAMESPACE_END
890
965
  } // namespace absl
@@ -404,7 +404,7 @@ class LayoutImpl<std::tuple<Elements...>, absl::index_sequence<SizeSeq...>,
404
404
  constexpr size_t Offset() const {
405
405
  static_assert(N < NumOffsets, "Index out of bounds");
406
406
  return adl_barrier::Align(
407
- Offset<N - 1>() + SizeOf<ElementType<N - 1>>() * size_[N - 1],
407
+ Offset<N - 1>() + SizeOf<ElementType<N - 1>>::value * size_[N - 1],
408
408
  ElementAlignment<N>::value);
409
409
  }
410
410
 
@@ -597,7 +597,7 @@ class LayoutImpl<std::tuple<Elements...>, absl::index_sequence<SizeSeq...>,
597
597
  constexpr size_t AllocSize() const {
598
598
  static_assert(NumTypes == NumSizes, "You must specify sizes of all fields");
599
599
  return Offset<NumTypes - 1>() +
600
- SizeOf<ElementType<NumTypes - 1>>() * size_[NumTypes - 1];
600
+ SizeOf<ElementType<NumTypes - 1>>::value * size_[NumTypes - 1];
601
601
  }
602
602
 
603
603
  // If built with --config=asan, poisons padding bytes (if any) in the
@@ -621,7 +621,7 @@ class LayoutImpl<std::tuple<Elements...>, absl::index_sequence<SizeSeq...>,
621
621
  // The `if` is an optimization. It doesn't affect the observable behaviour.
622
622
  if (ElementAlignment<N - 1>::value % ElementAlignment<N>::value) {
623
623
  size_t start =
624
- Offset<N - 1>() + SizeOf<ElementType<N - 1>>() * size_[N - 1];
624
+ Offset<N - 1>() + SizeOf<ElementType<N - 1>>::value * size_[N - 1];
625
625
  ASAN_POISON_MEMORY_REGION(p + start, Offset<N>() - start);
626
626
  }
627
627
  #endif
@@ -645,7 +645,7 @@ class LayoutImpl<std::tuple<Elements...>, absl::index_sequence<SizeSeq...>,
645
645
  // produce "unsigned*" where another produces "unsigned int *".
646
646
  std::string DebugString() const {
647
647
  const auto offsets = Offsets();
648
- const size_t sizes[] = {SizeOf<ElementType<OffsetSeq>>()...};
648
+ const size_t sizes[] = {SizeOf<ElementType<OffsetSeq>>::value...};
649
649
  const std::string types[] = {
650
650
  adl_barrier::TypeName<ElementType<OffsetSeq>>()...};
651
651
  std::string res = absl::StrCat("@0", types[0], "(", sizes[0], ")");
@@ -27,7 +27,7 @@ constexpr size_t Group::kWidth;
27
27
 
28
28
  // Returns "random" seed.
29
29
  inline size_t RandomSeed() {
30
- #if ABSL_HAVE_THREAD_LOCAL
30
+ #ifdef ABSL_HAVE_THREAD_LOCAL
31
31
  static thread_local size_t counter = 0;
32
32
  size_t value = ++counter;
33
33
  #else // ABSL_HAVE_THREAD_LOCAL
@@ -43,6 +43,19 @@ bool ShouldInsertBackwards(size_t hash, ctrl_t* ctrl) {
43
43
  return (H1(hash, ctrl) ^ RandomSeed()) % 13 > 6;
44
44
  }
45
45
 
46
+ void ConvertDeletedToEmptyAndFullToDeleted(
47
+ ctrl_t* ctrl, size_t capacity) {
48
+ assert(ctrl[capacity] == kSentinel);
49
+ assert(IsValidCapacity(capacity));
50
+ for (ctrl_t* pos = ctrl; pos != ctrl + capacity + 1; pos += Group::kWidth) {
51
+ Group{pos}.ConvertSpecialToEmptyAndFullToDeleted(pos);
52
+ }
53
+ // Copy the cloned ctrl bytes.
54
+ std::memcpy(ctrl + capacity + 1, ctrl, Group::kWidth);
55
+ ctrl[capacity] = kSentinel;
56
+ }
57
+
58
+
46
59
  } // namespace container_internal
47
60
  ABSL_NAMESPACE_END
48
61
  } // namespace absl
@@ -102,7 +102,6 @@
102
102
  #include <type_traits>
103
103
  #include <utility>
104
104
 
105
- #include "absl/base/internal/bits.h"
106
105
  #include "absl/base/internal/endian.h"
107
106
  #include "absl/base/optimization.h"
108
107
  #include "absl/base/port.h"
@@ -116,6 +115,7 @@
116
115
  #include "absl/container/internal/layout.h"
117
116
  #include "absl/memory/memory.h"
118
117
  #include "absl/meta/type_traits.h"
118
+ #include "absl/numeric/bits.h"
119
119
  #include "absl/utility/utility.h"
120
120
 
121
121
  namespace absl {
@@ -189,18 +189,9 @@ constexpr bool IsNoThrowSwappable(std::false_type /* is_swappable */) {
189
189
  }
190
190
 
191
191
  template <typename T>
192
- int TrailingZeros(T x) {
193
- return sizeof(T) == 8 ? base_internal::CountTrailingZerosNonZero64(
194
- static_cast<uint64_t>(x))
195
- : base_internal::CountTrailingZerosNonZero32(
196
- static_cast<uint32_t>(x));
197
- }
198
-
199
- template <typename T>
200
- int LeadingZeros(T x) {
201
- return sizeof(T) == 8
202
- ? base_internal::CountLeadingZeros64(static_cast<uint64_t>(x))
203
- : base_internal::CountLeadingZeros32(static_cast<uint32_t>(x));
192
+ uint32_t TrailingZeros(T x) {
193
+ ABSL_INTERNAL_ASSUME(x != 0);
194
+ return countr_zero(x);
204
195
  }
205
196
 
206
197
  // An abstraction over a bitmask. It provides an easy way to iterate through the
@@ -230,26 +221,24 @@ class BitMask {
230
221
  }
231
222
  explicit operator bool() const { return mask_ != 0; }
232
223
  int operator*() const { return LowestBitSet(); }
233
- int LowestBitSet() const {
224
+ uint32_t LowestBitSet() const {
234
225
  return container_internal::TrailingZeros(mask_) >> Shift;
235
226
  }
236
- int HighestBitSet() const {
237
- return (sizeof(T) * CHAR_BIT - container_internal::LeadingZeros(mask_) -
238
- 1) >>
239
- Shift;
227
+ uint32_t HighestBitSet() const {
228
+ return static_cast<uint32_t>((bit_width(mask_) - 1) >> Shift);
240
229
  }
241
230
 
242
231
  BitMask begin() const { return *this; }
243
232
  BitMask end() const { return BitMask(0); }
244
233
 
245
- int TrailingZeros() const {
234
+ uint32_t TrailingZeros() const {
246
235
  return container_internal::TrailingZeros(mask_) >> Shift;
247
236
  }
248
237
 
249
- int LeadingZeros() const {
238
+ uint32_t LeadingZeros() const {
250
239
  constexpr int total_significant_bits = SignificantBits << Shift;
251
240
  constexpr int extra_bits = sizeof(T) * 8 - total_significant_bits;
252
- return container_internal::LeadingZeros(mask_ << extra_bits) >> Shift;
241
+ return countl_zero(mask_ << extra_bits) >> Shift;
253
242
  }
254
243
 
255
244
  private:
@@ -380,8 +369,8 @@ struct GroupSse2Impl {
380
369
  // Returns the number of trailing empty or deleted elements in the group.
381
370
  uint32_t CountLeadingEmptyOrDeleted() const {
382
371
  auto special = _mm_set1_epi8(kSentinel);
383
- return TrailingZeros(
384
- _mm_movemask_epi8(_mm_cmpgt_epi8_fixed(special, ctrl)) + 1);
372
+ return TrailingZeros(static_cast<uint32_t>(
373
+ _mm_movemask_epi8(_mm_cmpgt_epi8_fixed(special, ctrl)) + 1));
385
374
  }
386
375
 
387
376
  void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const {
@@ -472,25 +461,23 @@ inline bool IsValidCapacity(size_t n) { return ((n + 1) & n) == 0 && n > 0; }
472
461
  // DELETED -> EMPTY
473
462
  // EMPTY -> EMPTY
474
463
  // FULL -> DELETED
475
- inline void ConvertDeletedToEmptyAndFullToDeleted(
476
- ctrl_t* ctrl, size_t capacity) {
477
- assert(ctrl[capacity] == kSentinel);
478
- assert(IsValidCapacity(capacity));
479
- for (ctrl_t* pos = ctrl; pos != ctrl + capacity + 1; pos += Group::kWidth) {
480
- Group{pos}.ConvertSpecialToEmptyAndFullToDeleted(pos);
481
- }
482
- // Copy the cloned ctrl bytes.
483
- std::memcpy(ctrl + capacity + 1, ctrl, Group::kWidth);
484
- ctrl[capacity] = kSentinel;
485
- }
464
+ void ConvertDeletedToEmptyAndFullToDeleted(ctrl_t* ctrl, size_t capacity);
486
465
 
487
466
  // Rounds up the capacity to the next power of 2 minus 1, with a minimum of 1.
488
467
  inline size_t NormalizeCapacity(size_t n) {
489
- return n ? ~size_t{} >> LeadingZeros(n) : 1;
468
+ return n ? ~size_t{} >> countl_zero(n) : 1;
490
469
  }
491
470
 
492
- // We use 7/8th as maximum load factor.
493
- // For 16-wide groups, that gives an average of two empty slots per group.
471
+ // General notes on capacity/growth methods below:
472
+ // - We use 7/8th as maximum load factor. For 16-wide groups, that gives an
473
+ // average of two empty slots per group.
474
+ // - For (capacity+1) >= Group::kWidth, growth is 7/8*capacity.
475
+ // - For (capacity+1) < Group::kWidth, growth == capacity. In this case, we
476
+ // never need to probe (the whole table fits in one group) so we don't need a
477
+ // load factor less than 1.
478
+
479
+ // Given `capacity` of the table, returns the size (i.e. number of full slots)
480
+ // at which we should grow the capacity.
494
481
  inline size_t CapacityToGrowth(size_t capacity) {
495
482
  assert(IsValidCapacity(capacity));
496
483
  // `capacity*7/8`
@@ -501,7 +488,7 @@ inline size_t CapacityToGrowth(size_t capacity) {
501
488
  return capacity - capacity / 8;
502
489
  }
503
490
  // From desired "growth" to a lowerbound of the necessary capacity.
504
- // Might not be a valid one and required NormalizeCapacity().
491
+ // Might not be a valid one and requires NormalizeCapacity().
505
492
  inline size_t GrowthToLowerboundCapacity(size_t growth) {
506
493
  // `growth*8/7`
507
494
  if (Group::kWidth == 8 && growth == 7) {
@@ -523,6 +510,64 @@ inline void AssertIsValid(ctrl_t* ctrl) {
523
510
  "been erased, or the table might have rehashed.");
524
511
  }
525
512
 
513
+ struct FindInfo {
514
+ size_t offset;
515
+ size_t probe_length;
516
+ };
517
+
518
+ // The representation of the object has two modes:
519
+ // - small: For capacities < kWidth-1
520
+ // - large: For the rest.
521
+ //
522
+ // Differences:
523
+ // - In small mode we are able to use the whole capacity. The extra control
524
+ // bytes give us at least one "empty" control byte to stop the iteration.
525
+ // This is important to make 1 a valid capacity.
526
+ //
527
+ // - In small mode only the first `capacity()` control bytes after the
528
+ // sentinel are valid. The rest contain dummy kEmpty values that do not
529
+ // represent a real slot. This is important to take into account on
530
+ // find_first_non_full(), where we never try ShouldInsertBackwards() for
531
+ // small tables.
532
+ inline bool is_small(size_t capacity) { return capacity < Group::kWidth - 1; }
533
+
534
+ inline probe_seq<Group::kWidth> probe(ctrl_t* ctrl, size_t hash,
535
+ size_t capacity) {
536
+ return probe_seq<Group::kWidth>(H1(hash, ctrl), capacity);
537
+ }
538
+
539
+ // Probes the raw_hash_set with the probe sequence for hash and returns the
540
+ // pointer to the first empty or deleted slot.
541
+ // NOTE: this function must work with tables having both kEmpty and kDelete
542
+ // in one group. Such tables appears during drop_deletes_without_resize.
543
+ //
544
+ // This function is very useful when insertions happen and:
545
+ // - the input is already a set
546
+ // - there are enough slots
547
+ // - the element with the hash is not in the table
548
+ inline FindInfo find_first_non_full(ctrl_t* ctrl, size_t hash,
549
+ size_t capacity) {
550
+ auto seq = probe(ctrl, hash, capacity);
551
+ while (true) {
552
+ Group g{ctrl + seq.offset()};
553
+ auto mask = g.MatchEmptyOrDeleted();
554
+ if (mask) {
555
+ #if !defined(NDEBUG)
556
+ // We want to add entropy even when ASLR is not enabled.
557
+ // In debug build we will randomly insert in either the front or back of
558
+ // the group.
559
+ // TODO(kfm,sbenza): revisit after we do unconditional mixing
560
+ if (!is_small(capacity) && ShouldInsertBackwards(hash, ctrl)) {
561
+ return {seq.offset(mask.HighestBitSet()), seq.index()};
562
+ }
563
+ #endif
564
+ return {seq.offset(mask.LowestBitSet()), seq.index()};
565
+ }
566
+ seq.next();
567
+ assert(seq.index() < capacity && "full table!");
568
+ }
569
+ }
570
+
526
571
  // Policy: a policy defines how to perform different operations on
527
572
  // the slots of the hashtable (see hash_policy_traits.h for the full interface
528
573
  // of policy).
@@ -747,10 +792,10 @@ class raw_hash_set {
747
792
  explicit raw_hash_set(size_t bucket_count, const hasher& hash = hasher(),
748
793
  const key_equal& eq = key_equal(),
749
794
  const allocator_type& alloc = allocator_type())
750
- : ctrl_(EmptyGroup()), settings_(0, hash, eq, alloc) {
795
+ : ctrl_(EmptyGroup()),
796
+ settings_(0, HashtablezInfoHandle(), hash, eq, alloc) {
751
797
  if (bucket_count) {
752
798
  capacity_ = NormalizeCapacity(bucket_count);
753
- reset_growth_left();
754
799
  initialize_slots();
755
800
  }
756
801
  }
@@ -856,10 +901,10 @@ class raw_hash_set {
856
901
  // than a full `insert`.
857
902
  for (const auto& v : that) {
858
903
  const size_t hash = PolicyTraits::apply(HashElement{hash_ref()}, v);
859
- auto target = find_first_non_full(hash);
904
+ auto target = find_first_non_full(ctrl_, hash, capacity_);
860
905
  set_ctrl(target.offset, H2(hash));
861
906
  emplace_at(target.offset, v);
862
- infoz_.RecordInsert(hash, target.probe_length);
907
+ infoz().RecordInsert(hash, target.probe_length);
863
908
  }
864
909
  size_ = that.size();
865
910
  growth_left() -= that.size();
@@ -873,28 +918,27 @@ class raw_hash_set {
873
918
  slots_(absl::exchange(that.slots_, nullptr)),
874
919
  size_(absl::exchange(that.size_, 0)),
875
920
  capacity_(absl::exchange(that.capacity_, 0)),
876
- infoz_(absl::exchange(that.infoz_, HashtablezInfoHandle())),
877
921
  // Hash, equality and allocator are copied instead of moved because
878
922
  // `that` must be left valid. If Hash is std::function<Key>, moving it
879
923
  // would create a nullptr functor that cannot be called.
880
- settings_(that.settings_) {
881
- // growth_left was copied above, reset the one from `that`.
882
- that.growth_left() = 0;
883
- }
924
+ settings_(absl::exchange(that.growth_left(), 0),
925
+ absl::exchange(that.infoz(), HashtablezInfoHandle()),
926
+ that.hash_ref(), that.eq_ref(), that.alloc_ref()) {}
884
927
 
885
928
  raw_hash_set(raw_hash_set&& that, const allocator_type& a)
886
929
  : ctrl_(EmptyGroup()),
887
930
  slots_(nullptr),
888
931
  size_(0),
889
932
  capacity_(0),
890
- settings_(0, that.hash_ref(), that.eq_ref(), a) {
933
+ settings_(0, HashtablezInfoHandle(), that.hash_ref(), that.eq_ref(),
934
+ a) {
891
935
  if (a == that.alloc_ref()) {
892
936
  std::swap(ctrl_, that.ctrl_);
893
937
  std::swap(slots_, that.slots_);
894
938
  std::swap(size_, that.size_);
895
939
  std::swap(capacity_, that.capacity_);
896
940
  std::swap(growth_left(), that.growth_left());
897
- std::swap(infoz_, that.infoz_);
941
+ std::swap(infoz(), that.infoz());
898
942
  } else {
899
943
  reserve(that.size());
900
944
  // Note: this will copy elements of dense_set and unordered_set instead of
@@ -965,7 +1009,7 @@ class raw_hash_set {
965
1009
  reset_growth_left();
966
1010
  }
967
1011
  assert(empty());
968
- infoz_.RecordStorageChanged(0, capacity_);
1012
+ infoz().RecordStorageChanged(0, capacity_);
969
1013
  }
970
1014
 
971
1015
  // This overload kicks in when the argument is an rvalue of insertable and
@@ -1038,7 +1082,7 @@ class raw_hash_set {
1038
1082
 
1039
1083
  template <class InputIt>
1040
1084
  void insert(InputIt first, InputIt last) {
1041
- for (; first != last; ++first) insert(*first);
1085
+ for (; first != last; ++first) emplace(*first);
1042
1086
  }
1043
1087
 
1044
1088
  template <class T, RequiresNotInit<T> = 0, RequiresInsertable<const T&> = 0>
@@ -1065,7 +1109,9 @@ class raw_hash_set {
1065
1109
  }
1066
1110
 
1067
1111
  iterator insert(const_iterator, node_type&& node) {
1068
- return insert(std::move(node)).first;
1112
+ auto res = insert(std::move(node));
1113
+ node = std::move(res.node);
1114
+ return res.position;
1069
1115
  }
1070
1116
 
1071
1117
  // This overload kicks in if we can deduce the key from args. This enables us
@@ -1255,7 +1301,7 @@ class raw_hash_set {
1255
1301
  swap(growth_left(), that.growth_left());
1256
1302
  swap(hash_ref(), that.hash_ref());
1257
1303
  swap(eq_ref(), that.eq_ref());
1258
- swap(infoz_, that.infoz_);
1304
+ swap(infoz(), that.infoz());
1259
1305
  SwapAlloc(alloc_ref(), that.alloc_ref(),
1260
1306
  typename AllocTraits::propagate_on_container_swap{});
1261
1307
  }
@@ -1264,7 +1310,7 @@ class raw_hash_set {
1264
1310
  if (n == 0 && capacity_ == 0) return;
1265
1311
  if (n == 0 && size_ == 0) {
1266
1312
  destroy_slots();
1267
- infoz_.RecordStorageChanged(0, 0);
1313
+ infoz().RecordStorageChanged(0, 0);
1268
1314
  return;
1269
1315
  }
1270
1316
  // bitor is a faster way of doing `max` here. We will round up to the next
@@ -1276,7 +1322,12 @@ class raw_hash_set {
1276
1322
  }
1277
1323
  }
1278
1324
 
1279
- void reserve(size_t n) { rehash(GrowthToLowerboundCapacity(n)); }
1325
+ void reserve(size_t n) {
1326
+ size_t m = GrowthToLowerboundCapacity(n);
1327
+ if (m > capacity_) {
1328
+ resize(NormalizeCapacity(m));
1329
+ }
1330
+ }
1280
1331
 
1281
1332
  // Extension API: support for heterogeneous keys.
1282
1333
  //
@@ -1301,7 +1352,7 @@ class raw_hash_set {
1301
1352
  void prefetch(const key_arg<K>& key) const {
1302
1353
  (void)key;
1303
1354
  #if defined(__GNUC__)
1304
- auto seq = probe(hash_ref()(key));
1355
+ auto seq = probe(ctrl_, hash_ref()(key), capacity_);
1305
1356
  __builtin_prefetch(static_cast<const void*>(ctrl_ + seq.offset()));
1306
1357
  __builtin_prefetch(static_cast<const void*>(slots_ + seq.offset()));
1307
1358
  #endif // __GNUC__
@@ -1316,7 +1367,7 @@ class raw_hash_set {
1316
1367
  // called heterogeneous key support.
1317
1368
  template <class K = key_type>
1318
1369
  iterator find(const key_arg<K>& key, size_t hash) {
1319
- auto seq = probe(hash);
1370
+ auto seq = probe(ctrl_, hash, capacity_);
1320
1371
  while (true) {
1321
1372
  Group g{ctrl_ + seq.offset()};
1322
1373
  for (int i : g.Match(H2(hash))) {
@@ -1477,7 +1528,7 @@ class raw_hash_set {
1477
1528
 
1478
1529
  set_ctrl(index, was_never_full ? kEmpty : kDeleted);
1479
1530
  growth_left() += was_never_full;
1480
- infoz_.RecordErase();
1531
+ infoz().RecordErase();
1481
1532
  }
1482
1533
 
1483
1534
  void initialize_slots() {
@@ -1494,7 +1545,7 @@ class raw_hash_set {
1494
1545
  // bound more carefully.
1495
1546
  if (std::is_same<SlotAlloc, std::allocator<slot_type>>::value &&
1496
1547
  slots_ == nullptr) {
1497
- infoz_ = Sample();
1548
+ infoz() = Sample();
1498
1549
  }
1499
1550
 
1500
1551
  auto layout = MakeLayout(capacity_);
@@ -1504,7 +1555,7 @@ class raw_hash_set {
1504
1555
  slots_ = layout.template Pointer<1>(mem);
1505
1556
  reset_ctrl();
1506
1557
  reset_growth_left();
1507
- infoz_.RecordStorageChanged(size_, capacity_);
1558
+ infoz().RecordStorageChanged(size_, capacity_);
1508
1559
  }
1509
1560
 
1510
1561
  void destroy_slots() {
@@ -1538,7 +1589,7 @@ class raw_hash_set {
1538
1589
  if (IsFull(old_ctrl[i])) {
1539
1590
  size_t hash = PolicyTraits::apply(HashElement{hash_ref()},
1540
1591
  PolicyTraits::element(old_slots + i));
1541
- auto target = find_first_non_full(hash);
1592
+ auto target = find_first_non_full(ctrl_, hash, capacity_);
1542
1593
  size_t new_i = target.offset;
1543
1594
  total_probe_length += target.probe_length;
1544
1595
  set_ctrl(new_i, H2(hash));
@@ -1552,12 +1603,12 @@ class raw_hash_set {
1552
1603
  Deallocate<Layout::Alignment()>(&alloc_ref(), old_ctrl,
1553
1604
  layout.AllocSize());
1554
1605
  }
1555
- infoz_.RecordRehash(total_probe_length);
1606
+ infoz().RecordRehash(total_probe_length);
1556
1607
  }
1557
1608
 
1558
1609
  void drop_deletes_without_resize() ABSL_ATTRIBUTE_NOINLINE {
1559
1610
  assert(IsValidCapacity(capacity_));
1560
- assert(!is_small());
1611
+ assert(!is_small(capacity_));
1561
1612
  // Algorithm:
1562
1613
  // - mark all DELETED slots as EMPTY
1563
1614
  // - mark all FULL slots as DELETED
@@ -1582,7 +1633,7 @@ class raw_hash_set {
1582
1633
  if (!IsDeleted(ctrl_[i])) continue;
1583
1634
  size_t hash = PolicyTraits::apply(HashElement{hash_ref()},
1584
1635
  PolicyTraits::element(slots_ + i));
1585
- auto target = find_first_non_full(hash);
1636
+ auto target = find_first_non_full(ctrl_, hash, capacity_);
1586
1637
  size_t new_i = target.offset;
1587
1638
  total_probe_length += target.probe_length;
1588
1639
 
@@ -1590,7 +1641,8 @@ class raw_hash_set {
1590
1641
  // If they do, we don't need to move the object as it falls already in the
1591
1642
  // best probe we can.
1592
1643
  const auto probe_index = [&](size_t pos) {
1593
- return ((pos - probe(hash).offset()) & capacity_) / Group::kWidth;
1644
+ return ((pos - probe(ctrl_, hash, capacity_).offset()) & capacity_) /
1645
+ Group::kWidth;
1594
1646
  };
1595
1647
 
1596
1648
  // Element doesn't move.
@@ -1617,7 +1669,7 @@ class raw_hash_set {
1617
1669
  }
1618
1670
  }
1619
1671
  reset_growth_left();
1620
- infoz_.RecordRehash(total_probe_length);
1672
+ infoz().RecordRehash(total_probe_length);
1621
1673
  }
1622
1674
 
1623
1675
  void rehash_and_grow_if_necessary() {
@@ -1634,7 +1686,7 @@ class raw_hash_set {
1634
1686
 
1635
1687
  bool has_element(const value_type& elem) const {
1636
1688
  size_t hash = PolicyTraits::apply(HashElement{hash_ref()}, elem);
1637
- auto seq = probe(hash);
1689
+ auto seq = probe(ctrl_, hash, capacity_);
1638
1690
  while (true) {
1639
1691
  Group g{ctrl_ + seq.offset()};
1640
1692
  for (int i : g.Match(H2(hash))) {
@@ -1649,41 +1701,6 @@ class raw_hash_set {
1649
1701
  return false;
1650
1702
  }
1651
1703
 
1652
- // Probes the raw_hash_set with the probe sequence for hash and returns the
1653
- // pointer to the first empty or deleted slot.
1654
- // NOTE: this function must work with tables having both kEmpty and kDelete
1655
- // in one group. Such tables appears during drop_deletes_without_resize.
1656
- //
1657
- // This function is very useful when insertions happen and:
1658
- // - the input is already a set
1659
- // - there are enough slots
1660
- // - the element with the hash is not in the table
1661
- struct FindInfo {
1662
- size_t offset;
1663
- size_t probe_length;
1664
- };
1665
- FindInfo find_first_non_full(size_t hash) {
1666
- auto seq = probe(hash);
1667
- while (true) {
1668
- Group g{ctrl_ + seq.offset()};
1669
- auto mask = g.MatchEmptyOrDeleted();
1670
- if (mask) {
1671
- #if !defined(NDEBUG)
1672
- // We want to add entropy even when ASLR is not enabled.
1673
- // In debug build we will randomly insert in either the front or back of
1674
- // the group.
1675
- // TODO(kfm,sbenza): revisit after we do unconditional mixing
1676
- if (!is_small() && ShouldInsertBackwards(hash, ctrl_)) {
1677
- return {seq.offset(mask.HighestBitSet()), seq.index()};
1678
- }
1679
- #endif
1680
- return {seq.offset(mask.LowestBitSet()), seq.index()};
1681
- }
1682
- seq.next();
1683
- assert(seq.index() < capacity_ && "full table!");
1684
- }
1685
- }
1686
-
1687
1704
  // TODO(alkis): Optimize this assuming *this and that don't overlap.
1688
1705
  raw_hash_set& move_assign(raw_hash_set&& that, std::true_type) {
1689
1706
  raw_hash_set tmp(std::move(that));
@@ -1700,7 +1717,7 @@ class raw_hash_set {
1700
1717
  template <class K>
1701
1718
  std::pair<size_t, bool> find_or_prepare_insert(const K& key) {
1702
1719
  auto hash = hash_ref()(key);
1703
- auto seq = probe(hash);
1720
+ auto seq = probe(ctrl_, hash, capacity_);
1704
1721
  while (true) {
1705
1722
  Group g{ctrl_ + seq.offset()};
1706
1723
  for (int i : g.Match(H2(hash))) {
@@ -1717,16 +1734,16 @@ class raw_hash_set {
1717
1734
  }
1718
1735
 
1719
1736
  size_t prepare_insert(size_t hash) ABSL_ATTRIBUTE_NOINLINE {
1720
- auto target = find_first_non_full(hash);
1737
+ auto target = find_first_non_full(ctrl_, hash, capacity_);
1721
1738
  if (ABSL_PREDICT_FALSE(growth_left() == 0 &&
1722
1739
  !IsDeleted(ctrl_[target.offset]))) {
1723
1740
  rehash_and_grow_if_necessary();
1724
- target = find_first_non_full(hash);
1741
+ target = find_first_non_full(ctrl_, hash, capacity_);
1725
1742
  }
1726
1743
  ++size_;
1727
1744
  growth_left() -= IsEmpty(ctrl_[target.offset]);
1728
1745
  set_ctrl(target.offset, H2(hash));
1729
- infoz_.RecordInsert(hash, target.probe_length);
1746
+ infoz().RecordInsert(hash, target.probe_length);
1730
1747
  return target.offset;
1731
1748
  }
1732
1749
 
@@ -1754,10 +1771,6 @@ class raw_hash_set {
1754
1771
  private:
1755
1772
  friend struct RawHashSetTestOnlyAccess;
1756
1773
 
1757
- probe_seq<Group::kWidth> probe(size_t hash) const {
1758
- return probe_seq<Group::kWidth>(H1(hash, ctrl_), capacity_);
1759
- }
1760
-
1761
1774
  // Reset all ctrl bytes back to kEmpty, except the sentinel.
1762
1775
  void reset_ctrl() {
1763
1776
  std::memset(ctrl_, kEmpty, capacity_ + Group::kWidth);
@@ -1787,29 +1800,15 @@ class raw_hash_set {
1787
1800
 
1788
1801
  size_t& growth_left() { return settings_.template get<0>(); }
1789
1802
 
1790
- // The representation of the object has two modes:
1791
- // - small: For capacities < kWidth-1
1792
- // - large: For the rest.
1793
- //
1794
- // Differences:
1795
- // - In small mode we are able to use the whole capacity. The extra control
1796
- // bytes give us at least one "empty" control byte to stop the iteration.
1797
- // This is important to make 1 a valid capacity.
1798
- //
1799
- // - In small mode only the first `capacity()` control bytes after the
1800
- // sentinel are valid. The rest contain dummy kEmpty values that do not
1801
- // represent a real slot. This is important to take into account on
1802
- // find_first_non_full(), where we never try ShouldInsertBackwards() for
1803
- // small tables.
1804
- bool is_small() const { return capacity_ < Group::kWidth - 1; }
1805
-
1806
- hasher& hash_ref() { return settings_.template get<1>(); }
1807
- const hasher& hash_ref() const { return settings_.template get<1>(); }
1808
- key_equal& eq_ref() { return settings_.template get<2>(); }
1809
- const key_equal& eq_ref() const { return settings_.template get<2>(); }
1810
- allocator_type& alloc_ref() { return settings_.template get<3>(); }
1803
+ HashtablezInfoHandle& infoz() { return settings_.template get<1>(); }
1804
+
1805
+ hasher& hash_ref() { return settings_.template get<2>(); }
1806
+ const hasher& hash_ref() const { return settings_.template get<2>(); }
1807
+ key_equal& eq_ref() { return settings_.template get<3>(); }
1808
+ const key_equal& eq_ref() const { return settings_.template get<3>(); }
1809
+ allocator_type& alloc_ref() { return settings_.template get<4>(); }
1811
1810
  const allocator_type& alloc_ref() const {
1812
- return settings_.template get<3>();
1811
+ return settings_.template get<4>();
1813
1812
  }
1814
1813
 
1815
1814
  // TODO(alkis): Investigate removing some of these fields:
@@ -1819,10 +1818,11 @@ class raw_hash_set {
1819
1818
  slot_type* slots_ = nullptr; // [capacity * slot_type]
1820
1819
  size_t size_ = 0; // number of full slots
1821
1820
  size_t capacity_ = 0; // total number of slots
1822
- HashtablezInfoHandle infoz_;
1823
- absl::container_internal::CompressedTuple<size_t /* growth_left */, hasher,
1821
+ absl::container_internal::CompressedTuple<size_t /* growth_left */,
1822
+ HashtablezInfoHandle, hasher,
1824
1823
  key_equal, allocator_type>
1825
- settings_{0, hasher{}, key_equal{}, allocator_type{}};
1824
+ settings_{0, HashtablezInfoHandle{}, hasher{}, key_equal{},
1825
+ allocator_type{}};
1826
1826
  };
1827
1827
 
1828
1828
  // Erases all elements that satisfy the predicate `pred` from the container `c`.
@@ -1846,7 +1846,7 @@ struct HashtableDebugAccess<Set, absl::void_t<typename Set::raw_hash_set>> {
1846
1846
  const typename Set::key_type& key) {
1847
1847
  size_t num_probes = 0;
1848
1848
  size_t hash = set.hash_ref()(key);
1849
- auto seq = set.probe(hash);
1849
+ auto seq = probe(set.ctrl_, hash, set.capacity_);
1850
1850
  while (true) {
1851
1851
  container_internal::Group g{set.ctrl_ + seq.offset()};
1852
1852
  for (int i : g.Match(container_internal::H2(hash))) {