• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_RUNTIME_RUNTIME_H_
6 #define V8_RUNTIME_RUNTIME_H_
7 
8 #include <memory>
9 
10 #include "include/v8-maybe.h"
11 #include "src/base/bit-field.h"
12 #include "src/base/platform/time.h"
13 #include "src/common/globals.h"
14 #include "src/handles/handles.h"
15 #include "src/objects/elements-kind.h"
16 #include "src/strings/unicode.h"
17 #include "src/utils/allocation.h"
18 #include "src/zone/zone.h"
19 
20 namespace v8 {
21 namespace internal {
22 
23 // * Each intrinsic is exposed in JavaScript via:
24 //    * %#name, which is always a runtime call.
25 //    * (optionally) %_#name, which can be inlined or just a runtime call, the
26 //      compiler in question decides.
27 //
28 // * IntrinsicTypes are Runtime::RUNTIME and Runtime::INLINE, respectively.
29 //
30 // * IDs are Runtime::k##name and Runtime::kInline##name, respectively.
31 //
32 // * All intrinsics have a C++ implementation Runtime_##name.
33 //
34 // * Each compiler has an explicit list of intrisics it supports, falling back
35 //   to a simple runtime call if necessary.
36 
37 // Entries have the form F(name, number of arguments, number of return values):
38 // A variable number of arguments is specified by a -1, additional restrictions
39 // are specified by inline comments. To declare only the runtime version (no
40 // inline), use the F macro below. To declare the runtime version and the inline
41 // version simultaneously, use the I macro below.
42 
43 #define FOR_EACH_INTRINSIC_ARRAY(F, I) \
44   F(ArrayIncludes_Slow, 3, 1)          \
45   F(ArrayIndexOf, 3, 1)                \
46   F(ArrayIsArray, 1, 1)                \
47   F(ArraySpeciesConstructor, 1, 1)     \
48   F(GrowArrayElements, 2, 1)           \
49   F(IsArray, 1, 1)                     \
50   F(NewArray, -1 /* >= 3 */, 1)        \
51   F(NormalizeElements, 1, 1)           \
52   F(TransitionElementsKind, 2, 1)      \
53   F(TransitionElementsKindWithKind, 2, 1)
54 
55 #define FOR_EACH_INTRINSIC_ATOMICS(F, I)               \
56   F(AtomicsLoad64, 2, 1)                               \
57   F(AtomicsStore64, 3, 1)                              \
58   F(AtomicsAdd, 3, 1)                                  \
59   F(AtomicsAnd, 3, 1)                                  \
60   F(AtomicsCompareExchange, 4, 1)                      \
61   F(AtomicsExchange, 3, 1)                             \
62   F(AtomicsNumWaitersForTesting, 2, 1)                 \
63   F(AtomicsNumAsyncWaitersForTesting, 0, 1)            \
64   F(AtomicsNumUnresolvedAsyncPromisesForTesting, 2, 1) \
65   F(AtomicsOr, 3, 1)                                   \
66   F(AtomicsSub, 3, 1)                                  \
67   F(AtomicsXor, 3, 1)                                  \
68   F(SetAllowAtomicsWait, 1, 1)                         \
69   F(AtomicsLoadSharedStructField, 2, 1)                \
70   F(AtomicsStoreSharedStructField, 3, 1)               \
71   F(AtomicsExchangeSharedStructField, 3, 1)
72 
73 #define FOR_EACH_INTRINSIC_BIGINT(F, I) \
74   F(BigIntBinaryOp, 3, 1)               \
75   F(BigIntCompareToBigInt, 3, 1)        \
76   F(BigIntCompareToNumber, 3, 1)        \
77   F(BigIntCompareToString, 3, 1)        \
78   F(BigIntEqualToBigInt, 2, 1)          \
79   F(BigIntEqualToNumber, 2, 1)          \
80   F(BigIntEqualToString, 2, 1)          \
81   F(BigIntMaxLengthBits, 0, 1)          \
82   F(BigIntToBoolean, 1, 1)              \
83   F(BigIntToNumber, 1, 1)               \
84   F(BigIntUnaryOp, 2, 1)                \
85   F(ToBigInt, 1, 1)
86 
87 #define FOR_EACH_INTRINSIC_CLASSES(F, I)    \
88   F(DefineClass, -1 /* >= 3 */, 1)          \
89   F(LoadFromSuper, 3, 1)                    \
90   F(LoadKeyedFromSuper, 3, 1)               \
91   F(StoreKeyedToSuper, 4, 1)                \
92   F(StoreToSuper, 4, 1)                     \
93   F(ThrowConstructorNonCallableError, 1, 1) \
94   F(ThrowNotSuperConstructor, 2, 1)         \
95   F(ThrowStaticPrototypeError, 0, 1)        \
96   F(ThrowSuperAlreadyCalledError, 0, 1)     \
97   F(ThrowSuperNotCalled, 0, 1)              \
98   F(ThrowUnsupportedSuperError, 0, 1)
99 
100 #define FOR_EACH_INTRINSIC_COLLECTIONS(F, I) \
101   F(MapGrow, 1, 1)                           \
102   F(MapShrink, 1, 1)                         \
103   F(SetGrow, 1, 1)                           \
104   F(SetShrink, 1, 1)                         \
105   F(TheHole, 0, 1)                           \
106   F(WeakCollectionDelete, 3, 1)              \
107   F(WeakCollectionSet, 4, 1)
108 
109 #define FOR_EACH_INTRINSIC_COMPILER(F, I) \
110   F(CompileOptimizedOSR, 0, 1)            \
111   F(CompileLazy, 1, 1)                    \
112   F(CompileBaseline, 1, 1)                \
113   F(CompileMaglev_Concurrent, 1, 1)       \
114   F(CompileMaglev_Synchronous, 1, 1)      \
115   F(CompileTurbofan_Concurrent, 1, 1)     \
116   F(CompileTurbofan_Synchronous, 1, 1)    \
117   F(InstallBaselineCode, 1, 1)            \
118   F(HealOptimizedCodeSlot, 1, 1)          \
119   F(InstantiateAsmJs, 4, 1)               \
120   F(NotifyDeoptimized, 0, 1)              \
121   F(ObserveNode, 1, 1)                    \
122   F(ResolvePossiblyDirectEval, 6, 1)      \
123   F(VerifyType, 1, 1)
124 
125 #define FOR_EACH_INTRINSIC_DATE(F, I) F(DateCurrentTime, 0, 1)
126 
127 #define FOR_EACH_INTRINSIC_DEBUG(F, I)          \
128   F(ClearStepping, 0, 1)                        \
129   F(CollectGarbage, 1, 1)                       \
130   F(DebugAsyncFunctionSuspended, 4, 1)          \
131   F(DebugBreakAtEntry, 1, 1)                    \
132   F(DebugCollectCoverage, 0, 1)                 \
133   F(DebugGetLoadedScriptIds, 0, 1)              \
134   F(DebugOnFunctionCall, 2, 1)                  \
135   F(DebugPopPromise, 0, 1)                      \
136   F(DebugPrepareStepInSuspendedGenerator, 0, 1) \
137   F(DebugPromiseThen, 1, 1)                     \
138   F(DebugPushPromise, 1, 1)                     \
139   F(DebugToggleBlockCoverage, 1, 1)             \
140   F(DebugTogglePreciseCoverage, 1, 1)           \
141   F(FunctionGetInferredName, 1, 1)              \
142   F(GetBreakLocations, 1, 1)                    \
143   F(GetGeneratorScopeCount, 1, 1)               \
144   F(GetGeneratorScopeDetails, 2, 1)             \
145   F(HandleDebuggerStatement, 0, 1)              \
146   F(IsBreakOnException, 1, 1)                   \
147   F(LiveEditPatchScript, 2, 1)                  \
148   F(ProfileCreateSnapshotDataBlob, 0, 1)        \
149   F(ScheduleBreak, 0, 1)                        \
150   F(ScriptLocationFromLine2, 4, 1)              \
151   F(SetGeneratorScopeVariableValue, 4, 1)       \
152   I(IncBlockCounter, 2, 1)
153 
154 #define FOR_EACH_INTRINSIC_FORIN(F, I) \
155   F(ForInEnumerate, 1, 1)              \
156   F(ForInHasProperty, 2, 1)
157 
158 #ifdef V8_TRACE_UNOPTIMIZED
159 #define FOR_EACH_INTRINSIC_TRACE_UNOPTIMIZED(F, I) \
160   F(TraceUnoptimizedBytecodeEntry, 3, 1)           \
161   F(TraceUnoptimizedBytecodeExit, 3, 1)
162 #else
163 #define FOR_EACH_INTRINSIC_TRACE_UNOPTIMIZED(F, I)
164 #endif
165 
166 #ifdef V8_TRACE_FEEDBACK_UPDATES
167 #define FOR_EACH_INTRINSIC_TRACE_FEEDBACK(F, I) F(TraceUpdateFeedback, 3, 1)
168 #else
169 #define FOR_EACH_INTRINSIC_TRACE_FEEDBACK(F, I)
170 #endif
171 
172 #define FOR_EACH_INTRINSIC_TRACE(F, I)       \
173   FOR_EACH_INTRINSIC_TRACE_UNOPTIMIZED(F, I) \
174   FOR_EACH_INTRINSIC_TRACE_FEEDBACK(F, I)
175 
176 #define FOR_EACH_INTRINSIC_FUNCTION(F, I)  \
177   F(Call, -1 /* >= 2 */, 1)                \
178   F(FunctionGetScriptSource, 1, 1)         \
179   F(FunctionGetScriptId, 1, 1)             \
180   F(FunctionGetScriptSourcePosition, 1, 1) \
181   F(FunctionGetSourceCode, 1, 1)           \
182   F(FunctionIsAPIFunction, 1, 1)           \
183   F(IsFunction, 1, 1)
184 
185 #define FOR_EACH_INTRINSIC_GENERATOR(F, I)    \
186   I(AsyncFunctionAwaitCaught, 2, 1)           \
187   I(AsyncFunctionAwaitUncaught, 2, 1)         \
188   I(AsyncFunctionEnter, 2, 1)                 \
189   I(AsyncFunctionReject, 2, 1)                \
190   I(AsyncFunctionResolve, 2, 1)               \
191   I(AsyncGeneratorAwaitCaught, 2, 1)          \
192   I(AsyncGeneratorAwaitUncaught, 2, 1)        \
193   F(AsyncGeneratorHasCatchHandlerForPC, 1, 1) \
194   I(AsyncGeneratorReject, 2, 1)               \
195   I(AsyncGeneratorResolve, 3, 1)              \
196   I(AsyncGeneratorYield, 3, 1)                \
197   I(CreateJSGeneratorObject, 2, 1)            \
198   I(GeneratorClose, 1, 1)                     \
199   F(GeneratorGetFunction, 1, 1)               \
200   I(GeneratorGetResumeMode, 1, 1)
201 
202 #ifdef V8_INTL_SUPPORT
203 #define FOR_EACH_INTRINSIC_INTL(F, I) \
204   F(FormatList, 2, 1)                 \
205   F(FormatListToParts, 2, 1)          \
206   F(StringToLowerCaseIntl, 1, 1)      \
207   F(StringToUpperCaseIntl, 1, 1)  // End of macro.
208 #else
209 #define FOR_EACH_INTRINSIC_INTL(F, I)
210 #endif  // V8_INTL_SUPPORT
211 
212 #define FOR_EACH_INTRINSIC_INTERNAL(F, I)            \
213   F(AccessCheck, 1, 1)                               \
214   F(AllocateByteArray, 1, 1)                         \
215   F(AllocateInYoungGeneration, 2, 1)                 \
216   F(AllocateInOldGeneration, 2, 1)                   \
217   F(AllocateSeqOneByteString, 1, 1)                  \
218   F(AllocateSeqTwoByteString, 1, 1)                  \
219   F(AllowDynamicFunction, 1, 1)                      \
220   I(CreateAsyncFromSyncIterator, 1, 1)               \
221   F(CreateListFromArrayLike, 1, 1)                   \
222   F(DoubleToStringWithRadix, 2, 1)                   \
223   F(FatalProcessOutOfMemoryInAllocateRaw, 0, 1)      \
224   F(FatalProcessOutOfMemoryInvalidArrayLength, 0, 1) \
225   F(GetAndResetRuntimeCallStats, -1 /* <= 2 */, 1)   \
226   F(GetTemplateObject, 3, 1)                         \
227   F(IncrementUseCounter, 1, 1)                       \
228   F(BytecodeBudgetInterrupt, 1, 1)                   \
229   F(BytecodeBudgetInterruptWithStackCheck, 1, 1)     \
230   F(NewError, 2, 1)                                  \
231   F(NewForeign, 0, 1)                                \
232   F(NewReferenceError, 2, 1)                         \
233   F(NewSyntaxError, 2, 1)                            \
234   F(NewTypeError, -1 /* [1, 4] */, 1)                \
235   F(OrdinaryHasInstance, 2, 1)                       \
236   F(PromoteScheduledException, 0, 1)                 \
237   F(ReportMessageFromMicrotask, 1, 1)                \
238   F(ReThrow, 1, 1)                                   \
239   F(ReThrowWithMessage, 2, 1)                        \
240   F(RunMicrotaskCallback, 2, 1)                      \
241   F(PerformMicrotaskCheckpoint, 0, 1)                \
242   F(SharedValueBarrierSlow, 1, 1)                    \
243   F(StackGuard, 0, 1)                                \
244   F(StackGuardWithGap, 1, 1)                         \
245   F(Throw, 1, 1)                                     \
246   F(ThrowApplyNonFunction, 1, 1)                     \
247   F(ThrowCalledNonCallable, 1, 1)                    \
248   F(ThrowConstructedNonConstructable, 1, 1)          \
249   F(ThrowConstructorReturnedNonObject, 0, 1)         \
250   F(ThrowInvalidStringLength, 0, 1)                  \
251   F(ThrowInvalidTypedArrayAlignment, 2, 1)           \
252   F(ThrowIteratorError, 1, 1)                        \
253   F(ThrowSpreadArgError, 2, 1)                       \
254   F(ThrowIteratorResultNotAnObject, 1, 1)            \
255   F(ThrowNoAccess, 0, 1)                             \
256   F(ThrowNotConstructor, 1, 1)                       \
257   F(ThrowPatternAssignmentNonCoercible, 1, 1)        \
258   F(ThrowRangeError, -1 /* >= 1 */, 1)               \
259   F(ThrowReferenceError, 1, 1)                       \
260   F(ThrowAccessedUninitializedVariable, 1, 1)        \
261   F(ThrowStackOverflow, 0, 1)                        \
262   F(ThrowSymbolAsyncIteratorInvalid, 0, 1)           \
263   F(ThrowSymbolIteratorInvalid, 0, 1)                \
264   F(ThrowThrowMethodMissing, 0, 1)                   \
265   F(ThrowTypeError, -1 /* >= 1 */, 1)                \
266   F(ThrowTypeErrorIfStrict, -1 /* >= 1 */, 1)        \
267   F(Typeof, 1, 1)                                    \
268   F(UnwindAndFindExceptionHandler, 0, 1)
269 
270 #define FOR_EACH_INTRINSIC_LITERALS(F, I)           \
271   F(CreateArrayLiteral, 4, 1)                       \
272   F(CreateArrayLiteralWithoutAllocationSite, 2, 1)  \
273   F(CreateObjectLiteral, 4, 1)                      \
274   F(CreateObjectLiteralWithoutAllocationSite, 2, 1) \
275   F(CreateRegExpLiteral, 4, 1)
276 
277 #define FOR_EACH_INTRINSIC_MODULE(F, I)    \
278   F(DynamicImportCall, -1 /* [2, 3] */, 1) \
279   I(GetImportMetaObject, 0, 1)             \
280   F(GetModuleNamespace, 1, 1)
281 
282 #define FOR_EACH_INTRINSIC_NUMBERS(F, I) \
283   F(ArrayBufferMaxByteLength, 0, 1)      \
284   F(GetHoleNaNLower, 0, 1)               \
285   F(GetHoleNaNUpper, 0, 1)               \
286   F(IsSmi, 1, 1)                         \
287   F(MaxSmi, 0, 1)                        \
288   F(NumberToStringSlow, 1, 1)            \
289   F(StringParseFloat, 1, 1)              \
290   F(StringParseInt, 2, 1)                \
291   F(StringToNumber, 1, 1)                \
292   F(TypedArrayMaxLength, 0, 1)
293 
294 #define FOR_EACH_INTRINSIC_OBJECT(F, I)                                \
295   F(AddDictionaryProperty, 3, 1)                                       \
296   F(AddPrivateBrand, 4, 1)                                             \
297   F(AllocateHeapNumber, 0, 1)                                          \
298   F(CollectTypeProfile, 3, 1)                                          \
299   F(CompleteInobjectSlackTrackingForMap, 1, 1)                         \
300   I(CopyDataProperties, 2, 1)                                          \
301   I(CopyDataPropertiesWithExcludedPropertiesOnStack, -1 /* >= 1 */, 1) \
302   I(CreateDataProperty, 3, 1)                                          \
303   I(CreateIterResultObject, 2, 1)                                      \
304   F(CreatePrivateAccessors, 2, 1)                                      \
305   F(DefineAccessorPropertyUnchecked, 5, 1)                             \
306   F(DefineKeyedOwnPropertyInLiteral, 6, 1)                             \
307   F(DefineGetterPropertyUnchecked, 4, 1)                               \
308   F(DefineSetterPropertyUnchecked, 4, 1)                               \
309   F(DeleteProperty, 3, 1)                                              \
310   F(GetDerivedMap, 2, 1)                                               \
311   F(GetFunctionName, 1, 1)                                             \
312   F(GetOwnPropertyDescriptor, 2, 1)                                    \
313   F(GetOwnPropertyKeys, 2, 1)                                          \
314   F(GetProperty, -1 /* [2, 3] */, 1)                                   \
315   F(HasFastPackedElements, 1, 1)                                       \
316   F(HasInPrototypeChain, 2, 1)                                         \
317   F(HasProperty, 2, 1)                                                 \
318   F(InternalSetPrototype, 2, 1)                                        \
319   F(IsJSReceiver, 1, 1)                                                \
320   F(JSReceiverPreventExtensionsDontThrow, 1, 1)                        \
321   F(JSReceiverPreventExtensionsThrow, 1, 1)                            \
322   F(JSReceiverGetPrototypeOf, 1, 1)                                    \
323   F(JSReceiverSetPrototypeOfDontThrow, 2, 1)                           \
324   F(JSReceiverSetPrototypeOfThrow, 2, 1)                               \
325   F(LoadPrivateGetter, 1, 1)                                           \
326   F(LoadPrivateSetter, 1, 1)                                           \
327   F(NewObject, 2, 1)                                                   \
328   F(ObjectCreate, 2, 1)                                                \
329   F(ObjectEntries, 1, 1)                                               \
330   F(ObjectEntriesSkipFastPath, 1, 1)                                   \
331   F(ObjectGetOwnPropertyNames, 1, 1)                                   \
332   F(ObjectGetOwnPropertyNamesTryFast, 1, 1)                            \
333   F(ObjectHasOwnProperty, 2, 1)                                        \
334   F(ObjectIsExtensible, 1, 1)                                          \
335   F(ObjectKeys, 1, 1)                                                  \
336   F(ObjectValues, 1, 1)                                                \
337   F(ObjectValuesSkipFastPath, 1, 1)                                    \
338   F(OptimizeObjectForAddingMultipleProperties, 2, 1)                   \
339   F(SetDataProperties, 2, 1)                                           \
340   F(SetKeyedProperty, 3, 1)                                            \
341   F(DefineObjectOwnProperty, 3, 1)                                     \
342   F(SetNamedProperty, 3, 1)                                            \
343   F(SetOwnPropertyIgnoreAttributes, 4, 1)                              \
344   F(DefineKeyedOwnPropertyInLiteral_Simple, 3, 1)                      \
345   F(ShrinkNameDictionary, 1, 1)                                        \
346   F(ShrinkSwissNameDictionary, 1, 1)                                   \
347   F(ToFastProperties, 1, 1)                                            \
348   F(ToLength, 1, 1)                                                    \
349   F(ToName, 1, 1)                                                      \
350   F(ToNumber, 1, 1)                                                    \
351   F(ToNumeric, 1, 1)                                                   \
352   F(ToObject, 1, 1)                                                    \
353   F(ToString, 1, 1)                                                    \
354   F(TryMigrateInstance, 1, 1)                                          \
355   F(SwissTableAdd, 4, 1)                                               \
356   F(SwissTableAllocate, 1, 1)                                          \
357   F(SwissTableDelete, 2, 1)                                            \
358   F(SwissTableDetailsAt, 2, 1)                                         \
359   F(SwissTableElementsCount, 1, 1)                                     \
360   F(SwissTableEquals, 2, 1)                                            \
361   F(SwissTableFindEntry, 2, 1)                                         \
362   F(SwissTableUpdate, 4, 1)                                            \
363   F(SwissTableValueAt, 2, 1)                                           \
364   F(SwissTableKeyAt, 2, 1)
365 
366 #define FOR_EACH_INTRINSIC_OPERATORS(F, I) \
367   F(Add, 2, 1)                             \
368   F(Equal, 2, 1)                           \
369   F(GreaterThan, 2, 1)                     \
370   F(GreaterThanOrEqual, 2, 1)              \
371   F(LessThan, 2, 1)                        \
372   F(LessThanOrEqual, 2, 1)                 \
373   F(NotEqual, 2, 1)                        \
374   F(StrictEqual, 2, 1)                     \
375   F(StrictNotEqual, 2, 1)                  \
376   F(ReferenceEqual, 2, 1)
377 
378 #define FOR_EACH_INTRINSIC_PROMISE(F, I) \
379   F(EnqueueMicrotask, 1, 1)              \
380   F(PromiseHookAfter, 1, 1)              \
381   F(PromiseHookBefore, 1, 1)             \
382   F(PromiseHookInit, 2, 1)               \
383   F(PromiseRejectEventFromStack, 2, 1)   \
384   F(PromiseRevokeReject, 1, 1)           \
385   F(PromiseStatus, 1, 1)                 \
386   F(RejectPromise, 3, 1)                 \
387   F(ResolvePromise, 2, 1)                \
388   F(PromiseRejectAfterResolved, 2, 1)    \
389   F(PromiseResolveAfterResolved, 2, 1)   \
390   F(ConstructAggregateErrorHelper, 4, 1) \
391   F(ConstructInternalAggregateErrorHelper, -1 /* <= 5*/, 1)
392 
393 #define FOR_EACH_INTRINSIC_PROXY(F, I) \
394   F(CheckProxyGetSetTrapResult, 2, 1)  \
395   F(CheckProxyHasTrapResult, 2, 1)     \
396   F(CheckProxyDeleteTrapResult, 2, 1)  \
397   F(GetPropertyWithReceiver, 3, 1)     \
398   F(IsJSProxy, 1, 1)                   \
399   F(JSProxyGetHandler, 1, 1)           \
400   F(JSProxyGetTarget, 1, 1)            \
401   F(SetPropertyWithReceiver, 4, 1)
402 
403 #define FOR_EACH_INTRINSIC_REGEXP(F, I)                          \
404   F(IsRegExp, 1, 1)                                              \
405   F(RegExpBuildIndices, 3, 1)                                    \
406   F(RegExpExec, 4, 1)                                            \
407   F(RegExpExecTreatMatchAtEndAsFailure, 4, 1)                    \
408   F(RegExpExperimentalOneshotExec, 4, 1)                         \
409   F(RegExpExperimentalOneshotExecTreatMatchAtEndAsFailure, 4, 1) \
410   F(RegExpExecMultiple, 4, 1)                                    \
411   F(RegExpInitializeAndCompile, 3, 1)                            \
412   F(RegExpReplaceRT, 3, 1)                                       \
413   F(RegExpSplit, 3, 1)                                           \
414   F(RegExpStringFromFlags, 1, 1)                                 \
415   F(StringReplaceNonGlobalRegExpWithFunction, 3, 1)              \
416   F(StringSplit, 3, 1)
417 
418 #define FOR_EACH_INTRINSIC_SCOPES(F, I)            \
419   F(DeclareEvalFunction, 2, 1)                     \
420   F(DeclareEvalVar, 1, 1)                          \
421   F(DeclareGlobals, 2, 1)                          \
422   F(DeclareModuleExports, 2, 1)                    \
423   F(DeleteLookupSlot, 1, 1)                        \
424   F(LoadLookupSlot, 1, 1)                          \
425   F(LoadLookupSlotInsideTypeof, 1, 1)              \
426                                                    \
427   F(NewClosure, 2, 1)                              \
428   F(NewClosure_Tenured, 2, 1)                      \
429   F(NewFunctionContext, 1, 1)                      \
430   F(NewRestParameter, 1, 1)                        \
431   F(NewSloppyArguments, 1, 1)                      \
432   F(NewStrictArguments, 1, 1)                      \
433   F(PushBlockContext, 1, 1)                        \
434   F(PushCatchContext, 2, 1)                        \
435   F(PushWithContext, 2, 1)                         \
436   F(StoreGlobalNoHoleCheckForReplLetOrConst, 2, 1) \
437   F(StoreLookupSlot_Sloppy, 2, 1)                  \
438   F(StoreLookupSlot_SloppyHoisting, 2, 1)          \
439   F(StoreLookupSlot_Strict, 2, 1)                  \
440   F(ThrowConstAssignError, 0, 1)
441 
442 #define FOR_EACH_INTRINSIC_SHADOW_REALM(F, I) \
443   F(ShadowRealmWrappedFunctionCreate, 2, 1)
444 
445 #define FOR_EACH_INTRINSIC_STRINGS(F, I)  \
446   F(FlattenString, 1, 1)                  \
447   F(GetSubstitution, 5, 1)                \
448   F(InternalizeString, 1, 1)              \
449   F(StringAdd, 2, 1)                      \
450   F(StringBuilderConcat, 3, 1)            \
451   F(StringCharCodeAt, 2, 1)               \
452   F(StringEqual, 2, 1)                    \
453   F(StringEscapeQuotes, 1, 1)             \
454   F(StringGreaterThan, 2, 1)              \
455   F(StringGreaterThanOrEqual, 2, 1)       \
456   F(StringLastIndexOf, 2, 1)              \
457   F(StringLessThan, 2, 1)                 \
458   F(StringLessThanOrEqual, 2, 1)          \
459   F(StringMaxLength, 0, 1)                \
460   F(StringReplaceOneCharWithString, 3, 1) \
461   F(StringSubstring, 3, 1)                \
462   F(StringToArray, 2, 1)
463 
464 #define FOR_EACH_INTRINSIC_SYMBOL(F, I)    \
465   F(CreatePrivateNameSymbol, 1, 1)         \
466   F(CreatePrivateBrandSymbol, 1, 1)        \
467   F(CreatePrivateSymbol, -1 /* <= 1 */, 1) \
468   F(SymbolDescriptiveString, 1, 1)         \
469   F(SymbolIsPrivate, 1, 1)
470 
471 #define FOR_EACH_INTRINSIC_TEST(F, I)         \
472   F(Abort, 1, 1)                              \
473   F(AbortCSADcheck, 1, 1)                     \
474   F(AbortJS, 1, 1)                            \
475   F(ActiveTierIsMaglev, 1, 1)                 \
476   F(ArrayIteratorProtector, 0, 1)             \
477   F(ArraySpeciesProtector, 0, 1)              \
478   F(BaselineOsr, -1, 1)                       \
479   F(BenchMaglev, 2, 1)                        \
480   F(ClearFunctionFeedback, 1, 1)              \
481   F(ClearMegamorphicStubCache, 0, 1)          \
482   F(CompleteInobjectSlackTracking, 1, 1)      \
483   F(ConstructConsString, 2, 1)                \
484   F(ConstructDouble, 2, 1)                    \
485   F(ConstructSlicedString, 2, 1)              \
486   F(DebugPrint, 1, 1)                         \
487   F(DebugPrintPtr, 1, 1)                      \
488   F(DebugTrace, 0, 1)                         \
489   F(DebugTrackRetainingPath, -1, 1)           \
490   F(DeoptimizeFunction, 1, 1)                 \
491   F(DisableOptimizationFinalization, 0, 1)    \
492   F(DisallowCodegenFromStrings, 1, 1)         \
493   F(DisassembleFunction, 1, 1)                \
494   F(EnableCodeLoggingForTesting, 0, 1)        \
495   F(EnsureFeedbackVectorForFunction, 1, 1)    \
496   F(FinalizeOptimization, 0, 1)               \
497   F(GetCallable, 0, 1)                        \
498   F(GetInitializerFunction, 1, 1)             \
499   F(GetOptimizationStatus, 1, 1)              \
500   F(GetUndetectable, 0, 1)                    \
501   F(GlobalPrint, 1, 1)                        \
502   F(HasDictionaryElements, 1, 1)              \
503   F(HasDoubleElements, 1, 1)                  \
504   F(HasElementsInALargeObjectSpace, 1, 1)     \
505   F(HasFastElements, 1, 1)                    \
506   F(HasFastProperties, 1, 1)                  \
507   F(HasFixedBigInt64Elements, 1, 1)           \
508   F(HasFixedBigUint64Elements, 1, 1)          \
509   F(HasFixedFloat32Elements, 1, 1)            \
510   F(HasFixedFloat64Elements, 1, 1)            \
511   F(HasFixedInt16Elements, 1, 1)              \
512   F(HasFixedInt32Elements, 1, 1)              \
513   F(HasFixedInt8Elements, 1, 1)               \
514   F(HasFixedUint16Elements, 1, 1)             \
515   F(HasFixedUint32Elements, 1, 1)             \
516   F(HasFixedUint8ClampedElements, 1, 1)       \
517   F(HasFixedUint8Elements, 1, 1)              \
518   F(HasHoleyElements, 1, 1)                   \
519   F(HasObjectElements, 1, 1)                  \
520   F(HasOwnConstDataProperty, 2, 1)            \
521   F(HasPackedElements, 1, 1)                  \
522   F(HasSloppyArgumentsElements, 1, 1)         \
523   F(HasSmiElements, 1, 1)                     \
524   F(HasSmiOrObjectElements, 1, 1)             \
525   F(HaveSameMap, 2, 1)                        \
526   F(HeapObjectVerify, 1, 1)                   \
527   F(ICsAreEnabled, 0, 1)                      \
528   F(InLargeObjectSpace, 1, 1)                 \
529   F(InYoungGeneration, 1, 1)                  \
530   F(Is64Bit, 0, 1)                            \
531   F(IsAtomicsWaitAllowed, 0, 1)               \
532   F(IsBeingInterpreted, 0, 1)                 \
533   F(IsConcatSpreadableProtector, 0, 1)        \
534   F(IsConcurrentRecompilationSupported, 0, 1) \
535   F(IsDictPropertyConstTrackingEnabled, 0, 1) \
536   F(IsSameHeapObject, 2, 1)                   \
537   F(IsSharedString, 1, 1)                     \
538   F(MapIteratorProtector, 0, 1)               \
539   F(NeverOptimizeFunction, 1, 1)              \
540   F(NewRegExpWithBacktrackLimit, 3, 1)        \
541   F(NotifyContextDisposed, 0, 1)              \
542   F(OptimizeMaglevOnNextCall, 1, 1)           \
543   F(OptimizeFunctionOnNextCall, -1, 1)        \
544   F(OptimizeOsr, -1, 1)                       \
545   F(PrepareFunctionForOptimization, -1, 1)    \
546   F(PretenureAllocationSite, 1, 1)            \
547   F(PrintWithNameForAssert, 2, 1)             \
548   F(PromiseSpeciesProtector, 0, 1)            \
549   F(RegExpSpeciesProtector, 0, 1)             \
550   F(RegexpHasBytecode, 2, 1)                  \
551   F(RegexpHasNativeCode, 2, 1)                \
552   F(RegexpIsUnmodified, 1, 1)                 \
553   F(RegexpTypeTag, 1, 1)                      \
554   F(RunningInSimulator, 0, 1)                 \
555   F(RuntimeEvaluateREPL, 1, 1)                \
556   F(ScheduleGCInStackCheck, 0, 1)             \
557   F(SerializeDeserializeNow, 0, 1)            \
558   F(SetAllocationTimeout, -1 /* 2 || 3 */, 1) \
559   F(SetForceSlowPath, 1, 1)                   \
560   F(SetIteratorProtector, 0, 1)               \
561   F(SharedGC, 0, 1)                           \
562   F(SimulateNewspaceFull, 0, 1)               \
563   F(StringIteratorProtector, 0, 1)            \
564   F(SystemBreak, 0, 1)                        \
565   F(TakeHeapSnapshot, -1, 1)                  \
566   F(TraceEnter, 0, 1)                         \
567   F(TraceExit, 1, 1)                          \
568   F(TurbofanStaticAssert, 1, 1)               \
569   F(TypedArraySpeciesProtector, 0, 1)         \
570   F(WaitForBackgroundOptimization, 0, 1)      \
571   F(WebSnapshotDeserialize, -1, 1)            \
572   F(WebSnapshotSerialize, -1, 1)              \
573   I(DeoptimizeNow, 0, 1)
574 
575 #define FOR_EACH_INTRINSIC_TYPEDARRAY(F, I)    \
576   F(ArrayBufferDetach, 1, 1)                   \
577   F(GrowableSharedArrayBufferByteLength, 1, 1) \
578   F(TypedArrayCopyElements, 3, 1)              \
579   F(TypedArrayGetBuffer, 1, 1)                 \
580   F(TypedArraySet, 2, 1)                       \
581   F(TypedArraySortFast, 1, 1)
582 
583 #define FOR_EACH_INTRINSIC_WASM(F, I) \
584   F(ThrowWasmError, 1, 1)             \
585   F(ThrowWasmStackOverflow, 0, 1)     \
586   F(WasmI32AtomicWait, 4, 1)          \
587   F(WasmI64AtomicWait, 5, 1)          \
588   F(WasmAtomicNotify, 3, 1)           \
589   F(WasmMemoryGrow, 2, 1)             \
590   F(WasmStackGuard, 0, 1)             \
591   F(WasmThrow, 2, 1)                  \
592   F(WasmReThrow, 1, 1)                \
593   F(WasmThrowJSTypeError, 0, 1)       \
594   F(WasmRefFunc, 1, 1)                \
595   F(WasmFunctionTableGet, 3, 1)       \
596   F(WasmFunctionTableSet, 4, 1)       \
597   F(WasmTableInit, 6, 1)              \
598   F(WasmTableCopy, 6, 1)              \
599   F(WasmTableGrow, 3, 1)              \
600   F(WasmTableFill, 5, 1)              \
601   F(WasmIsValidRefValue, 3, 1)        \
602   F(WasmCompileLazy, 2, 1)            \
603   F(WasmCompileWrapper, 2, 1)         \
604   F(WasmTriggerTierUp, 1, 1)          \
605   F(WasmDebugBreak, 0, 1)             \
606   F(WasmArrayCopy, 5, 1)              \
607   F(WasmArrayInitFromData, 5, 1)      \
608   F(WasmAllocateContinuation, 1, 1)   \
609   F(WasmSyncStackLimit, 0, 1)         \
610   F(WasmCreateResumePromise, 2, 1)
611 
612 #define FOR_EACH_INTRINSIC_WASM_TEST(F, I) \
613   F(DeserializeWasmModule, 2, 1)           \
614   F(DisallowWasmCodegen, 1, 1)             \
615   F(FreezeWasmLazyCompilation, 1, 1)       \
616   F(GetWasmExceptionTagId, 2, 1)           \
617   F(GetWasmExceptionValues, 1, 1)          \
618   F(GetWasmRecoveredTrapCount, 0, 1)       \
619   F(IsAsmWasmCode, 1, 1)                   \
620   F(IsLiftoffFunction, 1, 1)               \
621   F(IsTurboFanFunction, 1, 1)              \
622   F(IsThreadInWasm, 0, 1)                  \
623   F(IsWasmCode, 1, 1)                      \
624   F(IsWasmTrapHandlerEnabled, 0, 1)        \
625   F(SerializeWasmModule, 1, 1)             \
626   F(SetWasmCompileControls, 2, 1)          \
627   F(SetWasmInstantiateControls, 0, 1)      \
628   F(WasmGetNumberOfInstances, 1, 1)        \
629   F(WasmNumCodeSpaces, 1, 1)               \
630   F(WasmTierDown, 0, 1)                    \
631   F(WasmTierUp, 0, 1)                      \
632   F(WasmTierUpFunction, 2, 1)              \
633   F(WasmTraceEnter, 0, 1)                  \
634   F(WasmTraceExit, 1, 1)                   \
635   F(WasmTraceMemory, 1, 1)
636 
637 #define FOR_EACH_INTRINSIC_WEAKREF(F, I)                             \
638   F(JSFinalizationRegistryRegisterWeakCellWithUnregisterToken, 4, 1) \
639   F(JSWeakRefAddToKeptObjects, 1, 1)                                 \
640   F(ShrinkFinalizationRegistryUnregisterTokenMap, 1, 1)
641 
642 #define FOR_EACH_INTRINSIC_RETURN_PAIR_IMPL(F, I) \
643   F(DebugBreakOnBytecode, 1, 2)                   \
644   F(LoadLookupSlotForCall, 1, 2)
645 
646 // Most intrinsics are implemented in the runtime/ directory, but ICs are
647 // implemented in ic.cc for now.
648 #define FOR_EACH_INTRINSIC_IC(F, I)          \
649   F(ElementsTransitionAndStoreIC_Miss, 6, 1) \
650   F(KeyedLoadIC_Miss, 4, 1)                  \
651   F(KeyedStoreIC_Miss, 5, 1)                 \
652   F(DefineKeyedOwnIC_Miss, 5, 1)             \
653   F(StoreInArrayLiteralIC_Miss, 5, 1)        \
654   F(DefineNamedOwnIC_Slow, 3, 1)             \
655   F(KeyedStoreIC_Slow, 3, 1)                 \
656   F(DefineKeyedOwnIC_Slow, 3, 1)             \
657   F(LoadElementWithInterceptor, 2, 1)        \
658   F(LoadGlobalIC_Miss, 4, 1)                 \
659   F(LoadGlobalIC_Slow, 3, 1)                 \
660   F(LoadIC_Miss, 4, 1)                       \
661   F(LoadNoFeedbackIC_Miss, 4, 1)             \
662   F(LoadWithReceiverIC_Miss, 5, 1)           \
663   F(LoadWithReceiverNoFeedbackIC_Miss, 3, 1) \
664   F(LoadPropertyWithInterceptor, 5, 1)       \
665   F(StoreCallbackProperty, 5, 1)             \
666   F(StoreGlobalIC_Miss, 4, 1)                \
667   F(StoreGlobalICNoFeedback_Miss, 2, 1)      \
668   F(StoreGlobalIC_Slow, 5, 1)                \
669   F(StoreIC_Miss, 5, 1)                      \
670   F(DefineNamedOwnIC_Miss, 5, 1)             \
671   F(StoreInArrayLiteralIC_Slow, 5, 1)        \
672   F(StorePropertyWithInterceptor, 5, 1)      \
673   F(CloneObjectIC_Miss, 4, 1)                \
674   F(KeyedHasIC_Miss, 4, 1)                   \
675   F(HasElementWithInterceptor, 2, 1)
676 
677 #define FOR_EACH_INTRINSIC_RETURN_OBJECT_IMPL(F, I) \
678   FOR_EACH_INTRINSIC_ARRAY(F, I)                    \
679   FOR_EACH_INTRINSIC_ATOMICS(F, I)                  \
680   FOR_EACH_INTRINSIC_BIGINT(F, I)                   \
681   FOR_EACH_INTRINSIC_CLASSES(F, I)                  \
682   FOR_EACH_INTRINSIC_COLLECTIONS(F, I)              \
683   FOR_EACH_INTRINSIC_COMPILER(F, I)                 \
684   FOR_EACH_INTRINSIC_DATE(F, I)                     \
685   FOR_EACH_INTRINSIC_DEBUG(F, I)                    \
686   FOR_EACH_INTRINSIC_FORIN(F, I)                    \
687   FOR_EACH_INTRINSIC_FUNCTION(F, I)                 \
688   FOR_EACH_INTRINSIC_GENERATOR(F, I)                \
689   FOR_EACH_INTRINSIC_IC(F, I)                       \
690   FOR_EACH_INTRINSIC_INTERNAL(F, I)                 \
691   FOR_EACH_INTRINSIC_TRACE(F, I)                    \
692   FOR_EACH_INTRINSIC_INTL(F, I)                     \
693   FOR_EACH_INTRINSIC_LITERALS(F, I)                 \
694   FOR_EACH_INTRINSIC_MODULE(F, I)                   \
695   FOR_EACH_INTRINSIC_NUMBERS(F, I)                  \
696   FOR_EACH_INTRINSIC_OBJECT(F, I)                   \
697   FOR_EACH_INTRINSIC_OPERATORS(F, I)                \
698   FOR_EACH_INTRINSIC_PROMISE(F, I)                  \
699   FOR_EACH_INTRINSIC_PROXY(F, I)                    \
700   FOR_EACH_INTRINSIC_REGEXP(F, I)                   \
701   FOR_EACH_INTRINSIC_SCOPES(F, I)                   \
702   FOR_EACH_INTRINSIC_SHADOW_REALM(F, I)             \
703   FOR_EACH_INTRINSIC_STRINGS(F, I)                  \
704   FOR_EACH_INTRINSIC_SYMBOL(F, I)                   \
705   FOR_EACH_INTRINSIC_TEST(F, I)                     \
706   FOR_EACH_INTRINSIC_TYPEDARRAY(F, I)               \
707   IF_WASM(FOR_EACH_INTRINSIC_WASM, F, I)            \
708   IF_WASM(FOR_EACH_INTRINSIC_WASM_TEST, F, I)       \
709   FOR_EACH_INTRINSIC_WEAKREF(F, I)
710 
711 // Defines the list of all intrinsics, coming in 2 flavors, either returning an
712 // object or a pair.
713 #define FOR_EACH_INTRINSIC_IMPL(F, I)       \
714   FOR_EACH_INTRINSIC_RETURN_PAIR_IMPL(F, I) \
715   FOR_EACH_INTRINSIC_RETURN_OBJECT_IMPL(F, I)
716 
717 #define FOR_EACH_INTRINSIC_RETURN_OBJECT(F) \
718   FOR_EACH_INTRINSIC_RETURN_OBJECT_IMPL(F, F)
719 
720 #define FOR_EACH_INTRINSIC_RETURN_PAIR(F) \
721   FOR_EACH_INTRINSIC_RETURN_PAIR_IMPL(F, F)
722 
723 // The list of all intrinsics, including those that have inline versions, but
724 // not the inline versions themselves.
725 #define FOR_EACH_INTRINSIC(F) FOR_EACH_INTRINSIC_IMPL(F, F)
726 
727 // The list of all inline intrinsics only.
728 #define FOR_EACH_INLINE_INTRINSIC(I) FOR_EACH_INTRINSIC_IMPL(NOTHING, I)
729 
730 #define F(name, nargs, ressize)                                 \
731   Address Runtime_##name(int args_length, Address* args_object, \
732                          Isolate* isolate);
FOR_EACH_INTRINSIC_RETURN_OBJECT(F)733 FOR_EACH_INTRINSIC_RETURN_OBJECT(F)
734 #undef F
735 
736 //---------------------------------------------------------------------------
737 // Runtime provides access to all C++ runtime functions.
738 
739 class Runtime : public AllStatic {
740  public:
741   enum FunctionId : int32_t {
742 #define F(name, nargs, ressize) k##name,
743 #define I(name, nargs, ressize) kInline##name,
744     FOR_EACH_INTRINSIC(F) FOR_EACH_INLINE_INTRINSIC(I)
745 #undef I
746 #undef F
747         kNumFunctions,
748   };
749 
750   static constexpr int kNumInlineFunctions =
751 #define COUNT(...) +1
752       FOR_EACH_INLINE_INTRINSIC(COUNT);
753 #undef COUNT
754 
755   enum IntrinsicType { RUNTIME, INLINE };
756 
757   // Intrinsic function descriptor.
758   struct Function {
759     FunctionId function_id;
760     IntrinsicType intrinsic_type;
761     // The JS name of the function.
762     const char* name;
763 
764     // For RUNTIME functions, this is the C++ entry point.
765     // For INLINE functions this is the C++ entry point of the fall back.
766     Address entry;
767 
768     // The number of arguments expected. nargs is -1 if the function takes
769     // a variable number of arguments.
770     int8_t nargs;
771     // Size of result.  Most functions return a single pointer, size 1.
772     int8_t result_size;
773   };
774 
775   static const int kNotFound = -1;
776 
777   // Checks whether the runtime function with the given {id} depends on the
778   // "current context", i.e. because it does scoped lookups, or whether it's
779   // fine to just pass any context within the same "native context".
780   static bool NeedsExactContext(FunctionId id);
781 
782   // Checks whether the runtime function with the given {id} never returns
783   // to it's caller normally, i.e. whether it'll always raise an exception.
784   // More specifically: The C++ implementation returns the Heap::exception
785   // sentinel, always.
786   static bool IsNonReturning(FunctionId id);
787 
788   // Check if a runtime function with the given {id} may trigger a heap
789   // allocation.
790   static bool MayAllocate(FunctionId id);
791 
792   // Check if a runtime function with the given {id} is allowlisted for
793   // using it with fuzzers.
794   static bool IsAllowListedForFuzzing(FunctionId id);
795 
796   // Get the intrinsic function with the given name.
797   static const Function* FunctionForName(const unsigned char* name, int length);
798 
799   // Get the intrinsic function with the given FunctionId.
800   V8_EXPORT_PRIVATE static const Function* FunctionForId(FunctionId id);
801 
802   // Get the intrinsic function with the given function entry address.
803   static const Function* FunctionForEntry(Address ref);
804 
805   // Get the runtime intrinsic function table.
806   static const Function* RuntimeFunctionTable(Isolate* isolate);
807 
808   V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static Maybe<bool>
809   DeleteObjectProperty(Isolate* isolate, Handle<JSReceiver> receiver,
810                        Handle<Object> key, LanguageMode language_mode);
811 
812   // Perform a property store on object. If the key is a private name (i.e. this
813   // is a private field assignment), this method throws if the private field
814   // does not exist on object.
815   V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
816   SetObjectProperty(Isolate* isolate, Handle<Object> object, Handle<Object> key,
817                     Handle<Object> value, StoreOrigin store_origin,
818                     Maybe<ShouldThrow> should_throw = Nothing<ShouldThrow>());
819 
820   // Defines a property on object. If the key is a private name (i.e. this is a
821   // private field definition), this method throws if the field already exists
822   // on object.
823   V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
824   DefineObjectOwnProperty(Isolate* isolate, Handle<Object> object,
825                           Handle<Object> key, Handle<Object> value,
826                           StoreOrigin store_origin);
827 
828   // When "receiver" is not passed, it defaults to "lookup_start_object".
829   V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
830   GetObjectProperty(Isolate* isolate, Handle<Object> lookup_start_object,
831                     Handle<Object> key,
832                     Handle<Object> receiver = Handle<Object>(),
833                     bool* is_found = nullptr);
834 
835   V8_WARN_UNUSED_RESULT static MaybeHandle<Object> HasProperty(
836       Isolate* isolate, Handle<Object> object, Handle<Object> key);
837 
838   V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<JSArray>
839   GetInternalProperties(Isolate* isolate, Handle<Object>);
840 
841   V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ThrowIteratorError(
842       Isolate* isolate, Handle<Object> object);
843 };
844 
845 class RuntimeState {
846  public:
847   RuntimeState(const RuntimeState&) = delete;
848   RuntimeState& operator=(const RuntimeState&) = delete;
849 #ifndef V8_INTL_SUPPORT
to_upper_mapping()850   unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
851     return &to_upper_mapping_;
852   }
to_lower_mapping()853   unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
854     return &to_lower_mapping_;
855   }
856 #endif
857 
redirected_intrinsic_functions()858   Runtime::Function* redirected_intrinsic_functions() {
859     return redirected_intrinsic_functions_.get();
860   }
861 
set_redirected_intrinsic_functions(Runtime::Function * redirected_intrinsic_functions)862   void set_redirected_intrinsic_functions(
863       Runtime::Function* redirected_intrinsic_functions) {
864     redirected_intrinsic_functions_.reset(redirected_intrinsic_functions);
865   }
866 
867  private:
868   RuntimeState() = default;
869 #ifndef V8_INTL_SUPPORT
870   unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
871   unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
872 #endif
873 
874   std::unique_ptr<Runtime::Function[]> redirected_intrinsic_functions_;
875 
876   friend class Isolate;
877   friend class Runtime;
878 };
879 
880 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, Runtime::FunctionId);
881 
882 //---------------------------------------------------------------------------
883 // Constants used by interface to runtime functions.
884 
885 using AllocateDoubleAlignFlag = base::BitField<bool, 0, 1>;
886 
887 using AllowLargeObjectAllocationFlag = base::BitField<bool, 1, 1>;
888 
889 // A set of bits returned by Runtime_GetOptimizationStatus.
890 // These bits must be in sync with bits defined in test/mjsunit/mjsunit.js
891 enum class OptimizationStatus {
892   kIsFunction = 1 << 0,
893   kNeverOptimize = 1 << 1,
894   kAlwaysOptimize = 1 << 2,
895   kMaybeDeopted = 1 << 3,
896   kOptimized = 1 << 4,
897   kMaglevved = 1 << 5,
898   kTurboFanned = 1 << 6,
899   kInterpreted = 1 << 7,
900   kMarkedForOptimization = 1 << 8,
901   kMarkedForConcurrentOptimization = 1 << 9,
902   kOptimizingConcurrently = 1 << 10,
903   kIsExecuting = 1 << 11,
904   kTopmostFrameIsTurboFanned = 1 << 12,
905   kLiteMode = 1 << 13,
906   kMarkedForDeoptimization = 1 << 14,
907   kBaseline = 1 << 15,
908   kTopmostFrameIsInterpreted = 1 << 16,
909   kTopmostFrameIsBaseline = 1 << 17,
910 };
911 
912 }  // namespace internal
913 }  // namespace v8
914 
915 #endif  // V8_RUNTIME_RUNTIME_H_
916