@shd101wyy/yo 0.0.2

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 (339) hide show
  1. package/LICENSE.md +17 -0
  2. package/README.md +80 -0
  3. package/out/cjs/index.cjs +51 -0
  4. package/out/cjs/yo-cli.cjs +2158 -0
  5. package/out/esm/index.mjs +51 -0
  6. package/out/types/src/codegen/async/runtime.d.ts +2 -0
  7. package/out/types/src/codegen/async/state-code-gen.d.ts +10 -0
  8. package/out/types/src/codegen/async/state-machine.d.ts +13 -0
  9. package/out/types/src/codegen/c/collection.d.ts +3 -0
  10. package/out/types/src/codegen/codegen-c.d.ts +12 -0
  11. package/out/types/src/codegen/constants.d.ts +3 -0
  12. package/out/types/src/codegen/expressions/array.d.ts +4 -0
  13. package/out/types/src/codegen/expressions/generation.d.ts +11 -0
  14. package/out/types/src/codegen/expressions/index.d.ts +2 -0
  15. package/out/types/src/codegen/functions/collection.d.ts +5 -0
  16. package/out/types/src/codegen/functions/context.d.ts +57 -0
  17. package/out/types/src/codegen/functions/generation.d.ts +25 -0
  18. package/out/types/src/codegen/functions/index.d.ts +2 -0
  19. package/out/types/src/codegen/index.d.ts +20 -0
  20. package/out/types/src/codegen/parallelism/runtime.d.ts +2 -0
  21. package/out/types/src/codegen/types/collection.d.ts +8 -0
  22. package/out/types/src/codegen/types/generation.d.ts +13 -0
  23. package/out/types/src/codegen/types/index.d.ts +2 -0
  24. package/out/types/src/codegen/utils/fixup.d.ts +2 -0
  25. package/out/types/src/codegen/utils/index.d.ts +77 -0
  26. package/out/types/src/codegen/values/index.d.ts +1 -0
  27. package/out/types/src/emitter.d.ts +11 -0
  28. package/out/types/src/env.d.ts +85 -0
  29. package/out/types/src/error.d.ts +45 -0
  30. package/out/types/src/evaluator/async/await-analysis-types.d.ts +23 -0
  31. package/out/types/src/evaluator/async/await-analysis.d.ts +5 -0
  32. package/out/types/src/evaluator/builtins/alignof.d.ts +8 -0
  33. package/out/types/src/evaluator/builtins/and_or.d.ts +8 -0
  34. package/out/types/src/evaluator/builtins/arc_fns.d.ts +58 -0
  35. package/out/types/src/evaluator/builtins/array_fns.d.ts +0 -0
  36. package/out/types/src/evaluator/builtins/as.d.ts +8 -0
  37. package/out/types/src/evaluator/builtins/async_fns.d.ts +8 -0
  38. package/out/types/src/evaluator/builtins/compt_assert.d.ts +8 -0
  39. package/out/types/src/evaluator/builtins/compt_boolean_fns.d.ts +8 -0
  40. package/out/types/src/evaluator/builtins/compt_expect_error.d.ts +8 -0
  41. package/out/types/src/evaluator/builtins/compt_list_fns.d.ts +33 -0
  42. package/out/types/src/evaluator/builtins/compt_print.d.ts +8 -0
  43. package/out/types/src/evaluator/builtins/compt_string_fns.d.ts +8 -0
  44. package/out/types/src/evaluator/builtins/consume.d.ts +8 -0
  45. package/out/types/src/evaluator/builtins/drop.d.ts +8 -0
  46. package/out/types/src/evaluator/builtins/dup.d.ts +8 -0
  47. package/out/types/src/evaluator/builtins/expr_fns.d.ts +33 -0
  48. package/out/types/src/evaluator/builtins/future_fns.d.ts +8 -0
  49. package/out/types/src/evaluator/builtins/gc.d.ts +8 -0
  50. package/out/types/src/evaluator/builtins/gensym.d.ts +8 -0
  51. package/out/types/src/evaluator/builtins/impl_constraint.d.ts +8 -0
  52. package/out/types/src/evaluator/builtins/macro_expand.d.ts +8 -0
  53. package/out/types/src/evaluator/builtins/numeric_fns.d.ts +8 -0
  54. package/out/types/src/evaluator/builtins/panic.d.ts +8 -0
  55. package/out/types/src/evaluator/builtins/ptr_fns.d.ts +8 -0
  56. package/out/types/src/evaluator/builtins/quote.d.ts +13 -0
  57. package/out/types/src/evaluator/builtins/rc.d.ts +8 -0
  58. package/out/types/src/evaluator/builtins/sizeof.d.ts +8 -0
  59. package/out/types/src/evaluator/builtins/the.d.ts +8 -0
  60. package/out/types/src/evaluator/builtins/type_fns.d.ts +28 -0
  61. package/out/types/src/evaluator/builtins/va_start.d.ts +8 -0
  62. package/out/types/src/evaluator/builtins/var_fns.d.ts +18 -0
  63. package/out/types/src/evaluator/calls/array.d.ts +13 -0
  64. package/out/types/src/evaluator/calls/array_type.d.ts +11 -0
  65. package/out/types/src/evaluator/calls/closure_type.d.ts +11 -0
  66. package/out/types/src/evaluator/calls/compt_function.d.ts +19 -0
  67. package/out/types/src/evaluator/calls/compt_list_type.d.ts +11 -0
  68. package/out/types/src/evaluator/calls/function.d.ts +16 -0
  69. package/out/types/src/evaluator/calls/function_type.d.ts +15 -0
  70. package/out/types/src/evaluator/calls/helper.d.ts +42 -0
  71. package/out/types/src/evaluator/calls/iso.d.ts +15 -0
  72. package/out/types/src/evaluator/calls/module_type.d.ts +11 -0
  73. package/out/types/src/evaluator/calls/numeric_type.d.ts +15 -0
  74. package/out/types/src/evaluator/calls/pointer.d.ts +8 -0
  75. package/out/types/src/evaluator/calls/pointer_type.d.ts +14 -0
  76. package/out/types/src/evaluator/calls/type.d.ts +12 -0
  77. package/out/types/src/evaluator/context.d.ts +169 -0
  78. package/out/types/src/evaluator/exprs/_expr.d.ts +8 -0
  79. package/out/types/src/evaluator/exprs/assignment.d.ts +9 -0
  80. package/out/types/src/evaluator/exprs/begin.d.ts +10 -0
  81. package/out/types/src/evaluator/exprs/binding.d.ts +12 -0
  82. package/out/types/src/evaluator/exprs/c_include.d.ts +8 -0
  83. package/out/types/src/evaluator/exprs/cond.d.ts +8 -0
  84. package/out/types/src/evaluator/exprs/destructuring_assignment.d.ts +33 -0
  85. package/out/types/src/evaluator/exprs/exists.d.ts +0 -0
  86. package/out/types/src/evaluator/exprs/expr.d.ts +9 -0
  87. package/out/types/src/evaluator/exprs/extern.d.ts +8 -0
  88. package/out/types/src/evaluator/exprs/identifer_and_operator.d.ts +9 -0
  89. package/out/types/src/evaluator/exprs/import.d.ts +9 -0
  90. package/out/types/src/evaluator/exprs/initialization_assignment.d.ts +8 -0
  91. package/out/types/src/evaluator/exprs/match.d.ts +8 -0
  92. package/out/types/src/evaluator/exprs/open.d.ts +8 -0
  93. package/out/types/src/evaluator/exprs/property_access.d.ts +8 -0
  94. package/out/types/src/evaluator/exprs/recur.d.ts +8 -0
  95. package/out/types/src/evaluator/exprs/subtype_of.d.ts +21 -0
  96. package/out/types/src/evaluator/exprs/test.d.ts +8 -0
  97. package/out/types/src/evaluator/exprs/typeof.d.ts +8 -0
  98. package/out/types/src/evaluator/exprs/while.d.ts +8 -0
  99. package/out/types/src/evaluator/index.d.ts +26 -0
  100. package/out/types/src/evaluator/types/array.d.ts +8 -0
  101. package/out/types/src/evaluator/types/closure.d.ts +8 -0
  102. package/out/types/src/evaluator/types/compt_list.d.ts +8 -0
  103. package/out/types/src/evaluator/types/concrete_module.d.ts +8 -0
  104. package/out/types/src/evaluator/types/dyn.d.ts +8 -0
  105. package/out/types/src/evaluator/types/enum.d.ts +8 -0
  106. package/out/types/src/evaluator/types/expr_synthesizer.d.ts +14 -0
  107. package/out/types/src/evaluator/types/field.d.ts +14 -0
  108. package/out/types/src/evaluator/types/fn_module.d.ts +8 -0
  109. package/out/types/src/evaluator/types/function.d.ts +58 -0
  110. package/out/types/src/evaluator/types/future_module.d.ts +8 -0
  111. package/out/types/src/evaluator/types/module.d.ts +19 -0
  112. package/out/types/src/evaluator/types/newtype.d.ts +8 -0
  113. package/out/types/src/evaluator/types/object.d.ts +8 -0
  114. package/out/types/src/evaluator/types/proofs.d.ts +0 -0
  115. package/out/types/src/evaluator/types/slice.d.ts +8 -0
  116. package/out/types/src/evaluator/types/struct.d.ts +8 -0
  117. package/out/types/src/evaluator/types/synthesizer.d.ts +16 -0
  118. package/out/types/src/evaluator/types/tuple.d.ts +18 -0
  119. package/out/types/src/evaluator/types/union.d.ts +8 -0
  120. package/out/types/src/evaluator/types/utils.d.ts +71 -0
  121. package/out/types/src/evaluator/types/validation.d.ts +3 -0
  122. package/out/types/src/evaluator/utils/array-utils.d.ts +15 -0
  123. package/out/types/src/evaluator/utils/closure.d.ts +35 -0
  124. package/out/types/src/evaluator/utils.d.ts +4 -0
  125. package/out/types/src/evaluator/values/anonymous_function.d.ts +8 -0
  126. package/out/types/src/evaluator/values/anonymous_module.d.ts +17 -0
  127. package/out/types/src/evaluator/values/anonymous_struct.d.ts +8 -0
  128. package/out/types/src/evaluator/values/array.d.ts +8 -0
  129. package/out/types/src/evaluator/values/boolean.d.ts +3 -0
  130. package/out/types/src/evaluator/values/char.d.ts +3 -0
  131. package/out/types/src/evaluator/values/compt_list.d.ts +8 -0
  132. package/out/types/src/evaluator/values/dyn.d.ts +8 -0
  133. package/out/types/src/evaluator/values/float.d.ts +4 -0
  134. package/out/types/src/evaluator/values/integer.d.ts +4 -0
  135. package/out/types/src/evaluator/values/module.d.ts +58 -0
  136. package/out/types/src/evaluator/values/string.d.ts +3 -0
  137. package/out/types/src/evaluator/values/tuple.d.ts +32 -0
  138. package/out/types/src/expr.d.ts +456 -0
  139. package/out/types/src/function-value.d.ts +42 -0
  140. package/out/types/src/index.d.ts +4 -0
  141. package/out/types/src/lexer.d.ts +2 -0
  142. package/out/types/src/logger.d.ts +1 -0
  143. package/out/types/src/module-manager.d.ts +30 -0
  144. package/out/types/src/naming-checker.d.ts +4 -0
  145. package/out/types/src/parser.d.ts +33 -0
  146. package/out/types/src/test-runner.d.ts +30 -0
  147. package/out/types/src/tests/codegen.test.d.ts +1 -0
  148. package/out/types/src/tests/fixme.test.d.ts +1 -0
  149. package/out/types/src/tests/module-manager.test.d.ts +1 -0
  150. package/out/types/src/tests/parser.test.d.ts +1 -0
  151. package/out/types/src/tests/sample.test.d.ts +0 -0
  152. package/out/types/src/tests/std.test.d.ts +1 -0
  153. package/out/types/src/token.d.ts +40 -0
  154. package/out/types/src/type-value.d.ts +7 -0
  155. package/out/types/src/types/compatibility.d.ts +16 -0
  156. package/out/types/src/types/creators.d.ts +73 -0
  157. package/out/types/src/types/definitions.d.ts +218 -0
  158. package/out/types/src/types/guards.d.ts +70 -0
  159. package/out/types/src/types/hierarchy.d.ts +4 -0
  160. package/out/types/src/types/index.d.ts +7 -0
  161. package/out/types/src/types/module_field.d.ts +2 -0
  162. package/out/types/src/types/tags.d.ts +45 -0
  163. package/out/types/src/types/utils.d.ts +50 -0
  164. package/out/types/src/unit-value.d.ts +7 -0
  165. package/out/types/src/utils.d.ts +6 -0
  166. package/out/types/src/value-tag.d.ts +29 -0
  167. package/out/types/src/value.d.ts +110 -0
  168. package/out/types/src/yo-cli.d.ts +1 -0
  169. package/out/types/tsconfig.tsbuildinfo +1 -0
  170. package/package.json +57 -0
  171. package/scripts/check-liburing.js +76 -0
  172. package/std/alg/hash.yo +50 -0
  173. package/std/allocator.yo +113 -0
  174. package/std/allocators/c_allocator.yo +118 -0
  175. package/std/async.yo +13 -0
  176. package/std/collections/array_list.yo +415 -0
  177. package/std/collections/hash_map.yo +482 -0
  178. package/std/collections/hash_set.yo +706 -0
  179. package/std/collections/index.yo +11 -0
  180. package/std/collections/linked_list.yo +439 -0
  181. package/std/error.yo +0 -0
  182. package/std/gc.yo +10 -0
  183. package/std/index.yo +12 -0
  184. package/std/io/file.yo +191 -0
  185. package/std/io/index.yo +5 -0
  186. package/std/libc/assert.yo +39 -0
  187. package/std/libc/ctype.yo +57 -0
  188. package/std/libc/errno.yo +182 -0
  189. package/std/libc/float.yo +87 -0
  190. package/std/libc/index.yo +29 -0
  191. package/std/libc/limits.yo +65 -0
  192. package/std/libc/math.yo +679 -0
  193. package/std/libc/signal.yo +101 -0
  194. package/std/libc/stdatomic.yo +213 -0
  195. package/std/libc/stdint.yo +214 -0
  196. package/std/libc/stdio.yo +225 -0
  197. package/std/libc/stdlib.yo +204 -0
  198. package/std/libc/string.yo +151 -0
  199. package/std/libc/time.yo +92 -0
  200. package/std/libc/unistd.yo +130 -0
  201. package/std/monad.yo +152 -0
  202. package/std/prelude.yo +3094 -0
  203. package/std/string/index.yo +8 -0
  204. package/std/string/rune.yo +82 -0
  205. package/std/string/string.yo +288 -0
  206. package/std/sync.yo +95 -0
  207. package/std/thread.yo +36 -0
  208. package/std/time.yo +13 -0
  209. package/std/worker.yo +36 -0
  210. package/vendor/mimalloc/.gitattributes +12 -0
  211. package/vendor/mimalloc/CMakeLists.txt +763 -0
  212. package/vendor/mimalloc/LICENSE +21 -0
  213. package/vendor/mimalloc/SECURITY.md +41 -0
  214. package/vendor/mimalloc/azure-pipelines.yml +251 -0
  215. package/vendor/mimalloc/bin/mimalloc-redirect-arm64.dll +0 -0
  216. package/vendor/mimalloc/bin/mimalloc-redirect-arm64.lib +0 -0
  217. package/vendor/mimalloc/bin/mimalloc-redirect-arm64ec.dll +0 -0
  218. package/vendor/mimalloc/bin/mimalloc-redirect-arm64ec.lib +0 -0
  219. package/vendor/mimalloc/bin/mimalloc-redirect.dll +0 -0
  220. package/vendor/mimalloc/bin/mimalloc-redirect.lib +0 -0
  221. package/vendor/mimalloc/bin/mimalloc-redirect32.dll +0 -0
  222. package/vendor/mimalloc/bin/mimalloc-redirect32.lib +0 -0
  223. package/vendor/mimalloc/bin/minject-arm64.exe +0 -0
  224. package/vendor/mimalloc/bin/minject.exe +0 -0
  225. package/vendor/mimalloc/bin/minject32.exe +0 -0
  226. package/vendor/mimalloc/bin/readme.md +118 -0
  227. package/vendor/mimalloc/cmake/JoinPaths.cmake +23 -0
  228. package/vendor/mimalloc/cmake/mimalloc-config-version.cmake +19 -0
  229. package/vendor/mimalloc/cmake/mimalloc-config.cmake +14 -0
  230. package/vendor/mimalloc/contrib/docker/alpine/Dockerfile +23 -0
  231. package/vendor/mimalloc/contrib/docker/alpine-arm32v7/Dockerfile +28 -0
  232. package/vendor/mimalloc/contrib/docker/alpine-x86/Dockerfile +28 -0
  233. package/vendor/mimalloc/contrib/docker/manylinux-x64/Dockerfile +23 -0
  234. package/vendor/mimalloc/contrib/docker/readme.md +10 -0
  235. package/vendor/mimalloc/contrib/vcpkg/portfile.cmake +64 -0
  236. package/vendor/mimalloc/contrib/vcpkg/readme.md +40 -0
  237. package/vendor/mimalloc/contrib/vcpkg/usage +20 -0
  238. package/vendor/mimalloc/contrib/vcpkg/vcpkg-cmake-wrapper.cmake +20 -0
  239. package/vendor/mimalloc/contrib/vcpkg/vcpkg.json +48 -0
  240. package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-a.svg +887 -0
  241. package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-b.svg +1185 -0
  242. package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-rss-a.svg +757 -0
  243. package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-rss-b.svg +1028 -0
  244. package/vendor/mimalloc/doc/bench-2020/bench-r5a-1.svg +769 -0
  245. package/vendor/mimalloc/doc/bench-2020/bench-r5a-12xlarge-2020-01-16-a.svg +868 -0
  246. package/vendor/mimalloc/doc/bench-2020/bench-r5a-12xlarge-2020-01-16-b.svg +1157 -0
  247. package/vendor/mimalloc/doc/bench-2020/bench-r5a-2.svg +983 -0
  248. package/vendor/mimalloc/doc/bench-2020/bench-r5a-rss-1.svg +683 -0
  249. package/vendor/mimalloc/doc/bench-2020/bench-r5a-rss-2.svg +854 -0
  250. package/vendor/mimalloc/doc/bench-2020/bench-spec-rss.svg +713 -0
  251. package/vendor/mimalloc/doc/bench-2020/bench-spec.svg +713 -0
  252. package/vendor/mimalloc/doc/bench-2020/bench-z4-1.svg +890 -0
  253. package/vendor/mimalloc/doc/bench-2020/bench-z4-2.svg +1146 -0
  254. package/vendor/mimalloc/doc/bench-2020/bench-z4-rss-1.svg +796 -0
  255. package/vendor/mimalloc/doc/bench-2020/bench-z4-rss-2.svg +974 -0
  256. package/vendor/mimalloc/doc/bench-2021/bench-amd5950x-2021-01-30-a.svg +952 -0
  257. package/vendor/mimalloc/doc/bench-2021/bench-amd5950x-2021-01-30-b.svg +1255 -0
  258. package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-a.svg +955 -0
  259. package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-b.svg +1269 -0
  260. package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-rss-a.svg +836 -0
  261. package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-rss-b.svg +1131 -0
  262. package/vendor/mimalloc/doc/bench-2021/bench-macmini-2021-01-30.svg +766 -0
  263. package/vendor/mimalloc/doc/doxyfile +2895 -0
  264. package/vendor/mimalloc/doc/ds-logo.jpg +0 -0
  265. package/vendor/mimalloc/doc/ds-logo.png +0 -0
  266. package/vendor/mimalloc/doc/mimalloc-doc.h +1452 -0
  267. package/vendor/mimalloc/doc/mimalloc-doxygen.css +60 -0
  268. package/vendor/mimalloc/doc/mimalloc-logo-100.png +0 -0
  269. package/vendor/mimalloc/doc/mimalloc-logo.png +0 -0
  270. package/vendor/mimalloc/doc/mimalloc-logo.svg +161 -0
  271. package/vendor/mimalloc/doc/spades-logo.png +0 -0
  272. package/vendor/mimalloc/doc/unreal-logo.svg +43 -0
  273. package/vendor/mimalloc/ide/vs2022/mimalloc-lib.vcxproj +500 -0
  274. package/vendor/mimalloc/ide/vs2022/mimalloc-lib.vcxproj.filters +108 -0
  275. package/vendor/mimalloc/ide/vs2022/mimalloc-override-dll.vcxproj +508 -0
  276. package/vendor/mimalloc/ide/vs2022/mimalloc-override-dll.vcxproj.filters +111 -0
  277. package/vendor/mimalloc/ide/vs2022/mimalloc-override-test-dep.vcxproj +355 -0
  278. package/vendor/mimalloc/ide/vs2022/mimalloc-override-test.vcxproj +360 -0
  279. package/vendor/mimalloc/ide/vs2022/mimalloc-test-api.vcxproj +295 -0
  280. package/vendor/mimalloc/ide/vs2022/mimalloc-test-stress.vcxproj +292 -0
  281. package/vendor/mimalloc/ide/vs2022/mimalloc-test.vcxproj +289 -0
  282. package/vendor/mimalloc/ide/vs2022/mimalloc.sln +151 -0
  283. package/vendor/mimalloc/include/mimalloc/atomic.h +557 -0
  284. package/vendor/mimalloc/include/mimalloc/internal.h +1153 -0
  285. package/vendor/mimalloc/include/mimalloc/prim.h +421 -0
  286. package/vendor/mimalloc/include/mimalloc/track.h +145 -0
  287. package/vendor/mimalloc/include/mimalloc/types.h +685 -0
  288. package/vendor/mimalloc/include/mimalloc-new-delete.h +66 -0
  289. package/vendor/mimalloc/include/mimalloc-override.h +68 -0
  290. package/vendor/mimalloc/include/mimalloc-stats.h +103 -0
  291. package/vendor/mimalloc/include/mimalloc.h +612 -0
  292. package/vendor/mimalloc/mimalloc.pc.in +11 -0
  293. package/vendor/mimalloc/readme.md +946 -0
  294. package/vendor/mimalloc/src/alloc-aligned.c +360 -0
  295. package/vendor/mimalloc/src/alloc-override.c +316 -0
  296. package/vendor/mimalloc/src/alloc-posix.c +185 -0
  297. package/vendor/mimalloc/src/alloc.c +692 -0
  298. package/vendor/mimalloc/src/arena-abandon.c +346 -0
  299. package/vendor/mimalloc/src/arena.c +1043 -0
  300. package/vendor/mimalloc/src/bitmap.c +441 -0
  301. package/vendor/mimalloc/src/bitmap.h +119 -0
  302. package/vendor/mimalloc/src/free.c +572 -0
  303. package/vendor/mimalloc/src/heap.c +733 -0
  304. package/vendor/mimalloc/src/init.c +714 -0
  305. package/vendor/mimalloc/src/libc.c +334 -0
  306. package/vendor/mimalloc/src/options.c +663 -0
  307. package/vendor/mimalloc/src/os.c +770 -0
  308. package/vendor/mimalloc/src/page-queue.c +390 -0
  309. package/vendor/mimalloc/src/page.c +1049 -0
  310. package/vendor/mimalloc/src/prim/emscripten/prim.c +249 -0
  311. package/vendor/mimalloc/src/prim/osx/alloc-override-zone.c +461 -0
  312. package/vendor/mimalloc/src/prim/osx/prim.c +9 -0
  313. package/vendor/mimalloc/src/prim/prim.c +76 -0
  314. package/vendor/mimalloc/src/prim/readme.md +9 -0
  315. package/vendor/mimalloc/src/prim/unix/prim.c +934 -0
  316. package/vendor/mimalloc/src/prim/wasi/prim.c +284 -0
  317. package/vendor/mimalloc/src/prim/windows/etw-mimalloc.wprp +61 -0
  318. package/vendor/mimalloc/src/prim/windows/etw.h +905 -0
  319. package/vendor/mimalloc/src/prim/windows/etw.man +0 -0
  320. package/vendor/mimalloc/src/prim/windows/prim.c +878 -0
  321. package/vendor/mimalloc/src/prim/windows/readme.md +17 -0
  322. package/vendor/mimalloc/src/random.c +258 -0
  323. package/vendor/mimalloc/src/segment-map.c +142 -0
  324. package/vendor/mimalloc/src/segment.c +1702 -0
  325. package/vendor/mimalloc/src/static.c +41 -0
  326. package/vendor/mimalloc/src/stats.c +635 -0
  327. package/vendor/mimalloc/test/CMakeLists.txt +56 -0
  328. package/vendor/mimalloc/test/main-override-dep.cpp +51 -0
  329. package/vendor/mimalloc/test/main-override-dep.h +11 -0
  330. package/vendor/mimalloc/test/main-override-static.c +539 -0
  331. package/vendor/mimalloc/test/main-override.c +36 -0
  332. package/vendor/mimalloc/test/main-override.cpp +497 -0
  333. package/vendor/mimalloc/test/main.c +46 -0
  334. package/vendor/mimalloc/test/readme.md +16 -0
  335. package/vendor/mimalloc/test/test-api-fill.c +343 -0
  336. package/vendor/mimalloc/test/test-api.c +466 -0
  337. package/vendor/mimalloc/test/test-stress.c +428 -0
  338. package/vendor/mimalloc/test/test-wrong.c +92 -0
  339. package/vendor/mimalloc/test/testhelper.h +49 -0
@@ -0,0 +1,17 @@
1
+ ## Primitives:
2
+
3
+ - `prim.c` contains Windows primitives for OS allocation.
4
+
5
+ ## Event Tracing for Windows (ETW)
6
+
7
+ - `etw.h` is generated from `etw.man` which contains the manifest for mimalloc events.
8
+ (100 is an allocation, 101 is for a free)
9
+
10
+ - `etw-mimalloc.wprp` is a profile for the Windows Performance Recorder (WPR).
11
+ In an admin prompt, you can use:
12
+ ```
13
+ > wpr -start src\prim\windows\etw-mimalloc.wprp -filemode
14
+ > <my mimalloc program>
15
+ > wpr -stop test.etl
16
+ ```
17
+ and then open `test.etl` in the Windows Performance Analyzer (WPA).
@@ -0,0 +1,258 @@
1
+ /* ----------------------------------------------------------------------------
2
+ Copyright (c) 2019-2021, Microsoft Research, Daan Leijen
3
+ This is free software; you can redistribute it and/or modify it under the
4
+ terms of the MIT license. A copy of the license can be found in the file
5
+ "LICENSE" at the root of this distribution.
6
+ -----------------------------------------------------------------------------*/
7
+ #include "mimalloc.h"
8
+ #include "mimalloc/internal.h"
9
+ #include "mimalloc/prim.h" // _mi_prim_random_buf
10
+ #include <string.h> // memset
11
+
12
+ /* ----------------------------------------------------------------------------
13
+ We use our own PRNG to keep predictable performance of random number generation
14
+ and to avoid implementations that use a lock. We only use the OS provided
15
+ random source to initialize the initial seeds. Since we do not need ultimate
16
+ performance but we do rely on the security (for secret cookies in secure mode)
17
+ we use a cryptographically secure generator (chacha20).
18
+ -----------------------------------------------------------------------------*/
19
+
20
+ #define MI_CHACHA_ROUNDS (20) // perhaps use 12 for better performance?
21
+
22
+
23
+ /* ----------------------------------------------------------------------------
24
+ Chacha20 implementation as the original algorithm with a 64-bit nonce
25
+ and counter: https://en.wikipedia.org/wiki/Salsa20
26
+ The input matrix has sixteen 32-bit values:
27
+ Position 0 to 3: constant key
28
+ Position 4 to 11: the key
29
+ Position 12 to 13: the counter.
30
+ Position 14 to 15: the nonce.
31
+
32
+ The implementation uses regular C code which compiles very well on modern compilers.
33
+ (gcc x64 has no register spills, and clang 6+ uses SSE instructions)
34
+ -----------------------------------------------------------------------------*/
35
+
36
+ static inline uint32_t rotl(uint32_t x, uint32_t shift) {
37
+ return (x << shift) | (x >> (32 - shift));
38
+ }
39
+
40
+ static inline void qround(uint32_t x[16], size_t a, size_t b, size_t c, size_t d) {
41
+ x[a] += x[b]; x[d] = rotl(x[d] ^ x[a], 16);
42
+ x[c] += x[d]; x[b] = rotl(x[b] ^ x[c], 12);
43
+ x[a] += x[b]; x[d] = rotl(x[d] ^ x[a], 8);
44
+ x[c] += x[d]; x[b] = rotl(x[b] ^ x[c], 7);
45
+ }
46
+
47
+ static void chacha_block(mi_random_ctx_t* ctx)
48
+ {
49
+ // scramble into `x`
50
+ uint32_t x[16];
51
+ for (size_t i = 0; i < 16; i++) {
52
+ x[i] = ctx->input[i];
53
+ }
54
+ for (size_t i = 0; i < MI_CHACHA_ROUNDS; i += 2) {
55
+ qround(x, 0, 4, 8, 12);
56
+ qround(x, 1, 5, 9, 13);
57
+ qround(x, 2, 6, 10, 14);
58
+ qround(x, 3, 7, 11, 15);
59
+ qround(x, 0, 5, 10, 15);
60
+ qround(x, 1, 6, 11, 12);
61
+ qround(x, 2, 7, 8, 13);
62
+ qround(x, 3, 4, 9, 14);
63
+ }
64
+
65
+ // add scrambled data to the initial state
66
+ for (size_t i = 0; i < 16; i++) {
67
+ ctx->output[i] = x[i] + ctx->input[i];
68
+ }
69
+ ctx->output_available = 16;
70
+
71
+ // increment the counter for the next round
72
+ ctx->input[12] += 1;
73
+ if (ctx->input[12] == 0) {
74
+ ctx->input[13] += 1;
75
+ if (ctx->input[13] == 0) { // and keep increasing into the nonce
76
+ ctx->input[14] += 1;
77
+ }
78
+ }
79
+ }
80
+
81
+ static uint32_t chacha_next32(mi_random_ctx_t* ctx) {
82
+ if (ctx->output_available <= 0) {
83
+ chacha_block(ctx);
84
+ ctx->output_available = 16; // (assign again to suppress static analysis warning)
85
+ }
86
+ const uint32_t x = ctx->output[16 - ctx->output_available];
87
+ ctx->output[16 - ctx->output_available] = 0; // reset once the data is handed out
88
+ ctx->output_available--;
89
+ return x;
90
+ }
91
+
92
+ static inline uint32_t read32(const uint8_t* p, size_t idx32) {
93
+ const size_t i = 4*idx32;
94
+ return ((uint32_t)p[i+0] | (uint32_t)p[i+1] << 8 | (uint32_t)p[i+2] << 16 | (uint32_t)p[i+3] << 24);
95
+ }
96
+
97
+ static void chacha_init(mi_random_ctx_t* ctx, const uint8_t key[32], uint64_t nonce)
98
+ {
99
+ // since we only use chacha for randomness (and not encryption) we
100
+ // do not _need_ to read 32-bit values as little endian but we do anyways
101
+ // just for being compatible :-)
102
+ memset(ctx, 0, sizeof(*ctx));
103
+ for (size_t i = 0; i < 4; i++) {
104
+ const uint8_t* sigma = (uint8_t*)"expand 32-byte k";
105
+ ctx->input[i] = read32(sigma,i);
106
+ }
107
+ for (size_t i = 0; i < 8; i++) {
108
+ ctx->input[i + 4] = read32(key,i);
109
+ }
110
+ ctx->input[12] = 0;
111
+ ctx->input[13] = 0;
112
+ ctx->input[14] = (uint32_t)nonce;
113
+ ctx->input[15] = (uint32_t)(nonce >> 32);
114
+ }
115
+
116
+ static void chacha_split(mi_random_ctx_t* ctx, uint64_t nonce, mi_random_ctx_t* ctx_new) {
117
+ memset(ctx_new, 0, sizeof(*ctx_new));
118
+ _mi_memcpy(ctx_new->input, ctx->input, sizeof(ctx_new->input));
119
+ ctx_new->input[12] = 0;
120
+ ctx_new->input[13] = 0;
121
+ ctx_new->input[14] = (uint32_t)nonce;
122
+ ctx_new->input[15] = (uint32_t)(nonce >> 32);
123
+ mi_assert_internal(ctx->input[14] != ctx_new->input[14] || ctx->input[15] != ctx_new->input[15]); // do not reuse nonces!
124
+ chacha_block(ctx_new);
125
+ }
126
+
127
+
128
+ /* ----------------------------------------------------------------------------
129
+ Random interface
130
+ -----------------------------------------------------------------------------*/
131
+
132
+ #if MI_DEBUG>1
133
+ static bool mi_random_is_initialized(mi_random_ctx_t* ctx) {
134
+ return (ctx != NULL && ctx->input[0] != 0);
135
+ }
136
+ #endif
137
+
138
+ void _mi_random_split(mi_random_ctx_t* ctx, mi_random_ctx_t* ctx_new) {
139
+ mi_assert_internal(mi_random_is_initialized(ctx));
140
+ mi_assert_internal(ctx != ctx_new);
141
+ chacha_split(ctx, (uintptr_t)ctx_new /*nonce*/, ctx_new);
142
+ }
143
+
144
+ uintptr_t _mi_random_next(mi_random_ctx_t* ctx) {
145
+ mi_assert_internal(mi_random_is_initialized(ctx));
146
+ uintptr_t r;
147
+ do {
148
+ #if MI_INTPTR_SIZE <= 4
149
+ r = chacha_next32(ctx);
150
+ #elif MI_INTPTR_SIZE == 8
151
+ r = (((uintptr_t)chacha_next32(ctx) << 32) | chacha_next32(ctx));
152
+ #else
153
+ # error "define mi_random_next for this platform"
154
+ #endif
155
+ } while (r==0);
156
+ return r;
157
+ }
158
+
159
+
160
+ /* ----------------------------------------------------------------------------
161
+ To initialize a fresh random context.
162
+ If we cannot get good randomness, we fall back to weak randomness based on a timer and ASLR.
163
+ -----------------------------------------------------------------------------*/
164
+
165
+ uintptr_t _mi_os_random_weak(uintptr_t extra_seed) {
166
+ uintptr_t x = (uintptr_t)&_mi_os_random_weak ^ extra_seed; // ASLR makes the address random
167
+ x ^= _mi_prim_clock_now();
168
+ // and do a few randomization steps
169
+ uintptr_t max = ((x ^ (x >> 17)) & 0x0F) + 1;
170
+ for (uintptr_t i = 0; i < max || x==0; i++, x++) {
171
+ x = _mi_random_shuffle(x);
172
+ }
173
+ mi_assert_internal(x != 0);
174
+ return x;
175
+ }
176
+
177
+ static void mi_random_init_ex(mi_random_ctx_t* ctx, bool use_weak) {
178
+ uint8_t key[32];
179
+ if (use_weak || !_mi_prim_random_buf(key, sizeof(key))) {
180
+ // if we fail to get random data from the OS, we fall back to a
181
+ // weak random source based on the current time
182
+ #if !defined(__wasi__)
183
+ if (!use_weak) { _mi_warning_message("unable to use secure randomness\n"); }
184
+ #endif
185
+ uintptr_t x = _mi_os_random_weak(0);
186
+ for (size_t i = 0; i < 8; i++, x++) { // key is eight 32-bit words.
187
+ x = _mi_random_shuffle(x);
188
+ ((uint32_t*)key)[i] = (uint32_t)x;
189
+ }
190
+ ctx->weak = true;
191
+ }
192
+ else {
193
+ ctx->weak = false;
194
+ }
195
+ chacha_init(ctx, key, (uintptr_t)ctx /*nonce*/ );
196
+ }
197
+
198
+ void _mi_random_init(mi_random_ctx_t* ctx) {
199
+ mi_random_init_ex(ctx, false);
200
+ }
201
+
202
+ void _mi_random_init_weak(mi_random_ctx_t * ctx) {
203
+ mi_random_init_ex(ctx, true);
204
+ }
205
+
206
+ void _mi_random_reinit_if_weak(mi_random_ctx_t * ctx) {
207
+ if (ctx->weak) {
208
+ _mi_random_init(ctx);
209
+ }
210
+ }
211
+
212
+ /* --------------------------------------------------------
213
+ test vectors from <https://tools.ietf.org/html/rfc8439>
214
+ ----------------------------------------------------------- */
215
+ /*
216
+ static bool array_equals(uint32_t* x, uint32_t* y, size_t n) {
217
+ for (size_t i = 0; i < n; i++) {
218
+ if (x[i] != y[i]) return false;
219
+ }
220
+ return true;
221
+ }
222
+ static void chacha_test(void)
223
+ {
224
+ uint32_t x[4] = { 0x11111111, 0x01020304, 0x9b8d6f43, 0x01234567 };
225
+ uint32_t x_out[4] = { 0xea2a92f4, 0xcb1cf8ce, 0x4581472e, 0x5881c4bb };
226
+ qround(x, 0, 1, 2, 3);
227
+ mi_assert_internal(array_equals(x, x_out, 4));
228
+
229
+ uint32_t y[16] = {
230
+ 0x879531e0, 0xc5ecf37d, 0x516461b1, 0xc9a62f8a,
231
+ 0x44c20ef3, 0x3390af7f, 0xd9fc690b, 0x2a5f714c,
232
+ 0x53372767, 0xb00a5631, 0x974c541a, 0x359e9963,
233
+ 0x5c971061, 0x3d631689, 0x2098d9d6, 0x91dbd320 };
234
+ uint32_t y_out[16] = {
235
+ 0x879531e0, 0xc5ecf37d, 0xbdb886dc, 0xc9a62f8a,
236
+ 0x44c20ef3, 0x3390af7f, 0xd9fc690b, 0xcfacafd2,
237
+ 0xe46bea80, 0xb00a5631, 0x974c541a, 0x359e9963,
238
+ 0x5c971061, 0xccc07c79, 0x2098d9d6, 0x91dbd320 };
239
+ qround(y, 2, 7, 8, 13);
240
+ mi_assert_internal(array_equals(y, y_out, 16));
241
+
242
+ mi_random_ctx_t r = {
243
+ { 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574,
244
+ 0x03020100, 0x07060504, 0x0b0a0908, 0x0f0e0d0c,
245
+ 0x13121110, 0x17161514, 0x1b1a1918, 0x1f1e1d1c,
246
+ 0x00000001, 0x09000000, 0x4a000000, 0x00000000 },
247
+ {0},
248
+ 0
249
+ };
250
+ uint32_t r_out[16] = {
251
+ 0xe4e7f110, 0x15593bd1, 0x1fdd0f50, 0xc47120a3,
252
+ 0xc7f4d1c7, 0x0368c033, 0x9aaa2204, 0x4e6cd4c3,
253
+ 0x466482d2, 0x09aa9f07, 0x05d7c214, 0xa2028bd9,
254
+ 0xd19c12b5, 0xb94e16de, 0xe883d0cb, 0x4e3c50a2 };
255
+ chacha_block(&r);
256
+ mi_assert_internal(array_equals(r.output, r_out, 16));
257
+ }
258
+ */
@@ -0,0 +1,142 @@
1
+ /* ----------------------------------------------------------------------------
2
+ Copyright (c) 2019-2023, Microsoft Research, Daan Leijen
3
+ This is free software; you can redistribute it and/or modify it under the
4
+ terms of the MIT license. A copy of the license can be found in the file
5
+ "LICENSE" at the root of this distribution.
6
+ -----------------------------------------------------------------------------*/
7
+
8
+ /* -----------------------------------------------------------
9
+ The following functions are to reliably find the segment or
10
+ block that encompasses any pointer p (or NULL if it is not
11
+ in any of our segments).
12
+ We maintain a bitmap of all memory with 1 bit per MI_SEGMENT_SIZE (64MiB)
13
+ set to 1 if it contains the segment meta data.
14
+ ----------------------------------------------------------- */
15
+ #include "mimalloc.h"
16
+ #include "mimalloc/internal.h"
17
+ #include "mimalloc/atomic.h"
18
+
19
+ // Reduce total address space to reduce .bss (due to the `mi_segment_map`)
20
+ #if (MI_INTPTR_SIZE > 4) && MI_TRACK_ASAN
21
+ #define MI_SEGMENT_MAP_MAX_ADDRESS (128*1024ULL*MI_GiB) // 128 TiB (see issue #881)
22
+ #elif (MI_INTPTR_SIZE > 4)
23
+ #define MI_SEGMENT_MAP_MAX_ADDRESS (48*1024ULL*MI_GiB) // 48 TiB
24
+ #else
25
+ #define MI_SEGMENT_MAP_MAX_ADDRESS (UINT32_MAX)
26
+ #endif
27
+
28
+ #define MI_SEGMENT_MAP_PART_SIZE (MI_INTPTR_SIZE*MI_KiB - 128) // 128 > sizeof(mi_memid_t) !
29
+ #define MI_SEGMENT_MAP_PART_BITS (8*MI_SEGMENT_MAP_PART_SIZE)
30
+ #define MI_SEGMENT_MAP_PART_ENTRIES (MI_SEGMENT_MAP_PART_SIZE / MI_INTPTR_SIZE)
31
+ #define MI_SEGMENT_MAP_PART_BIT_SPAN (MI_SEGMENT_ALIGN) // memory area covered by 1 bit
32
+
33
+ #if (MI_SEGMENT_MAP_PART_BITS < (MI_SEGMENT_MAP_MAX_ADDRESS / MI_SEGMENT_MAP_PART_BIT_SPAN)) // prevent overflow on 32-bit (issue #1017)
34
+ #define MI_SEGMENT_MAP_PART_SPAN (MI_SEGMENT_MAP_PART_BITS * MI_SEGMENT_MAP_PART_BIT_SPAN)
35
+ #else
36
+ #define MI_SEGMENT_MAP_PART_SPAN MI_SEGMENT_MAP_MAX_ADDRESS
37
+ #endif
38
+
39
+ #define MI_SEGMENT_MAP_MAX_PARTS ((MI_SEGMENT_MAP_MAX_ADDRESS / MI_SEGMENT_MAP_PART_SPAN) + 1)
40
+
41
+ // A part of the segment map.
42
+ typedef struct mi_segmap_part_s {
43
+ mi_memid_t memid;
44
+ _Atomic(uintptr_t) map[MI_SEGMENT_MAP_PART_ENTRIES];
45
+ } mi_segmap_part_t;
46
+
47
+ // Allocate parts on-demand to reduce .bss footprint
48
+ static _Atomic(mi_segmap_part_t*) mi_segment_map[MI_SEGMENT_MAP_MAX_PARTS]; // = { NULL, .. }
49
+
50
+ static mi_segmap_part_t* mi_segment_map_index_of(const mi_segment_t* segment, bool create_on_demand, size_t* idx, size_t* bitidx) {
51
+ // note: segment can be invalid or NULL.
52
+ mi_assert_internal(_mi_ptr_segment(segment + 1) == segment); // is it aligned on MI_SEGMENT_SIZE?
53
+ *idx = 0;
54
+ *bitidx = 0;
55
+ if ((uintptr_t)segment >= MI_SEGMENT_MAP_MAX_ADDRESS) return NULL;
56
+ const uintptr_t segindex = ((uintptr_t)segment) / MI_SEGMENT_MAP_PART_SPAN;
57
+ if (segindex >= MI_SEGMENT_MAP_MAX_PARTS) return NULL;
58
+ mi_segmap_part_t* part = mi_atomic_load_ptr_relaxed(mi_segmap_part_t, &mi_segment_map[segindex]);
59
+
60
+ // allocate on demand to reduce .bss footprint
61
+ if mi_unlikely(part == NULL) {
62
+ if (!create_on_demand) return NULL;
63
+ mi_memid_t memid;
64
+ part = (mi_segmap_part_t*)_mi_os_zalloc(sizeof(mi_segmap_part_t), &memid);
65
+ if (part == NULL) return NULL;
66
+ part->memid = memid;
67
+ mi_segmap_part_t* expected = NULL;
68
+ if (!mi_atomic_cas_ptr_strong_release(mi_segmap_part_t, &mi_segment_map[segindex], &expected, part)) {
69
+ _mi_os_free(part, sizeof(mi_segmap_part_t), memid);
70
+ part = expected;
71
+ if (part == NULL) return NULL;
72
+ }
73
+ }
74
+ mi_assert(part != NULL);
75
+ const uintptr_t offset = ((uintptr_t)segment) % MI_SEGMENT_MAP_PART_SPAN;
76
+ const uintptr_t bitofs = offset / MI_SEGMENT_MAP_PART_BIT_SPAN;
77
+ *idx = bitofs / MI_INTPTR_BITS;
78
+ *bitidx = bitofs % MI_INTPTR_BITS;
79
+ return part;
80
+ }
81
+
82
+ void _mi_segment_map_allocated_at(const mi_segment_t* segment) {
83
+ if (segment->memid.memkind == MI_MEM_ARENA) return; // we lookup segments first in the arena's and don't need the segment map
84
+ size_t index;
85
+ size_t bitidx;
86
+ mi_segmap_part_t* part = mi_segment_map_index_of(segment, true /* alloc map if needed */, &index, &bitidx);
87
+ if (part == NULL) return; // outside our address range..
88
+ uintptr_t mask = mi_atomic_load_relaxed(&part->map[index]);
89
+ uintptr_t newmask;
90
+ do {
91
+ newmask = (mask | ((uintptr_t)1 << bitidx));
92
+ } while (!mi_atomic_cas_weak_release(&part->map[index], &mask, newmask));
93
+ }
94
+
95
+ void _mi_segment_map_freed_at(const mi_segment_t* segment) {
96
+ if (segment->memid.memkind == MI_MEM_ARENA) return;
97
+ size_t index;
98
+ size_t bitidx;
99
+ mi_segmap_part_t* part = mi_segment_map_index_of(segment, false /* don't alloc if not present */, &index, &bitidx);
100
+ if (part == NULL) return; // outside our address range..
101
+ uintptr_t mask = mi_atomic_load_relaxed(&part->map[index]);
102
+ uintptr_t newmask;
103
+ do {
104
+ newmask = (mask & ~((uintptr_t)1 << bitidx));
105
+ } while (!mi_atomic_cas_weak_release(&part->map[index], &mask, newmask));
106
+ }
107
+
108
+ // Determine the segment belonging to a pointer or NULL if it is not in a valid segment.
109
+ static mi_segment_t* _mi_segment_of(const void* p) {
110
+ if (p == NULL) return NULL;
111
+ mi_segment_t* segment = _mi_ptr_segment(p); // segment can be NULL
112
+ size_t index;
113
+ size_t bitidx;
114
+ mi_segmap_part_t* part = mi_segment_map_index_of(segment, false /* dont alloc if not present */, &index, &bitidx);
115
+ if (part == NULL) return NULL;
116
+ const uintptr_t mask = mi_atomic_load_relaxed(&part->map[index]);
117
+ if mi_likely((mask & ((uintptr_t)1 << bitidx)) != 0) {
118
+ bool cookie_ok = (_mi_ptr_cookie(segment) == segment->cookie);
119
+ mi_assert_internal(cookie_ok); MI_UNUSED(cookie_ok);
120
+ return segment; // yes, allocated by us
121
+ }
122
+ return NULL;
123
+ }
124
+
125
+ // Is this a valid pointer in our heap?
126
+ static bool mi_is_valid_pointer(const void* p) {
127
+ // first check if it is in an arena, then check if it is OS allocated
128
+ return (_mi_arena_contains(p) || _mi_segment_of(p) != NULL);
129
+ }
130
+
131
+ mi_decl_nodiscard mi_decl_export bool mi_is_in_heap_region(const void* p) mi_attr_noexcept {
132
+ return mi_is_valid_pointer(p);
133
+ }
134
+
135
+ void _mi_segment_map_unsafe_destroy(void) {
136
+ for (size_t i = 0; i < MI_SEGMENT_MAP_MAX_PARTS; i++) {
137
+ mi_segmap_part_t* part = mi_atomic_exchange_ptr_relaxed(mi_segmap_part_t, &mi_segment_map[i], NULL);
138
+ if (part != NULL) {
139
+ _mi_os_free(part, sizeof(mi_segmap_part_t), part->memid);
140
+ }
141
+ }
142
+ }