@qalqi/headless-hermes-linux-x64 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,193 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <cstdint>
11
+ #include <string>
12
+ #include <vector>
13
+
14
+ namespace hermes {
15
+ namespace vm {
16
+ class Debugger;
17
+ }
18
+ } // namespace hermes
19
+
20
+ namespace facebook {
21
+ namespace hermes {
22
+ namespace debugger {
23
+
24
+ class ProgramState;
25
+
26
+ /// Strings in the Debugger are UTF-8 encoded. When converting from a JavaScript
27
+ /// string, valid UTF-16 surrogate pairs are decoded. Surrogate halves are
28
+ /// converted into the Unicode replacement character.
29
+ using String = std::string;
30
+
31
+ /// Debugging entities like breakpoints are identified by a unique ID. The
32
+ /// Debugger will not re-use IDs even across different entity types. 0 is an
33
+ /// invalid ID.
34
+ using BreakpointID = uint64_t;
35
+ // NOTE: Can't be kInvalidID due to a clash with MacTypes.h's define kInvalidID.
36
+ constexpr uint64_t kInvalidBreakpoint = 0;
37
+
38
+ /// Scripts when loaded are identified by a script ID.
39
+ /// These are not reused within one invocation of the VM.
40
+ using ScriptID = uint32_t;
41
+
42
+ /// A SourceLocation is a small value-type representing a location in a source
43
+ /// file.
44
+ constexpr uint32_t kInvalidLocation = ~0u;
45
+ struct SourceLocation {
46
+ /// Line in the source. 1 based.
47
+ uint32_t line = kInvalidLocation;
48
+
49
+ /// Column in the source. 1 based.
50
+ uint32_t column = kInvalidLocation;
51
+
52
+ /// Identifier of the source file.
53
+ ScriptID fileId = kInvalidLocation;
54
+
55
+ /// Name of the source file.
56
+ String fileName;
57
+ };
58
+
59
+ /// CallFrameInfo is a value type representing an entry in a call stack.
60
+ struct CallFrameInfo {
61
+ /// Name of the function executing in this frame.
62
+ String functionName;
63
+
64
+ /// Source location of the program counter for this frame.
65
+ SourceLocation location;
66
+ };
67
+
68
+ /// StackTrace represents a list of call frames, either in the current execution
69
+ /// or captured in an exception.
70
+ struct StackTrace {
71
+ /// \return the number of call frames.
72
+ uint32_t callFrameCount() const {
73
+ return frames_.size();
74
+ }
75
+
76
+ /// \return call frame info at a given index. 0 represents the topmost
77
+ /// (current) frame on the call stack.
78
+ CallFrameInfo callFrameForIndex(uint32_t index) const {
79
+ return frames_.at(index);
80
+ }
81
+
82
+ StackTrace() {}
83
+
84
+ private:
85
+ explicit StackTrace(std::vector<CallFrameInfo> frames)
86
+ : frames_(std::move(frames)) {};
87
+ friend ProgramState;
88
+ friend ::hermes::vm::Debugger;
89
+ std::vector<CallFrameInfo> frames_;
90
+ };
91
+
92
+ /// ExceptionDetails is a value type describing an exception.
93
+ struct ExceptionDetails {
94
+ /// Textual description of the exception.
95
+ String text;
96
+
97
+ /// Location where the exception was thrown.
98
+ SourceLocation location;
99
+
100
+ /// Get the stack trace associated with the exception.
101
+ const StackTrace &getStackTrace() const {
102
+ return stackTrace_;
103
+ }
104
+
105
+ private:
106
+ friend ::hermes::vm::Debugger;
107
+ StackTrace stackTrace_;
108
+ };
109
+
110
+ /// A list of possible reasons for a Pause.
111
+ enum class PauseReason {
112
+ ScriptLoaded, /// A script file was loaded, and the debugger has requested
113
+ /// pausing after script load.
114
+ DebuggerStatement, /// A debugger; statement was hit.
115
+ Breakpoint, /// A breakpoint was hit.
116
+ StepFinish, /// A Step operation completed.
117
+ Exception, /// An Exception was thrown.
118
+ AsyncTriggerImplicit, /// The Pause is the result of
119
+ /// triggerAsyncPause(Implicit).
120
+ AsyncTriggerExplicit, /// The Pause is the result of
121
+ /// triggerAsyncPause(Explicit).
122
+ EvalComplete, /// An eval() function finished.
123
+ };
124
+
125
+ /// When stepping, the mode with which to step.
126
+ enum class StepMode {
127
+ Into, /// Enter into any function calls.
128
+ Over, /// Skip over any function calls.
129
+ Out, /// Step until the current function exits.
130
+ };
131
+
132
+ /// When setting pause on throw, this specifies when to pause.
133
+ enum class PauseOnThrowMode {
134
+ None, /// Never pause on exceptions.
135
+ Uncaught, /// Only pause on uncaught exceptions.
136
+ All, /// Pause any time an exception is thrown.
137
+ };
138
+
139
+ /// When requesting an async break, this specifies whether it was an implicit
140
+ /// break from the inspector or a user-requested explicit break.
141
+ enum class AsyncPauseKind {
142
+ /// Implicit pause to allow movement of jsi::Value types between threads.
143
+ /// The user will not be running commands and the inspector will immediately
144
+ /// request a Continue.
145
+ Implicit,
146
+
147
+ /// Explicit pause requested by the user.
148
+ /// Clears any stepping state and allows the user to run their own commands.
149
+ Explicit,
150
+ };
151
+
152
+ /// A type representing depth in a lexical scope chain.
153
+ using ScopeDepth = uint32_t;
154
+
155
+ /// Information about lexical entities (for now, just variable names).
156
+ struct LexicalInfo {
157
+ /// \return the number of scopes.
158
+ ScopeDepth getScopesCount() const {
159
+ return variableCountsByScope_.size();
160
+ }
161
+
162
+ /// \return the number of variables in a given scope.
163
+ uint32_t getVariablesCountInScope(ScopeDepth depth) const {
164
+ return variableCountsByScope_.at(depth);
165
+ }
166
+
167
+ private:
168
+ friend ::hermes::vm::Debugger;
169
+ std::vector<uint32_t> variableCountsByScope_;
170
+ };
171
+
172
+ /// Information about a breakpoint.
173
+ struct BreakpointInfo {
174
+ /// ID of the breakpoint.
175
+ /// kInvalidBreakpoint if the info is not valid.
176
+ BreakpointID id;
177
+
178
+ /// Whether the breakpoint is enabled.
179
+ bool enabled;
180
+
181
+ /// Whether the breakpoint has been resolved.
182
+ bool resolved;
183
+
184
+ /// The originally requested location of the breakpoint.
185
+ SourceLocation requestedLocation;
186
+
187
+ /// The resolved location of the breakpoint if resolved is true.
188
+ SourceLocation resolvedLocation;
189
+ };
190
+
191
+ } // namespace debugger
192
+ } // namespace hermes
193
+ } // namespace facebook
@@ -0,0 +1,217 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "hermes/Public/CtorConfig.h"
11
+ #include "hermes/Public/GCTripwireContext.h"
12
+
13
+ #include <algorithm>
14
+ #include <cassert>
15
+ #include <chrono>
16
+ #include <cstdint>
17
+ #include <functional>
18
+ #include <limits>
19
+ #include <memory>
20
+ #include <string>
21
+ #include <vector>
22
+
23
+ namespace hermes {
24
+ namespace vm {
25
+
26
+ /// A type big enough to accomodate the entire allocated address space.
27
+ /// Individual allocations are always 'uint32_t', but on a 64-bit machine, when
28
+ /// compressed pointer is OFF, we want to accommodate a larger total heap.
29
+ using gcheapsize_t = size_t;
30
+
31
+ /// Represents a value before and after an event.
32
+ /// NOTE: Not a std::pair because using the names are more readable than first
33
+ /// and second.
34
+ struct BeforeAndAfter {
35
+ uint64_t before;
36
+ uint64_t after;
37
+ };
38
+
39
+ struct GCAnalyticsEvent {
40
+ /// The same value as \p Name from GCConfig. Stored here for simplicity of
41
+ /// the API since this is passed in callbacks that might not be able to store
42
+ /// the name. For a given Runtime, this will be the same value every time.
43
+ std::string runtimeDescription;
44
+
45
+ /// The kind of GC this was. For a given Runtime, this will be the same value
46
+ /// every time.
47
+ std::string gcKind;
48
+
49
+ /// The type of collection that ran, typically differentiating a "young"
50
+ /// generation GC and an "old" generation GC. When other values say they're
51
+ /// "scoped to the collectionType", it means that for a generation GC
52
+ /// they're only reporting the numbers for that generation.
53
+ std::string collectionType;
54
+
55
+ /// The cause of this GC. Can be an arbitrary string describing the cause.
56
+ /// Typically "natural" is used to mean that the GC decided it was time, and
57
+ /// other causes mean it was forced by some other condition.
58
+ std::string cause;
59
+
60
+ /// The wall time a collection took from start to end.
61
+ std::chrono::milliseconds duration;
62
+
63
+ /// The CPU time a collection took from start to end. This time measure will
64
+ /// exclude time waiting on disk, mutexes, or time spent not scheduled to run.
65
+ std::chrono::milliseconds cpuDuration;
66
+
67
+ /// The number of bytes allocated in the heap before and after the collection.
68
+ /// measurement does not include fragmentation, and is the same as the sum of
69
+ /// all sizes in calls to \p GC::makeA into that generation (including any
70
+ /// rounding up the GC does).
71
+ /// The value is scoped to the \p collectionType.
72
+ BeforeAndAfter allocated;
73
+
74
+ /// The number of bytes in use by the heap before and after the collection.
75
+ /// This measurement can include fragmentation if the \p gcKind has that
76
+ /// concept.
77
+ /// The value is scoped to the \p collectionType.
78
+ BeforeAndAfter size;
79
+
80
+ /// The number of bytes external to the JS heap before and after the
81
+ /// collection.
82
+ /// The value is scoped to the \p collectionType.
83
+ BeforeAndAfter external;
84
+
85
+ /// The ratio of cells that survived the collection to all cells before
86
+ /// the collection. Note that this is in term of sizes of cells, not the
87
+ /// numbers of cells. Excludes any cells not in direct use by the JS program,
88
+ /// such as FillerCell or FreelistCell.
89
+ /// The value is scoped to the \p collectionType.
90
+ double survivalRatio;
91
+
92
+ /// A list of metadata tags to annotate this event with.
93
+ std::vector<std::string> tags;
94
+ };
95
+
96
+ /// Parameters to control a tripwire function called when the live set size
97
+ /// surpasses a given threshold after collections. Check documentation in
98
+ /// README.md
99
+ #define GC_TRIPWIRE_FIELDS(F) \
100
+ /* If the heap size is above this threshold after a collection, the tripwire \
101
+ * is triggered. */ \
102
+ F(constexpr, gcheapsize_t, Limit, std::numeric_limits<gcheapsize_t>::max()) \
103
+ \
104
+ /* The callback to call when the tripwire is considered triggered. */ \
105
+ F(HERMES_NON_CONSTEXPR, \
106
+ std::function<void(GCTripwireContext &)>, \
107
+ Callback, \
108
+ nullptr) \
109
+ /* GC_TRIPWIRE_FIELDS END */
110
+
111
+ _HERMES_CTORCONFIG_STRUCT(GCTripwireConfig, 1, GC_TRIPWIRE_FIELDS, {})
112
+
113
+ #undef HEAP_TRIPWIRE_FIELDS
114
+
115
+ #define GC_HANDLESAN_FIELDS(F) \
116
+ /* The probability with which the GC should keep moving the heap */ \
117
+ /* to detect stale GC handles. */ \
118
+ F(constexpr, double, SanitizeRate, 0.0) \
119
+ /* Random seed to use for basis of decisions whether or not to */ \
120
+ /* sanitize. A negative value will mean a seed will be chosen at */ \
121
+ /* random. */ \
122
+ F(constexpr, int64_t, RandomSeed, -1) \
123
+ /* GC_HANDLESAN_FIELDS END */
124
+
125
+ _HERMES_CTORCONFIG_STRUCT(GCSanitizeConfig, 1, GC_HANDLESAN_FIELDS, {})
126
+
127
+ #undef GC_HANDLESAN_FIELDS
128
+
129
+ /// How aggressively to return unused memory to the OS.
130
+ enum ReleaseUnused {
131
+ kReleaseUnusedNone = 0, /// Don't try to release unused memory.
132
+ kReleaseUnusedOld, /// Only old gen, on full collections.
133
+ kReleaseUnusedYoungOnFull, /// Also young gen, but only on full collections.
134
+ kReleaseUnusedYoungAlways /// Also young gen, also on young gen collections.
135
+ };
136
+
137
+ enum class GCEventKind {
138
+ CollectionStart,
139
+ CollectionEnd,
140
+ };
141
+
142
+ /// Parameters for GC Initialisation. Check documentation in README.md
143
+ /// constexpr indicates that the default value is constexpr.
144
+ #define GC_FIELDS(F) \
145
+ /* Initial heap size hint. */ \
146
+ F(constexpr, gcheapsize_t, InitHeapSize, 32 << 20) \
147
+ \
148
+ /* Maximum heap size hint. */ \
149
+ F(constexpr, gcheapsize_t, MaxHeapSize, 3u << 30) \
150
+ \
151
+ /* Sizing heuristic: fraction of heap to be occupied by live data. */ \
152
+ F(constexpr, double, OccupancyTarget, 0.5) \
153
+ \
154
+ /* Number of consecutive full collections considered to be an OOM. */ \
155
+ F(constexpr, \
156
+ unsigned, \
157
+ EffectiveOOMThreshold, \
158
+ std::numeric_limits<unsigned>::max()) \
159
+ \
160
+ /* Sanitizer configuration for the GC. */ \
161
+ F(constexpr, GCSanitizeConfig, SanitizeConfig) \
162
+ \
163
+ /* Whether to Keep track of GC Statistics. */ \
164
+ F(constexpr, bool, ShouldRecordStats, false) \
165
+ \
166
+ /* How aggressively to return unused memory to the OS. */ \
167
+ F(constexpr, ReleaseUnused, ShouldReleaseUnused, kReleaseUnusedOld) \
168
+ \
169
+ /* Name for this heap in logs. */ \
170
+ F(HERMES_NON_CONSTEXPR, std::string, Name, "") \
171
+ \
172
+ /* Configuration for the Heap Tripwire. */ \
173
+ F(HERMES_NON_CONSTEXPR, GCTripwireConfig, TripwireConfig) \
174
+ \
175
+ /* Whether to (initially) allocate from the young gen (true) or the */ \
176
+ /* old gen (false). */ \
177
+ F(constexpr, bool, AllocInYoung, true) \
178
+ \
179
+ /* Whether to fill the YG with invalid data after each collection. */ \
180
+ F(constexpr, bool, OverwriteDeadYGObjects, false) \
181
+ \
182
+ /* Whether to revert, if necessary, to young-gen allocation at TTI. */ \
183
+ F(constexpr, bool, RevertToYGAtTTI, false) \
184
+ \
185
+ /* Whether to use mprotect on GC metadata between GCs. */ \
186
+ F(constexpr, bool, ProtectMetadata, false) \
187
+ \
188
+ /* Callout for an analytics event. */ \
189
+ F(HERMES_NON_CONSTEXPR, \
190
+ std::function<void(const GCAnalyticsEvent &)>, \
191
+ AnalyticsCallback, \
192
+ nullptr) \
193
+ \
194
+ /* Called at GC events (see GCEventKind enum for the list). The */ \
195
+ /* second argument contains human-readable details about the event. */ \
196
+ /* NOTE: The function MUST NOT invoke any methods on the Runtime. */ \
197
+ F(HERMES_NON_CONSTEXPR, \
198
+ std::function<void(GCEventKind, const char *)>, \
199
+ Callback, \
200
+ nullptr) \
201
+ /* GC_FIELDS END */
202
+
203
+ /// Version of GCConfig.
204
+ /// Changing this struct in a non-compatible way (e.g., adding new field in the
205
+ /// middle or changing field types) requires bumping the version.
206
+ /// Date: Aug 10, 2026
207
+ #define HERMES_GCCONFIG_VERSION 1
208
+
209
+ _HERMES_CTORCONFIG_STRUCT(GCConfig, HERMES_GCCONFIG_VERSION, GC_FIELDS, {
210
+ // Make sure the max is at least the Init.
211
+ MaxHeapSize_ = std::max(InitHeapSize_, MaxHeapSize_);
212
+ })
213
+
214
+ #undef GC_FIELDS
215
+
216
+ } // namespace vm
217
+ } // namespace hermes
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <hermes/Public/HermesExport.h>
11
+
12
+ #include <iosfwd>
13
+ #include <string>
14
+ #include <system_error>
15
+
16
+ namespace hermes {
17
+ namespace vm {
18
+
19
+ /// Interface passed to the GC tripwire callback when it fires.
20
+ class HERMES_EXPORT GCTripwireContext {
21
+ public:
22
+ virtual ~GCTripwireContext();
23
+
24
+ /// Captures the heap to a file.
25
+ /// \param path to save the heap capture.
26
+ /// \return Empty error code if the heap capture succeeded, else a real error
27
+ /// code.
28
+ virtual std::error_code createSnapshotToFile(const std::string &path) = 0;
29
+
30
+ /// Captures the heap to a stream.
31
+ /// \param os stream to save the heap capture to.
32
+ /// \return Empty error code if the heap capture succeeded, else a real error
33
+ /// code.
34
+ virtual std::error_code createSnapshot(
35
+ std::ostream &os,
36
+ bool captureNumericValue) = 0;
37
+ };
38
+
39
+ } // namespace vm
40
+ } // namespace hermes
@@ -0,0 +1,14 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #ifndef HERMES_EXPORT
9
+ #ifdef _MSC_VER
10
+ #define HERMES_EXPORT __declspec(dllexport)
11
+ #else // _MSC_VER
12
+ #define HERMES_EXPORT __attribute__((visibility("default")))
13
+ #endif // _MSC_VER
14
+ #endif // !defined(HERMES_EXPORT)
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <hermes/Public/HermesExport.h>
11
+
12
+ #include <stdexcept>
13
+ #include <string>
14
+
15
+ namespace hermes {
16
+ namespace vm {
17
+
18
+ /// A std::runtime_error class for out-of-memory.
19
+ class HERMES_EXPORT JSOutOfMemoryError : public std::runtime_error {
20
+ friend class GCBase;
21
+ JSOutOfMemoryError(const std::string &what_arg)
22
+ : std::runtime_error(what_arg) {}
23
+ ~JSOutOfMemoryError() override;
24
+ };
25
+
26
+ } // namespace vm
27
+ } // namespace hermes
@@ -0,0 +1,184 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "hermes/Public/CrashManager.h"
11
+ #include "hermes/Public/CtorConfig.h"
12
+ #include "hermes/Public/GCConfig.h"
13
+
14
+ #include <cstdint>
15
+ #include <functional>
16
+ #include <memory>
17
+ #include <optional>
18
+
19
+ namespace hermes {
20
+ namespace vm {
21
+
22
+ enum CompilationMode {
23
+ SmartCompilation,
24
+ ForceEagerCompilation,
25
+ ForceLazyCompilation
26
+ };
27
+
28
+ enum class SynthTraceMode : int8_t {
29
+ None,
30
+ Replaying,
31
+ Tracing,
32
+ TracingAndReplaying,
33
+ };
34
+
35
+ class PinnedHermesValue;
36
+
37
+ /// Runs a thread's main function inside an embedder-provided scope.
38
+ /// A non-empty runner must invoke its argument exactly once and must not return
39
+ /// until the argument has returned; a runner that skips it silently discards
40
+ /// everything the thread was going to do. An empty runner leaves the thread
41
+ /// unwrapped.
42
+ /// The runner must not throw. Hermes VM is compiled with exceptions disabled
43
+ /// on most platforms, so an escaping exception terminates the process.
44
+ using ThreadRunner = std::function<void(std::function<void()>)>;
45
+
46
+ // Parameters for Runtime initialisation. Check documentation in README.md
47
+ // constexpr indicates that the default value is constexpr.
48
+ #define RUNTIME_FIELDS(F) \
49
+ /* Parameters to be passed on to the GC. */ \
50
+ F(HERMES_NON_CONSTEXPR, vm::GCConfig, GCConfig) \
51
+ \
52
+ /* Pre-allocated Register Stack */ \
53
+ F(constexpr, PinnedHermesValue *, RegisterStack, nullptr) \
54
+ \
55
+ /* Register Stack Size */ \
56
+ F(constexpr, unsigned, MaxNumRegisters, 128 * 1024) \
57
+ \
58
+ /* Native stack remaining before assuming overflow */ \
59
+ F(constexpr, unsigned, NativeStackGap, 64 * 1024) \
60
+ \
61
+ /* Whether or not the JIT is enabled */ \
62
+ F(constexpr, bool, EnableJIT, false) \
63
+ \
64
+ /* Whether to allow eval and Function ctor */ \
65
+ F(constexpr, bool, EnableEval, true) \
66
+ \
67
+ /* Whether to verify the IR generated by eval and Function ctor */ \
68
+ F(constexpr, bool, VerifyEvalIR, false) \
69
+ \
70
+ /* Whether to optimize the code inside eval and Function ctor */ \
71
+ F(constexpr, bool, OptimizedEval, false) \
72
+ \
73
+ /* Whether to emit async break check instructions in eval code */ \
74
+ F(constexpr, bool, AsyncBreakCheckInEval, true) \
75
+ \
76
+ /* Support for ES6 Proxy. */ \
77
+ F(constexpr, bool, ES6Proxy, true) \
78
+ \
79
+ /* Support for ES6 block scoping. */ \
80
+ F(constexpr, bool, ES6BlockScoping, false) \
81
+ \
82
+ /* Support for async generators in eval. */ \
83
+ F(constexpr, bool, EnableAsyncGenerators, false) \
84
+ \
85
+ /* Support for ECMA-402 Intl APIs. */ \
86
+ F(constexpr, bool, Intl, true) \
87
+ \
88
+ /* Support for using microtasks. */ \
89
+ F(constexpr, bool, MicrotaskQueue, true) \
90
+ \
91
+ /* Runtime set up for synth trace. */ \
92
+ F(constexpr, SynthTraceMode, SynthTraceMode, SynthTraceMode::None) \
93
+ \
94
+ /* Enable sampling certain statistics. */ \
95
+ F(constexpr, bool, EnableSampledStats, false) \
96
+ \
97
+ /* Whether to enable automatic sampling profiler registration */ \
98
+ F(constexpr, bool, EnableSampleProfiling, false) \
99
+ \
100
+ /* Whether to randomize stack placement etc. */ \
101
+ F(constexpr, bool, RandomizeMemoryLayout, false) \
102
+ \
103
+ /* Eagerly read bytecode into page cache. */ \
104
+ F(constexpr, unsigned, BytecodeWarmupPercent, 0) \
105
+ \
106
+ /* Signal-based I/O tracking. Slows down execution. If enabled, */ \
107
+ /* all bytecode buffers > 64 kB passed to Hermes must be mmap:ed. */ \
108
+ F(constexpr, bool, TrackIO, false) \
109
+ \
110
+ /* Enable contents of HermesInternal */ \
111
+ F(constexpr, bool, EnableHermesInternal, true) \
112
+ \
113
+ /* Enable methods exposed to JS for testing */ \
114
+ F(constexpr, bool, EnableHermesInternalTestMethods, false) \
115
+ \
116
+ /* Choose lazy/eager compilation mode. */ \
117
+ F(constexpr, \
118
+ CompilationMode, \
119
+ CompilationMode, \
120
+ CompilationMode::SmartCompilation) \
121
+ \
122
+ /* Choose whether generators are enabled. */ \
123
+ F(constexpr, bool, EnableGenerator, true) \
124
+ \
125
+ /* An interface for managing crashes. */ \
126
+ F(HERMES_NON_CONSTEXPR, \
127
+ std::shared_ptr<CrashManager>, \
128
+ CrashMgr, \
129
+ new NopCrashManager) \
130
+ \
131
+ /* The flags passed from a VM experiment */ \
132
+ F(constexpr, uint32_t, VMExperimentFlags, 0) \
133
+ \
134
+ /* Force JIT compilation on all functions. */ \
135
+ F(constexpr, bool, ForceJIT, false) \
136
+ \
137
+ /* JIT compilation threshold (number of calls before JIT'ing). */ \
138
+ F(constexpr, uint32_t, JITThreshold, 1 << 5) \
139
+ \
140
+ /* JIT memory limit, after which no more code will be JIT'ed. */ \
141
+ F(constexpr, uint32_t, JITMemoryLimit, 32u << 20) \
142
+ \
143
+ /* Maximum recompiles per function; 0 disables recompilation. */ \
144
+ F(constexpr, uint32_t, JITMaxRecompiles, 2) \
145
+ \
146
+ /* ById declines in one body before a recompile is considered. */ \
147
+ /* 0 is clamped to 1. Mirrors kDefaultRecompileDeclineThreshold. */ \
148
+ F(constexpr, uint32_t, JITRecompileThreshold, 64) \
149
+ \
150
+ /* Increase compliance with test262 (stricter checks at runtime). */ \
151
+ F(constexpr, bool, Test262, false) \
152
+ \
153
+ /* Wrap execution of the JSI finalizer worker thread. */ \
154
+ /* HostObject, HostFunction and NativeState destructors run */ \
155
+ /* there, and like the runner itself they must not throw. */ \
156
+ /* std::nullopt, the default, selects the platform default, which */ \
157
+ /* in builds with fbjni wraps the thread in a JNI ThreadScope */ \
158
+ /* when fbjni has a JavaVM. Setting an empty ThreadRunner */ \
159
+ /* suppresses that and leaves the thread unwrapped -- note that */ \
160
+ /* this must be spelled */ \
161
+ /* withFinalizerThreadRunner(ThreadRunner{}), since a bare {} is */ \
162
+ /* nullopt and so selects the platform default instead. */ \
163
+ F(HERMES_NON_CONSTEXPR, \
164
+ std::optional<ThreadRunner>, \
165
+ FinalizerThreadRunner, \
166
+ std::nullopt) \
167
+ /* RUNTIME_FIELDS END */
168
+
169
+ /// Version of RuntimeConfig.
170
+ /// Changing RuntimeConfig in a non-compatible way (e.g., adding new field in
171
+ /// the middle or changing field types) requires bumping the version.
172
+ /// Date: Aug 10, 2026
173
+ #define HERMES_RUNTIME_CONFIG_VERSION 1
174
+
175
+ _HERMES_CTORCONFIG_STRUCT(
176
+ RuntimeConfig,
177
+ HERMES_RUNTIME_CONFIG_VERSION,
178
+ RUNTIME_FIELDS,
179
+ {})
180
+
181
+ #undef RUNTIME_FIELDS
182
+
183
+ } // namespace vm
184
+ } // namespace hermes