@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,497 @@
1
+ #include <stdlib.h>
2
+ #include <stdio.h>
3
+ #include <assert.h>
4
+ #include <string.h>
5
+ #include <stdint.h>
6
+
7
+ #include <mimalloc.h>
8
+ #include <new>
9
+ #include <vector>
10
+ #include <future>
11
+ #include <iostream>
12
+ #include <thread>
13
+ #include <assert.h>
14
+
15
+ #ifdef _WIN32
16
+ #include <mimalloc-new-delete.h>
17
+ #include <windows.h>
18
+ static void msleep(unsigned long msecs) { Sleep(msecs); }
19
+ #else
20
+ #include <unistd.h>
21
+ static void msleep(unsigned long msecs) { usleep(msecs * 1000UL); }
22
+ #endif
23
+
24
+ static void heap_thread_free_large(); // issue #221
25
+ static void heap_no_delete(); // issue #202
26
+ static void heap_late_free(); // issue #204
27
+ static void padding_shrink(); // issue #209
28
+ static void various_tests();
29
+ static void test_mt_shutdown();
30
+ static void large_alloc(void); // issue #363
31
+ static void fail_aslr(); // issue #372
32
+ static void tsan_numa_test(); // issue #414
33
+ static void strdup_test(); // issue #445
34
+ static void bench_alloc_large(void); // issue #xxx
35
+ //static void test_large_migrate(void); // issue #691
36
+ static void heap_thread_free_huge();
37
+ static void test_std_string(); // issue #697
38
+ static void test_thread_local(); // issue #944
39
+ // static void test_mixed0(); // issue #942
40
+ static void test_mixed1(); // issue #942
41
+ static void test_stl_allocators();
42
+
43
+ #if _WIN32
44
+ #include "main-override-dep.h"
45
+ static void test_dep(); // issue #981: test overriding in another DLL
46
+ #else
47
+ static void test_dep() { };
48
+ #endif
49
+
50
+ int main() {
51
+ mi_stats_reset(); // ignore earlier allocations
52
+ various_tests();
53
+ test_mixed1();
54
+
55
+ test_dep();
56
+
57
+ //test_std_string();
58
+ //test_thread_local();
59
+ // heap_thread_free_huge();
60
+ /*
61
+ heap_thread_free_huge();
62
+ heap_thread_free_large();
63
+ heap_no_delete();
64
+ heap_late_free();
65
+ padding_shrink();
66
+ various_tests();
67
+ large_alloc();
68
+ tsan_numa_test();
69
+ strdup_test();
70
+ */
71
+ // test_stl_allocators();
72
+ // test_mt_shutdown();
73
+ // test_large_migrate();
74
+
75
+ //fail_aslr();
76
+ mi_stats_print(NULL);
77
+ return 0;
78
+ }
79
+
80
+ static void* p = malloc(8);
81
+
82
+ void free_p() {
83
+ free(p);
84
+ return;
85
+ }
86
+
87
+ class Test {
88
+ private:
89
+ int i;
90
+ public:
91
+ Test(int x) { i = x; }
92
+ ~Test() { }
93
+ };
94
+
95
+
96
+ static void various_tests() {
97
+ atexit(free_p);
98
+ void* p1 = malloc(78);
99
+ void* p2 = mi_malloc_aligned(24, 16);
100
+ free(p1);
101
+ p1 = malloc(8);
102
+ char* s = mi_strdup("hello\n");
103
+
104
+ mi_free(p2);
105
+ p2 = malloc(16);
106
+ p1 = realloc(p1, 32);
107
+ free(p1);
108
+ free(p2);
109
+ mi_free(s);
110
+
111
+ Test* t = new Test(42);
112
+ delete t;
113
+ t = new (std::nothrow) Test(42);
114
+ delete t;
115
+ auto tbuf = new unsigned char[sizeof(Test)];
116
+ t = new (tbuf) Test(42);
117
+ t->~Test();
118
+ delete[] tbuf;
119
+
120
+ #if _WIN32
121
+ const char* ptr = ::_Getdays(); // test _base overrid
122
+ free((void*)ptr);
123
+ #endif
124
+ }
125
+
126
+ class Static {
127
+ private:
128
+ void* p;
129
+ public:
130
+ Static() {
131
+ p = malloc(64);
132
+ return;
133
+ }
134
+ ~Static() {
135
+ free(p);
136
+ return;
137
+ }
138
+ };
139
+
140
+ static Static s = Static();
141
+
142
+
143
+ static bool test_stl_allocator1() {
144
+ std::vector<int, mi_stl_allocator<int> > vec;
145
+ vec.push_back(1);
146
+ vec.pop_back();
147
+ return vec.size() == 0;
148
+ }
149
+
150
+ struct some_struct { int i; int j; double z; };
151
+
152
+
153
+ #if _WIN32
154
+ static void test_dep()
155
+ {
156
+ TestAllocInDll t;
157
+ std::string s = t.GetString();
158
+ std::cout << "test_dep GetString: " << s << "\n";
159
+ }
160
+ #endif
161
+
162
+
163
+ static bool test_stl_allocator2() {
164
+ std::vector<some_struct, mi_stl_allocator<some_struct> > vec;
165
+ vec.push_back(some_struct());
166
+ vec.pop_back();
167
+ return vec.size() == 0;
168
+ }
169
+
170
+ #if MI_HAS_HEAP_STL_ALLOCATOR
171
+ static bool test_stl_allocator3() {
172
+ std::vector<int, mi_heap_stl_allocator<int> > vec;
173
+ vec.push_back(1);
174
+ vec.pop_back();
175
+ return vec.size() == 0;
176
+ }
177
+
178
+ static bool test_stl_allocator4() {
179
+ std::vector<some_struct, mi_heap_stl_allocator<some_struct> > vec;
180
+ vec.push_back(some_struct());
181
+ vec.pop_back();
182
+ return vec.size() == 0;
183
+ }
184
+
185
+ static bool test_stl_allocator5() {
186
+ std::vector<int, mi_heap_destroy_stl_allocator<int> > vec;
187
+ vec.push_back(1);
188
+ vec.pop_back();
189
+ return vec.size() == 0;
190
+ }
191
+
192
+ static bool test_stl_allocator6() {
193
+ std::vector<some_struct, mi_heap_destroy_stl_allocator<some_struct> > vec;
194
+ vec.push_back(some_struct());
195
+ vec.pop_back();
196
+ return vec.size() == 0;
197
+ }
198
+ #endif
199
+
200
+ static void test_stl_allocators() {
201
+ test_stl_allocator1();
202
+ test_stl_allocator2();
203
+ #if MI_HAS_HEAP_STL_ALLOCATOR
204
+ test_stl_allocator3();
205
+ test_stl_allocator4();
206
+ test_stl_allocator5();
207
+ test_stl_allocator6();
208
+ #endif
209
+ }
210
+
211
+ #if 0
212
+ #include <algorithm>
213
+ #include <chrono>
214
+ #include <functional>
215
+ #include <iostream>
216
+ #include <thread>
217
+ #include <vector>
218
+
219
+ static void test_mixed0() {
220
+ std::vector<std::unique_ptr<std::size_t>> numbers(1024 * 1024 * 100);
221
+ std::vector<std::thread> threads(1);
222
+
223
+ std::atomic<std::size_t> index{};
224
+
225
+ auto start = std::chrono::system_clock::now();
226
+
227
+ for (auto& thread : threads) {
228
+ thread = std::thread{[&index, &numbers]() {
229
+ while (true) {
230
+ auto i = index.fetch_add(1, std::memory_order_relaxed);
231
+ if (i >= numbers.size()) return;
232
+
233
+ numbers[i] = std::make_unique<std::size_t>(i);
234
+ }
235
+ }};
236
+ }
237
+
238
+ for (auto& thread : threads) thread.join();
239
+
240
+ auto end = std::chrono::system_clock::now();
241
+
242
+ auto duration =
243
+ std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
244
+ std::cout << "Running on " << threads.size() << " threads took " << duration
245
+ << std::endl;
246
+ }
247
+ #endif
248
+
249
+ void asd() {
250
+ void* p = malloc(128);
251
+ free(p);
252
+ }
253
+ static void test_mixed1() {
254
+ std::thread thread(asd);
255
+ thread.join();
256
+ }
257
+
258
+ #if 0
259
+ // issue #691
260
+ static char* cptr;
261
+
262
+ static void* thread1_allocate()
263
+ {
264
+ cptr = mi_calloc_tp(char,22085632);
265
+ return NULL;
266
+ }
267
+
268
+ static void* thread2_free()
269
+ {
270
+ assert(cptr);
271
+ mi_free(cptr);
272
+ cptr = NULL;
273
+ return NULL;
274
+ }
275
+
276
+ static void test_large_migrate(void) {
277
+ auto t1 = std::thread(thread1_allocate);
278
+ t1.join();
279
+ auto t2 = std::thread(thread2_free);
280
+ t2.join();
281
+ /*
282
+ pthread_t thread1, thread2;
283
+
284
+ pthread_create(&thread1, NULL, &thread1_allocate, NULL);
285
+ pthread_join(thread1, NULL);
286
+
287
+ pthread_create(&thread2, NULL, &thread2_free, NULL);
288
+ pthread_join(thread2, NULL);
289
+ */
290
+ return;
291
+ }
292
+ #endif
293
+
294
+ // issue 445
295
+ static void strdup_test() {
296
+ #ifdef _MSC_VER
297
+ char* s = _strdup("hello\n");
298
+ char* buf = NULL;
299
+ size_t len;
300
+ _dupenv_s(&buf, &len, "MIMALLOC_VERBOSE");
301
+ mi_free(buf);
302
+ mi_free(s);
303
+ #endif
304
+ }
305
+
306
+ // Issue #202
307
+ static void heap_no_delete_worker() {
308
+ mi_heap_t* heap = mi_heap_new();
309
+ void* q = mi_heap_malloc(heap, 1024); (void)(q);
310
+ // mi_heap_delete(heap); // uncomment to prevent assertion
311
+ }
312
+
313
+ static void heap_no_delete() {
314
+ auto t1 = std::thread(heap_no_delete_worker);
315
+ t1.join();
316
+ }
317
+
318
+
319
+ // Issue #697
320
+ static void test_std_string() {
321
+ std::string path = "/Users/xxxx/Library/Developer/Xcode/DerivedData/xxxxxxxxxx/Build/Intermediates.noindex/xxxxxxxxxxx/arm64/XX_lto.o/0.arm64.lto.o";
322
+ std::string path1 = "/Users/xxxx/Library/Developer/Xcode/DerivedData/xxxxxxxxxx/Build/Intermediates.noindex/xxxxxxxxxxx/arm64/XX_lto.o/1.arm64.lto.o";
323
+ std::cout << path + "\n>>> " + path1 + "\n>>> " << std::endl;
324
+ }
325
+
326
+ // Issue #204
327
+ static volatile void* global_p;
328
+
329
+ static void t1main() {
330
+ mi_heap_t* heap = mi_heap_new();
331
+ global_p = mi_heap_malloc(heap, 1024);
332
+ mi_heap_delete(heap);
333
+ }
334
+
335
+ static void heap_late_free() {
336
+ auto t1 = std::thread(t1main);
337
+
338
+ msleep(2000);
339
+ assert(global_p);
340
+ mi_free((void*)global_p);
341
+
342
+ t1.join();
343
+ }
344
+
345
+ // issue #209
346
+ static void* shared_p;
347
+ static void alloc0(/* void* arg */)
348
+ {
349
+ shared_p = mi_malloc(8);
350
+ }
351
+
352
+ static void padding_shrink(void)
353
+ {
354
+ auto t1 = std::thread(alloc0);
355
+ t1.join();
356
+ mi_free(shared_p);
357
+ }
358
+
359
+
360
+ // Issue #221
361
+ static void heap_thread_free_large_worker() {
362
+ mi_free(shared_p);
363
+ }
364
+
365
+ static void heap_thread_free_large() {
366
+ for (int i = 0; i < 100; i++) {
367
+ shared_p = mi_malloc_aligned(2 * 1024 * 1024 + 1, 8);
368
+ auto t1 = std::thread(heap_thread_free_large_worker);
369
+ t1.join();
370
+ }
371
+ }
372
+
373
+ static void heap_thread_free_huge_worker() {
374
+ mi_free(shared_p);
375
+ }
376
+
377
+ static void heap_thread_free_huge() {
378
+ for (int i = 0; i < 100; i++) {
379
+ shared_p = mi_malloc(1024 * 1024 * 1024);
380
+ auto t1 = std::thread(heap_thread_free_huge_worker);
381
+ t1.join();
382
+ }
383
+ }
384
+
385
+ static void test_mt_shutdown()
386
+ {
387
+ const int threads = 5;
388
+ std::vector< std::future< std::vector< char* > > > ts;
389
+
390
+ auto fn = [&]()
391
+ {
392
+ std::vector< char* > ps;
393
+ ps.reserve(1000);
394
+ for (int i = 0; i < 1000; i++)
395
+ ps.emplace_back(new char[1]);
396
+ return ps;
397
+ };
398
+
399
+ for (int i = 0; i < threads; i++)
400
+ ts.emplace_back(std::async(std::launch::async, fn));
401
+
402
+ for (auto& f : ts)
403
+ for (auto& p : f.get())
404
+ delete[] p;
405
+
406
+ std::cout << "done" << std::endl;
407
+ }
408
+
409
+ // issue #363
410
+ using namespace std;
411
+
412
+ void large_alloc(void)
413
+ {
414
+ char* a = new char[1ull << 25];
415
+ thread th([&] {
416
+ delete[] a;
417
+ });
418
+ th.join();
419
+ }
420
+
421
+ // issue #372
422
+ static void fail_aslr() {
423
+ size_t sz = (size_t)(4ULL << 40); // 4TiB
424
+ void* p = malloc(sz);
425
+ printf("pointer p: %p: area up to %p\n", p, (uint8_t*)p + sz);
426
+ *(int*)0x5FFFFFFF000 = 0; // should segfault
427
+ }
428
+
429
+ // issues #414
430
+ static void dummy_worker() {
431
+ void* p = mi_malloc(0);
432
+ mi_free(p);
433
+ }
434
+
435
+ static void tsan_numa_test() {
436
+ auto t1 = std::thread(dummy_worker);
437
+ dummy_worker();
438
+ t1.join();
439
+ }
440
+
441
+ // issue #?
442
+ #include <chrono>
443
+ #include <random>
444
+ #include <iostream>
445
+
446
+ static void bench_alloc_large(void) {
447
+ static constexpr int kNumBuffers = 20;
448
+ static constexpr size_t kMinBufferSize = 5 * 1024 * 1024;
449
+ static constexpr size_t kMaxBufferSize = 25 * 1024 * 1024;
450
+ std::unique_ptr<char[]> buffers[kNumBuffers];
451
+
452
+ std::random_device rd; (void)rd;
453
+ std::mt19937 gen(42); //rd());
454
+ std::uniform_int_distribution<> size_distribution(kMinBufferSize, kMaxBufferSize);
455
+ std::uniform_int_distribution<> buf_number_distribution(0, kNumBuffers - 1);
456
+
457
+ static constexpr int kNumIterations = 2000;
458
+ const auto start = std::chrono::steady_clock::now();
459
+ for (int i = 0; i < kNumIterations; ++i) {
460
+ int buffer_idx = buf_number_distribution(gen);
461
+ size_t new_size = size_distribution(gen);
462
+ buffers[buffer_idx] = std::make_unique<char[]>(new_size);
463
+ }
464
+ const auto end = std::chrono::steady_clock::now();
465
+ const auto num_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
466
+ const auto us_per_allocation = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / kNumIterations;
467
+ std::cout << kNumIterations << " allocations Done in " << num_ms << "ms." << std::endl;
468
+ std::cout << "Avg " << us_per_allocation << " us per allocation" << std::endl;
469
+ }
470
+
471
+
472
+ class MTest
473
+ {
474
+ char *data;
475
+ public:
476
+ MTest() { data = (char*)malloc(1024); }
477
+ ~MTest() { free(data); };
478
+ };
479
+
480
+ thread_local MTest tlVariable;
481
+
482
+ void threadFun( int i )
483
+ {
484
+ printf( "Thread %d\n", i );
485
+ std::this_thread::sleep_for( std::chrono::milliseconds(100) );
486
+ }
487
+
488
+ void test_thread_local()
489
+ {
490
+ for( int i=1; i < 100; ++i )
491
+ {
492
+ std::thread t( threadFun, i );
493
+ t.join();
494
+ mi_stats_print(NULL);
495
+ }
496
+ return;
497
+ }
@@ -0,0 +1,46 @@
1
+ #include <stdio.h>
2
+ #include <assert.h>
3
+ #include <mimalloc.h>
4
+
5
+ void test_heap(void* p_out) {
6
+ mi_heap_t* heap = mi_heap_new();
7
+ void* p1 = mi_heap_malloc(heap,32);
8
+ void* p2 = mi_heap_malloc(heap,48);
9
+ mi_free(p_out);
10
+ mi_heap_destroy(heap);
11
+ //mi_heap_delete(heap); mi_free(p1); mi_free(p2);
12
+ }
13
+
14
+ void test_large() {
15
+ const size_t N = 1000;
16
+
17
+ for (size_t i = 0; i < N; ++i) {
18
+ size_t sz = 1ull << 21;
19
+ char* a = mi_mallocn_tp(char,sz);
20
+ for (size_t k = 0; k < sz; k++) { a[k] = 'x'; }
21
+ mi_free(a);
22
+ }
23
+ }
24
+
25
+ int main() {
26
+ void* p1 = mi_malloc(16);
27
+ void* p2 = mi_malloc(1000000);
28
+ mi_free(p1);
29
+ mi_free(p2);
30
+ p1 = mi_malloc(16);
31
+ p2 = mi_malloc(16);
32
+ mi_free(p1);
33
+ mi_free(p2);
34
+
35
+ test_heap(mi_malloc(32));
36
+
37
+ p1 = mi_malloc_aligned(64, 16);
38
+ p2 = mi_malloc_aligned(160,24);
39
+ mi_free(p2);
40
+ mi_free(p1);
41
+ //test_large();
42
+
43
+ mi_collect(true);
44
+ mi_stats_print(NULL);
45
+ return 0;
46
+ }
@@ -0,0 +1,16 @@
1
+ Testing allocators is difficult as bugs may only surface after particular
2
+ allocation patterns. The main approach to testing _mimalloc_ is therefore
3
+ to have extensive internal invariant checking (see `page_is_valid` in `page.c`
4
+ for example), which is enabled in debug mode with `-DMI_DEBUG_FULL=ON`.
5
+ The main testing strategy is then to run [`mimalloc-bench`][bench] using full
6
+ invariant checking to catch any potential problems over a wide range of intensive
7
+ allocation benchmarks and programs.
8
+
9
+ However, this does not test well for the entire API surface and this is tested
10
+ with `test-api.c` when using `make test` (from `out/debug` etc). (This is
11
+ not complete yet, please add to it.)
12
+
13
+ The `main.c` and `main-override.c` are there to test if building and overriding
14
+ from a local install works and therefore these build a separate `test/CMakeLists.txt`.
15
+
16
+ [bench]: https://github.com/daanx/mimalloc-bench