react-nitro-hermes 0.0.1-alpha.8 → 0.0.1-alpha.9

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 (181) hide show
  1. package/hermes/CMakeLists.txt +874 -0
  2. package/hermes/android/HostObjectJniTest.cpp +178 -0
  3. package/hermes/android/build-logic/build.gradle.kts +31 -0
  4. package/hermes/android/build-logic/settings.gradle.kts +17 -0
  5. package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/helpers/internal/SerializeHermesCompilerPackageJson.kt +33 -0
  6. package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/plugins/internal/TestUtilsPlugin.kt +80 -0
  7. package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/tasks/internal/CustomExecTask.kt +46 -0
  8. package/hermes/android/build-logic/src/main/kotlin/publish.gradle.kts +82 -0
  9. package/hermes/android/build.gradle.kts +332 -0
  10. package/hermes/android/cppruntime/build.gradle +72 -0
  11. package/hermes/android/cppruntime/src/main/AndroidManifest.xml +2 -0
  12. package/hermes/android/cppruntime/src/main/cpp/CMakeLists.txt +8 -0
  13. package/hermes/android/cppruntime/src/main/cpp/stub.cpp +12 -0
  14. package/hermes/android/cross-compile/swift-libicu.patch +13 -0
  15. package/hermes/android/cross-compile/toolchain-android-arm-api13-gnustl.cmake +13 -0
  16. package/hermes/android/cross-compile/toolchain-android-arm-api15-gnustl.cmake +14 -0
  17. package/hermes/android/gradle/libs.versions.toml +30 -0
  18. package/hermes/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  19. package/hermes/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  20. package/hermes/android/gradle.properties +3 -0
  21. package/hermes/android/gradlew +248 -0
  22. package/hermes/android/gradlew.bat +93 -0
  23. package/hermes/android/intltest/build.gradle +147 -0
  24. package/hermes/android/intltest/java/com/facebook/hermes/test/CMakeLists.txt +45 -0
  25. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.cpp +68 -0
  26. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.h +44 -0
  27. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.java +45 -0
  28. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogueTestData.java +32 -0
  29. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesInstrumentationTest.java +150 -0
  30. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlAndroidTest.java +147 -0
  31. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlTest262.java +470 -0
  32. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesRuntimeFactory.cpp +73 -0
  33. package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.cpp +90 -0
  34. package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.h +62 -0
  35. package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.java +155 -0
  36. package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.cpp +48 -0
  37. package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.h +36 -0
  38. package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoad.cpp +13 -0
  39. package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoadEpilogue.cpp +13 -0
  40. package/hermes/android/intltest/src/main/AndroidManifest.xml +2 -0
  41. package/hermes/android/ios-artifacts/build.gradle.kts +65 -0
  42. package/hermes/android/settings.gradle.kts +27 -0
  43. package/hermes/cmake/modules/Hermes.cmake +481 -0
  44. package/hermes/cmake/modules/Lit.cmake +96 -0
  45. package/hermes/doc/Branches.md +38 -0
  46. package/hermes/doc/BuildingAndRunning.md +121 -0
  47. package/hermes/doc/CodingStandards.md +112 -0
  48. package/hermes/doc/CrossCompilation.md +79 -0
  49. package/hermes/doc/Design.md +217 -0
  50. package/hermes/doc/Emscripten.md +156 -0
  51. package/hermes/doc/Features.md +143 -0
  52. package/hermes/doc/GCSafeCoding.md +563 -0
  53. package/hermes/doc/GenGC.md +300 -0
  54. package/hermes/doc/Hades.md +344 -0
  55. package/hermes/doc/HighLevelOptimizations.md +37 -0
  56. package/hermes/doc/IR.md +1306 -0
  57. package/hermes/doc/IntlAPIs.md +196 -0
  58. package/hermes/doc/JIT.md +999 -0
  59. package/hermes/doc/LazyEvalCompilation.md +84 -0
  60. package/hermes/doc/MemoryProfilers.md +316 -0
  61. package/hermes/doc/Modules.md +144 -0
  62. package/hermes/doc/Optimizer.md +83 -0
  63. package/hermes/doc/PerfProfiling.md +29 -0
  64. package/hermes/doc/ProhibitInvoke.md +329 -0
  65. package/hermes/doc/ReactNative.md +40 -0
  66. package/hermes/doc/ReactNativeIntegration.md +94 -0
  67. package/hermes/doc/RegExp.md +24 -0
  68. package/hermes/doc/SpecIncompat.md +85 -0
  69. package/hermes/doc/Strings.md +140 -0
  70. package/hermes/doc/TypedLanguage.md +432 -0
  71. package/hermes/doc/VM.md +174 -0
  72. package/hermes/doc/blog/2024-11-09-octane-benchmark-jit-progress.md +17 -0
  73. package/hermes/doc/blog/2024-12-19-static-hermes-update-dec-2024.md +47 -0
  74. package/hermes/doc/blog/2024-12-23-compiling-javascript-to-wasm.md +267 -0
  75. package/hermes/doc/blog/2025-06-09-jsi-runtime-data-apis.md +23 -0
  76. package/hermes/doc/blog/2025-07-15-static-h-performance-june-2025.md +18 -0
  77. package/hermes/doc/blog/2025-11-02-hermes-compilation-runtime-modes.md +23 -0
  78. package/hermes/doc/blog/2025-11-06-hermes-memory-modes.md +35 -0
  79. package/hermes/doc/blog/2025-11-24-json-parsing-performance.md +17 -0
  80. package/hermes/doc/blog/2025-12-02-iserialization.md +11 -0
  81. package/hermes/doc/blog/2025-12-12-new-way-to-contribute.md +68 -0
  82. package/hermes/doc/blog/2026-06-05-new-hermes-stable-release.md +51 -0
  83. package/hermes/doc/blog/README.md +25 -0
  84. package/hermes/doc/blog/images/2024-11-09-octane-pi3.jpeg +0 -0
  85. package/hermes/doc/blog/images/2024-11-09-octane-pi5.jpeg +0 -0
  86. package/hermes/doc/blog/images/2025-07-15-perf-hv32-interpreter.jpeg +0 -0
  87. package/hermes/doc/blog/images/2025-07-15-perf-hv32-jit.jpeg +0 -0
  88. package/hermes/doc/icu_license.txt +420 -0
  89. package/hermes/doc/img/heap_snapshot_retainers.png +0 -0
  90. package/hermes/doc/img/logo.svg +1 -0
  91. package/hermes/doc/img/object_captured_by_environment.png +0 -0
  92. package/hermes/doc/img/root_categories.png +0 -0
  93. package/hermes/doc/plans/ir-type/flow-type-system.md +324 -0
  94. package/hermes/doc/plans/ir-type/ir-type-system-v2-design.md +652 -0
  95. package/hermes/doc/plans/ir-type/ir-type-system.md +220 -0
  96. package/hermes/doc/plans/ir-type/ir-type-v2-implementation.md +1187 -0
  97. package/hermes/doc/plans/ir-type/memory.md +48 -0
  98. package/hermes/doc/plans/ir-type/phase1-steps.md +512 -0
  99. package/hermes/doc/plans/ir-type/progress.md +239 -0
  100. package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-design.md +203 -0
  101. package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-results.md +71 -0
  102. package/hermes/doc/superpowers/plans/2026-07-28-worker-arraybuffer-input.md +597 -0
  103. package/hermes/doc/superpowers/plans/2026-08-18-jitemitter-split.md +1149 -0
  104. package/hermes/doc/superpowers/plans/2026-08-20-jit-type-asserts.md +969 -0
  105. package/hermes/doc/superpowers/plans/2026-08-23-jit-shared-compiler-driver.md +478 -0
  106. package/hermes/doc/superpowers/plans/2026-08-23-x86-64-jit-skeleton.md +797 -0
  107. package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-arith.md +444 -0
  108. package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-calls.md +261 -0
  109. package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-props.md +240 -0
  110. package/hermes/doc/superpowers/plans/2026-10-26-regexp-bytecode-sharing.md +2197 -0
  111. package/hermes/doc/superpowers/plans/2026-10-28-regexp-start-filter-and-exec-fast-paths.md +3981 -0
  112. package/hermes/doc/superpowers/specs/2026-07-28-worker-arraybuffer-input-design.md +206 -0
  113. package/hermes/doc/superpowers/specs/2026-08-18-jitemitter-split-design.md +530 -0
  114. package/hermes/doc/superpowers/specs/2026-08-20-jit-type-asserts-design.md +360 -0
  115. package/hermes/doc/superpowers/specs/2026-08-23-x86-64-jit-design.md +246 -0
  116. package/hermes/doc/superpowers/specs/2026-08-26-icu-free-normalize-design.md +355 -0
  117. package/hermes/doc/superpowers/specs/2026-08-27-icu-free-convert-to-case-design.md +305 -0
  118. package/hermes/doc/superpowers/specs/2026-08-27-icu-free-locale-compare-design.md +429 -0
  119. package/hermes/doc/superpowers/specs/2026-08-29-icu-free-date-format-design.md +297 -0
  120. package/hermes/doc/superpowers/specs/2026-10-26-regexp-bytecode-sharing-design.md +605 -0
  121. package/hermes/doc/superpowers/specs/2026-10-28-regexp-start-filter-and-exec-fast-paths-design.md +551 -0
  122. package/hermes/doc/typescript-stripping.md +90 -0
  123. package/hermes/external/CMakeLists.txt +20 -0
  124. package/hermes/utils/IntlGen/IntlGen.java +531 -0
  125. package/hermes/utils/bench_with_stats.py +827 -0
  126. package/hermes/utils/build-apple-framework.sh +323 -0
  127. package/hermes/utils/chrome_snapshot_parser.py +210 -0
  128. package/hermes/utils/cmake-dev-build.sh +18 -0
  129. package/hermes/utils/commons.sh +55 -0
  130. package/hermes/utils/dump-cpp-funcs.sh +3 -0
  131. package/hermes/utils/es5objects.js +198 -0
  132. package/hermes/utils/format.sh +145 -0
  133. package/hermes/utils/gen-promise-internal-bc.sh +66 -0
  134. package/hermes/utils/genUnicodeTable.py +2503 -0
  135. package/hermes/utils/hermes-lit/CMakeLists.txt +22 -0
  136. package/hermes/utils/hermes-lit/hermes-lit.in +15 -0
  137. package/hermes/utils/jit/README.md +134 -0
  138. package/hermes/utils/jit/jit-diff.sh +160 -0
  139. package/hermes/utils/jit/jit-dump.sh +193 -0
  140. package/hermes/utils/lit-expect-gen/generate.py +217 -0
  141. package/hermes/utils/promise/index.js +15 -0
  142. package/hermes/utils/promise/package.json +13 -0
  143. package/hermes/utils/promise/rollup.config.js +19 -0
  144. package/hermes/utils/promise/yarn.lock +247 -0
  145. package/hermes/utils/scripts/hermes/consts.js +26 -0
  146. package/hermes/utils/scripts/hermes/create-tarball.js +75 -0
  147. package/hermes/utils/scripts/hermes/get-hermes-version.js +57 -0
  148. package/hermes/utils/scripts/hermes/hermes-utils.js +122 -0
  149. package/hermes/utils/scripts/hermes/package.json +6 -0
  150. package/hermes/utils/scripts/hermes/prepare-artifacts.js +113 -0
  151. package/hermes/utils/scripts/hermes/publish-artifacts.js +109 -0
  152. package/hermes/utils/scripts/hermes/publish-npm.js +96 -0
  153. package/hermes/utils/scripts/hermes/scm-utils.js +41 -0
  154. package/hermes/utils/scripts/hermes/set-artifacts-version.js +64 -0
  155. package/hermes/utils/scripts/hermes/version-utils.js +98 -0
  156. package/hermes/utils/scripts/hermes/yarn.lock +240 -0
  157. package/hermes/utils/summarize_sizes.py +184 -0
  158. package/hermes/utils/symbolicate-nativecall-stats.py +112 -0
  159. package/hermes/utils/test_runner.py +13 -0
  160. package/hermes/utils/testsuite/README.facebook +3 -0
  161. package/hermes/utils/testsuite/README.md +69 -0
  162. package/hermes/utils/testsuite/cli.py +547 -0
  163. package/hermes/utils/testsuite/es_ast.py +337 -0
  164. package/hermes/utils/testsuite/external/LICENSE +28 -0
  165. package/hermes/utils/testsuite/external/README.facebook +8 -0
  166. package/hermes/utils/testsuite/external/__init__.py +0 -0
  167. package/hermes/utils/testsuite/external/_monkeyYaml.py +164 -0
  168. package/hermes/utils/testsuite/external/parse_test262.py +141 -0
  169. package/hermes/utils/testsuite/hermes.py +522 -0
  170. package/hermes/utils/testsuite/preprocess.py +365 -0
  171. package/hermes/utils/testsuite/progress.py +377 -0
  172. package/hermes/utils/testsuite/skiplist.json +4356 -0
  173. package/hermes/utils/testsuite/skiplist.py +270 -0
  174. package/hermes/utils/testsuite/test_run_defs.py +435 -0
  175. package/hermes/utils/testsuite/typing_defs.py +52 -0
  176. package/hermes/utils/testsuite/utils.py +214 -0
  177. package/hermes/utils/tidy.sh +22 -0
  178. package/hermes/utils/update-fbcode-hermes.sh +53 -0
  179. package/hermes/utils/updateErrorTest.py +193 -0
  180. package/hermes/utils/wasm-compile.sh +65 -0
  181. package/package.json +1 -1
@@ -0,0 +1,1149 @@
1
+ # JitEmitter.cpp Split Implementation Plan
2
+
3
+ > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
+
5
+ **Goal:** Split `lib/VM/JIT/arm64/JitEmitter.cpp` into eleven translation
6
+ units grouped by what they emit, moving the anonymous-namespace helpers
7
+ into a shared helper layer that every emitter can still reach.
8
+
9
+ **Architecture:** Every task is code motion. Definitions are cut from
10
+ `JitEmitter.cpp` and pasted into a new `.cpp` with a copyright header, the
11
+ `HERMESVM_JIT` guard, and the includes it needs; nothing is reworded,
12
+ renamed, or rewritten. The ~40 free `emit_*` helpers lose their anonymous
13
+ namespace and move to `JitEmitter-internal.h` (small hot ones, `inline`)
14
+ and `JitEmitter-internal.cpp` (bulky cold ones, external linkage). The
15
+ three `Emitter` member templates move to `JitEmitter.h` first, because a
16
+ template definition left in a `.cpp` stops being instantiable once its
17
+ callers live in other translation units.
18
+
19
+ **Tech Stack:** C++17 (no exceptions, no RTTI), asmjit, buck2 (primary),
20
+ CMake + Ninja (must stay green), LLVM lit + FileCheck, Sapling.
21
+
22
+ ## As executed
23
+
24
+ This plan was carried out in full. Five things diverged from it; the spec
25
+ carries the detail, this is the index.
26
+
27
+ 1. **The verification criterion changed before Task 2.** Byte-identical
28
+ emitted code turned out to be unachievable: `isCheapConst` picks
29
+ instruction forms from pointer values, so ASLR makes the dump differ
30
+ run to run on an unchanged binary. `capture.sh` below shows the
31
+ original narrow address normalization; what was actually used also
32
+ canonicalizes constant materialization to a `CONST` token and drops
33
+ the RO_DATA table, leaving ~91% of the dump compared byte for byte.
34
+ 2. **Task 4 grew and was retitled** to "Make the shared `Emitter`
35
+ definitions visible in `JitEmitter.h`". Beyond the three member
36
+ templates it also moves `isCheapConst` (a circular-include problem
37
+ found during the task) and the `Emitter::comment` logger check (a
38
+ code-size problem found by measurement afterwards).
39
+ 3. **Task 2 gained an always-inline attribute** on
40
+ `emit_load_from_base_offset`, release-only, after measurement showed
41
+ it was the one helper that measurably lost inlining.
42
+ 4. **Task 15 produced no commit.** Both size fixes it found were folded
43
+ into the commits that caused them, so no commit in the stack carries
44
+ a regression a later one cleans up.
45
+ 5. **Fix rounds amended the task's own commit** rather than appending,
46
+ by the user's decision, so the stack stays one commit per task.
47
+
48
+ ## This refactor inverts the usual TDD shape
49
+
50
+ There are no new tests to write, and writing any would be wrong. The
51
+ correctness criterion is a canonicalized `-Xdump-jitcode` comparison:
52
+ runtime addresses are normalized and constant materialization collapses
53
+ to a `CONST` token, because `isCheapConst` picks instruction forms from
54
+ pointer values that ASLR changes every run, leaving about 91% of the
55
+ dump compared byte for byte. So instead of "write a failing test, make
56
+ it pass", each task is:
57
+
58
+ 1. capture the emitted code before the move (done once, in Task 1),
59
+ 2. move the code,
60
+ 3. prove the emitted code did not change.
61
+
62
+ A task that changes emitted output has a bug in the move, not a test that
63
+ needs updating. Do not "fix" a diff by accepting it.
64
+
65
+ This applies to Tasks 2-14. Task 15 measures and changes no code.
66
+
67
+ ## Global Constraints
68
+
69
+ - **Comments are preserved verbatim.** Every comment, doc comment,
70
+ `NOTE:`, and `FIXME` moves with its code unchanged. Do not reword,
71
+ reflow, condense, or improve any prose. The only permitted edits: the
72
+ copyright header on a new file; a helper doc comment that the move from
73
+ an anonymous namespace into a header makes factually false; `\return` or
74
+ parameter docs naming a type or linkage the move changes. A reviewer
75
+ should be able to diff the concatenation of the new files against the
76
+ old one and see only motion.
77
+ - Copyright header (Meta MIT, from `CLAUDE.md`) at the top of every new
78
+ file, followed by a trailing newline at end of file.
79
+ - Every new `.cpp` opens with `#include "hermes/VM/JIT/Config.h"` then
80
+ `#if HERMESVM_JIT`, and closes with `#endif // HERMESVM_JIT`. BUCK globs
81
+ `lib/VM/**/*.cpp` unconditionally, so a file without the guard breaks
82
+ non-JIT builds.
83
+ - Every new `.cpp` and `.h` is added to `lib/VM/CMakeLists.txt` in the
84
+ `if (HERMESVM_ALLOW_JIT)` block. BUCK needs no edit; CMake does.
85
+ - C++ style: 80-column lines, 2-space indent.
86
+ - Run `arc f` after editing any `.cpp`/`.h`, before committing.
87
+ - Every `sl` invocation passes `--reason "<intent> - sl help <cmd>"`.
88
+ Never pass `--reason` to `jf`, `arc`, or `buck2`.
89
+ - Commit messages use the `[SH]` format with the body hard-wrapped at 72
90
+ columns. Title names the component, e.g.
91
+ `[SH] JIT: Move register allocation to JitEmitter-regalloc.cpp`.
92
+ - Do not amend or submit anything unless explicitly asked.
93
+ - File naming follows `JitEmitter-<part>.cpp`, lowercase suffix,
94
+ hyphenated for multiple words, matching `FlowChecker-expr.cpp` and
95
+ `ESTreeIRGen-stmt.cpp`.
96
+ - Sizes are not tracked. The bar is that no file lands over ~2,000 lines.
97
+ Do not add line or definition counts to this plan or the spec.
98
+
99
+ ## Two hazards that only appear when the file is split
100
+
101
+ Both are invisible today because there is exactly one emitter translation
102
+ unit, and both bite silently.
103
+
104
+ **Templates defined in the `.cpp`.** A function template is instantiated
105
+ only where its definition is visible. `JitEmitter.h` declares three member
106
+ templates and `JitEmitter.cpp` defines them; with one TU that is
107
+ indistinguishable from an ordinary method. Once callers live elsewhere,
108
+ those TUs see only the declaration and emit undefined references. Whether
109
+ the link actually breaks depends on whether the *defining* TU happens to
110
+ instantiate the same specialization, so some cases fail outright and
111
+ others link by accident and break on a later refactor. Task 4 removes the
112
+ hazard before any emitter moves.
113
+
114
+ **Non-function entities in the anonymous namespace.** The namespace holds
115
+ a `static_assert` and `constexpr uint32_t kMaxInlineBaseOffset`, which
116
+ `emit_load_from_base_offset` depends on. Deleting the namespace without
117
+ moving them leaves a helper referring to a constant that is gone. Task 2
118
+ moves them explicitly.
119
+
120
+ **A third, which dictates the task order.** The cold helpers call the hot
121
+ ones — `emit_stringprim_get_length_and_flags` calls
122
+ `emit_sh_ljs_get_pointer`, `emit_jsobject_init` calls
123
+ `emit_sh_cp_encode_non_null` and `emit_store_cp` — and nothing calls the
124
+ other way. So the hot helpers must reach the header (Task 2) before the
125
+ cold ones move to their own translation unit (Task 3); the reverse order
126
+ puts the cold helpers in a TU that cannot see what they call.
127
+
128
+ ## Resolved before planning
129
+
130
+ The spec listed one open question: whether any helper reaches into
131
+ `Emitter` internals, which would force it to stay a member or become a
132
+ friend. **It does not.** Every free helper in the anonymous namespace
133
+ takes `a64::Assembler &` and register operands and touches no `Emitter`
134
+ state. `OurErrorHandler` holds `asmjit::Error &` and a `std::function`;
135
+ `OurLogger` holds `a64::Assembler &` and a `PerfJitDump *`. The only
136
+ `Emitter` mention in that region is asmjit's own `BaseEmitter` in an
137
+ override signature. No helper needs friendship.
138
+
139
+ ---
140
+
141
+ ### Task 1: Baseline capture and verification harness
142
+
143
+ Produces no commit. It creates the reference the other fourteen tasks are
144
+ checked against, so it must run **before any source change**, on a clean
145
+ checkout of the commit the split starts from.
146
+
147
+ **Files:**
148
+ - Create: `/tmp/jitsplit/config.sh`, `capture.sh`, `verify.sh` (scratch)
149
+ - Create: `/tmp/jitsplit/baseline.txt` (the reference dump)
150
+
151
+ **Interfaces:**
152
+ - Produces: `/tmp/jitsplit/verify.sh`, invoked by every later task as
153
+ `bash /tmp/jitsplit/verify.sh`. Exits 0 only if the buck2 build, the
154
+ CMake build, the normalized JIT dump comparison, and the lit suite all
155
+ pass.
156
+ - Produces: `/tmp/jitsplit/config.sh`, defining `ROOT` and `CMAKE_DIR`,
157
+ sourced by `verify.sh`.
158
+
159
+ - [ ] **Step 1: Record the starting commit**
160
+
161
+ ```bash
162
+ cd ~/fbsource/xplat/static_h
163
+ mkdir -p /tmp/jitsplit
164
+ sl log -r . -T '{node}\n' --reason "record split baseline commit - sl help log" \
165
+ > /tmp/jitsplit/baseline-commit.txt
166
+ cat /tmp/jitsplit/baseline-commit.txt
167
+ ```
168
+
169
+ If `/tmp` is cleared before the stack is finished, re-run this whole task
170
+ against that commit to regenerate the baseline.
171
+
172
+ - [ ] **Step 2: Choose the CMake build directory and write the config**
173
+
174
+ Whether an in-tree CMake build directory works depends on the checkout.
175
+ On an EdenFS checkout (a path under `~/fbsource`) it does not; use an
176
+ out-of-tree directory. On an ordinary filesystem checkout, in-tree is
177
+ fine. **If it is not obvious which applies, ask rather than guessing** —
178
+ the wrong choice costs a full configure and a confusing failure.
179
+
180
+ Everything downstream reads the answer from one file, so nothing else in
181
+ this plan hardcodes a path. Write it:
182
+
183
+ ```bash
184
+ cat > /tmp/jitsplit/config.sh <<'EOF'
185
+ # Edit these two to match your checkout before running anything else.
186
+ ROOT="$HOME/fbsource/xplat/static_h"
187
+ CMAKE_DIR="$HOME/work/hws/fbsource-sh-debug"
188
+ EOF
189
+ ```
190
+
191
+ On the machine this plan was written on the checkout was EdenFS and
192
+ `~/work/hws/fbsource-sh-debug` already existed, configured out of tree
193
+ with `CMAKE_BUILD_TYPE=Debug`, Ninja and `HERMESVM_ALLOW_JIT=2`. Confirm
194
+ whatever you chose actually points at this checkout and compiles the JIT:
195
+
196
+ ```bash
197
+ source /tmp/jitsplit/config.sh
198
+ grep -E "^CMAKE_HOME_DIRECTORY|^HERMESVM_ALLOW_JIT|^CMAKE_BUILD_TYPE" \
199
+ "$CMAKE_DIR/CMakeCache.txt"
200
+ ```
201
+
202
+ Expected: `CMAKE_HOME_DIRECTORY` is this checkout, `HERMESVM_ALLOW_JIT=2`,
203
+ `CMAKE_BUILD_TYPE=Debug`. If the directory does not exist, create it:
204
+
205
+ ```bash
206
+ source /tmp/jitsplit/config.sh
207
+ cmake -B "$CMAKE_DIR" -S "$ROOT" -G Ninja \
208
+ -DCMAKE_BUILD_TYPE=Debug -DHERMESVM_ALLOW_JIT=2
209
+ ```
210
+
211
+ - [ ] **Step 3: Write the dump-capture script**
212
+
213
+ The corpus is every JIT lit test plus the typed tests that reach
214
+ `FastArrayLoad`. Scripts do not need to pass — several throw on purpose.
215
+ They need to be deterministic, and the capture needs to fail loudly rather
216
+ than quietly producing nothing, because a capture that degenerates to the
217
+ same error text every time would make all later comparisons pass
218
+ vacuously.
219
+
220
+ Normalization is deliberately narrow: only `0x` followed by exactly 16 hex
221
+ digits, the form the runtime addresses take. Anything shorter — immediates
222
+ and small constants — is left alone so a real change in one is visible.
223
+ The count of substitutions is emitted so a shift in it can be noticed.
224
+
225
+ ```bash
226
+ cat > /tmp/jitsplit/capture.sh <<'EOF'
227
+ #!/bin/bash
228
+ # Capture a normalized dump of all JIT-emitted code over a fixed corpus.
229
+ # Usage: capture.sh <hermes-binary> <repo-root> <output-file>
230
+ set -u
231
+ HERMES="$1"; ROOT="$2"; OUT="$3"
232
+
233
+ [ -x "$HERMES" ] || { echo "capture: no such binary: $HERMES" >&2; exit 1; }
234
+
235
+ TYPED=(
236
+ "$ROOT/test/shermes/array-typed.js"
237
+ "$ROOT/test/hermes/flow/array-for-of.js"
238
+ "$ROOT/test/hermes/flow/nbody.js"
239
+ )
240
+ JITTESTS=("$ROOT"/test/jit/*.js)
241
+ [ -e "${JITTESTS[0]}" ] || { echo "capture: no test/jit/*.js found" >&2; exit 1; }
242
+ for f in "${TYPED[@]}"; do
243
+ [ -f "$f" ] || { echo "capture: missing corpus file: $f" >&2; exit 1; }
244
+ done
245
+
246
+ : > "$OUT"
247
+ run_one() { # <label> <file> <extra-flag...>
248
+ local label="$1" file="$2"; shift 2
249
+ local before after
250
+ echo "===== $label =====" >> "$OUT"
251
+ before=$(wc -l < "$OUT")
252
+ "$HERMES" "$@" -Xjit=force -Xjit-threshold=1 -Xdump-jitcode=3 "$file" 2>&1 \
253
+ | sed -e 's/0x[0-9A-Fa-f]\{16\}/ADDR/g' >> "$OUT"
254
+ after=$(wc -l < "$OUT")
255
+ if [ "$after" -le "$((before + 2))" ]; then
256
+ echo "capture: $label produced almost no output; corpus is broken" >&2
257
+ exit 1
258
+ fi
259
+ }
260
+ for f in "${JITTESTS[@]}"; do run_one "$(basename "$f")" "$f"; done
261
+ for f in "${TYPED[@]}"; do run_one "typed $(basename "$f")" "$f" -typed; done
262
+
263
+ echo "lines: $(wc -l < "$OUT") ADDR substitutions: $(grep -c ADDR "$OUT")"
264
+ EOF
265
+ chmod +x /tmp/jitsplit/capture.sh
266
+ ```
267
+
268
+ - [ ] **Step 4: Confirm the corpus is deterministic and the filter is not too wide**
269
+
270
+ Two captures from one binary must be identical after normalization. They
271
+ must also differ *before* normalization only in the places the filter
272
+ touches — otherwise something else is varying and the filter is hiding it.
273
+
274
+ ```bash
275
+ source /tmp/jitsplit/config.sh
276
+ cd "$ROOT"
277
+ H="$HOME/fbsource/$(buck2 build //xplat/static_h:hermes --show-output 2>/dev/null | awk '{print $2}')"
278
+ bash /tmp/jitsplit/capture.sh "$H" "$ROOT" /tmp/jitsplit/a.txt
279
+ bash /tmp/jitsplit/capture.sh "$H" "$ROOT" /tmp/jitsplit/b.txt
280
+ diff -q /tmp/jitsplit/a.txt /tmp/jitsplit/b.txt && echo "DETERMINISTIC"
281
+ ```
282
+
283
+ Expected: both captures report the same `ADDR substitutions` count, and
284
+ `DETERMINISTIC`. If they differ, inspect the diff. If the differing lines
285
+ are addresses the filter missed, widen it minimally; if they are anything
286
+ else, that thing needs excluding on its own terms rather than by
287
+ broadening the address pattern.
288
+
289
+ Known residual risk, worth stating rather than pretending away: a
290
+ JIT-materialized 64-bit constant printed as a full 16-digit hex value is
291
+ indistinguishable from an address and would be masked. The substitution
292
+ count printed by `capture.sh` is the tripwire — if it changes between the
293
+ baseline and a later capture, a value moved into or out of that form and
294
+ the diff must be inspected by hand.
295
+
296
+ - [ ] **Step 5: Save the baseline dump**
297
+
298
+ ```bash
299
+ cp /tmp/jitsplit/a.txt /tmp/jitsplit/baseline.txt
300
+ rm -f /tmp/jitsplit/a.txt /tmp/jitsplit/b.txt
301
+ wc -l /tmp/jitsplit/baseline.txt
302
+ ```
303
+
304
+ No baseline size is captured here. Code size is measured with the repo's
305
+ own tooling — the `facebook:bloaty` skill, which compares a commit against
306
+ its parent — at the two points where it matters: after the inline-helper
307
+ commit in Task 2, and across the whole stack in Task 15. Measuring
308
+ `libhermesvm*.a` byte counts by hand would be misleading: an archive's
309
+ size includes per-member headers and padding, so turning one object into
310
+ eleven moves it regardless of code size, which is precisely the signal we
311
+ are trying to read.
312
+
313
+ - [ ] **Step 6: Write the per-task verification script**
314
+
315
+ ```bash
316
+ cat > /tmp/jitsplit/verify.sh <<'EOF'
317
+ #!/bin/bash
318
+ # Verify one code-motion commit. Exits non-zero on any failure.
319
+ set -u
320
+ source /tmp/jitsplit/config.sh
321
+ cd "$ROOT" || exit 1
322
+
323
+ echo "--- buck2 build"
324
+ buck2 build //xplat/static_h:hermes || { echo "FAIL: buck2 build"; exit 1; }
325
+
326
+ echo "--- cmake build ($CMAKE_DIR)"
327
+ cmake --build "$CMAKE_DIR" --target hermes > /tmp/jitsplit/cmake.log 2>&1 \
328
+ || { echo "FAIL: cmake build"; tail -30 /tmp/jitsplit/cmake.log; exit 1; }
329
+
330
+ echo "--- jit dump comparison"
331
+ H="$HOME/fbsource/$(buck2 build //xplat/static_h:hermes --show-output 2>/dev/null | awk '{print $2}')"
332
+ bash /tmp/jitsplit/capture.sh "$H" "$ROOT" /tmp/jitsplit/now.txt \
333
+ || { echo "FAIL: capture"; exit 1; }
334
+ if ! diff -u /tmp/jitsplit/baseline.txt /tmp/jitsplit/now.txt \
335
+ > /tmp/jitsplit/dump.diff; then
336
+ echo "FAIL: emitted code changed"
337
+ head -60 /tmp/jitsplit/dump.diff
338
+ exit 1
339
+ fi
340
+
341
+ echo "--- lit suite"
342
+ buck2 test //xplat/static_h:lit || { echo "FAIL: lit"; exit 1; }
343
+
344
+ echo "ALL CHECKS PASSED"
345
+ EOF
346
+ chmod +x /tmp/jitsplit/verify.sh
347
+ ```
348
+
349
+ - [ ] **Step 7: Prove the harness passes on an unmodified tree**
350
+
351
+ ```bash
352
+ bash /tmp/jitsplit/verify.sh
353
+ ```
354
+
355
+ Expected: `ALL CHECKS PASSED`. A harness that cannot pass on an unchanged
356
+ tree is worthless as a regression check. Do not start Task 2 until this
357
+ prints that line.
358
+
359
+ ---
360
+
361
+ ### Task 2: Move the hot helpers, macros and pragma into a header
362
+
363
+ The hot helpers move **first**, before the cold ones. The dependency runs
364
+ one way: cold helpers call hot helpers and not the reverse —
365
+ `emit_stringprim_get_length_and_flags` calls `emit_sh_ljs_get_pointer`,
366
+ `emit_jsobject_init` calls `emit_sh_cp_encode_non_null` and
367
+ `emit_store_cp`. Moving the cold helpers into their own translation unit
368
+ first would leave them calling helpers still private to `JitEmitter.cpp`,
369
+ and the new TU would not compile.
370
+
371
+ Still one emitter TU after this task. If moving helpers into a header
372
+ costs anything in code size, it shows up here, where the header extraction
373
+ is the only variable.
374
+
375
+ **Files:**
376
+ - Create: `lib/VM/JIT/arm64/JitEmitter-internal.h`
377
+ - Create: `lib/VM/JIT/arm64/JitEmitter-internal.cpp` (empty skeleton; Task 3
378
+ fills it)
379
+ - Modify: `lib/VM/JIT/arm64/JitEmitter.cpp`
380
+ - Modify: `lib/VM/CMakeLists.txt`
381
+
382
+ **Interfaces:**
383
+ - Produces, all `inline`, in `namespace hermes::vm::arm64` in
384
+ `JitEmitter-internal.h`: `emit_sh_ljs_get_tag`,
385
+ `emit_sh_ljs_tag_is_pointer`, `emit_sh_ljs_tag_is_object`,
386
+ `emit_sh_ljs_tag_is_string`, `emit_sh_ljs_get_pointer`,
387
+ `emit_sh_ljs_object`, `emit_sh_ljs_object2`, `emit_sh_ljs_is_double`,
388
+ `emit_sh_ljs_string`, `emit_shv_string`, `emit_sh_ljs_is_object`,
389
+ `emit_sh_ljs_is_string`, `emit_sh_ljs_is_bigint`, `emit_sh_ljs_is_empty`,
390
+ `emit_sh_ljs_is_null`, `emit_sh_ljs_is_bool`, `emit_sh_ljs_is_undefined`,
391
+ `emit_sh_ljs_is_symbol`, `emit_sh_ljs_bool`, `emit_sh_ljs_bool_const`,
392
+ `emit_sh_cp_decode`, `emit_sh_cp_decode_non_null`,
393
+ `emit_sh_cp_encode_non_null`, `emit_load_cp`, `emit_store_cp`,
394
+ `emit_load_shv`, `emit_store_shv`, `emit_load_from_base_offset`,
395
+ `emit_load_slot16`, `maxNaturalBaseOffset`, `emit_double_is_int`,
396
+ `emit_double_is_uint32`, `emit_gccell_get_kind`, `emit_cellkind_in_range`,
397
+ `emit_cmp_imm32`, `emit_add_imm_u24`, `isCheapConst`, `isStpGpXImm`,
398
+ `emit_sh_cp_decode_non_null_preserve_input`,
399
+ `emit_sh_shv_decode`; plus `class Emit_sh_shv_decode` with its inline
400
+ constructor and inline `emitAll`; plus `constexpr uint32_t
401
+ kMaxInlineBaseOffset`; plus the `static_assert` from the top of the
402
+ anonymous namespace; plus the macros `EXPECT_ERROR`,
403
+ `EMIT_RUNTIME_CALL`, `EMIT_RUNTIME_CALL_WITHOUT_SAVED_IP`,
404
+ `EMIT_RUNTIME_CALL_WITHOUT_THUNK_AND_SAVED_IP`.
405
+ - Produces in `JitEmitter-internal.cpp`:
406
+ `Emit_sh_shv_decode::emitFirstCase`, `Emit_sh_shv_decode::emitRestCases`.
407
+ - Consumes: nothing from earlier tasks.
408
+
409
+ - [ ] **Step 1: Create the two file skeletons**
410
+
411
+ `JitEmitter-internal.h`:
412
+
413
+ ```cpp
414
+ /**
415
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
416
+ *
417
+ * This source code is licensed under the MIT license found in the
418
+ * LICENSE file in the root directory of this source tree.
419
+ */
420
+
421
+ #pragma once
422
+
423
+ #include "hermes/VM/JIT/Config.h"
424
+ #if HERMESVM_JIT
425
+
426
+ #include "JitEmitter.h"
427
+
428
+ namespace hermes::vm::arm64 {
429
+
430
+ // Declarations and inline definitions move here.
431
+
432
+ } // namespace hermes::vm::arm64
433
+
434
+ #endif // HERMESVM_JIT
435
+ ```
436
+
437
+ `JitEmitter-internal.cpp` gets the copyright header,
438
+ `#include "JitEmitter-internal.h"`, the guard, and an empty
439
+ `namespace hermes::vm::arm64 { }`. It stays almost empty until Task 3.
440
+
441
+ Add `#include "JitEmitter-internal.h"` to `JitEmitter.cpp` next to its
442
+ existing `#include "JitImpl.h"`, and add both new files to
443
+ `lib/VM/CMakeLists.txt` inside the `if (HERMESVM_ALLOW_JIT)` block:
444
+
445
+ ```cmake
446
+ JIT/arm64/JitEmitter-internal.cpp JIT/arm64/JitEmitter-internal.h
447
+ ```
448
+
449
+ - [ ] **Step 2: Move the hot free helpers into the header**
450
+
451
+ Cut each helper named in the Produces list above from `JitEmitter.cpp`'s
452
+ anonymous namespace and paste it into `JitEmitter-internal.h`, in the same
453
+ order, doc comments unchanged, each marked `inline`. `isCheapConst`
454
+ currently sits just below the anonymous namespace as a file-scope
455
+ `static`; it moves too, losing `static` and gaining `inline`.
456
+
457
+ Leave the four cold helpers and the two classes where they are — Task 3
458
+ moves them. The anonymous namespace therefore still exists after this
459
+ task, holding only those.
460
+
461
+ - [ ] **Step 3: Move the non-function entities**
462
+
463
+ The anonymous namespace is not only functions. Move these too, or the
464
+ helpers that depend on them will not compile:
465
+
466
+ - the `static_assert(HERMESVALUE_VERSION == 2, ...)` at the top of the
467
+ block
468
+ - `constexpr uint32_t kMaxInlineBaseOffset = maxNaturalBaseOffset(8);`,
469
+ which `emit_load_from_base_offset` reads
470
+
471
+ `kMaxInlineBaseOffset` must appear after `maxNaturalBaseOffset` in the
472
+ header, since it calls it at compile time.
473
+
474
+ - [ ] **Step 4: Move `Emit_sh_shv_decode`**
475
+
476
+ Put the class definition, its inline constructor, and its inline `emitAll`
477
+ in the header. Move `emitFirstCase` and `emitRestCases` — already defined
478
+ out of line today — into `JitEmitter-internal.cpp`.
479
+
480
+ - [ ] **Step 5: Move the macros and the pragma**
481
+
482
+ Move `EXPECT_ERROR` and the three `EMIT_RUNTIME_CALL` macros into the
483
+ header. Move the `-Wmissing-designated-field-initializers` pragma block
484
+ there too: every TU that builds a `SlowPath` with designated initializers
485
+ needs it, which is most of them.
486
+
487
+ ```cpp
488
+ // Disable warnings about missing designated initializers since they occur often
489
+ // when we construct SlowPaths.
490
+ #ifdef __clang__
491
+ #if __has_warning("-Wmissing-designated-field-initializers")
492
+ #pragma clang diagnostic ignored "-Wmissing-designated-field-initializers"
493
+ #endif
494
+ #endif
495
+ ```
496
+
497
+ Note the tradeoff in the commit message rather than silently widening a
498
+ suppression: today this pragma affects one translation unit; in the header
499
+ it affects every TU that includes it, and everything after the include in
500
+ those TUs, not only `SlowPath` construction. It is not wrapped in
501
+ `push`/`pop` because the suppression has to stay active through the whole
502
+ of each emitter TU — that is where the designated initializers are. The
503
+ blast radius is bounded by the include list: only emitter TUs include this
504
+ header.
505
+
506
+ - [ ] **Step 6: Format**
507
+
508
+ ```bash
509
+ cd ~/fbsource/xplat/static_h && arc f
510
+ ```
511
+
512
+ - [ ] **Step 7: Verify**
513
+
514
+ ```bash
515
+ bash /tmp/jitsplit/verify.sh
516
+ ```
517
+
518
+ Expected: `ALL CHECKS PASSED`.
519
+
520
+ - [ ] **Step 8: Commit**
521
+
522
+ ```bash
523
+ cd ~/fbsource/xplat/static_h
524
+ sl commit -m "$(cat <<'EOF'
525
+ [SH] JIT: Move the inline emitter helpers to JitEmitter-internal.h
526
+
527
+ Summary:
528
+ Move the remaining free `emit_*` helpers, the `Emit_sh_shv_decode` class,
529
+ the `EXPECT_ERROR` and `EMIT_RUNTIME_CALL` macros, and the
530
+ missing-designated-initializer pragma out of `JitEmitter.cpp`'s anonymous
531
+ namespace and into `JitEmitter-internal.h`, marked `inline` so they can
532
+ still be inlined once the emitters are split across translation units.
533
+ `Emit_sh_shv_decode::emitFirstCase` and `emitRestCases` were already out
534
+ of line and go to `JitEmitter-internal.cpp`.
535
+
536
+ The anonymous namespace also held a `static_assert` and
537
+ `kMaxInlineBaseOffset`, which `emit_load_from_base_offset` reads; both
538
+ move with the helpers. The namespace still exists, holding only the four
539
+ bulky helpers and the two asmjit subclasses, which move next.
540
+
541
+ The hot helpers move before the cold ones because the dependency runs
542
+ that way: the cold helpers call `emit_sh_ljs_get_pointer`,
543
+ `emit_sh_cp_encode_non_null` and `emit_store_cp`, and nothing calls in
544
+ the other direction. Moving the cold ones out first would put them in a
545
+ translation unit that cannot see the helpers they use.
546
+
547
+ The pragma has to be shared because every translation unit that
548
+ constructs a `SlowPath` with designated initializers needs it. Moving it
549
+ to a header does widen the suppression from one translation unit to every
550
+ TU that includes the header, and to everything after the include rather
551
+ than only `SlowPath` construction. It is not wrapped in `push`/`pop`
552
+ because it has to stay active through the whole of each emitter TU; the
553
+ blast radius is bounded by the include list.
554
+
555
+ Nothing has been split yet, so this isolates the cost of the header move
556
+ itself. Pure code motion; the emitted machine code is unchanged.
557
+
558
+ Test Plan:
559
+ `buck2 build //xplat/static_h:hermes`, a CMake build of the same target,
560
+ and `buck2 test //xplat/static_h:lit`. `-Xdump-jitcode=3` output over the
561
+ JIT and typed lit tests is byte-identical to the pre-split baseline with
562
+ addresses normalized. Code size compared against the parent commit with
563
+ the `facebook:bloaty` skill.
564
+
565
+ Reviewers: Hermes
566
+
567
+ Subscribers:
568
+
569
+ Tasks:
570
+
571
+ Tags:
572
+ EOF
573
+ )" --reason "commit inline helper extraction - sl help commit"
574
+ ```
575
+
576
+ - [ ] **Step 9: Measure code size against the parent commit**
577
+
578
+ This is the measurement that answers the inlining question, taken while
579
+ there is still a single emitter TU, so nothing else can be blamed for a
580
+ change. It runs after the commit because the tooling compares a commit
581
+ against its parent.
582
+
583
+ Use the repo's own size tooling rather than measuring artifacts by hand:
584
+
585
+ ```
586
+ facebook:bloaty
587
+ ```
588
+
589
+ That skill selects the right optimized `hermesvm` artifact and reports a
590
+ per-symbol breakdown. Do not substitute a byte count of `libhermesvm*.a`
591
+ from the `<buck output dir>`: an archive's size includes per-member
592
+ headers and alignment padding, so it moves when one object becomes eleven
593
+ regardless of how much code there is, and a bare `find` can pick up a
594
+ stale or differently-configured artifact.
595
+
596
+ Report the number. A large increase means helpers stopped being inlined,
597
+ and the fix is to reconsider which helpers are `inline`, not to carry on.
598
+
599
+ ---
600
+
601
+ ### Task 3: Move the cold helpers into JitEmitter-internal.cpp
602
+
603
+ These are the four bulky, rarely called helpers and the two asmjit
604
+ subclasses left behind by Task 2. They can move now because the hot
605
+ helpers they call already live in `JitEmitter-internal.h`.
606
+
607
+ **Files:**
608
+ - Modify: `lib/VM/JIT/arm64/JitEmitter-internal.h` (add declarations)
609
+ - Modify: `lib/VM/JIT/arm64/JitEmitter-internal.cpp` (add definitions)
610
+ - Modify: `lib/VM/JIT/arm64/JitEmitter.cpp` (remove the moved definitions
611
+ and the now-empty anonymous namespace)
612
+
613
+ **Interfaces:**
614
+ - Produces, in `namespace hermes::vm::arm64`: the free functions
615
+ `emit_jsobject_init`, `emit_environment_init`,
616
+ `emit_stringprim_get_length_and_flags` and `emit_load_builtin_closure`,
617
+ each **declared** in `JitEmitter-internal.h` and **defined** in
618
+ `JitEmitter-internal.cpp`, with signatures copied verbatim from their
619
+ current definitions; and the classes `OurErrorHandler` and `OurLogger`,
620
+ whose **class bodies go in the header** with any out-of-line member
621
+ definitions in the `.cpp`.
622
+ - Consumes: the two files and every hot helper from Task 2.
623
+
624
+ - [ ] **Step 1: Move the cold helpers**
625
+
626
+ Cut these from the anonymous namespace in `JitEmitter.cpp`, in the same
627
+ relative order, doc comments unchanged:
628
+
629
+ - `emit_stringprim_get_length_and_flags` — declaration to the header,
630
+ body to the `.cpp`
631
+ - `emit_jsobject_init` — same
632
+ - `emit_environment_init` — same
633
+ - `emit_load_builtin_closure` — same
634
+ - `class OurErrorHandler` — class body to the header
635
+ - `class OurLogger` — class body to the header
636
+
637
+ - [ ] **Step 2: Delete the now-empty anonymous namespace**
638
+
639
+ `JitEmitter.cpp` should no longer have a `namespace { ... }` block. The
640
+ `STATISTIC(JITNumGetByIdSpec, ...)` declaration stays in `JitEmitter.cpp`
641
+ for now; Task 9 moves it.
642
+
643
+ - [ ] **Step 3: Format**
644
+
645
+ ```bash
646
+ cd ~/fbsource/xplat/static_h && arc f
647
+ ```
648
+
649
+ - [ ] **Step 4: Verify**
650
+
651
+ ```bash
652
+ bash /tmp/jitsplit/verify.sh
653
+ ```
654
+
655
+ Expected: `ALL CHECKS PASSED`. If the dump differs, the move changed
656
+ behaviour — revert and redo it rather than accepting the new output.
657
+
658
+ - [ ] **Step 5: Commit**
659
+
660
+ ```bash
661
+ cd ~/fbsource/xplat/static_h
662
+ sl commit -m "$(cat <<'EOF'
663
+ [SH] JIT: Move the cold emitter helpers to JitEmitter-internal.cpp
664
+
665
+ Summary:
666
+ Move the bulky, rarely called free helpers out of `JitEmitter.cpp`'s
667
+ anonymous namespace and into the helper layer created by the previous
668
+ commit: `emit_jsobject_init`, `emit_environment_init`,
669
+ `emit_stringprim_get_length_and_flags`, `emit_load_builtin_closure`, and
670
+ the `OurErrorHandler` and `OurLogger` classes. They keep their bodies out
671
+ of the header and gain declarations in it, so they have external linkage
672
+ under the same names.
673
+
674
+ They move after the inline helpers rather than before, because they call
675
+ `emit_sh_ljs_get_pointer`, `emit_sh_cp_encode_non_null` and
676
+ `emit_store_cp`; those had to be visible outside `JitEmitter.cpp` first.
677
+
678
+ With this, `JitEmitter.cpp`'s anonymous namespace is gone. Pure code
679
+ motion, so the emitted machine code is unchanged.
680
+
681
+ Test Plan:
682
+ `buck2 build //xplat/static_h:hermes`, a CMake build of the same target,
683
+ and `buck2 test //xplat/static_h:lit`. `-Xdump-jitcode=3` output over the
684
+ JIT and typed lit tests is byte-identical to the pre-split baseline with
685
+ addresses normalized.
686
+
687
+ Reviewers: Hermes
688
+
689
+ Subscribers:
690
+
691
+ Tasks:
692
+
693
+ Tags:
694
+ EOF
695
+ )" --reason "commit cold helper extraction - sl help commit"
696
+ ```
697
+
698
+ ---
699
+
700
+ ### Task 4: Move the Emitter member template definitions into JitEmitter.h
701
+
702
+ Must land before any emitter moves out of `JitEmitter.cpp`, because Task 5
703
+ is the first task that would break the link.
704
+
705
+ `JitEmitter.h` declares three member templates whose definitions live in
706
+ `JitEmitter.cpp`. A template is instantiated only where its definition is
707
+ visible, so once a caller lives in another TU it emits an undefined
708
+ reference instead. That reference resolves only if the *defining* TU
709
+ happens to instantiate the same specialization, which makes the failure
710
+ mode inconsistent:
711
+
712
+ - `_allocTemp<HWReg::GpX>` and `_allocTemp<HWReg::VecD>` are called only
713
+ from `allocTempGpX()` and `allocTempVecD()`, which are inline in
714
+ `JitEmitter.h` itself. Nothing in the register-allocation group calls
715
+ them, so `JitEmitter-regalloc.cpp` would hold the definition and never
716
+ instantiate it — undefined in every TU that allocates a temp.
717
+ - `loadBits64InGp<a64::GpX>` would be instantiated inside
718
+ `JitEmitter-const.cpp` by its own callers and so would link **by
719
+ accident**, while `loadBits64InGp<a64::GpW>`, used only by `loadParam`
720
+ in the core TU, would not.
721
+
722
+ Putting the definitions in the header is the ordinary mechanism and needs
723
+ no instantiation list to maintain when someone later calls one with a new
724
+ register type. The bodies are small — 17, 14 and 11 lines.
725
+
726
+ **Files:**
727
+ - Modify: `lib/VM/JIT/arm64/JitEmitter.h`
728
+ - Modify: `lib/VM/JIT/arm64/JitEmitter.cpp`
729
+
730
+ **Interfaces:**
731
+ - Produces: definitions of `Emitter::movHWFromHW`, `Emitter::_allocTemp`
732
+ and `Emitter::loadBits64InGp`, visible to every TU that includes
733
+ `JitEmitter.h`.
734
+ - Consumes: nothing.
735
+
736
+ - [ ] **Step 1: Move the three definitions**
737
+
738
+ Cut these from `JitEmitter.cpp` and paste them into `JitEmitter.h`
739
+ **immediately after the closing `}; // class Emitter`** and before the
740
+ closing `} // namespace hermes::vm::arm64`, so the definition sits next to
741
+ the declaration and nobody has to hunt for it:
742
+
743
+ - `template <bool use> void Emitter::movHWFromHW(HWReg dst, HWReg src)`
744
+ - `template <class TAG> HWReg Emitter::_allocTemp(TempRegAlloc &ra, llvh::Optional<HWReg> preferred)`
745
+ - `template <typename REG> void Emitter::loadBits64InGp(...)`
746
+
747
+ Keep their doc comments with them. Leave the declarations inside the class
748
+ exactly as they are.
749
+
750
+ - [ ] **Step 2: Check nothing else is in the same position**
751
+
752
+ `JitEmitter.h` has four template sites. Confirm the other one,
753
+ `bitMask32`, is already defined in the header and needs nothing:
754
+
755
+ ```bash
756
+ grep -nE "^\s*template" lib/VM/JIT/arm64/JitEmitter.h
757
+ ```
758
+
759
+ Expected: four hits — `bitMask32` (already defined inline just below its
760
+ declaration) and the three now defined after the class. If a fifth appears
761
+ later, it needs the same treatment before its TU moves.
762
+
763
+ - [ ] **Step 3: Format**
764
+
765
+ ```bash
766
+ cd ~/fbsource/xplat/static_h && arc f
767
+ ```
768
+
769
+ - [ ] **Step 4: Verify**
770
+
771
+ ```bash
772
+ bash /tmp/jitsplit/verify.sh
773
+ ```
774
+
775
+ Expected: `ALL CHECKS PASSED`. This task cannot change emitted code — it
776
+ only changes where a definition is parsed.
777
+
778
+ - [ ] **Step 5: Commit**
779
+
780
+ ```bash
781
+ cd ~/fbsource/xplat/static_h
782
+ sl commit -m "$(cat <<'EOF'
783
+ [SH] JIT: Define the Emitter member templates in JitEmitter.h
784
+
785
+ Summary:
786
+ Move the definitions of `Emitter::movHWFromHW`, `Emitter::_allocTemp` and
787
+ `Emitter::loadBits64InGp` from `JitEmitter.cpp` into `JitEmitter.h`,
788
+ directly after the class that declares them.
789
+
790
+ A function template is only instantiated where its definition is visible.
791
+ That is invisible while `JitEmitter.cpp` is the sole emitter translation
792
+ unit, but splitting it would leave callers in other units emitting
793
+ undefined references. The failure would not even be uniform:
794
+ `_allocTemp<GpX>` and `_allocTemp<VecD>` are reached only through the
795
+ inline `allocTempGpX()`/`allocTempVecD()` wrappers in the header and are
796
+ instantiated nowhere in the register-allocation group, so they would be
797
+ undefined everywhere, while `loadBits64InGp<GpX>` would happen to be
798
+ instantiated alongside its definition and link by accident, leaving only
799
+ `loadBits64InGp<GpW>` broken.
800
+
801
+ Defining them in the header is the ordinary mechanism and, unlike
802
+ explicit instantiation, needs no list to maintain when a new register
803
+ type is used. The three bodies are small.
804
+
805
+ Test Plan:
806
+ `buck2 build //xplat/static_h:hermes`, a CMake build of the same target,
807
+ and `buck2 test //xplat/static_h:lit`. `-Xdump-jitcode=3` output over the
808
+ JIT and typed lit tests is byte-identical to the pre-split baseline with
809
+ addresses normalized.
810
+
811
+ Reviewers: Hermes
812
+
813
+ Subscribers:
814
+
815
+ Tasks:
816
+
817
+ Tags:
818
+ EOF
819
+ )" --reason "commit template definition move - sl help commit"
820
+ ```
821
+
822
+ ---
823
+
824
+ ## Tasks 5 through 14: one translation unit each
825
+
826
+ These ten tasks are mechanically identical and independent of each other.
827
+ Order is smallest first, to shake out the pattern before the big ones.
828
+
829
+ **The shared step sequence, applied in every one of Tasks 5-14:**
830
+
831
+ 1. **Create the file.** Copyright header, then:
832
+
833
+ ```cpp
834
+ #include "hermes/VM/JIT/Config.h"
835
+ #if HERMESVM_JIT
836
+ #include "JitEmitter.h"
837
+ #include "JitEmitter-internal.h"
838
+ #include "JitImpl.h"
839
+
840
+ namespace hermes::vm::arm64 {
841
+
842
+ // Definitions move here.
843
+
844
+ } // namespace hermes::vm::arm64
845
+ #endif // HERMESVM_JIT
846
+ ```
847
+
848
+ 2. **Move the definitions** listed for that task out of `JitEmitter.cpp`,
849
+ in the same relative order, comments unchanged.
850
+ 3. **Fix includes.** Build, and add only the includes the compiler
851
+ actually demands. Do not copy `JitEmitter.cpp`'s whole include list.
852
+ 4. **Add the file to `lib/VM/CMakeLists.txt`** in the
853
+ `if (HERMESVM_ALLOW_JIT)` block.
854
+ 5. **`arc f`**
855
+ 6. **`bash /tmp/jitsplit/verify.sh`** — expect `ALL CHECKS PASSED`.
856
+ 7. **Commit** with title
857
+ `[SH] JIT: Move <topic> to JitEmitter-<part>.cpp`, a summary saying it
858
+ is pure code motion and listing what moved, and the Test Plan wording
859
+ used in Tasks 2-4.
860
+
861
+ If a link error naming a template appears despite Task 4, a fourth member
862
+ template has been added since this plan was written; give it the Task 4
863
+ treatment in its own commit rather than working around it here.
864
+
865
+ ---
866
+
867
+ ### Task 5: `JitEmitter-regalloc.cpp`
868
+
869
+ **Files:** Create `lib/VM/JIT/arm64/JitEmitter-regalloc.cpp`; modify
870
+ `JitEmitter.cpp`, `lib/VM/CMakeLists.txt`.
871
+
872
+ - [ ] Move: `_storeHWToFrame`, `movHWFromFR`,
873
+ `movHWFromMem`, `movFRFromHW`, `syncFrameOutParam`, `freeReg`,
874
+ `syncAndFreeTempReg`, `useReg`, `_spillTempForFR`, `syncToFrame`,
875
+ `syncAllFRTempExcept`, `freeAllFRTempExcept`, `freeFRTemp`,
876
+ `_assignAllocatedLocalHWReg`, `_isFRInRegister`,
877
+ `getOrAllocFRInVecD`, `getOrAllocFRInGpX`, `getOrAllocFRInAnyReg`,
878
+ `frUpdatedWithHW`, `frUpdateType`.
879
+ `movHWFromHW` and `_allocTemp` are no longer in `JitEmitter.cpp` at
880
+ all after Task 4; do not look for them.
881
+ - [ ] Add to CMake, `arc f`
882
+ - [ ] `bash /tmp/jitsplit/verify.sh` → `ALL CHECKS PASSED`
883
+ - [ ] Commit: `[SH] JIT: Move register allocation to JitEmitter-regalloc.cpp`
884
+
885
+ ### Task 6: `JitEmitter-alloc.cpp`
886
+
887
+ **Files:** Create `lib/VM/JIT/arm64/JitEmitter-alloc.cpp`; modify
888
+ `JitEmitter.cpp`, `lib/VM/CMakeLists.txt`.
889
+
890
+ - [ ] Move: `bumpAllocAndUnpoison`, `initGCCell`, `allocInYoung`,
891
+ `alloc2InYoung`
892
+ - [ ] Add to CMake, `arc f`
893
+ - [ ] `bash /tmp/jitsplit/verify.sh` → `ALL CHECKS PASSED`
894
+ - [ ] Commit: `[SH] JIT: Move young-gen allocation to JitEmitter-alloc.cpp`
895
+
896
+ ### Task 7: `JitEmitter-const.cpp`
897
+
898
+ **Files:** Create `lib/VM/JIT/arm64/JitEmitter-const.cpp`; modify
899
+ `JitEmitter.cpp`, `lib/VM/CMakeLists.txt`.
900
+
901
+ - [ ] Move: `loadConstDouble`, `loadSmallHermesValueInGpX`,
902
+ `loadConstStringInGpX`, `loadConstBits64`, `loadConstString`,
903
+ `loadConstBigInt`. `loadBits64InGp` is not in this list — Task 4
904
+ moved its definition to `JitEmitter.h`.
905
+ - [ ] Add to CMake, `arc f`
906
+ - [ ] `bash /tmp/jitsplit/verify.sh` → `ALL CHECKS PASSED`
907
+ - [ ] Commit: `[SH] JIT: Move constant materialization to JitEmitter-const.cpp`
908
+
909
+ ### Task 8: `JitEmitter-object.cpp`
910
+
911
+ **Files:** Create `lib/VM/JIT/arm64/JitEmitter-object.cpp`; modify
912
+ `JitEmitter.cpp`, `lib/VM/CMakeLists.txt`.
913
+
914
+ - [ ] Move: `newObject`, `newObjectWithParent`, `newObjectWithBuffer`,
915
+ `newObjectWithBufferSlow`, `newObjectWithBufferAndParent`,
916
+ `newTypedObjectWithBuffer`, `loadParentNoTraps`, `typedLoadParent`,
917
+ `instanceOf`
918
+ - [ ] Add to CMake, `arc f`
919
+ - [ ] `bash /tmp/jitsplit/verify.sh` → `ALL CHECKS PASSED`
920
+ - [ ] Commit: `[SH] JIT: Move object construction to JitEmitter-object.cpp`
921
+
922
+ ### Task 9: `JitEmitter-property.cpp`
923
+
924
+ The largest task. `Emitter::GetByIdImpl` is a nested class of `Emitter`,
925
+ forward-declared in `JitEmitter.h` and marked
926
+ `HERMES_ATTRIBUTE_INTERNAL_LINKAGE`; it must be defined in exactly one TU,
927
+ and that TU is this one. The `STATISTIC(JITNumGetByIdSpec, ...)`
928
+ declaration moves here too, along with `#include "llvh/ADT/Statistic.h"`
929
+ and the `#define DEBUG_TYPE "jit"` that `STATISTIC` needs.
930
+
931
+ **Files:** Create `lib/VM/JIT/arm64/JitEmitter-property.cpp`; modify
932
+ `JitEmitter.cpp`, `lib/VM/CMakeLists.txt`.
933
+
934
+ - [ ] Move: the `GetByIdImpl` class, `getByIdImpl`, `getByIdWithReceiver`,
935
+ `getByVal`, `getByValWithReceiver`, `getByIndex`, `putByIdImpl`,
936
+ `putByValImpl`, `putByValWithReceiver`, `delByVal`, `defineOwnById`,
937
+ `defineOwnInDenseArray`, `defineOwnByIndex`, `defineOwnByVal`,
938
+ `defineOwnGetterSetterByVal`, `getOwnBySlotIdx`, `putOwnBySlotIdx`,
939
+ `addOwnPrivateBySym`, `getOwnPrivateBySym`, `putOwnPrivateBySym`,
940
+ `createPrivateName`, `isIn`, `privateIsIn`
941
+ - [ ] Move `STATISTIC(JITNumGetByIdSpec, ...)`, `#define DEBUG_TYPE "jit"`
942
+ and the `llvh/ADT/Statistic.h` include; drop them from
943
+ `JitEmitter.cpp` only if nothing else there still uses them
944
+ - [ ] Add to CMake, `arc f`
945
+ - [ ] `bash /tmp/jitsplit/verify.sh` → `ALL CHECKS PASSED`
946
+ - [ ] Commit: `[SH] JIT: Move the property protocol to JitEmitter-property.cpp`
947
+
948
+ ### Task 10: `JitEmitter-call.cpp`
949
+
950
+ **Files:** Create `lib/VM/JIT/arm64/JitEmitter-call.cpp`; modify
951
+ `JitEmitter.cpp`, `lib/VM/CMakeLists.txt`.
952
+
953
+ - [ ] Move: `callImpl`, `call`, `callN`, `callBuiltin`,
954
+ `callWithNewTarget`, `callWithNewTargetLong`, `callRequire`,
955
+ `getBuiltinClosure`, `createThis`, `selectObject`, `loadThisNS`,
956
+ `coerceThisNS`, `getNewTarget`
957
+ - [ ] Add to CMake, `arc f`
958
+ - [ ] `bash /tmp/jitsplit/verify.sh` → `ALL CHECKS PASSED`
959
+ - [ ] Commit: `[SH] JIT: Move call emission to JitEmitter-call.cpp`
960
+
961
+ ### Task 11: `JitEmitter-env.cpp`
962
+
963
+ **Files:** Create `lib/VM/JIT/arm64/JitEmitter-env.cpp`; modify
964
+ `JitEmitter.cpp`, `lib/VM/CMakeLists.txt`.
965
+
966
+ - [ ] Move: `createTopLevelEnvironment`, `createFunctionEnvironment`,
967
+ `createEnvironment`, `getParentEnvironment`, `getEnvironment`,
968
+ `getClosureEnvironment`, `loadFromEnvironment`, `storeToEnvironment`,
969
+ `createClosure`, `createBaseClass`, `createDerivedClass`,
970
+ `createGenerator`
971
+ - [ ] Add to CMake, `arc f`
972
+ - [ ] `bash /tmp/jitsplit/verify.sh` → `ALL CHECKS PASSED`
973
+ - [ ] Commit: `[SH] JIT: Move environments and closures to JitEmitter-env.cpp`
974
+
975
+ ### Task 12: `JitEmitter-array.cpp`
976
+
977
+ **Files:** Create `lib/VM/JIT/arm64/JitEmitter-array.cpp`; modify
978
+ `JitEmitter.cpp`, `lib/VM/CMakeLists.txt`.
979
+
980
+ - [ ] Move: `newArray`, `newArrayWithBuffer`, `newFastArray`,
981
+ `fastArrayLength`, `fastArrayLoad`, `fastArrayStore`,
982
+ `fastArrayPush`, `fastArrayAppend`, `iteratorBegin`, `iteratorNext`,
983
+ `iteratorClose`, `getPNameList`, `getNextPName`, `toPropertyKey`,
984
+ `getArgumentsLength`, `getArgumentsPropByValImpl`,
985
+ `reifyArgumentsImpl`
986
+ - [ ] Add to CMake, `arc f`
987
+ - [ ] `bash /tmp/jitsplit/verify.sh` → `ALL CHECKS PASSED`
988
+ - [ ] Commit: `[SH] JIT: Move arrays, iterators and arguments to JitEmitter-array.cpp`
989
+
990
+ ### Task 13: `JitEmitter-arith.cpp`
991
+
992
+ **Files:** Create `lib/VM/JIT/arm64/JitEmitter-arith.cpp`; modify
993
+ `JitEmitter.cpp`, `lib/VM/CMakeLists.txt`.
994
+
995
+ - [ ] Move: `toNumber`, `toNumeric`, `toInt32`, `addEmptyString`,
996
+ `arithUnop`, `booleanNot`, `bitNot`, `typeOf`, `addS`, `mod`,
997
+ `arithBinOp`, `bitBinOp`, `strictEqualImpl`, `compareImpl`
998
+ - [ ] Add to CMake, `arc f`
999
+ - [ ] `bash /tmp/jitsplit/verify.sh` → `ALL CHECKS PASSED`
1000
+ - [ ] Commit: `[SH] JIT: Move arithmetic and comparison to JitEmitter-arith.cpp`
1001
+
1002
+ ### Task 14: `JitEmitter-control.cpp`
1003
+
1004
+ **Files:** Create `lib/VM/JIT/arm64/JitEmitter-control.cpp`; modify
1005
+ `JitEmitter.cpp`, `lib/VM/CMakeLists.txt`.
1006
+
1007
+ - [ ] Move: `jmpTypeOfIs`, `typeOfIs`, `uintSwitchImm`, `stringSwitchImm`,
1008
+ `jmpTrueFalse`, `jmp`, `jmpUndefined`, `jmpBuiltinIs`, `jCond`,
1009
+ `jStrictEqual`, `throwInst`, `throwIfEmptyUndefinedImpl`,
1010
+ `throwIfThisInitialized`, `catchInst`, `ret`
1011
+ - [ ] Add to CMake, `arc f`
1012
+ - [ ] `bash /tmp/jitsplit/verify.sh` → `ALL CHECKS PASSED`
1013
+ - [ ] Commit: `[SH] JIT: Move control flow to JitEmitter-control.cpp`
1014
+
1015
+ After Task 14, `JitEmitter.cpp` should hold only the machinery:
1016
+ `Emitter::Emitter`, `enter`, `comment`, `addToRuntime`,
1017
+ `assertPostInstructionInvariants`, `newBasicBlock`, `getDebugFunctionName`,
1018
+ `frameSetup`, `leave`, `callThunk`, `callThunkWithSavedIP`,
1019
+ `callWithoutThunk`, `emitIncrementCounter`, `initHCLazyIDMayAlloc`,
1020
+ `loadFrameAddr`, `getBytecodeIP`, `unreachable`, `profilePoint`,
1021
+ `directEval`, `mov`, `loadParam`, `getGlobalObject`, `declareGlobalVar`,
1022
+ `debugger`, `createRegExp`, `newPrefLabel`, `reserveData`, `uint64Const`,
1023
+ `registerThunk`, `emitCatchTable`, `emitSlowPaths`, `emitROData`,
1024
+ `emitThunks`, and the `operator<<` at the top.
1025
+
1026
+ ---
1027
+
1028
+ ### Task 15: Measurement report
1029
+
1030
+ Changes no code. Its output is a decision: ship the stack as is, or
1031
+ investigate a regression.
1032
+
1033
+ **Files:**
1034
+ - Modify: `doc/superpowers/specs/2026-08-18-jitemitter-split-design.md`
1035
+
1036
+ - [ ] **Step 1: Establish the timing noise floor**
1037
+
1038
+ Before comparing two binaries, measure the spread on one. This is not a
1039
+ formality: during the work that produced this plan, a code size
1040
+ "regression" turned out to be run-to-run variance, with the unchanged
1041
+ baseline producing the larger figure once in ten runs.
1042
+
1043
+ ```bash
1044
+ source /tmp/jitsplit/config.sh
1045
+ H="$HOME/fbsource/$(buck2 build //xplat/static_h:hermes --show-output 2>/dev/null | awk '{print $2}')"
1046
+ for i in $(seq 1 10); do
1047
+ /usr/bin/time -p "$H" -Xjit=force -Xjit-threshold=1 \
1048
+ "$ROOT/test/jit/many-property-caches.js" 2>&1 | awk '/^real/{print $2}'
1049
+ done | sort -n | tee /tmp/jitsplit/noise-timing.txt
1050
+ ```
1051
+
1052
+ Record min and max. Any later difference smaller than that spread is not a
1053
+ result.
1054
+
1055
+ - [ ] **Step 2: Compare JIT compile time against the baseline commit**
1056
+
1057
+ Check out the commit in `/tmp/jitsplit/baseline-commit.txt`, build, run the
1058
+ same ten timing iterations, compare medians, then return to the top of the
1059
+ stack.
1060
+
1061
+ - [ ] **Step 3: Compare code size across the whole stack**
1062
+
1063
+ Use the repo's size tooling, which selects the right optimized artifact
1064
+ and reports per-symbol deltas:
1065
+
1066
+ ```
1067
+ binary-size-analysis
1068
+ ```
1069
+
1070
+ Give it the range from the commit in `/tmp/jitsplit/baseline-commit.txt`
1071
+ to the top of the stack. For a single commit, `facebook:bloaty` compares
1072
+ against the parent instead.
1073
+
1074
+ Do not measure this by hand with `find` and `stat` over the
1075
+ `<buck output dir>`. Two things make that wrong here: an archive's byte
1076
+ count includes per-member headers and alignment padding, so splitting one
1077
+ object into eleven changes it independently of how much code exists; and a
1078
+ bare glob can pick a stale or differently-configured artifact. The number
1079
+ that matters is the size of the text section in one explicitly chosen
1080
+ optimized build, which is what the skills report.
1081
+
1082
+ - [ ] **Step 4: Record the outcome in the spec**
1083
+
1084
+ Replace the spec's "Risks" entry about inlining with the measured numbers
1085
+ and the noise floors they are judged against. If there is a real
1086
+ regression, say so and propose the fix — most likely moving a specific
1087
+ helper back to `inline` in the header — rather than quietly shipping it.
1088
+
1089
+ - [ ] **Step 5: Commit if the spec changed**
1090
+
1091
+ ```bash
1092
+ cd ~/fbsource/xplat/static_h
1093
+ sl commit doc/superpowers/specs/2026-08-18-jitemitter-split-design.md \
1094
+ -m "[SH]EASY: Record JitEmitter split size and timing results
1095
+
1096
+ Summary:
1097
+ Record the measured binary size and JIT compile time for the completed
1098
+ \`JitEmitter.cpp\` split, together with the noise floors they are judged
1099
+ against. Documentation only.
1100
+
1101
+ Test Plan: Documentation only; no build or tests affected.
1102
+
1103
+ Reviewers: Hermes
1104
+
1105
+ Subscribers:
1106
+
1107
+ Tasks:
1108
+
1109
+ Tags:" --reason "record measurement results - sl help commit"
1110
+ ```
1111
+
1112
+ ---
1113
+
1114
+ ## Self-Review
1115
+
1116
+ **Spec coverage.** Layout: Tasks 5-14, one per file, every definition
1117
+ named. Helper layer and placement rule: Tasks 2 and 3. Comment
1118
+ preservation: the first Global Constraint. Build system: the
1119
+ `HERMESVM_JIT` guard and CMake entry are constraints, and the CMake build
1120
+ is step 2 of `verify.sh`. Verification: `verify.sh` implements the
1121
+ per-commit list; Task 15 implements the closing measurements with a noise
1122
+ floor for each metric. Naming: a Global Constraint, used by every file
1123
+ name here. The spec's open risk about helpers touching `Emitter` is
1124
+ resolved above.
1125
+
1126
+ **Placeholders.** None. The exact include list per new file is
1127
+ deliberately not enumerated — step 3 of the shared sequence says to add
1128
+ only what the compiler demands, which is more reliable than a guessed
1129
+ list.
1130
+
1131
+ **Type consistency.** Helper names in Task 2's Produces block are copied
1132
+ from the current source. `verify.sh`, `capture.sh` and `config.sh` are
1133
+ created in Task 1 and referenced by those names throughout; `capture.sh`
1134
+ takes `<hermes-binary> <repo-root> <output-file>` and is called with those
1135
+ three arguments. `ROOT` and `CMAKE_DIR` are defined only in `config.sh`
1136
+ and never hardcoded elsewhere. `baseline.txt` is written in Task 1 and
1137
+ read by `verify.sh`.
1138
+
1139
+ **Known limitation, stated rather than hidden.** The dump comparison
1140
+ cannot distinguish a JIT-materialized 64-bit constant printed as a full
1141
+ 16-digit hex value from an address, so such a constant changing would be
1142
+ masked. `capture.sh` prints the substitution count as a tripwire. Closing
1143
+ this properly would need the dump to tag addresses distinctly, which is a
1144
+ change to `-Xdump-jitcode` and out of scope here.
1145
+
1146
+ **Scratch files in `/tmp`.** They do not survive a reboot; Step 1 records
1147
+ the baseline commit so they can be regenerated. Somewhere durable would
1148
+ mean picking a path outside the repo, which is environment-dependent —
1149
+ exactly what the spec says to ask about rather than bake in.