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,1306 @@
1
+ ---
2
+ id: ir
3
+ title: Design of the IR
4
+ ---
5
+
6
+ ### Introduction
7
+
8
+ This document is a reference manual for the Hermes High-level IR. The IR is a
9
+ Static Single Assignment (SSA) based representation that captures the JavaScript
10
+ language semantics. It features optional types (values may be annotated with
11
+ types).
12
+
13
+ The IR representation is designed to be used as an in-memory form. The IR can be
14
+ dumped to human readable assembly-like format.
15
+
16
+ ### Well-Formedness
17
+
18
+ This section describes the rules that define a valid IR.
19
+
20
+ - Instructions must be dominated by their operands.
21
+
22
+ - Basic block must end with a terminator, which is a branch instruction or a
23
+ return instruction.
24
+
25
+ - There has to be exactly one terminator for each basic block.
26
+
27
+ - AllocStack instructions must appear at the 'entry' basic block (the first basic
28
+ block in the function).
29
+
30
+ - PHI Nodes must appear at the beginning of the basic block and must contain
31
+ an entry for each predecessor.
32
+
33
+ ### Frames:
34
+
35
+ Every JavaScript function is a closure that can capture variables from its
36
+ declaration scope. The declaration scope may be the global scope or another
37
+ function. A closure is a pair of function code, which contains the code of the
38
+ function, and a context which saves the environment that the closure may access.
39
+
40
+ Function variables that are captured by a closure are allocated in a scope on
41
+ the heap and the scope is passed as part of the context to the closure.
42
+ Closures may access variables at all nest-levels, which means that they can
43
+ access multiple scopes. We implement this feature by nesting scopes and linking
44
+ them together. Each scope (the set of captured variables) also has a reference
45
+ to the scope of the caller function. Closures can access variables at different
46
+ nesting levels by loading the parent scope for each scope.
47
+
48
+ At the IR Level we define a few instructions that can load and store frame
49
+ variables. Functions own variables, that are storage units that represent
50
+ variables at the source level. These variables can be optimized away or
51
+ promoted to the stack, etc. We define the AllocStack instruction for allocating
52
+ variable storage. The only instructions that can access the storage values
53
+ (Variable and AllocStack) are the Load and Store instructions. It is not
54
+ possible to save the address of the allocation itself. Depending on the
55
+ implementation of the virtual machine, the heap allocations may be packed into a
56
+ single frame.
57
+
58
+
59
+ ### Types:
60
+
61
+ The Hermes high-level IR is optionally typed. Values may be annotated with the
62
+ expected type of the value. The types are optional and untyped programs are
63
+ correct. The types represent primitive JavaScript types, or refinement of these
64
+ types. All values can be annotated with types: Functions, Instructions and
65
+ Parameters. Annotations of functions represent the type of the returned value.
66
+ The type annotations are not a suggestion or a hint. They must be correct and
67
+ consistent or else the program may fail at run time. Programs are expected to
68
+ run and have the same semantics when the type annotations are stripped.
69
+
70
+ Some instructions in the IR expect operands of specific types, or produce
71
+ specific types. For example, the CondBranch instruction expects the condition
72
+ operand to be annotated as a boolean type. The ToBool instruction produces
73
+ values that are annotated as boolean type.
74
+
75
+ The optimizer may optimize the IR based on type annotations. For example, if the
76
+ operand of the instruction ToBool is annotated with the boolean type then the
77
+ optimizer is free to remove the instruction and replace all uses with the
78
+ operand of the conversion instruction.
79
+
80
+ ### Example:
81
+
82
+ This is a short example of a valid program in textual IR. The function contains
83
+ four basic blocks with a few instructions. The code below follow the
84
+ requirements of a well-formed function defined in the previous section.
85
+
86
+ function forEach(cond : boolean, value : number)
87
+ %BB0:
88
+ %0 = BranchInst %BB1
89
+ %BB1:
90
+ %2 = CondBranchInst %cond, %BB2, %BB3
91
+ %BB2:
92
+ %3 = ReturnInst %cond
93
+ %BB3:
94
+ %4 = ReturnInst %value
95
+
96
+
97
+ ### Side Effects:
98
+
99
+ The instructions in the IR are annotated with side effect labels. The
100
+ labels describe the kind of effect the instruction has on memory, IO
101
+ state (for example, hardware IO such as drawing to a screen or sending
102
+ a network packet), and whether they can throw. The two kind of memory
103
+ side effects are 'read' and 'write'. ('write' actually indicates
104
+ "read and/or write".) These side effect specifications indicate that
105
+ the instruction does not have IO effects or throw. The 'unknown' side
106
+ effect is maximally conservative: it indicates that the instruction
107
+ may read, write, have IO effects, and/or throw. These side effect
108
+ annotations allow the optimizer to decide which optimizations are
109
+ legal. For example, it is not legal to sink instructions that can
110
+ write to memory past each other. It is not legal to hoist instructions
111
+ that read to memory outside of a loop if there is another instruction
112
+ that writes to memory in that loop, because the writer instruction may
113
+ clobber memory that the reader may read.
114
+
115
+ Some instructions that allocate memory are marked as not having any side
116
+ effects. This is because the instructions only touch the newly allocated memory
117
+ and do not influence the rest of the heap. Notice that we don't model the effect
118
+ of instructions on the garbage collector or anything like that, just the content
119
+ of the allocated memory.
120
+
121
+ ## Register allocation
122
+
123
+ In Hermes, register allocation is performed on the IR. An infinite number of
124
+ virtual registers are allocated while preserving the constraints of the IR and
125
+ of the low-level target. Registers are allocated in an attempt to reduce the
126
+ number of registers, values across PhiNodes are coalesced, AllocStack
127
+ instructions are assigned with a dedicated register and arguments to call
128
+ instructions are placed in consecutive registers.
129
+
130
+ While in SSA form, the IR does not support all of the things that can be done
131
+ with registers. This is why the Register Allocator introduces MOV instructions
132
+ that represent a copy of one register to another. We lower some of the
133
+ load/store instructions into MOVs, and spill registers with MOV instructions.
134
+
135
+ ## Generator Overview
136
+
137
+ When generating the IR for a generator function, we make two functions:
138
+ an outer GeneratorFunction and an inner function.
139
+ The outer function calls CreateGenerator on the inner function,
140
+ and returns the resultant generator.
141
+
142
+ An async function is the outer function of its own generator: it calls
143
+ CreateGenerator on the inner function and passes the resultant generator to
144
+ the `spawnAsync` builtin, which drives it.
145
+
146
+ The inner function assumes that it can store and retrieve state from
147
+ its own closure. As such, it contains instructions to start, save/yield,
148
+ and resume generators.
149
+
150
+ CreateGenerator:
151
+ An instruction to create a generator given a `Function`.
152
+ First, it creates an inner GeneratorInnerFunction, then it wraps it in a Generator object.
153
+ Used by the GeneratorFunction to create the generator which is returned upon calling it,
154
+ and by the AsyncFunction to create the generator it passes to `spawnAsync`.
155
+
156
+ StartGenerator:
157
+ Always the first instruction executed when an inner function is called.
158
+ Restores values for all local variables in the generator,
159
+ and jumps to the resume point of the generator if it's suspended.
160
+ If the generator hasn't been started yet, simply continues execution.
161
+
162
+ SaveAndYield:
163
+ Saves necessary state to the closure and yields execution.
164
+ In practice, this will save state and use the return opcode to
165
+ allow the caller to get the yield result.
166
+ Emitting a SaveAndYield also emits its corresponding ResumeGenerator.
167
+
168
+ ResumeGenerator:
169
+ Placed at the start of the block following the SaveAndYield to which it
170
+ corresponds. Resumes execution by loading context from the closure,
171
+ and then using state stored in the closure, does one of 3 things:
172
+ - Continues execution with the result of the instruction being the
173
+ argument to `.next()`.
174
+ - Throws a value immediately
175
+ - Sets an `%isReturn` flag to true, which later instructions may branch on to execute the `finally`
176
+ if necessary, and then return.
177
+
178
+ ## Instruction semantics
179
+
180
+ This section describes the semantic of the instruction that are defined in the
181
+ IR. Please make sure to update this section as new instructions are added to the
182
+ compiler.
183
+
184
+
185
+ ### BranchInst
186
+
187
+ BranchInst | _
188
+ --- | --- |
189
+ Description | Jumps to a different basic block.
190
+ Example | %0 = BranchInst %BB1
191
+ Arguments | A single operand which is the target basic block.
192
+ Semantics | Terminates a basic block and 'jumps' to a different basic block.
193
+ Effects | Does not read or write from memory.
194
+
195
+ ### ReturnInst
196
+
197
+ ReturnInst | _
198
+ --- | --- |
199
+ Description | Leaves the function and returns a value.
200
+ Example | %0 = ReturnInst %17
201
+ Arguments | A single operand which is the returned value. Notice the functions that return without an explicit value return the 'undefined' value.
202
+ Semantics | Terminates a basic block and transfer the control to the caller of the current function.
203
+ Effects | Does not read or write from memory.
204
+
205
+ ### AllocStackInst
206
+
207
+ AllocStackInst | _
208
+ --- | --- |
209
+ Description | Allocates a variable on the stack.
210
+ Example | %0 = AllocStackInst $name
211
+ Arguments | $name is the textual representation of the variable at the sourcecode level.
212
+ Semantics | AllocStack allocates a variable on the stack. Depending on the implementation of the VM, the variables may be packed into a single frame. AllocStack values may be used by instructions in different functions that represent closures created by the current functions. AllocStack values are used to represent local and captured variables. The AllocStack itself needs to be used directly. It is not possible to save a reference to the reference. The lifetime of the AllocStack may not exceed the lifetime of the allocating function.
213
+ Effects | Does not read or write from memory.
214
+
215
+ ### LoadFrameInst
216
+
217
+ LoadFrameInst | _
218
+ --- | --- |
219
+ Description | Loads a value from a variable.
220
+ Example | %1 = LoadFrameInst %scope, %variable
221
+ Arguments | %variable is a location in %scope to load from.
222
+ Semantics | The the instruction reads from a variable. The variable must be valid and found in the given scope.
223
+ Effects | Reads from memory.
224
+
225
+
226
+ ### LoadStackInst
227
+
228
+ LoadStackInst | _
229
+ --- | --- |
230
+ Description | Loads a value from a stack allocated memory pointed by a reference.
231
+ Example | %1 = LoadInst %0
232
+ Arguments | The address from which the instruction loads.
233
+ Semantics | The the instruction reads from memory. The address must be a valid stack address.
234
+ Effects | Reads from memory.
235
+
236
+ ### StoreFrameInst
237
+
238
+ StoreFrameInst | _
239
+ --- | --- |
240
+ Description | Stores a value to a frame variable.
241
+ Example | %1 = StoreFrameInst %scope, %value, %variable
242
+ Arguments | %value is the value to be stored. %variable is a variable in %scope where where the value will be stored.
243
+ Semantics | The the instruction saves a value to memory. The variable must be a real variable found in the scope.
244
+ Effects | Writes to memory.
245
+
246
+ ### StoreStackInst
247
+
248
+ StoreStackInst | _
249
+ --- | --- |
250
+ Description | Stores a value to a stack allocated memory.
251
+ Example | %1 = StoreStackInst %value, %stack_allocated
252
+ Arguments | %value is the value to be stored. %address is the reference to stack allocation.
253
+ Semantics | The the instruction saves a value to memory. The address must be a valid stack allocation.
254
+ Effects | Writes to memory.
255
+
256
+ ### ToPropertyKeyInst
257
+
258
+ ToPropertyKeyInst | _
259
+ --- | --- |
260
+ Description | Converts a JavaScript value into a property key.
261
+ Example | %1 = ToPropertyKeyInst %input
262
+ Arguments | The value to cast.
263
+ Semantics | Implements ES15 7.1.19 ToPropertyKey ( argument ).
264
+ Effects | May execute.
265
+
266
+ ### AsNumberInst
267
+
268
+ AsNumberInst | _
269
+ --- | --- |
270
+ Description | Casts a JavaScript value into a number value.
271
+ Example | %1 = AsNumberInst %input
272
+ Arguments | The value to cast.
273
+ Semantics | The instruction follows the JavaScript rules for converting types into numbers.
274
+ Effects | May read or write to memory.
275
+
276
+ ### AsInt32Inst
277
+
278
+ AsInt32Inst | _
279
+ --- | --- |
280
+ Description | Casts a JavaScript value into a signed 32-bit integer value.
281
+ Example | %1 = AsInt32Inst %input
282
+ Arguments | The value to cast.
283
+ Semantics | The instruction follows the JavaScript rules for converting types into 32-bit signed integers.
284
+ Effects | May read or write to memory.
285
+
286
+ ### AsUint32Inst
287
+
288
+ AsUint32Inst | _
289
+ --- | --- |
290
+ Description | Casts a JavaScript value into an unsigned 32-bit integer value.
291
+ Example | %1 = AsUint32Inst %input
292
+ Arguments | The value to cast.
293
+ Semantics | The instruction follows the JavaScript rules for converting types into 32-bit unsigned integers (equivalent to `>>> 0`).
294
+ Effects | May read or write to memory.
295
+
296
+ ### AddEmptyStringInst
297
+
298
+ AddEmptyStringInst | _
299
+ --- | --- |
300
+ Description | Convert a value to string as if evaluating `value + ''`
301
+ Example | %1 = AddEmptyStringInst %input
302
+ Arguments | The value to cast.
303
+ Semantics | The instruction follows the JavaScript rules for adding an empty string to a value (ES5.1 11.6.1).
304
+ Effects | May read or write to memory or throw.
305
+
306
+ ### CreatePrivateNameInst
307
+
308
+ CreatePrivateNameInst | _
309
+ --- | --- |
310
+ Description | Create a globally unique private value, settings its internal [[Description]] to the given string literal. Practically speakig, this will result in a symbol value created at runtime with its [[Description]] set.
311
+ Example | %1 = CreatePrivateNameInst %descString
312
+ Arguments | %descString is the string description of the name. It must be a string literal.
313
+ Semantics | Allocate a new globally unique private name.
314
+ Effects | Does not read or write to memory.
315
+
316
+ ### CondBranchInst
317
+
318
+ CondBranchInst | _
319
+ --- | --- |
320
+ Description | Jumps to one of two blocks depending on a condition value.
321
+ Example | %1 = CondBranchInst %cond, %BB1, %BB2
322
+ Arguments | %cond is the condition variable, %BB1 is the 'True' block, %BB2 is the 'False' block.
323
+ Semantics | The instruction observes the value of a typed value and jumps to one of two basic blocks. If the condition is evaluated as 'True' the program jumps to the 'True' block. Otherwise the program jumps to the 'False' block.
324
+ Effects | Does not read or write from memory.
325
+
326
+ ### HBCCompareBranchInst
327
+
328
+ HBCCompareBranchInst | _
329
+ --- | --- |
330
+ Description | Performs a binary comparison of the two operands and a conditional branch depending on the result.
331
+ Example | %0 = CompareBranch %x, %y, %BB1, %BB2
332
+ Arguments | %x and %y are the operands of the binary operation, %BB1 is the 'True' block, %BB2 is the 'False' block.
333
+ Semantics | The instruction follows the rules of JavaScript for each one of the binary operators defined in the instruction. If the condition is evaluated as 'True' the program jumps to the 'True' block. Otherwise the program jumps to the 'False' block.
334
+ Effects | May read and write memory.
335
+
336
+ ### HBCFCompareBranchInst
337
+
338
+ HBCFCompareBranchInst | _
339
+ --- | --- |
340
+ Description | Performs a binary comparison of the two numbers and a conditional branch depending on the result.
341
+ Example | %0 = HBCFCompareBranch %x, %y, %BB1, %BB2
342
+ Arguments | %x and %y are the operands of the binary operation, %BB1 is the 'True' block, %BB2 is the 'False' block.
343
+ Semantics | Performs a numeric comparison on the two doubles. If the condition is evaluated as 'True' the program jumps to the 'True' block. Otherwise the program jumps to the 'False' block.
344
+ Effects | Does not read or write to memory.
345
+
346
+ ### HBCCmpBrTypeOfIsInst
347
+
348
+ HBCCmpBrTypeOfIsInst | _
349
+ --- | --- |
350
+ Description | Compare the type of a value against known types and branch.
351
+ Example | %0 = HBCCmpBrTypeOfIsInst %val, %types, %trueBlock, %falseBlock
352
+ Arguments | %val is the argument to the typeof comparison, %types is a TypeOfIsTypes (see Typeof.h), %trueBlock and %falseBlock are the targets
353
+ Semantics | Branch to true if the type of %val matches the bit in %types, false otherwise.
354
+ Effects | Does not read or write memory.
355
+
356
+ ### GetParentScopeInst
357
+
358
+ GetParentScopeInst | _
359
+ --- | --- |
360
+ Description | Retrieve the parent scope of the current function.
361
+ Example | %0 = GetParentScopeInst %varScope, %parentScopeParam
362
+ Arguments | %varScope is the VariableScope that describes the parent environment. %parentScopeParam is dummy parameter used to model usage of the parent environment.
363
+ Semantics | The instruction returns the enclosing environment of the currently executing function.
364
+ Effects | Does not read or write to memory.
365
+
366
+ ### CreateScopeInst
367
+
368
+ CreateScopeInst | _
369
+ --- | --- |
370
+ Description | Creates a new scope which can be used to store variables.
371
+ Example | %0 = CreateScopeInst %variablescope, %parentScope
372
+ Arguments | %variablescope is a VariableScope describing the variables stored in the produced scope. %parentScope is the scope to use as the parent of the new scope, or EmptySentinel if the scope does not have a parent.
373
+ Semantics | The instruction creates a new scope which can be used to store/retrieve variables, and allow inner functions to access variables in an enclosing scope.
374
+ Effects | Does not read or write to memory.
375
+
376
+ ### ResolveScopeInst
377
+
378
+ ResolveScopeInst | _
379
+ --- | --- |
380
+ Description | Traverse the scope chain to retrieve an enclosing scope.
381
+ Example | %0 = ResolveScopeInst %variablescope, %startVarScope, %startScope
382
+ Arguments | %variablescope is the VariableScope corresponding to the enclosing scope to retrieve. %startScope is the scope from which to start traversing. %startVarScope is the VariableScope associated with %startScope.
383
+ Semantics | The instruction retrieves the requested scope, which must be reachable from the starting scope.
384
+ Effects | Does not read or write to memory.
385
+
386
+ ### LIRResolveScopeInst
387
+
388
+ LIRResolveScopeInst | _
389
+ --- | --- |
390
+ Description | Traverse the scope chain to retrieve an enclosing scope.
391
+ Example | %0 = LIRResolveScopeInst %variablescope, %startScope, %numLevels
392
+ Arguments | %variablescope is the VariableScope corresponding to the enclosing scope to retrieve. %startScope is the scope from which to start traversing. %numLevels is the number of levels to walk up the chain.
393
+ Semantics | The instruction retrieves the requested scope, which must be %numLevels up from the starting scope.
394
+ Effects | Does not read or write to memory.
395
+
396
+ ### GetClosureScopeInst
397
+
398
+ GetClosureScopeInst | _
399
+ --- | --- |
400
+ Description | Retrieve the scope from the given closure.
401
+ Example | %0 = GetClosureScopeInst %varScope, %function, %closure
402
+ Arguments | %varScope is the VariableScope that describes the resulting scope. %function is the IR function that the closure operand is known to refer to. %closure is the closure from which to read the scope.
403
+ Semantics | The instruction returns the scope stored in the given closure.
404
+ Effects | Does not read or write to memory.
405
+
406
+ ### CreateFunctionInst
407
+
408
+ CreateFunctionInst | _
409
+ --- | --- |
410
+ Description | Constructs a new function into the current scope from its code representation.
411
+ Example | %0 = CreateFunction %scope, %varScope, %function
412
+ Arguments | %function is the function that represents the code of the generated closure. %scope is the surrounding environment. %varScope is the VariableScope that describes %scope.
413
+ Semantics | The instruction creates a new closure that may access the lexical scope of the current function
414
+ Effects | Does not read or write to memory.
415
+
416
+ ### CreateClassInst
417
+
418
+ CreateClassInst | _
419
+ --- | --- |
420
+ Description | Constructs a new class into the current scope from its constructor code representation.
421
+ Example | %0 = CreateClassInst %scope, %varScope, %function, %superClass, %homeObjectOutput
422
+ Arguments | %function is the function that represents the code of the constructor. %scope is the surrounding environment. %varScope is the VariableScope that describes %scope. %superClass is the class to inherit from; in base classes this is an empty sentinel value. %homeObjectOutput is an out parameter which will contain the home object (.prototype) of the class.
423
+ Semantics | The instruction creates a new class that may access the lexical scope of the current function, and an inherit from a given super class. (ES2023 15.7.14) This results in the creation of 2 objects: the class function object itself, and the "home" object. The home object is where methods are put. The home object can be found on the .prototype of the class, and the class can be found on the .constructor of the home object.
424
+ Effects | Writes to stack memory. May execute JS if it's a derived class.
425
+
426
+ ### BinaryOperatorInst
427
+
428
+ BinaryOperatorInst | _
429
+ --- | --- |
430
+ Description | Performs the binary operation on the two operands.
431
+ Example | %0 = BinaryOperatorInst %x, %y
432
+ Arguments | %x and %y are the operands of the binary operation.
433
+ Semantics | The instruction follows the rules of JavaScript for each one of the binary operators defined in the instruction.
434
+ Effects | May read and write memory.
435
+
436
+ ### DirectEvalInst
437
+
438
+ DirectEvalInst | _
439
+ --- | --- |
440
+ Description | Implement direct eval.
441
+ Example | `%0 = DirectEvalInst %%evalText, %strictCaller`
442
+ Arguments | %evalArg is the value which will be evaluated.
443
+ Semantics | Implement the semantics of ES6 `PerformEval(%evalText, evalRealm, strictCaller, direct=true)` (ES6 18.2.1.1).
444
+ Effects | Unknown
445
+
446
+ ### CreateThisInst
447
+
448
+ CreateThisInst | _
449
+ --- | --- |
450
+ Description | Creates the object to be used as the `this` parameter of a construct call.
451
+ Example | %0 = CreateThisInst %closure, %newtarget, %functionCode
452
+ Arguments | %closure is the closure that will be invoked as a constructor, it may be any value, and the instruction will throw if it is not a valid callable. %newtarget is the new.target value to use for the call, it must either be the same value as %closure, or a valid callable. %functionCode is the IR function that is known to be associated with the closure operand, or EmptySentinel.
453
+ Semantics | The instruction is responsible for preparing the `this` parameter of a construct call. If %closure is a legacy class constructor, the instruction does not do anything and immediately produces undefined, since those constructors handle creating `this` internally. Otherwise, this the instruction determines the `new.target` to use for retrieving the `.prototype` (which may involve iterating over bound functions), reads the `.prototype` from it, and creates an object with that value as its parent.
454
+ Effects | May execute JS if %closure is not a legacy class constructor.
455
+
456
+ ### CallInst
457
+
458
+ CallInst | _
459
+ --- | --- |
460
+ Description | Calls another function with some arguments.
461
+ Example | %0 = CallInst %callee, %target, %calleeIsAlwaysClosure, %env, %newtarget %this, %arg0, %arg1, %arg2, ...
462
+ Arguments | %callee is the closure to execute. %target is either EmptySentinel or the only possible Function this call can invoke. %calleeIsAlwaysClosure indicates whether the callee needs to be checked for being a function. %env is the environment for the function or EmptySentinel. %newtarget is the new.target value to use for the call. %this is a reference to the 'this' value. Arguments %arg0 ... %argN are the arguments passed to the function.
463
+ Semantics | The instruction passes the control to the callee, that must be of closure type. The arguments are mapped to the parameters. Unmapped parameters are initialized to 'undefined'.
464
+ Effects | May read and write memory.
465
+
466
+ ### CallBuiltinInst
467
+
468
+ CallBuiltinInst | _
469
+ --- | --- |
470
+ Description | Calls a builtin function passing "undefined" for this
471
+ Example | %0 = CallBuiltinInst %builtinNumber, %undefined, %undefined, %arg0, %arg1, %arg2, ...
472
+ Arguments | %builtinNumber is the builtin to execute. Arguments %arg0 ... %argN are the arguments passed to the function.
473
+ Semantics | The instruction passes the control to the builtin in a VM-specific way. The arguments are mapped to the parameters. Unmapped parameters are initialized to 'undefined'.
474
+ Effects | May read and write memory.
475
+
476
+ ### CallIntrinsicInst
477
+
478
+ CallIntrinsicInst | _
479
+ --- | --- |
480
+ Description | Calls an unsafe compiler intrinsic, passing "undefined" for this
481
+ Example | %0 = CallIntrinsicInst %intrinsicsIndex, %undefined, %arg0, %arg1, %arg2, ...
482
+ Arguments | %intrinsicsIndex is the intrinsic to execute. Arguments %arg0 ... %argN are the arguments passed to the function.
483
+ Semantics | The instruction passes the control to the intrinsics in a VM-specific way. The arguments are mapped to the parameters.
484
+ Effects | May read and write memory.
485
+
486
+ ### GetBuiltinClosureInst
487
+
488
+ GetBuiltinClosureInst | _
489
+ --- | --- |
490
+ Description | Get a closure of a builtin function
491
+ Example | %0 = GetBuiltinClosureInst %builtinNumber
492
+ Arguments | %builtinNumber is the builtin to return the closure of.
493
+ Semantics |
494
+ Effects | Reads from memory.
495
+
496
+ ### LoadPropertyInst
497
+
498
+ LoadPropertyInst | _
499
+ --- | --- |
500
+ Description | Loads the value of a field from a JavaScript object.
501
+ Example | %0 = LoadPropertyInst %object, %property
502
+ Arguments | %object is the object to load from. %property is the name of the field.
503
+ Semantics | The instruction follows the rules of JavaScript property access in ES5.1 sec 11.2.1. The operation GetValue (ES5.1. sec 8.7.1) is then applied to the returned Reference.
504
+ Effects | May read and write memory or throw.
505
+
506
+ ### LoadOwnPrivateFieldInst
507
+
508
+ LoadOwnPrivateFieldInst | _
509
+ --- | --- |
510
+ Description | Loads the value of a private name from a JavaScript object.
511
+ Example | %0 = LoadOwnPrivateFieldInst %object, %property : symbol
512
+ Arguments | %object is the object to load from. %property is the private name symbol.
513
+ Semantics | The instruction honors ES2024 7.3.30 PrivateGet. It looks up a private name on the object and throws if it does not exist. However, this does not have to deal with accessors or methods because those are stored outside of the instance.
514
+ Effects | May execute JS.
515
+
516
+ TryLoadGlobalPropertyInst | _
517
+ --- | --- |
518
+ Description | Loads the value of an existing field from the global object or throw if it doesn't exist.
519
+ Example | %0 = TryLoadGlobalPropertyInst %object, %property
520
+ Arguments | %object is the global object. %property is the name of the field, which must be a string literal.
521
+ Semantics | Similar to LoadPropertyInst, but throw if the field doesn't exist.
522
+ Effects | May read and write memory or throw.
523
+
524
+ ### LoadPropertyWithReceiverInst
525
+
526
+ LoadPropertyWithReceiverInst | _
527
+ --- | --- |
528
+ Description | Loads the value of a field from a JavaScript object.
529
+ Example | %0 = LoadPropertyWithReceiverInst %object, %property, %receiver
530
+ Arguments | %object is the object to load from. %property is the name of the field. %receiver is receiver of the operation.
531
+ Semantics | The instruction implements ES2024 6.2.5.5 GetValue. This is used for `super` references.
532
+ Effects | May read and write memory or throw.
533
+
534
+ ### DeletePropertyInst
535
+
536
+ DeletePropertyInst | _
537
+ --- | --- |
538
+ Description | Deletes the value of a field from a JavaScript object.
539
+ Example | %0 = DeletePropertyInst %object, %property
540
+ Arguments | %object is the object to modify. %property is the name of the field.
541
+ Semantics | The instruction follows the rules of JavaScript property access.
542
+ Effects | May read and write memory.
543
+
544
+ ### StorePropertyInst
545
+
546
+ StorePropertyInst | _
547
+ --- | --- |
548
+ Description | Stores a value to field in a JavaScript object.
549
+ Example | %4 = StorePropertyInst %value, %object, %property
550
+ Arguments | %value is the value to be stored. %object is the object where the field %property will be created or modified.
551
+ Semantics | The instruction follows the rules of JavaScript property access in ES5.1 sec 11.2.1. The operation PutValue (ES5.1. sec 8.7.2) is then applied to the returned Reference.
552
+ Effects | May read and write memory or throw.
553
+
554
+
555
+ ### StorePropertyWithReceiverInst
556
+
557
+ StorePropertyWithReceiverInst | _
558
+ --- | --- |
559
+ Description | Stores a value to field in a JavaScript object, with a specified receiver object.
560
+ Example | %4 = StorePropertyWithReceiverInst %value, %object, %property, %receiver, %isStrict
561
+ Arguments | %value is the value to be stored. %object is the object where the field %property will be created or modified. %receiver will be the receiver operand when invoking the `[[Set]] ` internal method. If %isStrict is true, the operation will fail if there is an incompatible property descriptor found during the attempted store..
562
+ Semantics | This follows the same semantics as StorePropertyInst, except the receiver is explicitly specified.
563
+ Effects | May read and write memory or throw.
564
+
565
+ ### TryStoreGlobalPropertyInst
566
+
567
+ TryStoreGlobalPropertyInst | _
568
+ --- | --- |
569
+ Description | Attempt to store a value into an existing field of the global object and throw if it doesn't exist.
570
+ Example | %4 = TryStoreGlobalPropertyInst %value, %object, %property
571
+ Arguments | %value is the value to be stored. %object is the global object, where the field %property will be stored. %property must be a string literal.
572
+ Semantics | Similar to StorePropertyInst, but throw if the field doesn't exist.
573
+ Effects | May read and write memory or throw.
574
+
575
+ ### DefineOwnPropertyInst
576
+
577
+ DefineOwnPropertyInst | _
578
+ --- | --- |
579
+ Description | Define an *own property* of JavaScript object. Will throw if the property write was not successful (e.g. trying to store to a non-writable property.)
580
+ Example | %4 = DefineOwnPropertyInst %value, %object : object, %property, %enumerable : boolean
581
+ Arguments | %value is the value to be stored. %object *must* be of an object type; it's the object where the field with name %property will be created or modified. %enumerable determines whether a new property will be created as enumerable or not.
582
+ Semantics | Implements ES15 7.3.8 DefinePropertyOrThrow. The instruction follows the rules of JavaScript *own* property access. The property is created or updated in the instance of the object, regardless of whether the same property already exists earlier in the prototype chain.
583
+ Effects | May read and write memory.
584
+
585
+ ### DefineOwnInDenseArrayInst
586
+
587
+ DefineOwnInDenseArrayInst | _
588
+ --- | --- |
589
+ Description | Define an *own property* in a dense JavaScript array at a specific index. This is an optimized version for dense array property assignment. Used only when populating newly created array literals.
590
+ Example | %0 = DefineOwnInDenseArrayInst %value, %array : object, %arrayIndex : LiteralNumber
591
+ Arguments | %value is the value to be stored. %array is the dense array object where the property will be defined. %arrayIndex is a literal number representing the array index where the property will be stored.
592
+ Semantics | This instruction is used for efficient property definition. It requires that the array is dense and that the ArrayStorage underlying it has a size which is greater than the arrayIndex operand. The property is defined directly at the specified index without prototype chain traversal.
593
+ Effects | Writes to heap.
594
+
595
+
596
+ ### StoreOwnPrivateFieldInst
597
+
598
+ StoreOwnPrivateFieldInst | _
599
+ --- | --- |
600
+ Description | Store a private *own property* to an object.
601
+ Example | `%4 = StoreOwnPrivateFieldInst %value, %object, %property : symbol, %enumerable : boolean`
602
+ Arguments | *%value* is the value to be stored. *%object* should be an object, if not this throws. *%property* must be the value of a symbol. *%enumerable* must always be false.
603
+ Semantics | This instruction implements ES2024 7.3.31 PrivateSet. This instruction will throw if the private property does not already exist on %object.
604
+ Effects | May read and write memory.
605
+
606
+ ### AddOwnPrivateFieldInst
607
+
608
+ AddOwnPrivateFieldInst | _
609
+ --- | --- |
610
+ Description | Add a new private own field.
611
+ Example | `%4 = AddOwnPrivateFieldInst %value, %object, %property : symbol, %enumerable : boolean`
612
+ Arguments | *%value* is the value to be stored. *%object* must be an object. *%property* must be the value of a symbol. *%enumerable* should always be false.
613
+ Semantics | This instruction is used to initialize private fields on objects. As such it implements ES2024 7.3.27 PrivateFieldAdd- except this instruction will assume that the property being added does not already exist.
614
+ Effects | May read and write memory.
615
+
616
+ ### PrivateBrandCheckInst
617
+
618
+ PrivateBrandCheckInst | _
619
+ --- | --- |
620
+ Description | Check that an object has a private brand installed.
621
+ Example | `PrivateBrandCheckInst %object, %brand : privateName`
622
+ Arguments | *%object* is the object to check. *%brand* must be a private name representing the brand to look for.
623
+ Semantics | This instruction implements the brand check for private methods and accessors. It throws a TypeError if the brand is not present on the object.
624
+ Effects | May read memory and throw.
625
+
626
+ ### DefineOwnGetterSetterInst
627
+
628
+ DefineOwnGetterSetterInst | _
629
+ --- | --- |
630
+ Description | Associates a pair of getter and setter with an *own* field in a JavaScript object, replacing the previous value.
631
+ Example | %4 = DefineOwnGetterSetterInst %getter, %setter, %object, %property, %enumerable
632
+ Arguments | %getter is a getter accessor, or undefined. %setter is a setter accessor, or undefined. %object is the object where the field %property will be created or modified. %enumerable determines whether a new property will be created as enumerable or not.
633
+ Semantics | The instruction follows the rules of JavaScript property access. The property is created or updated in the instance of the object, regardless of whether the same property already exists earlier in the prototype chain. It replaces both accessors even if one or both of the parameters are undefined.
634
+ Effects | May read and write memory.
635
+
636
+ ### AllocObjectInst
637
+
638
+ AllocObjectInst | _
639
+ --- | --- |
640
+ Description | Allocates a new JavaScript object on the heap.
641
+ Example | `%0 = AllocObjectInst %sizeHint : LiteralNumber, %parent : EmptySentinel or null or Value`
642
+ Arguments | *%sizeHint% indicates that the object will need at least that many property slots. *%parent* is the optional parent to create the object with: *EmptySentinel* means use *Object.prototype*, *null* means no parent, or otherwise use the specified value.
643
+ Semantics | The instruction creates a new JavaScript object on the heap. If the parent is invalid (not EmptySenyinel, null or object), it is silently ignored.
644
+ Effects | Does not read or write to memory.
645
+
646
+ ### AllocObjectLiteralInst
647
+
648
+ AllocObjectLiteralInst | _
649
+ --- | --- |
650
+ Description | Allocates a new JavaScript object on the heap. During lowering pass it will be lowered to either an AllocObjectInst or a LIRAllocObjectFromBufferInst.
651
+ Example | %0 = AllocObjectLiteralInst %parent, "prop1" : string, 10 : number
652
+ Arguments | %parent is the parent of the new object. %prop_map is a vector of (Literal*, value*) pairs which represents the properties and their keys in the object literal.
653
+ Semantics | The instruction creates a new JavaScript object on the heap with an initial list of properties.
654
+ Effects | Does not read or write to memory.
655
+
656
+ ### AllocTypedObjectInst
657
+
658
+ AllocTypedObjectInst | _
659
+ --- | --- |
660
+ Description | Allocates a new typed object on the heap. During lowering pass it will be lowered to either an AllocObjectInst or a LIRAllocObjectFromBufferInst.
661
+ Example | %0 = AllocTypedObjectInst %parent, "prop1" : string, 10 : number
662
+ Arguments | %parent is the parent of the new object, and the other operands are alternating (Literal*, value*) pairs which represent the properties and their keys in the typed class.
663
+ Semantics | The instruction creates a new JavaScript object on the heap with an initial list of properties, which may include 'uninit' values. Properties are enumerable.
664
+ Effects | Does not read or write to memory.
665
+
666
+ ### AllocTypedNonEnumObjectInst
667
+
668
+ AllocTypedNonEnumObjectInst | _
669
+ --- | --- |
670
+ Description | Allocates a new typed object on the heap with non-enumerable properties. Used for home objects (class prototypes with methods). During lowering pass it will be lowered to a LIRAllocTypedNonEnumObjectFromBufferInst.
671
+ Example | %0 = AllocTypedNonEnumObjectInst %parent, "prop1" : string, 10 : number
672
+ Arguments | %parent is the parent of the new object, and the other operands are alternating (Literal*, value*) pairs which represent the properties and their keys in the typed class.
673
+ Semantics | The instruction creates a new JavaScript object on the heap with an initial list of non-enumerable properties, which may include 'uninit' values.
674
+ Effects | Does not read or write to memory.
675
+
676
+ ### AllocArrayInst
677
+
678
+ AllocArrayInst | _
679
+ --- | --- |
680
+ Description | Allocates a new JavaScript array on the heap.
681
+ Example | %0 = AllocArrayInst %sizeHint, %value0, %value1, ...
682
+ Arguments | sizeHint tells the size of the array that the VM should allocate. It must be equal or larger than the initial list of elements in this instruction. The rest of the values are all literal values as the initial elements of the array. Non-literal values or values after elision will be inserted into the array separately.
683
+ Semantics | The instruction creates a new JavaScript array on the heap with a hinted size and initial list of elements.
684
+ Effects | Does not read or write to memory.
685
+
686
+ ### AllocFastArrayInst
687
+
688
+ AllocFastArrayInst | _
689
+ --- | --- |
690
+ Description | Allocates a new FastArray on the heap.
691
+ Example | %0 = AllocFastArrayInst %capacity
692
+ Arguments | %capacity is a hint to the VM for how large the initial capacity should be.
693
+ Semantics | The instruction creates a new empty FastArray on the heap.
694
+ Effects | Does not read or write to memory.
695
+
696
+ ### GetTemplateObjectInst
697
+
698
+ GetTemplateObjectInst | _
699
+ --- | --- |
700
+ Description | Gets the object to pass to the tagged template function.
701
+ Example | %0 = GetTemplateObjectInst %templateObjID, %dup, %string1, ...
702
+ Arguments | %templateObjID is the cache key for the template. %dup indicates whether the raw strings are duplicates of the cooked strings. If %dup is true, then all %string operands are raw. Otherwise, some number of raw %string operands are followed by the _same_ number of cooked %string operands.
703
+ Semantics | If cached, retrieves from the template cache. Otherwise, updates the cache with a new template object with the cooked strings, which also contains an object containing the raw strings. Returns the resultant object.
704
+ Effects | Does not read or write to program memory. Updates template cache.
705
+
706
+ ### TypeOfInst
707
+
708
+ TypeOfInst | _
709
+ --- | --- |
710
+ Description | The JS `typeof` operator
711
+ Example | %0 = TypeOfInst %val
712
+ Arguments | %val is the value whose type we want to obtain.
713
+ Semantics | Obtains a string representing the type of the operand.
714
+ Effects | Does not read or write to memory.
715
+
716
+ ### TypeOfIsInst
717
+
718
+ TypeOfIsInst | _
719
+ --- | --- |
720
+ Description | Compare the type of a value against known types
721
+ Example | %0 = TypeOfIsInst %val, %types
722
+ Arguments | %val is the value whose type we want to compare, %types is the TypeOfIsTypes (see Typeof.h) to compare against.
723
+ Semantics | Returns true if the type of %val matches the bit in the TypeOfIsTypes, false otherwise.
724
+ Effects | Does not read or write to memory.
725
+
726
+ ### CreateArgumentsInst
727
+
728
+ CreateArgumentsInst | _
729
+ --- | --- |
730
+ Description | Allocates the JavaScript `arguments` array-like object on the heap.
731
+ Example | %0 = CreateArgumentsInst
732
+ Arguments | None.
733
+ Semantics | The instruction creates the `arguments` object, populates it with copies of the values of the arguments (according to "strict mode" semantics) and sets `arguments.length` to the number of arguments (`this` isn't copied or counted). There should be only one CreateArgumentsInst in a function.
734
+ Effects | Does not read or write to memory.
735
+
736
+ ### CreateRegExpInst
737
+
738
+ CreateRegExpInst | _
739
+ --- | --- |
740
+ Description | Construct a RegExp object from a regexp literal.
741
+ Example | %0 = CreateRegExpInst "pattern", "flags"
742
+ Arguments | `pattern: LiteralString` and `flags: LiteralString`
743
+ Semantics | It is equivalent to calling `RegExp(pattern, flags)`, except that it calls the built-in constructor, even if `RegExp` has been overridden.
744
+ Effects | Does not read or write to memory.
745
+
746
+ ### SwitchInst
747
+
748
+ SwitchInst | _
749
+ --- | --- |
750
+ Description | The ‘switch‘ instruction is used to transfer control to one of different places.
751
+ Example | %0 = SwitchInst %input, %default, [%val0, %block0], [%val1, %block1] ..
752
+ Arguments | The instruction accepts an input, a default block, and one or more pairs of value-destination values. The value must be a primitive JS type, and the destination must be a basic block within the current function.
753
+ Semantics | The semantic of the instruction is identical to a sequence of 'if' statements that compare the value of the input to each of the case statements. Repeating the same value is not allowed.
754
+ Effects | May read and write memory.
755
+
756
+ ### GetPNamesInst
757
+
758
+ GetPNamesInt | _
759
+ --- | --- |
760
+ Description | Generates the property enumerator, which is a collection of registers that hold the state of the enumerator (iterator, object base, index, size, etc).
761
+ Example | %0 = GetPNamesInt %propertyAddr, %baseAddr, %indexAddr, %sizeAddr, %iteratorAddr, %onEmpty, %onLast
762
+ Arguments | The first 5 parameters are addresses (stack allocated addresses) that represent the state of the property enumerator. The last two argument are jump destination for the two cases: empty object and object with some properties.
763
+ Semantics | This instruction is a terminator instruction and prepares the enumerator for the GetNextPNameInst instruction to consume.
764
+ Effects | May read and write memory.
765
+
766
+ ### GetNextPNameInst
767
+
768
+ GetNextPNameInst | _
769
+ --- | --- |
770
+ Description | Loads the next property from the object property enumerator.
771
+ Example | %0 = GetNextPNameInst %propertyAddr, %baseAddr, %indexAddr, %sizeAddr, %iteratorAddr, %onLast, %onSome
772
+ Arguments | The first argument is the destination where the name of the property is written into. The next 4 arguments are the state of the property enumerator. The last two arguments are the destination blocks for: no next property, or some property available.
773
+ Semantics | This instruction is a terminator instruction that uses the state that was prepared by the GetPNamesInst instruction.
774
+ Effects | May read and write memory.
775
+
776
+ ### CatchInst
777
+
778
+ CatchInst | _
779
+ --- | --- |
780
+ Description | This instruction catches an exception, and returns that exception.
781
+ Example | %0 = CatchInst
782
+ Arguments | This instruction does not have arguments.
783
+ Semantics | This instruction will be generated for each catch block and for each finally block. The current exception will be returned. CatchInst can only show up at the beginning of a basic block. The coverage and depth information for the CatchInst will be constructed dynamically later during bytecode generation.
784
+ Effects | May read and write memory.
785
+
786
+ ### ThrowInst
787
+
788
+ ThrowInst | _
789
+ --- | --- |
790
+ Description | This instruction will throw an exception.
791
+ Example | %0 = ThrowInst %e, %catchTarget
792
+ Arguments | This instruction takes one required operand, which is the register that contains the exception value. The second operand is optional and indicates the closest surrounding catch block; it must be present if there is one, and must be missing otherwise.
793
+ Semantics | This instruction is a terminator instruction that will transition the control to the CatchInst that covers this instruction with closest scope.
794
+ Effects | May read and write memory.
795
+
796
+ ### ThrowTypeErrorInst
797
+
798
+ ThrowTypeErrorInst | _
799
+ --- | --- |
800
+ Description | This instruction will create and throw a TypeError.
801
+ Example | %0 = ThrowTypeErrorInst %message
802
+ Arguments | This instruction takes one argument, %message, which will be converted to a string and used as the message for the TypeError.
803
+ Semantics | This instruction is a terminator instruction that will transition the control to the CatchInst that covers this instruction with closest scope.
804
+ Effects | Will throw.
805
+
806
+ ### TryStartInst
807
+
808
+ TryStartInst | _
809
+ --- | --- |
810
+ Description | Mark the beginning of the try blocks.
811
+ Example | %0 = TryStartInst %catchTargetBlock, %tryBodyBlock
812
+ Arguments | This instruction takes 2 arguments: %tryBodyBlock is the block where the body of Try starts, %catchTargetBlock is the basic block that contains the CatchInst which covers this try. Both %tryBodyBlock and %catchTargetBlock are successors of this instruction.
813
+ Semantics | This is a nop, used only for tracking the beginning of try blocks.
814
+ Effects | Does not read or write memory.
815
+
816
+ ### TryEndInst
817
+
818
+ TryEndInst | _
819
+ --- | --- |
820
+ Description | A terminator that marks the end of the try blocks.
821
+ Example | %0 = TryEndInst %CatchBlock, %BranchDest
822
+ Arguments | The active catch block and the destination block to branch to.
823
+ Semantics | This is a nop, used only for tracking the end of try blocks.
824
+ Effects | Technically this instruction itself does not touch memory, however we mark it as may write to prevent optimizations going pass this instruction.
825
+
826
+ ### BranchIfBuiltinInst
827
+
828
+ BranchIfBuiltinInst | _
829
+ --- | --- |
830
+ Description | Check if a value is the same as a known builtin value.
831
+ Example | %0 = BranchIfBuiltin %builtinNumber, %arg, %trueDest, %falseDest
832
+ Arguments | The builtin number, the value to check, and the blocks to branch to.
833
+ Semantics | Branch to %trueDest if %arg is the same pointer as the builtin with %builtinNumber, else branch to %falseDest.
834
+ Effects | None
835
+
836
+ ### PhiInst
837
+
838
+ PhiInst | _
839
+ --- | --- |
840
+ Description | This is a Phi node instruction.
841
+ Example | %0 = PhiInst %value0, %block0, [%value1, %block1]
842
+ Arguments | A list of pairs of value and incoming basic block.
843
+ Semantics | The PhiNode needs to have a single entry for each incoming basic block of the block the PHI is located in. The incoming value must dominate the last instruction in the incoming block.
844
+ Effects | Does not read or write memory.
845
+
846
+ ### MovInst
847
+
848
+ MovInst | _
849
+ --- | --- |
850
+ Description | The MOV inst represents a low-level operation of moving one register to another.
851
+ Example | %0 = MovInst %value0
852
+ Arguments | Any value.
853
+ Semantics | The Mov instruction is only valid after Register Allocation in bytecode as we move away from SSA form.
854
+ Effects | Does not read or write memory.
855
+
856
+ ### ImplicitMovInst
857
+
858
+ ImplicitMovInst | _
859
+ --- | --- |
860
+ Description | The ImplicitMov inst represents moving one register to another, except the mov will be performed implicitly by an immediately-subsequent instruction. This is used to express to the optimizer instructions which modify registers other than their destination.
861
+ Example | %0 = ImplicitMovInst %value0
862
+ Arguments | Any value.
863
+ Semantics | The ImplicitMov instruction is only valid after Register Allocation in bytecode as we move away from SSA form.
864
+ Effects | Does not read or write memory.
865
+
866
+
867
+ ### DebuggerInst
868
+
869
+ DebuggerInst | _
870
+ --- | --- |
871
+ Description | This instruction corresponds to the JavaScript `debugger` statement.
872
+ Example | %0 = DebuggerInst
873
+ Arguments | It takes no arguments and returns no values.
874
+ Semantics | Its behavior is implementation-dependent.
875
+ Effects | Does not read or write to memory.
876
+
877
+ ### GetNewTargetInst
878
+
879
+ GetNewTargetInst | _
880
+ --- | --- |
881
+ Description | Obtains the value of `new.target` in the current function or constructor.
882
+ Example | %0 = GetNewTargetInst, %param
883
+ Arguments | %param is a dummy JSDynamicParam used to quickly find usages of `new.target`.
884
+ Semantics | It must only be called from a ES6 class constructor or ES5 function. If the callee was invoked from `new`, it returns the function object of the direct constructor, otherwise `undefined`.
885
+ Effects | Does not read or write memory
886
+
887
+ ### ThrowIfInst
888
+
889
+ ThrowIfInst | _
890
+ --- | --- |
891
+ Description | Check whether the value belongs to one of the "rejected" types, and if it is, throw ReferenceError, otherwise return it.
892
+ Example | %_ = ThrowIfInst %value, %rejectedTypesUnion
893
+ Arguments | %value is the value to check. %rejectedTypesUnion is a union of types that should be rejected.
894
+ Semantics | It is used to implement ES6 TDZ functionality. Variables declared with `let` are *poisoned* with *empty* until they are initialized.
895
+ Effects | Potentially throws an exception. Has no other side effects.
896
+
897
+ ### ThrowIfThisInitializedInst
898
+
899
+ ThrowIfThisInitializedInst | _
900
+ --- | --- |
901
+ Description | Check whether the value of `this` in a derived class constructor is already initialized. If so, throw.
902
+ Example | %_ = ThrowIfThisInitializedInst %thisVal
903
+ Arguments | %thisVal is the value to check.
904
+ Semantics | This is used to guard against double-initialization of `this`, which happens by invoking `super()` multiple times.
905
+ Effects | Potentially throws an exception. Has no other side effects.
906
+
907
+ ### CoerceThisNS
908
+
909
+ CoerceThisNS | _
910
+ --- | --- |
911
+ Description | Coerces its argument using the rules of "this" coercion to object in non-strict mode.
912
+ Example | %0 = CoerceThisNS %value0
913
+ Arguments | Any value.
914
+ Semantics |
915
+ Effects | Does not read or write memory (it potentially creates a new object)
916
+
917
+ ### CreateGenerator
918
+
919
+ CreateGenerator | _
920
+ --- | --- |
921
+ Description | Constructs a new GeneratorInnerFunction from its code representation, and wraps it in a Generator object.
922
+ Example | %0 = CreateFunction %scope, %varScope, %function
923
+ Arguments | %function is the function that represents the code of the generator's inner function. %scope is the surrounding environment. %varScope is the VariableScope that describes %scope.
924
+ Semantics | Creates a new GeneratorInnerFunction closure that may access the environment and wraps it in a generator
925
+ Effects | Does not read or write to memory (creates a new object).
926
+
927
+ ### SaveAndYield
928
+
929
+ SaveAndYield | _
930
+ --- | --- |
931
+ Description | Saves information needed to resume generator execution and yield.
932
+ Example | %0 = SaveAndYield %value, %isDelegated, %next
933
+ Arguments | %value is the value to yield, %isDelegated determines if the value to be yielded should be wrapped (true when inside a yield*), %next is the next BasicBlock to execute upon resuming, which must begin with a ResumeGeneratorInst (generated alongside SaveAndYield).
934
+ Semantics | Saves the frame variables and the next IP to the closure, and yield execution.
935
+ Effects | Reads and writes to memory, may throw or execute.
936
+
937
+ ### ResumeGenerator
938
+
939
+ ResumeGenerator | _
940
+ --- | --- |
941
+ Description | Perform the user-requested action on resuming a generator.
942
+ Example | %0 = ResumeGenerator %isReturn
943
+ Arguments | %isReturn is an output argument set to true if the user requested a return, false otherwise.
944
+ Semantics | If the user requested next(), continue on. If the user requested throw(), throw. If the user requested return(), set %isReturn to true and continue. Subsequent instructions will check %isReturn and execute any `finally` handlers, for example, before returning.
945
+ Effects | May read and write memory. (may throw)
946
+
947
+ ### IteratorBegin
948
+
949
+ IteratorBegin | _
950
+ --- | --- |
951
+ Description | Begins array destructuring on a given iterable source.
952
+ Example | %0 = IteratorBegin %sourceOrNext
953
+ Arguments | %sourceOrNext[in/out] is the stack location for source to destructure from. Is set to source if performing array iteration, else set to the `.next()` method of the iterator.
954
+ Semantics | If %sourceOrNext is an Array then it remains unmodified and the instruction returns `0`, but if it is not, it is replaced with the 'next' method so that it can be called on each step of the iteration and the instruction returns the iterator object. If the `[Symbol.iterator]` function throws, this instruction will throw.
955
+ Effects | May read and write memory, may throw or execute.
956
+
957
+ ### IteratorNext
958
+
959
+ IteratorNext | _
960
+ --- | --- |
961
+ Description | Destructures the next value from a given iterator.
962
+ Example | %0 = IteratorNext %iterator %sourceOrNext
963
+ Arguments | %iterator is the index or the iterator. %sourceOrNext is the input stack location (source to destructure from) or the next method.
964
+ Semantics | If %iterator is an index: if %iterator is less than `%sourceOrNext.length`, reads the value from %sourceOrNext and increments the index, else sets %iterator to undefined and returns undefined. If %iterator is an actual iterator, calls %sourceOrNext as a next method and evaluates to the result value. When iteration is complete, sets %iterator to undefined as a signal that we're done.
965
+ ```
966
+ if (typeof %iterator === 'undefined') {
967
+ return undefined;
968
+ }
969
+ if (typeof %iterator === 'number') {
970
+ if (%iterator >= %sourceOrNext.length) {
971
+ %iterator = undefined;
972
+ return undefined;
973
+ }
974
+ return %sourceOrNext[%iterator];
975
+ }
976
+ var iterResult = %sourceOrNext();
977
+ if (iterResult.done) {
978
+ %iterator = undefined;
979
+ return undefined;
980
+ }
981
+ return iterResult.value;
982
+ ```
983
+ Effects | May read and write memory, may throw or execute.
984
+
985
+ ### IteratorClose
986
+
987
+ IteratorClose | _
988
+ --- | --- |
989
+ Description | Closes an iterator if it exists.
990
+ Example | %0 = IteratorClose %iterator %ignoreInnerException
991
+ Arguments | %iterator is the index or the iterator. %ignoreInnerException is a boolean literal.
992
+ Semantics | If %iterator is an iterator, calls `.return()` on it to close it. Otherwise, this is a no-op. If `.return()` throws, the exception is ignored when %ignoreInnerException is true.
993
+ Effects | May read and write memory, may throw or execute.
994
+
995
+ ### UnreachableInst
996
+
997
+ UnreachableInst | _
998
+ --- | --- |
999
+ Description | Crashes the VM (ifndef NDEBUG).
1000
+ Example | %0 = UnreachableInst
1001
+ Arguments | None.
1002
+ Semantics | Can be added to stubs and similar to verify that they are never executed.
1003
+ Effects | Marked as reading/writing memory to avoid reordering.
1004
+
1005
+ ## Target Instructions
1006
+
1007
+ Some high-level IR instructions are lowered into a sequence of low-level machine
1008
+ instructions. In order to perform register allocation on these instructions we
1009
+ need to perform lowering, which is a form of instruction selection. The semantic
1010
+ of these instructions are identical to the semantic of the relevant target
1011
+ instructions.
1012
+
1013
+ ### LIRGetGlobalObjectInst
1014
+
1015
+ LIRGetGlobalObjectInst | _
1016
+ --- | --- |
1017
+ Description | Obtain the "global" object
1018
+ Example | %0 = LIRGetGlobalObjectInst
1019
+ Arguments | None.
1020
+ Semantics | The instruction returns a reference to the "global" object.
1021
+ Effects | Does not read or write to memory.
1022
+
1023
+ ### HBCCreateFunctionEnvironmentInst
1024
+
1025
+ HBCCreateFunctionEnvironmentInst | _
1026
+ --- | --- |
1027
+ Description | Create a new environment with the function's parent environment as its parent.
1028
+ Example | %0 = HBCCreateFunctionEnvironmentInst %varScope, %parentScopeParam
1029
+ Arguments | %varScope is the variable scope that this instruction will produce. %parentScopeParam is dummy parameter used to model usage of the parent environment.
1030
+ Semantics | The instruction creates a new environment for a function.
1031
+ Effects | Does not read or write to memory.
1032
+
1033
+ ### HBCResolveParentEnvironmentInst
1034
+
1035
+ HBCResolveParentEnvironmentInst | _
1036
+ --- | --- |
1037
+ Description | Traverse the chain of environments starting at the current function's parent to find a given environment.
1038
+ Example | %0 = HBCResolveParentEnvironmentInst %varScope, %numLevels, %parentScopeParam
1039
+ Arguments | %varScope is the variable scope to resolve to. %numLevels is the number of scopes up from the current function's parent that the result will be found. %parentScopeParam is dummy parameter used to model usage of the parent environment.
1040
+ Semantics | The instruction resolves an environment that is a parent of the current function's environment.
1041
+ Effects | Does not read or write to memory.
1042
+
1043
+ ### LIRAllocObjectFromBufferInst
1044
+
1045
+ LIRAllocObjectFromBufferInst | _
1046
+ --- | --- |
1047
+ Description | Allocates a new JavaScript object on the heap, and initializes it with values from the object buffer.
1048
+ Example | %0 = LIRAllocObjectFromBufferInst %parent, %value0, %value1, ...
1049
+ Arguments | %parent is the parent of the new object. The subsequent values are all literal values, with alternating keys and values. Non-serializable values will be inserted into the array separately.
1050
+ Semantics | The instruction creates a new JavaScript object on the heap with an initial list of properties.
1051
+ Effects | Does not read or write to memory.
1052
+
1053
+ ### LIRAllocTypedObjectFromBufferInst
1054
+
1055
+ LIRAllocTypedObjectFromBufferInst | _
1056
+ --- | --- |
1057
+ Description | Allocates a new typed class instance on the heap, and initializes it with values from the buffer. Properties are enumerable.
1058
+ Example | %0 = LIRAllocTypedObjectFromBufferInst %parent, %key0, %value0, ...
1059
+ Arguments | The %parent is the parent of the result object. The remaining operands are all literal values, with alternating keys and values. Non-literal values will be inserted into the array separately.
1060
+ Semantics | The instruction creates a new JavaScript typed object on the heap with an initial list of enumerable properties.
1061
+ Effects | Does not read or write to memory.
1062
+
1063
+ ### LIRAllocTypedNonEnumObjectFromBufferInst
1064
+
1065
+ LIRAllocTypedNonEnumObjectFromBufferInst | _
1066
+ --- | --- |
1067
+ Description | Allocates a new typed class instance on the heap with non-enumerable properties, and initializes it with values from the buffer. Used for home objects (class prototypes).
1068
+ Example | %0 = LIRAllocTypedNonEnumObjectFromBufferInst %parent, %key0, %value0, ...
1069
+ Arguments | The %parent is the parent of the result object. The remaining operands are all literal values, with alternating keys and values. Non-literal values will be inserted into the array separately.
1070
+ Semantics | The instruction creates a new JavaScript typed object on the heap with an initial list of non-enumerable properties.
1071
+ Effects | Does not read or write to memory.
1072
+
1073
+ ### HBCCallNInst
1074
+
1075
+ HBCCallNInst | _
1076
+ --- | --- |
1077
+ Description | Calls a function with a fixed number of arguments (from 1 to 4, inclusive).
1078
+ Example | %0 = HBCCallNInst %callee, %this, %arg0, %arg1, %arg2
1079
+ Arguments | %callee is the function to execute. %this is a reference to the 'this' value. Arguments %arg0 ... %argN are the arguments passed to the function.
1080
+ Semantics | The instruction copies its arguments (starting from this) into the parameter-passing registers at the end of the frame, and passes the control to the callee, which must be of closure type. The arguments are mapped to the parameters. Unmapped parameters are initialized to 'undefined'.
1081
+ Effects | May read and write memory.
1082
+
1083
+ ### HBCCallWithArgCountInst
1084
+
1085
+ HBCCallWithArgCountInst | _
1086
+ --- | --- |
1087
+ Description | This instruction contains the same operands as CallInst, in addition to explicitly passing in the argument count as an operand.
1088
+ Example | %0 = HBCCallWithArgCountInst %callee, %target, %calleeIsAlwaysClosure, %env, %newtarget, $argcount, %this, %arg0, %arg1, %arg2, ...
1089
+ Arguments | %argcount is the number of arguments to the function, including 'this'.
1090
+ Semantics | The instruction passes the control to the callee, that must be of closure type. The arguments are mapped to the parameters. Unmapped parameters are initialized to 'undefined'.
1091
+ Effects | May read and write memory.
1092
+
1093
+ ### prload
1094
+
1095
+ | prload | _ |
1096
+ |-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1097
+ | Description | Load a typed object property by index |
1098
+ | Example | `%0 = prload (:type) %object, %propIndex, %propName` |
1099
+ | Arguments | %object is the object to load from. %propIndex is the property index. %propName is the property name (which isn't actually used). `type` is the type of the property. |
1100
+ | Semantics | Load the property without any checking. |
1101
+ | Effects | May read memory. |
1102
+
1103
+ ### prstore
1104
+
1105
+ | prstore | _ |
1106
+ |-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1107
+ | Description | Store a typed object property by index |
1108
+ | Example | `prstore %value, %object, %propIndex, %propName, %nonPointer` |
1109
+ | Arguments | `%value` is the value to store. `%object` is the object to store into. `%propIndex` is the property index. `%propName` is the property name (which isn't actually used). `%nonPointer` is a boolean indicating whether the property is a non-pointer type (meaning that both the old and the new value are not pointers). |
1110
+ | Semantics | Store the property without any checking. |
1111
+ | Effects | May read memory. |
1112
+
1113
+ ### FastArrayLoad
1114
+
1115
+ FastArrayLoad | _
1116
+ --- | --- |
1117
+ Description | Loads an element from a FastArray, validates the index.
1118
+ Example | FastArrayLoad %array (:object), %index (:number)
1119
+ Arguments | %array is the array, %index is the index to read
1120
+ Semantics | Throw if the index is not an unsigned integer within range, otherwise, load the value at %index from %array.
1121
+ Effects | May read memory or throw.
1122
+
1123
+ ### FastArrayStore
1124
+
1125
+ FastArrayStore
1126
+ --- | --- |
1127
+ Description | Stores an element to an array, validates the index.
1128
+ Example | FastArrayStore %storedValue, %array, %index
1129
+ Arguments | %array is the array, %index is the index to write to, %storedValue is the value to write
1130
+ Semantics | Throw if the index is not an unsigned integer within range, otherwise, store %storedValue to %array.
1131
+ Effects | May write memory or throw.
1132
+
1133
+ ### FastArrayLength
1134
+
1135
+ FastArrayLength | _
1136
+ --- | --- |
1137
+ Description | Read the length of a FastArray
1138
+ Example | FastArrayLength (:number) %array
1139
+ Arguments | %array is the array
1140
+ Semantics | Read the length property of the array and return it.
1141
+ Effects | May read memory.
1142
+
1143
+ ### FastArrayPushInst
1144
+
1145
+ FastArrayPushInst | _
1146
+ --- | --- |
1147
+ Description | Pushes an element onto a FastArray.
1148
+ Example | FastArrayPushInst %pushedValue, %array
1149
+ Arguments | %pushedValue is the value to be pushed, %array is the array we are pushing onto.
1150
+ Semantics | Push an element onto the target array, increasing its length by 1. If accommodating the additional element causes a reallocation past the maximum allowable allocation size, throw an exception.
1151
+ Effects | May write memory or throw.
1152
+
1153
+ ### FastArrayAppendInst
1154
+
1155
+ FastArrayAppendInst | _
1156
+ --- | --- |
1157
+ Description | Appends the elements of one FastArray to another.
1158
+ Example | FastArrayAppendInst %other, %array
1159
+ Arguments | %other is array from which elements will be copied, %array is the array onto which elements will be appended.
1160
+ Semantics | Copy the elements from %other into the end of %array, increasing its length by the number of elements in %other. If accommodating the additional elements causes a reallocation past the maximum allowable allocation size, throw an exception.
1161
+ Effects | May write memory or throw.
1162
+
1163
+ ### LoadParentNoTraps
1164
+
1165
+ LoadParentNoTraps | _
1166
+ --- | --- |
1167
+ Description | Loads the parent for a legacy, ordinary untyped object. The given object cannot be proxy. Returns `null` or an object.
1168
+ Example | %0 = LoadParentNoTraps %object
1169
+ Arguments | %object must be of type object.
1170
+ Semantics | Read the parent.
1171
+ Effects | May read memory.
1172
+
1173
+ ### TypedLoadParent
1174
+
1175
+ TypedLoadParent | _
1176
+ --- | --- |
1177
+ Description | Loads the parent (the vtable) for a typed object instance of a class
1178
+ Example | %0 = TypedLoadParent %object
1179
+ Arguments | %object is an instance of a typed class
1180
+ Semantics | Read the parent without any checks.
1181
+ Effects | May read memory.
1182
+
1183
+ ### FUnaryMath
1184
+
1185
+ FUnaryMath | _
1186
+ --- |-----------------------------------------------|
1187
+ Description | Instruction class for a floating point unary math operation.
1188
+ Example | FNegate (:number), %operand (:number)
1189
+ Arguments | %operand is the input value
1190
+ Semantics | Perform the specified op on a floating point number, return a number.
1191
+ Effects | None
1192
+
1193
+ ### FBinaryMath
1194
+
1195
+ FBinaryMath | _
1196
+ --- |-----------------------------------------------|
1197
+ Description | Instruction class for a floating point binary math operation.
1198
+ Example | FAdd (:number), %left (:number), %right (:number)
1199
+ Arguments | %left and %right are the input values
1200
+ Semantics | Perform the specified op on two floating point numbers (same type), return a number.
1201
+ Effects | None
1202
+
1203
+ ### FCompare
1204
+
1205
+ FCompare | _
1206
+ --- |-----------------------------------------------|
1207
+ Description | Instruction class for comparing floating point numbers
1208
+ Example | FLessThan (:bool), %left (:number), %right (:number)
1209
+ Arguments | %left and %right are the input values
1210
+ Semantics | Perform the specified compare on two floating point numbers (same type), return bool. Note that if any operand is NaN, comparison always returns false.
1211
+ Effects | None
1212
+
1213
+ ### StringConcat
1214
+
1215
+ StringConcat | _
1216
+ --- |-----------------------------------------------|
1217
+ Description | Concatenate `N` strings and return the resultant string.
1218
+ Example | StringConcat (:string), %op1 (:string), ..., %opN (:string)
1219
+ Arguments | %op1 to %opN are the input values which must be strings.
1220
+ Semantics | Perform the specified concatenation on strings.
1221
+ Effects | None
1222
+
1223
+ ### HBCStringConcat
1224
+
1225
+ HBCStringConcat | _
1226
+ --- |-----------------------------------------------|
1227
+ Description | Concatenate 2 strings and return the resultant string.
1228
+ Example | StringConcat (:string), %left (:string), %right (:string)
1229
+ Arguments | %left and %right are the input values which must be strings.
1230
+ Semantics | Perform the specified concatenation on strings.
1231
+ Effects | None
1232
+
1233
+ ### UnionNarrowTrusted
1234
+
1235
+ UnionNarrowTrusted | _
1236
+ --- |-----------------------------------------------|
1237
+ Description | Narrow a union type when the compiler has proven that the operand is more specific.
1238
+ Example | UnionNarrowTrusted (:number), %operand (:number | empty)
1239
+ Arguments | %operand is the input value
1240
+ Semantics | Narrow the type, but doesn't change the value.
1241
+ Effects | None
1242
+
1243
+ ### CheckedTypeCast
1244
+
1245
+ CheckedTypeCast | _
1246
+ --- |-----------------------------------------------|
1247
+ Description | Attempt to cast to the result type, throw if unable.
1248
+ Example | CheckedTypeCast (:U), %operand (:T), %type
1249
+ Arguments | %operand is the value to cast, %type is the type to cast to
1250
+ Semantics | Cast from type `T` to `U`, throw when the cast is not valid. The result type may be narrower than the
1251
+ specified cast type, if the compiler can prove that the input value is more specific.
1252
+ Effects | May throw.
1253
+
1254
+ ### NativeCall
1255
+
1256
+ NativeCall | _
1257
+ --- |-----------------------------------------------|
1258
+ Description | Call a native function.
1259
+ Example | NativeCall (:type) %nativeFunctionPtr, %nativeSignature, %arg1, %arg2, ...
1260
+ Arguments | %nativeFunctionPtr is the pointer to the native function. %nativeSignature is the signature of the native function. Arguments %arg1 ... %argN are the arguments passed to the function encoded as JS values.
1261
+ Semantics | The JS arguments are converted to native types. The result is converted to the JS type.
1262
+ Effects | Unknown.
1263
+
1264
+ ### GetNativeRuntime
1265
+
1266
+ GetNativeRuntime | _
1267
+ --- |-----------------------------------------------|
1268
+ Description | Get a native pointer to the native runtime to be passed to a native function.
1269
+ Example | GetNativeRuntime (:number)
1270
+ Arguments | None
1271
+ Semantics | Get the native runtime pointer.
1272
+ Effects | None
1273
+
1274
+ ### LIRDeadValue
1275
+
1276
+ LIRDeadValue | _
1277
+ --- |-----------------------------------------------|
1278
+ Description | Create a "dead value" of the specified type. This instruction is created during lowering in code that will never execute, but is needed to satisfy the type constraints of downstream instruction that will also never execute.
1279
+ Example | LIRDeadValue (:number)
1280
+ Arguments | None
1281
+ Semantics | Create a value of the specified type.
1282
+ Effects | None
1283
+
1284
+ ### LazyCompilationData
1285
+
1286
+ NOTE: LazyCompilationData relies on the fact that we don't delete Variables during the lazy compilation pipeline. That means no stack promotion, and the existing full optimization pipeline cannot run, because we haven't yet figured out which variables are captured by child functions.
1287
+
1288
+ LazyCompilationData | _
1289
+ --- |-----------------------------------------------|
1290
+ Description | Data needed for lazy compilation, including the VariableScope chain used to access captured variables.
1291
+ Example | LazyCompilationData %capturedThis, %capturedNewTarget, %capturedArguments, %capturedHomeObject, %parentVS, %parentParentVS, ...
1292
+ Arguments | The captured values are used in case the lazy function may have arrow functions as children which need to capture the values as variables. In the case of %capturedHomeObject, this is needed even for non-arrow functions. %parentVS the immediately enclosing VariableScope. The remaining operands are successively the ancestors of %parentVS, which are kept as operands to ensure the VariableScopes aren't deleted across lazy compilation calls.
1293
+ Semantics | Information needed for lazy compilation. Deleted after use.
1294
+ Effects | None
1295
+
1296
+ ### EvalCompilationData
1297
+
1298
+ NOTE: EvalCompilationData relies on the fact that we don't delete Variables during the eval compilation pipeline. That means no stack promotion, and the existing full optimization pipeline cannot run, because we haven't yet figured out which variables are captured by child functions.
1299
+
1300
+ EvalCompilationData | _
1301
+ --- |-----------------------------------------------|
1302
+ Description | Data needed for eval compilation within this function, including the VariableScope chain used to access captured variables.
1303
+ Example | EvalCompilationData %capturedThis, %capturedNewTarget, %capturedArguments, %VS, %parentVS, ...
1304
+ Arguments | The captured values are used in case the eval function may have arrow functions as children which need to capture the values as variables. %VS the VariableScope for the function (block scoping not supported). The remaining operands are successively the ancestors of %VS, which are kept as operands to ensure the VariableScopes aren't deleted across compilation calls.
1305
+ Semantics | Information needed for eval compilation.
1306
+ Effects | None