ruby_memprofiler_pprof 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. checksums.yaml +7 -0
  2. data/ext/ruby_memprofiler_pprof/backtrace.c +429 -0
  3. data/ext/ruby_memprofiler_pprof/collector.c +1055 -0
  4. data/ext/ruby_memprofiler_pprof/compat.c +182 -0
  5. data/ext/ruby_memprofiler_pprof/extconf.rb +72 -0
  6. data/ext/ruby_memprofiler_pprof/pprof.upb.c +170 -0
  7. data/ext/ruby_memprofiler_pprof/pprof.upb.h +848 -0
  8. data/ext/ruby_memprofiler_pprof/pprof_out.c +285 -0
  9. data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.c +11 -0
  10. data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.h +301 -0
  11. data/ext/ruby_memprofiler_pprof/strtab.c +391 -0
  12. data/ext/ruby_memprofiler_pprof/vendor/upb/BUILD +719 -0
  13. data/ext/ruby_memprofiler_pprof/vendor/upb/CONTRIBUTING.md +37 -0
  14. data/ext/ruby_memprofiler_pprof/vendor/upb/DESIGN.md +201 -0
  15. data/ext/ruby_memprofiler_pprof/vendor/upb/LICENSE +26 -0
  16. data/ext/ruby_memprofiler_pprof/vendor/upb/README.md +78 -0
  17. data/ext/ruby_memprofiler_pprof/vendor/upb/WORKSPACE +58 -0
  18. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/BUILD +53 -0
  19. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/amalgamate.py +129 -0
  20. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/build_defs.bzl +160 -0
  21. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/lua.BUILD +127 -0
  22. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/protobuf.patch +54 -0
  23. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/py_proto_library.bzl +137 -0
  24. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/python_downloads.bzl +84 -0
  25. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/system_python.bzl +101 -0
  26. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/upb_proto_library.bzl +388 -0
  27. data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/workspace_deps.bzl +89 -0
  28. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD +252 -0
  29. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD.googleapis +54 -0
  30. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/benchmark.cc +333 -0
  31. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/build_defs.bzl +88 -0
  32. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/compare.py +118 -0
  33. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor.proto +888 -0
  34. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor_sv.proto +890 -0
  35. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/empty.proto +6 -0
  36. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_protobuf_binary_cc.py +64 -0
  37. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_synthetic_protos.py +118 -0
  38. data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_upb_binary_c.py +65 -0
  39. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/BUILD.bazel +102 -0
  40. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/README.md +23 -0
  41. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/build_defs.bzl +73 -0
  42. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/make_cmakelists.py +340 -0
  43. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test.py +57 -0
  44. data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test_lib.py +186 -0
  45. data/ext/ruby_memprofiler_pprof/vendor/upb/docs/render.py +43 -0
  46. data/ext/ruby_memprofiler_pprof/vendor/upb/docs/style-guide.md +65 -0
  47. data/ext/ruby_memprofiler_pprof/vendor/upb/docs/vs-cpp-protos.md +255 -0
  48. data/ext/ruby_memprofiler_pprof/vendor/upb/docs/wrapping-upb.md +444 -0
  49. data/ext/ruby_memprofiler_pprof/vendor/upb/python/BUILD +216 -0
  50. data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.c +394 -0
  51. data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.h +63 -0
  52. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.c +1694 -0
  53. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.h +80 -0
  54. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.c +704 -0
  55. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.h +114 -0
  56. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.c +650 -0
  57. data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.h +48 -0
  58. data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/BUILD.bazel +193 -0
  59. data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/dist.bzl +190 -0
  60. data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.c +247 -0
  61. data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.h +39 -0
  62. data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.c +522 -0
  63. data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.h +66 -0
  64. data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.c +1909 -0
  65. data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.h +101 -0
  66. data/ext/ruby_memprofiler_pprof/vendor/upb/python/minimal_test.py +183 -0
  67. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/BUILD +70 -0
  68. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/README.md +11 -0
  69. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_database_test_wrapper.py +30 -0
  70. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_pool_test_wrapper.py +45 -0
  71. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_test_wrapper.py +46 -0
  72. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/generator_test_wrapper.py +30 -0
  73. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/json_format_test_wrapper.py +30 -0
  74. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/keywords_test_wrapper.py +30 -0
  75. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_factory_test_wrapper.py +37 -0
  76. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_test_wrapper.py +52 -0
  77. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/proto_builder_test_wrapper.py +32 -0
  78. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/pyproto_test_wrapper.bzl +36 -0
  79. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/reflection_test_wrapper.py +45 -0
  80. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/service_reflection_test_wrapper.py +30 -0
  81. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/symbol_database_test_wrapper.py +30 -0
  82. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_encoding_test_wrapper.py +30 -0
  83. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_format_test_wrapper.py +30 -0
  84. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/unknown_fields_test_wrapper.py +30 -0
  85. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/well_known_types_test_wrapper.py +36 -0
  86. data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/wire_format_test_wrapper.py +30 -0
  87. data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.c +350 -0
  88. data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.h +230 -0
  89. data/ext/ruby_memprofiler_pprof/vendor/upb/python/py_extension.bzl +55 -0
  90. data/ext/ruby_memprofiler_pprof/vendor/upb/python/python_api.h +61 -0
  91. data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.c +828 -0
  92. data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.h +69 -0
  93. data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.c +404 -0
  94. data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.h +39 -0
  95. data/ext/ruby_memprofiler_pprof/vendor/upb/python/version_script.lds +6 -0
  96. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/LICENSE +32 -0
  97. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/README.google +9 -0
  98. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/console.lua +156 -0
  99. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/lunit.lua +725 -0
  100. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/BUILD +19 -0
  101. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/LICENSE +21 -0
  102. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/naive.c +92 -0
  103. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-neon.c +157 -0
  104. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-sse.c +170 -0
  105. data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/utf8_range.h +9 -0
  106. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/BUILD.bazel +129 -0
  107. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/README.md +8 -0
  108. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/def.c +939 -0
  109. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/lua_proto_library.bzl +138 -0
  110. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/main.c +83 -0
  111. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/msg.c +1118 -0
  112. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test.proto +69 -0
  113. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test_upb.lua +846 -0
  114. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.c +258 -0
  115. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.h +132 -0
  116. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.lua +58 -0
  117. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upbc.cc +134 -0
  118. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.c +192 -0
  119. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.h +174 -0
  120. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb.c +346 -0
  121. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb_failures.txt +1 -0
  122. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.c +1221 -0
  123. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.h +94 -0
  124. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.c +1055 -0
  125. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.h +153 -0
  126. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_internal.h +211 -0
  127. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.c +3262 -0
  128. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.h +414 -0
  129. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.hpp +438 -0
  130. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/empty.proto +1 -0
  131. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.c +604 -0
  132. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.h +71 -0
  133. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/BUILD +13 -0
  134. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/file_descriptor_parsenew_fuzzer.cc +43 -0
  135. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.c +1509 -0
  136. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.h +47 -0
  137. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.c +776 -0
  138. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.h +62 -0
  139. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.c +1147 -0
  140. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.h +189 -0
  141. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.hpp +112 -0
  142. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.c +363 -0
  143. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.h +263 -0
  144. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_internal.h +59 -0
  145. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_test.cc +425 -0
  146. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_test.cc +230 -0
  147. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.c +428 -0
  148. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.h +114 -0
  149. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_internal.h +836 -0
  150. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.cc +491 -0
  151. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.proto +195 -0
  152. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_def.inc +261 -0
  153. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_undef.inc +62 -0
  154. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.c +323 -0
  155. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.h +109 -0
  156. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.hpp +37 -0
  157. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table.c +926 -0
  158. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table_internal.h +385 -0
  159. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test.proto +74 -0
  160. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.cc +186 -0
  161. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.proto +12 -0
  162. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_generated_code.cc +977 -0
  163. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_table.cc +580 -0
  164. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.c +472 -0
  165. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.h +64 -0
  166. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.c +362 -0
  167. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.h +378 -0
  168. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.hpp +115 -0
  169. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb_internal.h +68 -0
  170. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/BUILD +121 -0
  171. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/README.md +7 -0
  172. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.c +300 -0
  173. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.h +66 -0
  174. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare_test.cc +236 -0
  175. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.c +572 -0
  176. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.h +62 -0
  177. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_public_import_test.proto +32 -0
  178. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_regular_import_test.proto +36 -0
  179. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.cc +143 -0
  180. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.proto +119 -0
  181. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_weak_import_test.proto +28 -0
  182. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_wweak_import_test.proto +28 -0
  183. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.c +311 -0
  184. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.h +94 -0
  185. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.cc +202 -0
  186. data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.proto +48 -0
  187. data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/BUILD +78 -0
  188. data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.cc +77 -0
  189. data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.h +112 -0
  190. data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upb.cc +1997 -0
  191. data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upbdefs.cc +193 -0
  192. data/lib/ruby_memprofiler_pprof/atfork.rb +77 -0
  193. data/lib/ruby_memprofiler_pprof/block_flusher.rb +61 -0
  194. data/lib/ruby_memprofiler_pprof/file_flusher.rb +45 -0
  195. data/lib/ruby_memprofiler_pprof/profile_app.rb +30 -0
  196. data/lib/ruby_memprofiler_pprof/profile_data.rb +18 -0
  197. data/lib/ruby_memprofiler_pprof/version.rb +5 -0
  198. data/lib/ruby_memprofiler_pprof.rb +8 -0
  199. data/libexec/ruby_memprofiler_pprof_profile +16 -0
  200. metadata +257 -0
@@ -0,0 +1,153 @@
1
+ /*
2
+ * Copyright (c) 2009-2021, Google LLC
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions are met:
7
+ * * Redistributions of source code must retain the above copyright
8
+ * notice, this list of conditions and the following disclaimer.
9
+ * * Redistributions in binary form must reproduce the above copyright
10
+ * notice, this list of conditions and the following disclaimer in the
11
+ * documentation and/or other materials provided with the distribution.
12
+ * * Neither the name of Google LLC nor the
13
+ * names of its contributors may be used to endorse or promote products
14
+ * derived from this software without specific prior written permission.
15
+ *
16
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
+ * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
20
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+
28
+ // These are the specialized field parser functions for the fast parser.
29
+ // Generated tables will refer to these by name.
30
+ //
31
+ // The function names are encoded with names like:
32
+ //
33
+ // // 123 4
34
+ // upb_pss_1bt(); // Parse singular string, 1 byte tag.
35
+ //
36
+ // In position 1:
37
+ // - 'p' for parse, most function use this
38
+ // - 'c' for copy, for when we are copying strings instead of aliasing
39
+ //
40
+ // In position 2 (cardinality):
41
+ // - 's' for singular, with or without hasbit
42
+ // - 'o' for oneof
43
+ // - 'r' for non-packed repeated
44
+ // - 'p' for packed repeated
45
+ //
46
+ // In position 3 (type):
47
+ // - 'b1' for bool
48
+ // - 'v4' for 4-byte varint
49
+ // - 'v8' for 8-byte varint
50
+ // - 'z4' for zig-zag-encoded 4-byte varint
51
+ // - 'z8' for zig-zag-encoded 8-byte varint
52
+ // - 'f4' for 4-byte fixed
53
+ // - 'f8' for 8-byte fixed
54
+ // - 'm' for sub-message
55
+ // - 's' for string (validate UTF-8)
56
+ // - 'b' for bytes
57
+ //
58
+ // In position 4 (tag length):
59
+ // - '1' for one-byte tags (field numbers 1-15)
60
+ // - '2' for two-byte tags (field numbers 16-2048)
61
+
62
+ #ifndef UPB_DECODE_FAST_H_
63
+ #define UPB_DECODE_FAST_H_
64
+
65
+ #include "upb/msg.h"
66
+
67
+ struct upb_Decoder;
68
+
69
+ // The fallback, generic parsing function that can handle any field type.
70
+ // This just uses the regular (non-fast) parser to parse a single field.
71
+ const char* fastdecode_generic(struct upb_Decoder* d, const char* ptr,
72
+ upb_Message* msg, intptr_t table,
73
+ uint64_t hasbits, uint64_t data);
74
+
75
+ #define UPB_PARSE_PARAMS \
76
+ struct upb_Decoder *d, const char *ptr, upb_Message *msg, intptr_t table, \
77
+ uint64_t hasbits, uint64_t data
78
+
79
+ /* primitive fields ***********************************************************/
80
+
81
+ #define F(card, type, valbytes, tagbytes) \
82
+ const char* upb_p##card##type##valbytes##_##tagbytes##bt(UPB_PARSE_PARAMS);
83
+
84
+ #define TYPES(card, tagbytes) \
85
+ F(card, b, 1, tagbytes) \
86
+ F(card, v, 4, tagbytes) \
87
+ F(card, v, 8, tagbytes) \
88
+ F(card, z, 4, tagbytes) \
89
+ F(card, z, 8, tagbytes) \
90
+ F(card, f, 4, tagbytes) \
91
+ F(card, f, 8, tagbytes)
92
+
93
+ #define TAGBYTES(card) \
94
+ TYPES(card, 1) \
95
+ TYPES(card, 2)
96
+
97
+ TAGBYTES(s)
98
+ TAGBYTES(o)
99
+ TAGBYTES(r)
100
+ TAGBYTES(p)
101
+
102
+ #undef F
103
+ #undef TYPES
104
+ #undef TAGBYTES
105
+
106
+ /* string fields **************************************************************/
107
+
108
+ #define F(card, tagbytes, type) \
109
+ const char* upb_p##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS); \
110
+ const char* upb_c##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS);
111
+
112
+ #define UTF8(card, tagbytes) \
113
+ F(card, tagbytes, s) \
114
+ F(card, tagbytes, b)
115
+
116
+ #define TAGBYTES(card) \
117
+ UTF8(card, 1) \
118
+ UTF8(card, 2)
119
+
120
+ TAGBYTES(s)
121
+ TAGBYTES(o)
122
+ TAGBYTES(r)
123
+
124
+ #undef F
125
+ #undef TAGBYTES
126
+
127
+ /* sub-message fields *********************************************************/
128
+
129
+ #define F(card, tagbytes, size_ceil, ceil_arg) \
130
+ const char* upb_p##card##m_##tagbytes##bt_max##size_ceil##b(UPB_PARSE_PARAMS);
131
+
132
+ #define SIZES(card, tagbytes) \
133
+ F(card, tagbytes, 64, 64) \
134
+ F(card, tagbytes, 128, 128) \
135
+ F(card, tagbytes, 192, 192) \
136
+ F(card, tagbytes, 256, 256) \
137
+ F(card, tagbytes, max, -1)
138
+
139
+ #define TAGBYTES(card) \
140
+ SIZES(card, 1) \
141
+ SIZES(card, 2)
142
+
143
+ TAGBYTES(s)
144
+ TAGBYTES(o)
145
+ TAGBYTES(r)
146
+
147
+ #undef TAGBYTES
148
+ #undef SIZES
149
+ #undef F
150
+
151
+ #undef UPB_PARSE_PARAMS
152
+
153
+ #endif /* UPB_DECODE_FAST_H_ */
@@ -0,0 +1,211 @@
1
+ /*
2
+ * Copyright (c) 2009-2021, Google LLC
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions are met:
7
+ * * Redistributions of source code must retain the above copyright
8
+ * notice, this list of conditions and the following disclaimer.
9
+ * * Redistributions in binary form must reproduce the above copyright
10
+ * notice, this list of conditions and the following disclaimer in the
11
+ * documentation and/or other materials provided with the distribution.
12
+ * * Neither the name of Google LLC nor the
13
+ * names of its contributors may be used to endorse or promote products
14
+ * derived from this software without specific prior written permission.
15
+ *
16
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
+ * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
20
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+
28
+ /*
29
+ * Internal implementation details of the decoder that are shared between
30
+ * decode.c and decode_fast.c.
31
+ */
32
+
33
+ #ifndef UPB_DECODE_INT_H_
34
+ #define UPB_DECODE_INT_H_
35
+
36
+ #include <setjmp.h>
37
+
38
+ #include "third_party/utf8_range/utf8_range.h"
39
+ #include "upb/decode.h"
40
+ #include "upb/msg_internal.h"
41
+ #include "upb/upb_internal.h"
42
+
43
+ /* Must be last. */
44
+ #include "upb/port_def.inc"
45
+
46
+ #define DECODE_NOGROUP (uint32_t) - 1
47
+
48
+ typedef struct upb_Decoder {
49
+ const char* end; /* Can read up to 16 bytes slop beyond this. */
50
+ const char* limit_ptr; /* = end + UPB_MIN(limit, 0) */
51
+ upb_Message* unknown_msg; /* If non-NULL, add unknown data at buffer flip. */
52
+ const char* unknown; /* Start of unknown data. */
53
+ const upb_ExtensionRegistry*
54
+ extreg; /* For looking up extensions during the parse. */
55
+ int limit; /* Submessage limit relative to end. */
56
+ int depth; /* Tracks recursion depth to bound stack usage. */
57
+ uint32_t end_group; /* field number of END_GROUP tag, else DECODE_NOGROUP */
58
+ uint16_t options;
59
+ bool missing_required;
60
+ char patch[32];
61
+ upb_Arena arena;
62
+ jmp_buf err;
63
+
64
+ #ifndef NDEBUG
65
+ const char* debug_tagstart;
66
+ const char* debug_valstart;
67
+ #endif
68
+ } upb_Decoder;
69
+
70
+ /* Error function that will abort decoding with longjmp(). We can't declare this
71
+ * UPB_NORETURN, even though it is appropriate, because if we do then compilers
72
+ * will "helpfully" refuse to tailcall to it
73
+ * (see: https://stackoverflow.com/a/55657013), which will defeat a major goal
74
+ * of our optimizations. That is also why we must declare it in a separate file,
75
+ * otherwise the compiler will see that it calls longjmp() and deduce that it is
76
+ * noreturn. */
77
+ const char* fastdecode_err(upb_Decoder* d, int status);
78
+
79
+ extern const uint8_t upb_utf8_offsets[];
80
+
81
+ UPB_INLINE
82
+ bool decode_verifyutf8_inl(const char* ptr, int len) {
83
+ const char* end = ptr + len;
84
+
85
+ // Check 8 bytes at a time for any non-ASCII char.
86
+ while (end - ptr >= 8) {
87
+ uint64_t data;
88
+ memcpy(&data, ptr, 8);
89
+ if (data & 0x8080808080808080) goto non_ascii;
90
+ ptr += 8;
91
+ }
92
+
93
+ // Check one byte at a time for non-ASCII.
94
+ while (ptr < end) {
95
+ if (*ptr & 0x80) goto non_ascii;
96
+ ptr++;
97
+ }
98
+
99
+ return true;
100
+
101
+ non_ascii:
102
+ return utf8_range2((const unsigned char*)ptr, end - ptr) == 0;
103
+ }
104
+
105
+ const char* decode_checkrequired(upb_Decoder* d, const char* ptr,
106
+ const upb_Message* msg,
107
+ const upb_MiniTable* l);
108
+
109
+ /* x86-64 pointers always have the high 16 bits matching. So we can shift
110
+ * left 8 and right 8 without loss of information. */
111
+ UPB_INLINE intptr_t decode_totable(const upb_MiniTable* tablep) {
112
+ return ((intptr_t)tablep << 8) | tablep->table_mask;
113
+ }
114
+
115
+ UPB_INLINE const upb_MiniTable* decode_totablep(intptr_t table) {
116
+ return (const upb_MiniTable*)(table >> 8);
117
+ }
118
+
119
+ UPB_INLINE
120
+ const char* decode_isdonefallback_inl(upb_Decoder* d, const char* ptr,
121
+ int overrun, int* status) {
122
+ if (overrun < d->limit) {
123
+ /* Need to copy remaining data into patch buffer. */
124
+ UPB_ASSERT(overrun < 16);
125
+ if (d->unknown_msg) {
126
+ if (!_upb_Message_AddUnknown(d->unknown_msg, d->unknown, ptr - d->unknown,
127
+ &d->arena)) {
128
+ *status = kUpb_DecodeStatus_OutOfMemory;
129
+ return NULL;
130
+ }
131
+ d->unknown = &d->patch[0] + overrun;
132
+ }
133
+ memset(d->patch + 16, 0, 16);
134
+ memcpy(d->patch, d->end, 16);
135
+ ptr = &d->patch[0] + overrun;
136
+ d->end = &d->patch[16];
137
+ d->limit -= 16;
138
+ d->limit_ptr = d->end + d->limit;
139
+ d->options &= ~kUpb_DecodeOption_AliasString;
140
+ UPB_ASSERT(ptr < d->limit_ptr);
141
+ return ptr;
142
+ } else {
143
+ *status = kUpb_DecodeStatus_Malformed;
144
+ return NULL;
145
+ }
146
+ }
147
+
148
+ const char* decode_isdonefallback(upb_Decoder* d, const char* ptr, int overrun);
149
+
150
+ UPB_INLINE
151
+ bool decode_isdone(upb_Decoder* d, const char** ptr) {
152
+ int overrun = *ptr - d->end;
153
+ if (UPB_LIKELY(*ptr < d->limit_ptr)) {
154
+ return false;
155
+ } else if (UPB_LIKELY(overrun == d->limit)) {
156
+ return true;
157
+ } else {
158
+ *ptr = decode_isdonefallback(d, *ptr, overrun);
159
+ return false;
160
+ }
161
+ }
162
+
163
+ #if UPB_FASTTABLE
164
+ UPB_INLINE
165
+ const char* fastdecode_tagdispatch(upb_Decoder* d, const char* ptr,
166
+ upb_Message* msg, intptr_t table,
167
+ uint64_t hasbits, uint64_t tag) {
168
+ const upb_MiniTable* table_p = decode_totablep(table);
169
+ uint8_t mask = table;
170
+ uint64_t data;
171
+ size_t idx = tag & mask;
172
+ UPB_ASSUME((idx & 7) == 0);
173
+ idx >>= 3;
174
+ data = table_p->fasttable[idx].field_data ^ tag;
175
+ UPB_MUSTTAIL return table_p->fasttable[idx].field_parser(d, ptr, msg, table,
176
+ hasbits, data);
177
+ }
178
+ #endif
179
+
180
+ UPB_INLINE uint32_t fastdecode_loadtag(const char* ptr) {
181
+ uint16_t tag;
182
+ memcpy(&tag, ptr, 2);
183
+ return tag;
184
+ }
185
+
186
+ UPB_INLINE void decode_checklimit(upb_Decoder* d) {
187
+ UPB_ASSERT(d->limit_ptr == d->end + UPB_MIN(0, d->limit));
188
+ }
189
+
190
+ UPB_INLINE int decode_pushlimit(upb_Decoder* d, const char* ptr, int size) {
191
+ int limit = size + (int)(ptr - d->end);
192
+ int delta = d->limit - limit;
193
+ decode_checklimit(d);
194
+ d->limit = limit;
195
+ d->limit_ptr = d->end + UPB_MIN(0, limit);
196
+ decode_checklimit(d);
197
+ return delta;
198
+ }
199
+
200
+ UPB_INLINE void decode_poplimit(upb_Decoder* d, const char* ptr,
201
+ int saved_delta) {
202
+ UPB_ASSERT(ptr - d->end == d->limit);
203
+ decode_checklimit(d);
204
+ d->limit += saved_delta;
205
+ d->limit_ptr = d->end + UPB_MIN(0, d->limit);
206
+ decode_checklimit(d);
207
+ }
208
+
209
+ #include "upb/port_undef.inc"
210
+
211
+ #endif /* UPB_DECODE_INT_H_ */