json-model-compiler 2.0b26__tar.gz → 2.0b31__tar.gz

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 (209) hide show
  1. {json_model_compiler-2.0b26/site → json_model_compiler-2.0b31}/BACKLOG.md +90 -25
  2. json_model_compiler-2.0b31/BENCH.md +69 -0
  3. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/Makefile +6 -2
  4. {json_model_compiler-2.0b26/json_model_compiler.egg-info → json_model_compiler-2.0b31}/PKG-INFO +6 -15
  5. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/README.md +5 -14
  6. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/about.sh +4 -4
  7. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/docker/jmc +1 -1
  8. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/analyze.py +1 -0
  9. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/clang.py +142 -14
  10. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/jmc.pod +9 -1
  11. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/python_entry.py +1 -1
  12. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/irep.py +549 -53
  13. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/java.py +8 -5
  14. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/javascript.py +7 -4
  15. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/language.py +29 -7
  16. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/mtypes.py +2 -0
  17. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/optim.py +170 -13
  18. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/perl.py +26 -6
  19. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/plpgsql.py +7 -4
  20. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/python.py +8 -6
  21. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/c/json-model.h +48 -0
  22. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/support.py +11 -0
  23. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/script.py +11 -3
  24. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/utils.py +155 -64
  25. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/xstatic.py +147 -68
  26. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31/json_model_compiler.egg-info}/PKG-INFO +6 -15
  27. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model_compiler.egg-info/SOURCES.txt +18 -1
  28. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/jmc-ir.model.json +3 -2
  29. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/pyproject.toml +1 -1
  30. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31/site}/BACKLOG.md +90 -25
  31. json_model_compiler-2.0b31/site/BENCH.md +69 -0
  32. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/site/README.md +5 -14
  33. json_model_compiler-2.0b31/site/benchmarks/2025101700.csv +163 -0
  34. json_model_compiler-2.0b31/site/benchmarks/2025101700.json +296 -0
  35. json_model_compiler-2.0b31/site/benchmarks/2025101700.md +206 -0
  36. json_model_compiler-2.0b31/site/benchmarks/2025101701.csv +163 -0
  37. json_model_compiler-2.0b31/site/benchmarks/2025101701.json +296 -0
  38. json_model_compiler-2.0b31/site/benchmarks/2025101701.md +207 -0
  39. json_model_compiler-2.0b31/site/benchmarks/2025101808.csv +163 -0
  40. json_model_compiler-2.0b31/site/benchmarks/2025101808.json +296 -0
  41. json_model_compiler-2.0b31/site/benchmarks/2025101808.md +208 -0
  42. json_model_compiler-2.0b31/site/benchmarks/2025101900.csv +163 -0
  43. json_model_compiler-2.0b31/site/benchmarks/2025101900.json +296 -0
  44. json_model_compiler-2.0b31/site/benchmarks/2025101900.md +208 -0
  45. json_model_compiler-2.0b31/site/benchmarks/2025102200.csv +164 -0
  46. json_model_compiler-2.0b31/site/benchmarks/2025102200.json +296 -0
  47. json_model_compiler-2.0b31/site/benchmarks/2025102200.md +209 -0
  48. json_model_compiler-2.0b31/site/index.html +131 -0
  49. json_model_compiler-2.0b26/site/index.html +0 -50
  50. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/.gitignore +0 -0
  51. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/.gitmodules +0 -0
  52. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/API.md +0 -0
  53. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/DESIGN.md +0 -0
  54. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/DEV.md +0 -0
  55. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/DOC.md +0 -0
  56. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/HOWTO.md +0 -0
  57. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/INTEGRATION.md +0 -0
  58. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/MANIFEST.in +0 -0
  59. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/PUBS.md +0 -0
  60. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/SPEC.md +0 -0
  61. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/TUTO.md +0 -0
  62. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/docker/.dockerignore +0 -0
  63. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/docker/.gitignore +0 -0
  64. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/docker/Dockerfile +0 -0
  65. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/docker/Makefile +0 -0
  66. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/docker/README.md +0 -0
  67. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/README.md +0 -0
  68. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/__init__.py +0 -0
  69. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/convert.py +0 -0
  70. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/clang_entry.c +0 -0
  71. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/clang_free.c +0 -0
  72. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/clang_init.c +0 -0
  73. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/clang_pcre2_fun.c +0 -0
  74. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/clang_re2_fun.c +0 -0
  75. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/java_free.java +0 -0
  76. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/java_init.java +0 -0
  77. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/javascript_exe.js +0 -0
  78. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/javascript_foot.js +0 -0
  79. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/javascript_free.js +0 -0
  80. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/javascript_head.js +0 -0
  81. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/javascript_init.js +0 -0
  82. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/javascript_main.js +0 -0
  83. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/perl_entry.pl +0 -0
  84. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/perl_exe.pl +0 -0
  85. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/perl_free.pl +0 -0
  86. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/perl_init.pl +0 -0
  87. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/perl_main.pl +0 -0
  88. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/perl_pkg.pl +0 -0
  89. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/plpgsql_entry.sql +0 -0
  90. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/python_exe.py +0 -0
  91. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/python_free.py +0 -0
  92. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/python_init.py +0 -0
  93. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/data/python_main.py +0 -0
  94. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/export.py +0 -0
  95. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/model.py +0 -0
  96. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/objmerge.py +0 -0
  97. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/recurse.py +0 -0
  98. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/resolver.py +0 -0
  99. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/Makefile +0 -0
  100. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/__init__.py +0 -0
  101. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/c/Makefile +0 -0
  102. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/c/json-model.c +0 -0
  103. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/c/main.c +0 -0
  104. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/.gitignore +0 -0
  105. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/Makefile +0 -0
  106. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/README.md +0 -0
  107. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/env.bash +0 -0
  108. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/json_model/Checker.java +0 -0
  109. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/json_model/GSON.java +0 -0
  110. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/json_model/JSON.java +0 -0
  111. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/json_model/JSONP.java +0 -0
  112. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/json_model/Jackson.java +0 -0
  113. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/json_model/Main.java +0 -0
  114. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/json_model/ModelChecker.java +0 -0
  115. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/json_model/Path.java +0 -0
  116. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/json_model/Report.java +0 -0
  117. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/json_model/Runtime.java +0 -0
  118. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/java/pom.xml +0 -0
  119. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/js/README.md +0 -0
  120. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/js/index.js +0 -0
  121. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/js/main.js +0 -0
  122. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/js/package.json +0 -0
  123. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/.gitignore +0 -0
  124. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/Changes +0 -0
  125. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/LICENSE +0 -0
  126. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/MANIFEST +0 -0
  127. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/Makefile.PL +0 -0
  128. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/README +0 -0
  129. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/ignore.txt +0 -0
  130. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/lib/JSON/JsonModel.pm +0 -0
  131. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/t/00-load.t +0 -0
  132. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/t/manifest.t +0 -0
  133. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/t/pod-coverage.t +0 -0
  134. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/t/pod.t +0 -0
  135. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/pl/xt/boilerplate.t +0 -0
  136. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/sql/META.json +0 -0
  137. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/sql/Makefile +0 -0
  138. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/sql/json_model--2.0.sql +0 -0
  139. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/sql/json_model.control +0 -0
  140. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/runtime/types.py +0 -0
  141. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model/url_cache.py +0 -0
  142. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model_compiler.egg-info/dependency_links.txt +0 -0
  143. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model_compiler.egg-info/entry_points.txt +0 -0
  144. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model_compiler.egg-info/requires.txt +0 -0
  145. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/json_model_compiler.egg-info/top_level.txt +0 -0
  146. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/ansiblelint-meta.model.json +0 -0
  147. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/cypress.model.json +0 -0
  148. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/diploma-arrete.model.json +0 -0
  149. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/diploma-export.model.json +0 -0
  150. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/everything.model.json +0 -0
  151. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/fresq.model.json +0 -0
  152. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/geo-easy.model.json +0 -0
  153. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/geo.model.json +0 -0
  154. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-model-latest.model.json +0 -0
  155. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-model-moschin.model.json +0 -0
  156. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-model-no-merge.model.json +0 -0
  157. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-model-v1.model.json +0 -0
  158. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-model-v2-en.model.json +0 -0
  159. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-model-v2.model.json +0 -0
  160. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-model.model.json +0 -0
  161. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-01-fuzzy.model.json +0 -0
  162. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-01-nesting.model.json +0 -0
  163. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-01.model.json +0 -0
  164. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-02-fuzzy.model.json +0 -0
  165. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-02-nesting.model.json +0 -0
  166. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-02.model.json +0 -0
  167. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-03-fuzzy.model.json +0 -0
  168. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-03-nesting.model.json +0 -0
  169. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-03.model.json +0 -0
  170. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-04-fuzzy.model.json +0 -0
  171. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-04-mongodb.model.json +0 -0
  172. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-04-nesting.model.json +0 -0
  173. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-04.model.json +0 -0
  174. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-06-fuzzy.model.json +0 -0
  175. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-06.model.json +0 -0
  176. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-07-fuzzy.model.json +0 -0
  177. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-07.model.json +0 -0
  178. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-2019-09-fuzzy.model.json +0 -0
  179. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-2019-09.model.json +0 -0
  180. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-2020-12-fuzzy.model.json +0 -0
  181. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-2020-12-tight.model.json +0 -0
  182. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-2020-12.model.json +0 -0
  183. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-next-fuzzy.model.json +0 -0
  184. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-next.model.json +0 -0
  185. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-tight.model.json +0 -0
  186. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-tighter-loose.model.json +0 -0
  187. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-draft-tighter.model.json +0 -0
  188. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/json-schema-linter.model.json +0 -0
  189. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/jsound.model.json +0 -0
  190. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/l10n.model.json +0 -0
  191. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/lazygit.model.json +0 -0
  192. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/openapi-311-fuzzy.model.json +0 -0
  193. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/openapi-311-models.model.json +0 -0
  194. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/openapi-311.model.json +0 -0
  195. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/person.model.json +0 -0
  196. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/person2.model.json +0 -0
  197. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/models/pgxn.model.json +0 -0
  198. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/package.json +0 -0
  199. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/setup.cfg +0 -0
  200. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/site/API.md +0 -0
  201. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/site/DOC.md +0 -0
  202. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/site/DOCKER.md +0 -0
  203. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/site/HOWTO.md +0 -0
  204. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/site/PUBS.md +0 -0
  205. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/site/SPEC.md +0 -0
  206. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/site/TUTO.md +0 -0
  207. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/site/cover.md +0 -0
  208. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/site/favicon.ico +0 -0
  209. {json_model_compiler-2.0b26 → json_model_compiler-2.0b31}/site/json_logo.svg +0 -0
@@ -2,34 +2,61 @@
2
2
 
3
3
  ## Current Tasks
4
4
 
5
- - [x] models: write model for json IR
6
- - [x] static: fix value path in some object variants
7
- - [x] static: add a max threshold/ratio for may property unrolling
8
- - [x] perf: add jsb version to final summary
9
- - [x] command: add `--no-predef` option for testing
10
- - [x] command: remove inline-or option and implementation
11
- - [x] command: allow to pass options with environment variable `JMC_OPTS`
12
- - [x] docker: environment control for perf tests
13
- - [x] command: `jmc -C -o foo.json` generates python instead of json
14
- - [ ] optim: improve xor-to-or with references
5
+ - [x] pr: improve radar chart responsiveness and sorting
6
+ - [x] backend: remove intermediate variable on return
7
+ - [x] backend: remove unused boolean variable declaration on simple direct return
8
+ - [x] ~backend: remove redundant scalar test in some cases~
9
+ - [x] backend: remove reporting instructions under no reporting
10
+ - [x] backend: add late code filtering to catch some backend-specific stuff
11
+ - [x] c-backend: remove redundant scalar test in some cases (with late filtering)
12
+ - [x] c-backend: remove some useless braces around one instruction (with late filtering)
13
+ - [x] backend: simplify conditional assignment patterns with one boolean constant
14
+ - [x] backend: merge boolean declaration and first assignment if possible
15
+ - [x] backend: optimize pattern "if (! res) res = E; ret res;"
16
+ - [x] backend: refactoring, cleanup and generalization
17
+ - [x] static: add likely/unlikely hints to clang
18
+ - [x] c-backend: optimize startwith implementation
19
+ - [x] backend: optimize pattern "res = E1; if (! res) res = E2;"
20
+ - [x] backend: optimize full pattern "(E && ...) || (E && ...)"
21
+ - [x] backend: or/and flattening
22
+ - [x] backend: optimize partial pattern "... || (E && ...) || (E && ...) || ...;"
23
+ - [x] backend: optimize pattern "V = E1; if (V) V = E2;"
24
+ - [x] perf: add launcher script
25
+ - [x] c-backend: cleanup duplicated `json_is_boolean` calls
26
+ - [x] c-backend: fix bad constant string expression syntax
27
+ - [ ] backend: generate direct code for search constant on small sets
28
+ - [ ] backend: fix `TRUE AND` in `mv-07/json-schema-draft-tight.sql`
29
+ - [ ] backend: fix `unused but set variable` warning
30
+ - [ ] backend: cleanup unused assigned variable, see `mv-08/openapi-311.c`
31
+ - [ ] backend: useless computations in `mv-17/xor_01.pl`
32
+ - [ ] static: improve likely hints, eg may only category
33
+ - [ ] backend: optimize pattern "res = E1; return res || E2;" (only one use)
34
+ - [ ] backend: remove useless `ELSE NULL` see `mv-02/geo.sql`
35
+ - [ ] backend: optimize pattern "res = E; if (! res) ret F; res not used before set;"
36
+ - [ ] backend: optimize pattern "{ decl X = ... ; res = f(X (once) ) }"
37
+ - [ ] backend: simplify assignment patterns with ternary operator when available?
38
+ - [ ] backend: consider applying language-specific formatting tools? `clang-format`, `flake8`…
39
+ - [ ] backend: remove reporting expressions under no reporting
40
+ - [ ] c-backend: get pval string into a variable for strcmp unrolling and inlining
41
+ - [ ] c-backend: add number of chunks limit to strcmp optimization
42
+ - [ ] c-backend: strcmp to const inlining and unrolling for all instances
43
+ - [ ] static: partial discriminator with else?
44
+ - [ ] static: optimize not string cst test?
15
45
  - [ ] perf: compute performance overhead globally instead of per run
16
- - [ ] perf: experiment object matching with various mandatory/optional properties
17
- - [ ] static: close may/must? merge with open?
18
- - [ ] optim: and to merge optimization for open object models
19
- - [ ] static: add a dynamic test for different strategies in object checking
20
- - [ ] tests: add ir optimized output
46
+ - [ ] tests: add ir optimized output (too large?)
21
47
  - [ ] tests: add pytest ir tests
22
48
  - [ ] tests: add generated ir model check
23
49
  - [ ] tests: drop language outputs for IR only?!
24
50
  - [ ] tests: check generated IR with IR model
51
+ - [ ] perf: experiment object matching with various mandatory/optional properties
52
+ - [ ] static: close may/must? merge with open?
53
+ - [ ] static: add a dynamic test for different strategies in object checking
25
54
  - [ ] backend: refactor ir optimizations
26
55
  - [ ] command: add direct ir to lang conversion
27
- - [ ] backend: improve and extend IR optimizations?
28
- - [ ] artifact: make work with dind
29
- - [ ] static: recognize already compile objects and reuse function esp under no no-reporting?
56
+ - [ ] artifact: make work with dind (docker compose?)
57
+ - [ ] static: recognize already compile objects and reuse function esp under no-reporting?
30
58
  - [ ] tests: check how clang compares to gcc
31
59
  - [ ] tests: add non regression tests to docker build
32
- - [ ] tests: fix sql test errors from `Makefile`
33
60
  - [ ] service: json to lang conversion API
34
61
  - [ ] api: web interface with caching and security
35
62
  - [ ] web-frontend: dev as a use case for jm
@@ -48,11 +75,13 @@
48
75
  - [ ] export: improve pydantic, do not generate bad fields (dash and other chars)
49
76
  - [ ] test: some pydantic exports? imports?
50
77
  - [ ] pr: submit jsonschema-benchmark java PR
51
- - [ ] pr: submit jsonschema-benchmark PL/pgSQL PR
52
78
  - [ ] frontends: reject json with duplicated props
53
79
  - [ ] c-backend: header file for generated code?
54
- - [ ] tests: perl _uninitialized value $tag_0 in hash element at `./mv-18/dis_01.pl:171._
80
+ - [ ] backend: implement str comparison using some fast hash in some cases?
55
81
  - [ ] command: allow to pass some options from rc file?
82
+ - [ ] tests: parallelize per-case instead of per-dir?
83
+ - [ ] static: shorten xor exit?
84
+ - [ ] perf: profile some cases
56
85
 
57
86
  ## Re Do
58
87
 
@@ -94,7 +123,6 @@
94
123
  - [ ] use: py type dataclass/pydantic export?
95
124
  - [ ] use: test with corrector? ref? kiva?
96
125
  - [ ] static: sort list of models? option?
97
- - [ ] optim: merge `&` of objects in some cases?
98
126
  - [ ] static: fix double reports, eg constraint type and constraints or object props and object
99
127
  - [ ] py-backend: fix failure verbosity `ref/json-model.py.check` vs others
100
128
  - [ ] static: keep deeper names?
@@ -127,7 +155,6 @@
127
155
  - [ ] py-backend: package independent runtime?
128
156
  - [ ] command: improve cache to keep track of urls?
129
157
  - [ ] project: establish priority
130
- - [ ] frontend: accept raw sequence of values? list of values?
131
158
  - [ ] project: improve backlog management with thematic sections
132
159
  - [ ] design: $-refs may only appear in defs for simpler compiler AND better readability?
133
160
  - [ ] project: move all code's TODO here
@@ -140,12 +167,10 @@
140
167
  - [ ] design: should it allow unexpected ints as constants?
141
168
  - [ ] dynamic: JSON IR to lambda?!
142
169
  - [ ] backend: add JSON output?
143
- - [ ] backend: direct code for blaze?
144
170
  - [ ] dynamic: rely on static and eval
145
171
  - [ ] frontend: add multi-level naming option
146
172
  - [ ] optim: ultimate type on loose should yield `float`
147
173
  - [ ] static: abstract imperative language code generation (wip)
148
- - [ ] backend: do not generate intermediate empty functions for direct objects?
149
174
  - [ ] backend: do not generate intermediate empty functions for property values when possible
150
175
  - [ ] backend: reduce/minimize language abstraction? `T_var_val`?
151
176
  - [ ] backend: rethink function boundaries?
@@ -225,6 +250,7 @@
225
250
  - [ ] rust-backend: see [json crate](https://docs.rs/json/latest/json/).
226
251
  - [ ] cpp-backend: see [json](https://github.com/nlohmann/json) and `re2`. json lib popularity?
227
252
  - [ ] cpp-backend: also see [simdjson](https://github.com/simdjson/simdjson)?
253
+ - [ ] backend: direct code for blaze? vs c++?
228
254
  - [ ] kotlin-backend: see [serialization](https://kotlinlang.org/docs/serialization.html).
229
255
  - [ ] mongodb-backend: generate bson stuff, as an option to schema generation?
230
256
  - [ ] ts-backend: js sharing ?
@@ -244,6 +270,7 @@
244
270
  - [ ] design: documentation use case, with added _markdown description_
245
271
  - [ ] pr: validation must be optimized for the valid case, as it is the most likely.
246
272
  - [ ] case: use trafo in geo to have either 2 or 3 vectors, no mix.
273
+ - [ ] clang: cJSON? json-c? other JSON library for C?
247
274
 
248
275
  ## Done
249
276
 
@@ -633,3 +660,41 @@
633
660
  - [x] static: skip model function to call obj function directly on references
634
661
  - [x] backend: apply skip functions also for all pmap/cmap/cc through IR
635
662
  - [x] optim: direct mandatory-only attributes objects with expected count checked ahead
663
+ - [x] models: write model for json IR
664
+ - [x] static: fix value path in some object variants
665
+ - [x] static: add a max threshold/ratio for may property unrolling
666
+ - [x] perf: add jsb version to final summary
667
+ - [x] command: add `--no-predef` option for testing
668
+ - [x] command: remove inline-or option and implementation
669
+ - [x] command: allow to pass options with environment variable `JMC_OPTS`
670
+ - [x] docker: environment control for perf tests
671
+ - [x] command: `jmc -C -o foo.json` generates python instead of json
672
+ - [x] perf: ensure properly aligned data in box report
673
+ - [x] perf: allow to collect data over several runs
674
+ - [x] optim: and-to-merge optimization for open object models
675
+ - [x] perf: allow to collect user time instead of elapsed time
676
+ - [x] backend: improve and extend IR optimizations (wip)
677
+ - [x] tests: perl _uninitialized value `$tag_0` in hash element at `./mv-18/dis_01.pl:171`._
678
+ - [x] ~tests: fix sql test errors from `Makefile`~
679
+ - [x] ~pr: submit jsonschema-benchmark PL/pgSQL PR~
680
+ - [x] optim: get rid of double object with C, Python and Java
681
+ - [x] backend: ~do not generate intermediate empty functions for direct objects? (skip)~
682
+ - [x] static: skip map target functions for objects
683
+ - [x] static: skip map target functions for references
684
+ - [x] optim: add more if simplifications in IR
685
+ - [x] optim: improve xor-to-or over references and sub-ors
686
+ - [x] python: remove useless (debugging) assertion in generated code
687
+ - [x] perf: also show docker id of tested image
688
+ - [x] optim: more xor/not/or simplifications
689
+ - [x] optim: xor-to-or model difference based on not exclusion, possibly behind refs
690
+ - [x] pr: add a benchmarking performance artifact page
691
+ - [x] backend: shamefully ignore bad json due to strange prop names
692
+ - [x] static: fix disjunct analysis issue
693
+ - [x] optim: fix infinite loop between xor-to-or and partial eval
694
+ - [x] pr: improve bench page
695
+ - [x] command: set default to compile on `-F language` instead of model preprocessing
696
+ - [x] c-backend: add _optimized_ str comparison code for eq and ne, enabled by default
697
+ - [x] c-backend: consider big endian for strcmp runtime and code generation
698
+ - [x] perf: allow running over a subset of tools only
699
+ - [x] static: remove unexpected `$ANY` messages (irep dead code elimination)
700
+ - [x] pr: add new artifact (2025101808)
@@ -0,0 +1,69 @@
1
+ # JSON Model Compiler Benchmark Artifacts
2
+
3
+ These artifacts compare
4
+ [JSON Model Compiler](https://github.com/clairey-zx81/json-model) generated code in
5
+ C, JS, Java (GSON, Jackson and JSONP using Johnzon) and Python with
6
+ [Sourcemeta Blaze CLI](https://github.com/sourcemeta/jsonschema) using test cases from
7
+ [JSON Schema Benchmark](https://github.com/sourcemeta-research/jsonschema-benchmark).
8
+
9
+ ## Recent Artifacts
10
+
11
+ - [2025102200](benchmarks/2025102200.md) no predefs, jmc 2.0b31 vs jsc 11.11.1, 5 runs, 1000 iterations.
12
+ - [2025101900](benchmarks/2025101900.md) no predefs, jmc 2.0b30 vs jsc 11.11.1, 7 runs, 2000 iterations.
13
+ - [2025101808](benchmarks/2025101808.md) no predefs, jmc 2.0b30 vs jsc 11.11.1, 11 runs, 1000 iterations.
14
+ - [2025101701](benchmarks/2025101701.md) no predefs, jmc 2.0b29 vs jsc 11.11.1, 5 runs, 10000 iterations.
15
+ - [2025101700](benchmarks/2025101700.md) no predefs, jmc 2.0b29 vs jsc 11.11.1, 3 runs, 1000 iterations.
16
+
17
+ ## Benchmarking Script
18
+
19
+ The [benchmarking script](https://github.com/clairey-zx81/json-model/blob/main/tests/perf/benchmark.sh)
20
+ is provided as docker image [zx80/jmc-bench](https://hub.docker.com/repository/docker/zx80/jmc-bench).
21
+ It downloads the benchmark schemas and test values, and runs through docker-in-docker
22
+ [zx80/jmc](https://hub.docker.com/repository/docker/zx80/jmc) for JMC runs and
23
+ [sourcemeta/jsonschema](https://github.com/sourcemeta/jsonschema/pkgs/container/jsonschema)
24
+ for comparison using the Blaze CLI.
25
+
26
+ It is typically started on a large host with the `start_bench.sh` script which
27
+ will span the necessary dockers:
28
+
29
+ ```sh
30
+ JMC=latest JMC_OPTS=--no-predef \
31
+ nohup ./start_bench.sh latest -p 20 -l 1000 -r 5 --cap-py &
32
+ # in the generated directory, look for the summary markdown and radar json files.
33
+ ```
34
+
35
+ The main script options are:
36
+
37
+ - `-p PARA` parallelism (a little less that the number of available cores, default is _8_)
38
+ - `-l LOOP` loop iterations for performance average (at least _1000_, the default)
39
+ - `-r RUNS` number of runs (odd number, default is _3_)
40
+ - `--cap-py` reduce python iterations by a factor of 10 (default is _no_)
41
+
42
+ ## Benchmarking Conditions
43
+
44
+ JSON schemas for the benchmark are translated to models based on
45
+ [JSON Schema Utils](https://github.com/zx80/json-schema-utils).
46
+
47
+ Runs are performed in _fast_ mode: the rejection reasons are not collected, and
48
+ the run stops as soon as possible.
49
+
50
+ - Compilation times are the _minimum_ encountered of over the runs.
51
+ whereas performance times are the _median_ over the runs.
52
+ - For JMC, the compilation time includes the schema to model conversion,
53
+ which adds a uniform time to all target languages.
54
+ - The C backend also includes the runtime compilation from sources.
55
+ - To smooth out the wide range of collected performances (from 10 ns to
56
+ over 300 µs for validating one value), a relative comparison ratio is shown.
57
+
58
+ Note that performance figures **must** be taken with a pinch of salt, please consider
59
+ the following caveats, and others:
60
+
61
+ - test cases may or may not be representative of specific use cases,
62
+ especially wrt schema/model and value sizes.
63
+ - compilers, libraries and other updates can have dramatic effects.
64
+ - blaze does _not_ implement checking string values (eg dates, url…),
65
+ so these checks may be disactivated (see `JMC_OPTS`) for fairness.
66
+ - the overall load on the host can impact measures.
67
+ - due to intrinsic limitations of the underlying libraries and the quality of models,
68
+ some results may differ, mostly for good reasons: regex incompatibilities, stricter
69
+ definitions…
@@ -88,6 +88,10 @@ jmc.1: json_model/data/jmc.pod dev
88
88
  year=$$(date +%Y)
89
89
  pod2man $< | sed "s/^\.TH JMC 1.*/.TH JMC 1 $$year \"v$$version\" \"User Documentation\"/" > $@
90
90
 
91
+ .PHONY: www
92
+ www: build.site
93
+ cd site && $(PYTHON) -m http.server 3000
94
+
91
95
  #
92
96
  # PUBLICATION
93
97
  #
@@ -100,8 +104,8 @@ build.site: site/MODELS.md site/JMC.md site/ABOUT.md
100
104
  .PHONY: publish.site
101
105
  publish.site: build.site
102
106
  rsync -avL --progress ./site/. $(SITE):$(SITEPATH)/.
103
- ssh $(SITE) chmod a+rx $(SITEPATH) $(SITEPATH)/models
104
- ssh $(SITE) chmod a+r $(SITEPATH)/* $(SITEPATH)/models/*
107
+ ssh $(SITE) chmod a+rx $(SITEPATH) $(SITEPATH)/models $(SITEPATH)/benchmarks
108
+ ssh $(SITE) chmod a+r $(SITEPATH)/* $(SITEPATH)/models/* $(SITEPATH)/benchmarks/*
105
109
 
106
110
  .PHONY: publish.py
107
111
  publish.py: dev
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json_model_compiler
3
- Version: 2.0b26
3
+ Version: 2.0b31
4
4
  Summary: JSON Model Tools
5
5
  Author: Fabien Coelho, Claire Yannou-Medrala
6
6
  License-Expression: CC0-1.0
@@ -155,20 +155,11 @@ print("reasons:", reasons)
155
155
 
156
156
  ## JSON Model Validation Performance
157
157
 
158
- Preliminary performance tests below compare validation times for a _large_ 500 KB JSON OpenAPI
159
- description using JSON Model compiled to C, Java, JS, Python, Perl and
160
- JSON Schema Blaze 11.5.0 implementation, with an average collected on 1000 runs,
161
- in _fast_ (no reporting) mode, including format validations, on a laptop:
162
-
163
- - JSON Model C: _197_ µs/check (about ⅕ ms)
164
- - JSON Model Java (with GSON): _304_ µs/check (under ⅓ ms)
165
- - JSON Model JS: _747_ µs/check (under ¾ ms)
166
- - JSON Schema C++ Blaze: _1677_ µs/check (under 2 ms, 30 seconds compilation time)
167
- - JSON Model Python: _3,944_ µs/check (under 4 ms)
168
- - JSON Model Perl: _32,024_ µs/check (about 32 ms)
169
-
170
- On this benchmark, JSON Model Compiler outperforms the fastest JSON Schema library 8:1,
171
- and both Java and JavaScript model validation are faster than the C++ schema validation.
158
+ See the [benchmark page](BENCH.md) for artifacts which compare various
159
+ [JSON Model Compiler](https://github.com/clairey-zx81/json-model) runs (C, JS, Java, Python) with
160
+ [Sourcemeta Blaze CLI](https://github.com/sourcemeta/jsonschema) using test cases from
161
+ [JSON Schema Benchmark](https://github.com/sourcemeta-research/jsonschema-benchmark).
162
+ Overall, JMC C implementation is about 50% faster than Blaze C++ on these tests.
172
163
 
173
164
  ## More Information
174
165
 
@@ -123,20 +123,11 @@ print("reasons:", reasons)
123
123
 
124
124
  ## JSON Model Validation Performance
125
125
 
126
- Preliminary performance tests below compare validation times for a _large_ 500 KB JSON OpenAPI
127
- description using JSON Model compiled to C, Java, JS, Python, Perl and
128
- JSON Schema Blaze 11.5.0 implementation, with an average collected on 1000 runs,
129
- in _fast_ (no reporting) mode, including format validations, on a laptop:
130
-
131
- - JSON Model C: _197_ µs/check (about ⅕ ms)
132
- - JSON Model Java (with GSON): _304_ µs/check (under ⅓ ms)
133
- - JSON Model JS: _747_ µs/check (under ¾ ms)
134
- - JSON Schema C++ Blaze: _1677_ µs/check (under 2 ms, 30 seconds compilation time)
135
- - JSON Model Python: _3,944_ µs/check (under 4 ms)
136
- - JSON Model Perl: _32,024_ µs/check (about 32 ms)
137
-
138
- On this benchmark, JSON Model Compiler outperforms the fastest JSON Schema library 8:1,
139
- and both Java and JavaScript model validation are faster than the C++ schema validation.
126
+ See the [benchmark page](BENCH.md) for artifacts which compare various
127
+ [JSON Model Compiler](https://github.com/clairey-zx81/json-model) runs (C, JS, Java, Python) with
128
+ [Sourcemeta Blaze CLI](https://github.com/sourcemeta/jsonschema) using test cases from
129
+ [JSON Schema Benchmark](https://github.com/sourcemeta-research/jsonschema-benchmark).
130
+ Overall, JMC C implementation is about 50% faster than Blaze C++ on these tests.
140
131
 
141
132
  ## More Information
142
133
 
@@ -80,6 +80,7 @@ cloc --md \
80
80
  json_model/data/*.java \
81
81
  | tail -1 | sed "s/SUM:/Java/"
82
82
 
83
+ # all of the above
83
84
  cloc --md \
84
85
  json_model/python.py \
85
86
  json_model/data/*.py \
@@ -118,8 +119,7 @@ Test models cover the various features of JSON Model.
118
119
  Each model is tested for each target language (Python, C, JavaScript, PL/pgSQL, Perl, Java)
119
120
  on a set of test vectors.
120
121
 
122
+ - number of models: $(echo tests/*/*.model.json | wc -w)
123
+ - model JSON locs: $(cat tests/*/*.model.json | wc -l)
124
+ - number of test values: $(cat tests/*/*.values.json | egrep '(true|false)' | wc -l)
121
125
  EOF
122
-
123
- echo "- number of models: $(echo tests/*/*.model.json | wc -w)"
124
- echo "- model JSON locs: $(cat tests/*/*.model.json | wc -l)"
125
- echo "- number of test values: $(cat tests/*/*.values.json | egrep '(true|false)' | wc -l)"
@@ -8,7 +8,7 @@
8
8
  # - WORKDIR: working directory to use
9
9
 
10
10
  docker_image="zx80/jmc:${JMC:-latest}"
11
- docker_root=(docker run --name awesome_jmc_$$ -v "${WORKDIR:-.}:/app/workspace" --rm)
11
+ docker_root=(docker run --name acme_jmc_$$ -v "${WORKDIR:-.}:/app/workspace" --rm)
12
12
 
13
13
  # export environment variables to docker
14
14
  for var in $JMC_ENV ; do
@@ -435,6 +435,7 @@ def disjunct_analyse(jm: JsonModel, model: ModelType, mpath: ModelPath, lists: b
435
435
  log.debug("not enough object with mandatory constant props for disjunction")
436
436
  return None
437
437
  # build tag candidates, for each prop which models indexes are ok, and all values
438
+ # property name -> set of models that contain the property with a constant
438
439
  tag_to_model: dict[str, set[int]] = {}
439
440
  # cumulated constants
440
441
  tag_to_csts: dict[str, ConstSet] = {}
@@ -1,10 +1,68 @@
1
+ import re
1
2
  import json
2
3
  from .language import Language, Block, Var, PropMap, ConstList
3
4
  from .language import JsonExpr, BoolExpr, IntExpr, StrExpr, PathExpr, Expr
4
- from .mtypes import Jsonable, JsonScalar, Number
5
+ from .mtypes import Jsonable, JsonScalar, Number, TestHint, Conditionals
6
+ from .utils import log
5
7
 
6
8
  _ESC_TABLE = { '"': r'\"', "\\": "\\\\" }
7
9
 
10
+ #
11
+ # Attempt at optimizing string equality tests with chuncked comparisons,
12
+ # avoiding a function call and a loop. It is unclear whether it is a good idea.
13
+ # See runtime/c/json-model.h for the generated macro definitions.
14
+ #
15
+ # TODO add max chunks?
16
+ # TODO generate likely/unlikely hints? likely on must, unlikely on may??
17
+ #
18
+ def _str_cmp_chunk(s: str, chunk: bytes, size: int,
19
+ little: bool = True, eq: bool = True) -> BoolExpr:
20
+ """Generate a chunck of byte string comparison."""
21
+ cmp_fun = "jm_str_eq" if eq else "jm_str_ne"
22
+ assert 1 <= size <= 8, "valid number of bytes"
23
+ if size == 1:
24
+ return f"{cmp_fun}_1({s}, {hex(chunk[0])})" if chunk else f"{cmp_fun}_0({s})"
25
+ else:
26
+ x: str = ""
27
+ for b in chunk:
28
+ if little:
29
+ x = hex(b)[2:] + x
30
+ else:
31
+ x += hex(b)[2:]
32
+ # adjust to 4/8 byte boundary
33
+ zeros = "00" * ((8 if size > 4 else 4) - len(x) // 2)
34
+ x = "0x" + ((zeros + x) if little else (x + zeros)) + ("LL" if size > 4 else "")
35
+ return f"{cmp_fun}_{size}({s}, {x})"
36
+
37
+ def _str_cmp(s: str, cst: str, little: bool = True, eq: bool = True, start: bool = False) -> BoolExpr:
38
+ """Generate a fast byte string comparison for known constants."""
39
+ bcst = json.loads(cst).encode("UTF8")
40
+ remain = len(bcst) + (0 if start else 1) # add implicit null termination
41
+ # filter out multiple array calls
42
+ if remain > 8 and ("json_array_get(" in s or "json_string_value(" in s):
43
+ assert not start
44
+ cmp_fun = "jm_str_eq" if eq else "jm_str_ne"
45
+ return f"{cmp_fun}({s}, {cst})"
46
+ # generate chuncked comparison expression
47
+ index = 0
48
+ expr = ""
49
+ while remain > 0:
50
+ if remain >= 8:
51
+ size = 8
52
+ elif remain > 4:
53
+ size = remain % 8
54
+ elif remain == 4:
55
+ size = 4
56
+ else:
57
+ size = remain % 4
58
+ ptr = s if index == 0 else f"{s} + {index}"
59
+ if expr:
60
+ expr += " && " if eq else " || "
61
+ expr += _str_cmp_chunk(ptr, bcst[index:index+size], size, little, eq)
62
+ index += size
63
+ remain -= size
64
+ return expr
65
+
8
66
  class CLangJansson(Language):
9
67
  """Generate JSON value checker in C with Jansson and PCRE2.
10
68
 
@@ -15,8 +73,9 @@ class CLangJansson(Language):
15
73
  def __init__(self, *,
16
74
  debug: bool = False,
17
75
  with_path: bool = True, with_report: bool = True, with_comment: bool = True,
18
- with_predef: bool = True,
19
- inline: bool = True, relib: str = "pcre2", int_t: str = "int64_t"):
76
+ with_predef: bool = True, strcmp_opt: bool = True, byte_order: str = "le",
77
+ inline: bool = True, with_hints: bool = True,
78
+ relib: str = "pcre2", int_t: str = "int64_t"):
20
79
 
21
80
  super().__init__(
22
81
  "C",
@@ -24,16 +83,19 @@ class CLangJansson(Language):
24
83
  not_op="!", and_op="&&", or_op="||", lcom="//",
25
84
  true="true", false="false", null="NULL", check_t="jm_check_fun_t", json_t="json_t *",
26
85
  path_t="jm_path_t", float_t="double", str_t="const char *",
27
- match_t="bool" if relib == "pcre2" else "int",
86
+ match_t="bool" if relib == "pcre2" else "int", with_hints=with_hints,
28
87
  eoi=";", relib=relib, debug=debug, with_predef=with_predef,
29
88
  set_caps=(type(None), bool, int, float, str)) # type: ignore
30
89
 
90
+ assert byte_order in ("le", "be"), f"expecting little (le) or big (be) endian: {byte_order}"
31
91
  assert relib in ("pcre2", "re2"), f"regex engine {relib} is not supported, try: pcre2/re2"
32
92
 
33
93
  # we keep 2 ints: "int64_t" and "int"
34
94
  self._int: str = int_t
35
95
  self._json_esc_table = str.maketrans(_ESC_TABLE)
36
96
  self._inline = "INLINE " if inline else ""
97
+ self._strcmp_opt = strcmp_opt
98
+ self._byte_order = byte_order
37
99
 
38
100
  #
39
101
  # file
@@ -141,7 +203,7 @@ class CLangJansson(Language):
141
203
  return f"jm_is_valid_json({val}, {path}, rep)"
142
204
  else:
143
205
  return super().predef(var, name, path, is_str)
144
-
206
+
145
207
  def value(self, var: Var, tvar: type) -> Expr:
146
208
  """Known type value extraction."""
147
209
  if tvar is type(None):
@@ -166,6 +228,9 @@ class CLangJansson(Language):
166
228
  return f"json_object_get({obj}, {prop})" if is_var else \
167
229
  f"json_object_get({obj}, {self.esc(prop)})" # type: ignore
168
230
 
231
+ def obj_has_prop_val(self, dst: Var, obj: Var, prop: str|StrExpr, is_var: bool = False) -> BoolExpr:
232
+ return f"({dst} = {self.obj_prop_val(obj, prop, is_var)}) != NULL"
233
+
169
234
  #
170
235
  # inlined length computation
171
236
  #
@@ -188,6 +253,11 @@ class CLangJansson(Language):
188
253
  return f"({fun} = {mapname}({prop}))"
189
254
 
190
255
  def str_start(self, val: str, start: str) -> BoolExpr:
256
+ if self._strcmp_opt:
257
+ try:
258
+ return _str_cmp(val, json.dumps(start), self._byte_order == "le", True, True)
259
+ except: # if rejected, proceed with generic solution
260
+ pass
191
261
  return f"strncmp({val}, {self.esc(start)}, strlen({self.esc(start)})) == 0"
192
262
 
193
263
  def str_end(self, val: str, end: str) -> BoolExpr:
@@ -221,8 +291,15 @@ class CLangJansson(Language):
221
291
  def str_cmp(self, e1: StrExpr, op: str, e2: StrExpr) -> BoolExpr:
222
292
  assert op in ("=", "!=", "<", "<=", ">=", ">")
223
293
  if op == "=":
224
- return f"strcmp({e1}, {e2}) == 0"
294
+ if self._strcmp_opt and len(e2) >= 2 and e2[0] == '"' and e2[-1] == '"':
295
+ return _str_cmp(e1, e2, self._byte_order == "le", True)
296
+ else:
297
+ return f"strcmp({e1}, {e2}) == 0"
225
298
  elif op == "!=":
299
+ if self._strcmp_opt and len(e2) >= 2 and e2[0] == '"' and e2[-1] == '"':
300
+ return "(" + _str_cmp(e1, e2, self._byte_order == "le", False) + ")"
301
+ else:
302
+ return f"strcmp({e1}, {e2}) != 0"
226
303
  return f"strcmp({e1}, {e2}) != 0"
227
304
  elif op == ">=":
228
305
  return f"strcmp({e1}, {e2}) >= 0"
@@ -303,18 +380,27 @@ class CLangJansson(Language):
303
380
  f"for ({self._int} {idx} = {start}; {idx} < {end}; {idx}++)"
304
381
  ] + self.indent(body)
305
382
 
306
- def if_stmt(self, cond: BoolExpr, true: Block, false: Block = []) -> Block:
383
+ def _hint(self, e: str, likely: TestHint) -> str:
384
+ if self._with_hints and likely is not None:
385
+ return f"likely({e})" if likely else f"unlikely({e})"
386
+ else:
387
+ return e
388
+
389
+ def if_stmt(self, cond: BoolExpr, true: Block, false: Block = [], likely: TestHint = None) -> Block:
390
+
391
+ # handle expectation hints
392
+
307
393
  if true and false:
308
- return [ f"if ({cond})" ] + self.indent(true) + ["else"] + self.indent(false)
394
+ return [ f"if ({self._hint(cond, likely)})" ] + self.indent(true) + ["else"] + self.indent(false)
309
395
  elif true:
310
- return [ f"if ({cond})" ] + self.indent(true)
396
+ return [ f"if ({self._hint(cond, likely)})" ] + self.indent(true)
311
397
  else:
312
- return [ f"if (!({cond}))" ] + self.indent(false)
398
+ return [ f"if (!({self._hint(cond, likely)}))" ] + self.indent(false)
313
399
 
314
- def mif_stmt(self, cond_true: list[tuple[BoolExpr, Block]], false: Block = []) -> Block:
400
+ def mif_stmt(self, cond_true: Conditionals, false: Block = []) -> Block:
315
401
  code, op = [], "if"
316
- for cond, true in cond_true:
317
- code += [ f"{op} ({cond})" ]
402
+ for cond, likely, true in cond_true:
403
+ code += [ f"{op} ({self._hint(cond, likely)})" ]
318
404
  code += self.indent(true)
319
405
  op = "else if"
320
406
  if false:
@@ -508,7 +594,7 @@ class CLangJansson(Language):
508
594
  if len(types) == 1:
509
595
  tcs = types.pop()
510
596
  val = self._var_cst(var, tcs)
511
- return f"{self.is_a(var, tcs)} && jm_search_cst(&{val}, {name}, {len(constants)});"
597
+ return f"{self.is_a(var, tcs)} && jm_search_cst(&{val}, {name}, {len(constants)})"
512
598
  else: # multi type managed in a generated function
513
599
  return f"{name}_test({var})"
514
600
 
@@ -572,3 +658,45 @@ class CLangJansson(Language):
572
658
 
573
659
  def gen_free(self, free: Block) -> Block:
574
660
  return self.file_subs("clang_free.c", free)
661
+
662
+ def filter_code(self, code: Block) -> Block:
663
+
664
+ for i in range(len(code)):
665
+ line = code[i]
666
+ if line is None:
667
+ continue
668
+ # remove redundant checks generated in some cases
669
+ if "jm_json_is_scalar" in line:
670
+ line = re.sub(r" jm_json_is_scalar\((\w+)\) && json_is_string\(\1\)",
671
+ r" json_is_string(\1)", line)
672
+ code[i] = line
673
+ if "json_is_boolean" in line:
674
+ line = re.sub(r" json_is_boolean\((\w+)\) && json_is_boolean\(\1\)",
675
+ r" json_is_boolean(\1)", line)
676
+ code[i] = line
677
+ # remove useless braces around one instruction in some safe cases
678
+ if re.match(r"^ +\{$", line):
679
+ ninst, n, opened = 0, 0, 1
680
+ while True:
681
+ n += 1
682
+ nline = code[i+n]
683
+ if nline is None or re.match(r"^ *$", nline) or re.match(r"^ *//", nline):
684
+ continue
685
+ if re.match(r"^ +\{$", nline):
686
+ opened += 1
687
+ elif re.match(r"^ +\}$", nline):
688
+ opened -= 1
689
+ if opened == 0:
690
+ break
691
+ elif " if (" in nline:
692
+ # keep braces around nested ifs
693
+ ninst = -1
694
+ break
695
+ else:
696
+ # note this is intentionnaly pessimistic
697
+ ninst += 1
698
+ if ninst == 1:
699
+ # log.warning(code[i:i+n+1])
700
+ code[i], code[i+n] = None, None
701
+
702
+ return list(filter(lambda s: s is not None, code))
@@ -19,7 +19,7 @@ B<jmc> - JSON Model Compiler
19
19
  [--include [INCLUDE ...]] [--library [LIBRARY ...]] [--define [DEFINE ...]]
20
20
  [--javac JAVAC] [--jflags JFLAGS] [-[-no]-schema-version]
21
21
  [--name NAME] [-[-no]-report] [--none] [--true] [--false] [--test-vector]
22
- [--map-threshold THRESHOLD] [--map-share]
22
+ [--map-threshold THRESHOLD] [--map-share] [-[-no]-strcmp-optimize] [--byte-order (le|be)]
23
23
  [--unroll-may-ratioi RATIO] [--unroll-may-threshold THRESHOLD]
24
24
  [-[-no]-predef] [--short-version]
25
25
  [--op {P,U,J,N,E,C} | --preproc | --dump | --jdump | --nope | --export | --compile]
@@ -212,6 +212,14 @@ generate a statically linked executable.
212
212
 
213
213
  generate inline hints.
214
214
 
215
+ =item B<--strcmp-optimize> B<--no-strcmp-optimize>
216
+
217
+ whether to optimize string comparisons in some cases.
218
+
219
+ =item B<--byte-order ORDER>
220
+
221
+ set byte order for string comparison, either C<le> (little endian) or C<be> (big endian).
222
+
215
223
  =back
216
224
 
217
225
  =head2 Java Compilation
@@ -4,7 +4,7 @@ def CHECK_FUNCTION_NAME_fun(name: str) -> CheckFun:
4
4
 
5
5
  # entry point for generated checkers
6
6
  def CHECK_FUNCTION_NAME(val: Jsonable, name: str = "", rep: Report = None) -> bool:
7
- """Check val validity agains JSON Model name."""
7
+ """Check val validity against JSON Model name."""
8
8
  if name not in CHECK_FUNCTION_NAME_map:
9
9
  raise Exception(f"unexpected model name: {name}")
10
10
  checker = CHECK_FUNCTION_NAME_map[name]