runtime.h 38.2 KB
Newer Older
1
// Copyright 2012 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5 6
#ifndef V8_RUNTIME_RUNTIME_H_
#define V8_RUNTIME_RUNTIME_H_
7

8 9
#include <memory>

10
#include "include/v8.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 21
namespace v8 {
namespace internal {
22

23
// * Each intrinsic is exposed in JavaScript via:
24
//    * %#name, which is always a runtime call.
25 26
//    * (optionally) %_#name, which can be inlined or just a runtime call, the
//      compiler in question decides.
27 28 29 30 31 32 33 34 35 36
//
// * IntrinsicTypes are Runtime::RUNTIME and Runtime::INLINE, respectively.
//
// * IDs are Runtime::k##name and Runtime::kInline##name, respectively.
//
// * All intrinsics have a C++ implementation Runtime_##name.
//
// * Each compiler has an explicit list of intrisics it supports, falling back
//   to a simple runtime call if necessary.

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 40 41
// are specified by inline comments. To declare only the runtime version (no
// inline), use the F macro below. To declare the runtime version and the inline
// version simultaneously, use the I macro below.
42

43 44 45 46 47 48
#define FOR_EACH_INTRINSIC_ARRAY(F, I) \
  F(ArrayIncludes_Slow, 3, 1)          \
  F(ArrayIndexOf, 3, 1)                \
  F(ArrayIsArray, 1, 1)                \
  F(ArraySpeciesConstructor, 1, 1)     \
  F(GrowArrayElements, 2, 1)           \
49
  F(IsArray, 1, 1)                     \
50 51 52 53
  F(NewArray, -1 /* >= 3 */, 1)        \
  F(NormalizeElements, 1, 1)           \
  F(TransitionElementsKind, 2, 1)      \
  F(TransitionElementsKindWithKind, 2, 1)
54

55 56 57 58 59 60 61 62 63 64 65 66 67
#define FOR_EACH_INTRINSIC_ATOMICS(F, I)               \
  F(AtomicsLoad64, 2, 1)                               \
  F(AtomicsStore64, 3, 1)                              \
  F(AtomicsAdd, 3, 1)                                  \
  F(AtomicsAnd, 3, 1)                                  \
  F(AtomicsCompareExchange, 4, 1)                      \
  F(AtomicsExchange, 3, 1)                             \
  F(AtomicsNumWaitersForTesting, 2, 1)                 \
  F(AtomicsNumAsyncWaitersForTesting, 0, 1)            \
  F(AtomicsNumUnresolvedAsyncPromisesForTesting, 2, 1) \
  F(AtomicsOr, 3, 1)                                   \
  F(AtomicsSub, 3, 1)                                  \
  F(AtomicsXor, 3, 1)                                  \
68
  F(SetAllowAtomicsWait, 1, 1)
binji's avatar
binji committed
69

70 71 72 73 74 75 76 77 78 79 80
#define FOR_EACH_INTRINSIC_BIGINT(F, I) \
  F(BigIntBinaryOp, 3, 1)               \
  F(BigIntCompareToBigInt, 3, 1)        \
  F(BigIntCompareToNumber, 3, 1)        \
  F(BigIntCompareToString, 3, 1)        \
  F(BigIntEqualToBigInt, 2, 1)          \
  F(BigIntEqualToNumber, 2, 1)          \
  F(BigIntEqualToString, 2, 1)          \
  F(BigIntToBoolean, 1, 1)              \
  F(BigIntToNumber, 1, 1)               \
  F(BigIntUnaryOp, 2, 1)                \
81
  F(ToBigInt, 1, 1)
82

83
#define FOR_EACH_INTRINSIC_CLASSES(F, I)    \
84 85 86
  F(DefineClass, -1 /* >= 3 */, 1)          \
  F(LoadFromSuper, 3, 1)                    \
  F(LoadKeyedFromSuper, 3, 1)               \
87 88
  F(StoreKeyedToSuper, 4, 1)                \
  F(StoreToSuper, 4, 1)                     \
89 90 91 92 93 94
  F(ThrowConstructorNonCallableError, 1, 1) \
  F(ThrowNotSuperConstructor, 2, 1)         \
  F(ThrowStaticPrototypeError, 0, 1)        \
  F(ThrowSuperAlreadyCalledError, 0, 1)     \
  F(ThrowSuperNotCalled, 0, 1)              \
  F(ThrowUnsupportedSuperError, 0, 1)
95

96 97 98 99 100 101 102
#define FOR_EACH_INTRINSIC_COLLECTIONS(F, I) \
  F(MapGrow, 1, 1)                           \
  F(MapShrink, 1, 1)                         \
  F(SetGrow, 1, 1)                           \
  F(SetShrink, 1, 1)                         \
  F(TheHole, 0, 1)                           \
  F(WeakCollectionDelete, 3, 1)              \
103
  F(WeakCollectionSet, 4, 1)
104

105
#define FOR_EACH_INTRINSIC_COMPILER(F, I) \
106
  F(CompileForOnStackReplacement, 0, 1)   \
107
  F(CompileLazy, 1, 1)                    \
108
  F(CompileBaseline, 1, 1)                \
109 110
  F(CompileOptimized_Concurrent, 1, 1)    \
  F(CompileOptimized_NotConcurrent, 1, 1) \
111
  F(InstallBaselineCode, 1, 1)            \
112
  F(HealOptimizedCodeSlot, 1, 1)          \
113 114
  F(FunctionFirstExecution, 1, 1)         \
  F(InstantiateAsmJs, 4, 1)               \
115
  F(NotifyDeoptimized, 0, 1)              \
116
  F(ObserveNode, 1, 1)                    \
117 118
  F(ResolvePossiblyDirectEval, 6, 1)      \
  F(VerifyType, 1, 1)
119

120
#define FOR_EACH_INTRINSIC_DATE(F, I) F(DateCurrentTime, 0, 1)
121

122
#define FOR_EACH_INTRINSIC_DEBUG(F, I)          \
123
  F(ClearStepping, 0, 1)                        \
124
  F(CollectGarbage, 1, 1)                       \
125 126
  F(DebugAsyncFunctionEntered, 1, 1)            \
  F(DebugAsyncFunctionSuspended, 1, 1)          \
127 128
  F(DebugAsyncFunctionResumed, 1, 1)            \
  F(DebugAsyncFunctionFinished, 2, 1)           \
129 130
  F(DebugBreakAtEntry, 1, 1)                    \
  F(DebugCollectCoverage, 0, 1)                 \
131
  F(DebugGetLoadedScriptIds, 0, 1)              \
132
  F(DebugOnFunctionCall, 2, 1)                  \
133 134 135 136 137 138 139 140 141 142 143
  F(DebugPopPromise, 0, 1)                      \
  F(DebugPrepareStepInSuspendedGenerator, 0, 1) \
  F(DebugPushPromise, 1, 1)                     \
  F(DebugToggleBlockCoverage, 1, 1)             \
  F(DebugTogglePreciseCoverage, 1, 1)           \
  F(FunctionGetInferredName, 1, 1)              \
  F(GetBreakLocations, 1, 1)                    \
  F(GetGeneratorScopeCount, 1, 1)               \
  F(GetGeneratorScopeDetails, 2, 1)             \
  F(HandleDebuggerStatement, 0, 1)              \
  F(IsBreakOnException, 1, 1)                   \
144 145
  F(LiveEditPatchScript, 2, 1)                  \
  F(ProfileCreateSnapshotDataBlob, 0, 1)        \
146
  F(ScheduleBreak, 0, 1)                        \
147
  F(ScriptLocationFromLine2, 4, 1)              \
148
  F(SetGeneratorScopeVariableValue, 4, 1)       \
149
  I(IncBlockCounter, 2, 1)
150

151 152
#define FOR_EACH_INTRINSIC_FORIN(F, I) \
  F(ForInEnumerate, 1, 1)              \
153
  F(ForInHasProperty, 2, 1)
154

155 156 157 158
#ifdef V8_TRACE_UNOPTIMIZED
#define FOR_EACH_INTRINSIC_TRACE_UNOPTIMIZED(F, I) \
  F(TraceUnoptimizedBytecodeEntry, 3, 1)           \
  F(TraceUnoptimizedBytecodeExit, 3, 1)
159
#else
160
#define FOR_EACH_INTRINSIC_TRACE_UNOPTIMIZED(F, I)
161 162
#endif

163
#ifdef V8_TRACE_FEEDBACK_UPDATES
164
#define FOR_EACH_INTRINSIC_TRACE_FEEDBACK(F, I) F(TraceUpdateFeedback, 3, 1)
165
#else
166
#define FOR_EACH_INTRINSIC_TRACE_FEEDBACK(F, I)
167 168
#endif

169 170 171
#define FOR_EACH_INTRINSIC_TRACE(F, I)       \
  FOR_EACH_INTRINSIC_TRACE_UNOPTIMIZED(F, I) \
  FOR_EACH_INTRINSIC_TRACE_FEEDBACK(F, I)
172

173
#define FOR_EACH_INTRINSIC_FUNCTION(F, I)  \
174
  F(Call, -1 /* >= 2 */, 1)                \
175
  F(FunctionGetScriptSource, 1, 1)         \
176
  F(FunctionGetScriptId, 1, 1)             \
177
  F(FunctionGetScriptSourcePosition, 1, 1) \
178
  F(FunctionGetSourceCode, 1, 1)           \
179
  F(FunctionIsAPIFunction, 1, 1)           \
180
  F(IsFunction, 1, 1)
181

182
#define FOR_EACH_INTRINSIC_GENERATOR(F, I)    \
183 184
  I(AsyncFunctionAwaitCaught, 2, 1)           \
  I(AsyncFunctionAwaitUncaught, 2, 1)         \
185 186 187
  I(AsyncFunctionEnter, 2, 1)                 \
  I(AsyncFunctionReject, 3, 1)                \
  I(AsyncFunctionResolve, 3, 1)               \
188 189
  I(AsyncGeneratorAwaitCaught, 2, 1)          \
  I(AsyncGeneratorAwaitUncaught, 2, 1)        \
190
  F(AsyncGeneratorHasCatchHandlerForPC, 1, 1) \
191 192 193 194 195
  I(AsyncGeneratorReject, 2, 1)               \
  I(AsyncGeneratorResolve, 3, 1)              \
  I(AsyncGeneratorYield, 3, 1)                \
  I(CreateJSGeneratorObject, 2, 1)            \
  I(GeneratorClose, 1, 1)                     \
196
  F(GeneratorGetFunction, 1, 1)               \
197
  I(GeneratorGetResumeMode, 1, 1)
198

199
#ifdef V8_INTL_SUPPORT
200 201 202 203
#define FOR_EACH_INTRINSIC_INTL(F, I) \
  F(FormatList, 2, 1)                 \
  F(FormatListToParts, 2, 1)          \
  F(StringToLowerCaseIntl, 1, 1)      \
204
  F(StringToUpperCaseIntl, 1, 1)  // End of macro.
205
#else
206
#define FOR_EACH_INTRINSIC_INTL(F, I)
207
#endif  // V8_INTL_SUPPORT
208

209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
#define FOR_EACH_INTRINSIC_INTERNAL(F, I)                    \
  F(AccessCheck, 1, 1)                                       \
  F(AllocateByteArray, 1, 1)                                 \
  F(AllocateInYoungGeneration, 2, 1)                         \
  F(AllocateInOldGeneration, 2, 1)                           \
  F(AllocateSeqOneByteString, 1, 1)                          \
  F(AllocateSeqTwoByteString, 1, 1)                          \
  F(AllowDynamicFunction, 1, 1)                              \
  I(CreateAsyncFromSyncIterator, 1, 1)                       \
  F(CreateListFromArrayLike, 1, 1)                           \
  F(DoubleToStringWithRadix, 2, 1)                           \
  F(FatalProcessOutOfMemoryInAllocateRaw, 0, 1)              \
  F(FatalProcessOutOfMemoryInvalidArrayLength, 0, 1)         \
  F(GetAndResetRuntimeCallStats, -1 /* <= 2 */, 1)           \
  F(GetTemplateObject, 3, 1)                                 \
  F(IncrementUseCounter, 1, 1)                               \
  F(BytecodeBudgetInterruptFromBytecode, 1, 1)               \
  F(BytecodeBudgetInterruptWithStackCheckFromBytecode, 1, 1) \
  F(BytecodeBudgetInterruptFromCode, 1, 1)                   \
  F(NewError, 2, 1)                                          \
  F(NewReferenceError, 2, 1)                                 \
  F(NewSyntaxError, 2, 1)                                    \
  F(NewTypeError, -1 /* [1, 4] */, 1)                        \
  F(OrdinaryHasInstance, 2, 1)                               \
  F(PromoteScheduledException, 0, 1)                         \
  F(ReportMessageFromMicrotask, 1, 1)                        \
  F(ReThrow, 1, 1)                                           \
  F(RunMicrotaskCallback, 2, 1)                              \
  F(PerformMicrotaskCheckpoint, 0, 1)                        \
  F(StackGuard, 0, 1)                                        \
  F(StackGuardWithGap, 1, 1)                                 \
  F(Throw, 1, 1)                                             \
  F(ThrowApplyNonFunction, 1, 1)                             \
  F(ThrowCalledNonCallable, 1, 1)                            \
  F(ThrowConstructedNonConstructable, 1, 1)                  \
  F(ThrowConstructorReturnedNonObject, 0, 1)                 \
  F(ThrowInvalidStringLength, 0, 1)                          \
  F(ThrowInvalidTypedArrayAlignment, 2, 1)                   \
  F(ThrowIteratorError, 1, 1)                                \
  F(ThrowSpreadArgError, 2, 1)                               \
  F(ThrowIteratorResultNotAnObject, 1, 1)                    \
  F(ThrowNotConstructor, 1, 1)                               \
  F(ThrowPatternAssignmentNonCoercible, 1, 1)                \
  F(ThrowRangeError, -1 /* >= 1 */, 1)                       \
  F(ThrowReferenceError, 1, 1)                               \
  F(ThrowAccessedUninitializedVariable, 1, 1)                \
  F(ThrowStackOverflow, 0, 1)                                \
  F(ThrowSymbolAsyncIteratorInvalid, 0, 1)                   \
  F(ThrowSymbolIteratorInvalid, 0, 1)                        \
  F(ThrowThrowMethodMissing, 0, 1)                           \
  F(ThrowTypeError, -1 /* >= 1 */, 1)                        \
  F(ThrowTypeErrorIfStrict, -1 /* >= 1 */, 1)                \
  F(Typeof, 1, 1)                                            \
262
  F(UnwindAndFindExceptionHandler, 0, 1)
263

264
#define FOR_EACH_INTRINSIC_LITERALS(F, I)           \
265
  F(CreateArrayLiteral, 4, 1)                       \
266
  F(CreateArrayLiteralWithoutAllocationSite, 2, 1)  \
267 268
  F(CreateObjectLiteral, 4, 1)                      \
  F(CreateObjectLiteralWithoutAllocationSite, 2, 1) \
269
  F(CreateRegExpLiteral, 4, 1)
270

271 272 273
#define FOR_EACH_INTRINSIC_MODULE(F, I)    \
  F(DynamicImportCall, -1 /* [2, 3] */, 1) \
  I(GetImportMetaObject, 0, 1)             \
274
  F(GetModuleNamespace, 1, 1)
275

276
#define FOR_EACH_INTRINSIC_NUMBERS(F, I) \
277
  F(ArrayBufferMaxByteLength, 0, 1)      \
278 279
  F(GetHoleNaNLower, 0, 1)               \
  F(GetHoleNaNUpper, 0, 1)               \
280
  F(IsSmi, 1, 1)                         \
281
  F(MaxSmi, 0, 1)                        \
282
  F(NumberToStringSlow, 1, 1)            \
283 284
  F(StringParseFloat, 1, 1)              \
  F(StringParseInt, 2, 1)                \
285 286
  F(StringToNumber, 1, 1)                \
  F(TypedArrayMaxLength, 0, 1)
287

288
#define FOR_EACH_INTRINSIC_OBJECT(F, I)                         \
289
  F(AddDictionaryProperty, 3, 1)                                \
290
  F(AddPrivateField, 3, 1)                                      \
291
  F(AddPrivateBrand, 3, 1)                                      \
292
  F(AllocateHeapNumber, 0, 1)                                   \
293 294
  F(CollectTypeProfile, 3, 1)                                   \
  F(CompleteInobjectSlackTrackingForMap, 1, 1)                  \
295
  I(CopyDataProperties, 2, 1)                                   \
296
  F(CopyDataPropertiesWithExcludedProperties, -1 /* >= 1 */, 1) \
297 298
  I(CreateDataProperty, 3, 1)                                   \
  I(CreateIterResultObject, 2, 1)                               \
299
  F(CreatePrivateAccessors, 2, 1)                               \
300 301
  F(DefineAccessorPropertyUnchecked, 5, 1)                      \
  F(DefineDataPropertyInLiteral, 6, 1)                          \
302
  F(DefineGetterPropertyUnchecked, 4, 1)                        \
303 304
  F(DefineSetterPropertyUnchecked, 4, 1)                        \
  F(DeleteProperty, 3, 1)                                       \
305
  F(GetDerivedMap, 2, 1)                                        \
306 307 308
  F(GetFunctionName, 1, 1)                                      \
  F(GetOwnPropertyDescriptor, 2, 1)                             \
  F(GetOwnPropertyKeys, 2, 1)                                   \
309
  F(GetProperty, -1 /* [2, 3] */, 1)                            \
310 311
  F(HasFastPackedElements, 1, 1)                                \
  F(HasInPrototypeChain, 2, 1)                                  \
312
  F(HasProperty, 2, 1)                                          \
313
  F(InternalSetPrototype, 2, 1)                                 \
314
  F(IsJSReceiver, 1, 1)                                         \
315 316
  F(JSReceiverPreventExtensionsDontThrow, 1, 1)                 \
  F(JSReceiverPreventExtensionsThrow, 1, 1)                     \
317
  F(JSReceiverGetPrototypeOf, 1, 1)                             \
318 319
  F(JSReceiverSetPrototypeOfDontThrow, 2, 1)                    \
  F(JSReceiverSetPrototypeOfThrow, 2, 1)                        \
320 321
  F(LoadPrivateGetter, 1, 1)                                    \
  F(LoadPrivateSetter, 1, 1)                                    \
322 323 324 325
  F(NewObject, 2, 1)                                            \
  F(ObjectCreate, 2, 1)                                         \
  F(ObjectEntries, 1, 1)                                        \
  F(ObjectEntriesSkipFastPath, 1, 1)                            \
326
  F(ObjectGetOwnPropertyNames, 1, 1)                            \
327
  F(ObjectGetOwnPropertyNamesTryFast, 1, 1)                     \
328
  F(ObjectHasOwnProperty, 2, 1)                                 \
329
  F(ObjectIsExtensible, 1, 1)                                   \
330
  F(ObjectKeys, 1, 1)                                           \
331 332 333
  F(ObjectValues, 1, 1)                                         \
  F(ObjectValuesSkipFastPath, 1, 1)                             \
  F(OptimizeObjectForAddingMultipleProperties, 2, 1)            \
334
  F(SetDataProperties, 2, 1)                                    \
335 336
  F(SetKeyedProperty, 3, 1)                                     \
  F(SetNamedProperty, 3, 1)                                     \
337
  F(SetOwnPropertyIgnoreAttributes, 4, 1)                       \
338
  F(StoreDataPropertyInLiteral, 3, 1)                           \
339
  F(ShrinkNameDictionary, 1, 1)                                 \
340
  F(ShrinkSwissNameDictionary, 1, 1)                            \
341
  F(ToFastProperties, 1, 1)                                     \
342
  F(ToLength, 1, 1)                                             \
343
  F(ToName, 1, 1)                                               \
344
  F(ToNumber, 1, 1)                                             \
345
  F(ToNumeric, 1, 1)                                            \
346
  F(ToObject, 1, 1)                                             \
347
  F(ToString, 1, 1)                                             \
348 349 350 351 352 353 354 355 356
  F(TryMigrateInstance, 1, 1)                                   \
  F(SwissTableAdd, 4, 1)                                        \
  F(SwissTableAllocate, 1, 1)                                   \
  F(SwissTableDelete, 2, 1)                                     \
  F(SwissTableDetailsAt, 2, 1)                                  \
  F(SwissTableElementsCount, 1, 1)                              \
  F(SwissTableEquals, 2, 1)                                     \
  F(SwissTableFindEntry, 2, 1)                                  \
  F(SwissTableUpdate, 4, 1)                                     \
357 358
  F(SwissTableValueAt, 2, 1)                                    \
  F(SwissTableKeyAt, 2, 1)
359

360 361 362 363 364 365 366 367 368
#define FOR_EACH_INTRINSIC_OPERATORS(F, I) \
  F(Add, 2, 1)                             \
  F(Equal, 2, 1)                           \
  F(GreaterThan, 2, 1)                     \
  F(GreaterThanOrEqual, 2, 1)              \
  F(LessThan, 2, 1)                        \
  F(LessThanOrEqual, 2, 1)                 \
  F(NotEqual, 2, 1)                        \
  F(StrictEqual, 2, 1)                     \
369 370
  F(StrictNotEqual, 2, 1)                  \
  F(ReferenceEqual, 2, 1)
371

372 373 374 375 376
#define FOR_EACH_INTRINSIC_PROMISE(F, I) \
  F(EnqueueMicrotask, 1, 1)              \
  F(PromiseHookAfter, 1, 1)              \
  F(PromiseHookBefore, 1, 1)             \
  F(PromiseHookInit, 2, 1)               \
377
  F(AwaitPromisesInit, 5, 1)             \
378
  F(AwaitPromisesInitOld, 5, 1)          \
379 380 381
  F(PromiseRejectEventFromStack, 2, 1)   \
  F(PromiseRevokeReject, 1, 1)           \
  F(PromiseStatus, 1, 1)                 \
382 383
  F(RejectPromise, 3, 1)                 \
  F(ResolvePromise, 2, 1)                \
384
  F(PromiseRejectAfterResolved, 2, 1)    \
385
  F(PromiseResolveAfterResolved, 2, 1)   \
386 387
  F(ConstructAggregateErrorHelper, 4, 1) \
  F(ConstructInternalAggregateErrorHelper, -1 /* <= 5*/, 1)
388

389 390
#define FOR_EACH_INTRINSIC_PROXY(F, I) \
  F(CheckProxyGetSetTrapResult, 2, 1)  \
391
  F(CheckProxyHasTrapResult, 2, 1)     \
392
  F(CheckProxyDeleteTrapResult, 2, 1)  \
393
  F(GetPropertyWithReceiver, 3, 1)     \
394 395 396
  F(IsJSProxy, 1, 1)                   \
  F(JSProxyGetHandler, 1, 1)           \
  F(JSProxyGetTarget, 1, 1)            \
397
  F(SetPropertyWithReceiver, 4, 1)
398

399
#define FOR_EACH_INTRINSIC_REGEXP(F, I)                          \
400
  F(IsRegExp, 1, 1)                                              \
401 402 403 404 405 406 407 408 409
  F(RegExpBuildIndices, 3, 1)                                    \
  F(RegExpExec, 4, 1)                                            \
  F(RegExpExecTreatMatchAtEndAsFailure, 4, 1)                    \
  F(RegExpExperimentalOneshotExec, 4, 1)                         \
  F(RegExpExperimentalOneshotExecTreatMatchAtEndAsFailure, 4, 1) \
  F(RegExpExecMultiple, 4, 1)                                    \
  F(RegExpInitializeAndCompile, 3, 1)                            \
  F(RegExpReplaceRT, 3, 1)                                       \
  F(RegExpSplit, 3, 1)                                           \
410
  F(RegExpStringFromFlags, 1, 1)                                 \
411
  F(StringReplaceNonGlobalRegExpWithFunction, 3, 1)              \
412
  F(StringSplit, 3, 1)
413

414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
#define FOR_EACH_INTRINSIC_SCOPES(F, I)            \
  F(DeclareEvalFunction, 2, 1)                     \
  F(DeclareEvalVar, 1, 1)                          \
  F(DeclareGlobals, 2, 1)                          \
  F(DeclareModuleExports, 2, 1)                    \
  F(DeleteLookupSlot, 1, 1)                        \
  F(LoadLookupSlot, 1, 1)                          \
  F(LoadLookupSlotInsideTypeof, 1, 1)              \
                                                   \
  F(NewClosure, 2, 1)                              \
  F(NewClosure_Tenured, 2, 1)                      \
  F(NewFunctionContext, 1, 1)                      \
  F(NewRestParameter, 1, 1)                        \
  F(NewSloppyArguments, 1, 1)                      \
  F(NewStrictArguments, 1, 1)                      \
  F(PushBlockContext, 1, 1)                        \
  F(PushCatchContext, 2, 1)                        \
  F(PushWithContext, 2, 1)                         \
  F(StoreGlobalNoHoleCheckForReplLetOrConst, 2, 1) \
  F(StoreLookupSlot_Sloppy, 2, 1)                  \
  F(StoreLookupSlot_SloppyHoisting, 2, 1)          \
  F(StoreLookupSlot_Strict, 2, 1)                  \
436
  F(ThrowConstAssignError, 0, 1)
437

438
#define FOR_EACH_INTRINSIC_STRINGS(F, I)  \
439
  F(FlattenString, 1, 1)                  \
440
  F(GetSubstitution, 5, 1)                \
441 442 443 444 445
  F(InternalizeString, 1, 1)              \
  F(StringAdd, 2, 1)                      \
  F(StringBuilderConcat, 3, 1)            \
  F(StringCharCodeAt, 2, 1)               \
  F(StringEqual, 2, 1)                    \
446
  F(StringEscapeQuotes, 1, 1)             \
447 448
  F(StringGreaterThan, 2, 1)              \
  F(StringGreaterThanOrEqual, 2, 1)       \
449
  F(StringLastIndexOf, 2, 1)              \
450 451
  F(StringLessThan, 2, 1)                 \
  F(StringLessThanOrEqual, 2, 1)          \
452 453 454
  F(StringMaxLength, 0, 1)                \
  F(StringReplaceOneCharWithString, 3, 1) \
  F(StringSubstring, 3, 1)                \
455
  F(StringToArray, 2, 1)
456

457
#define FOR_EACH_INTRINSIC_SYMBOL(F, I)    \
458
  F(CreatePrivateNameSymbol, 1, 1)         \
459
  F(CreatePrivateBrandSymbol, 1, 1)        \
460
  F(CreatePrivateSymbol, -1 /* <= 1 */, 1) \
461
  F(SymbolDescriptiveString, 1, 1)         \
462 463
  F(SymbolIsPrivate, 1, 1)

464 465 466
#define FOR_EACH_INTRINSIC_TEST(F, I)         \
  F(Abort, 1, 1)                              \
  F(AbortCSAAssert, 1, 1)                     \
467 468
  F(AbortJS, 1, 1)                            \
  F(ArrayIteratorProtector, 0, 1)             \
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
  F(ArraySpeciesProtector, 0, 1)              \
  F(BaselineOsr, -1, 1)                       \
  F(ClearFunctionFeedback, 1, 1)              \
  F(ClearMegamorphicStubCache, 0, 1)          \
  F(CompleteInobjectSlackTracking, 1, 1)      \
  F(ConstructConsString, 2, 1)                \
  F(ConstructDouble, 2, 1)                    \
  F(ConstructSlicedString, 2, 1)              \
  F(DebugPrint, 1, 1)                         \
  F(DebugPrintPtr, 1, 1)                      \
  F(DebugTrace, 0, 1)                         \
  F(DebugTrackRetainingPath, -1, 1)           \
  F(DeoptimizeFunction, 1, 1)                 \
  F(DisallowCodegenFromStrings, 1, 1)         \
  F(DisassembleFunction, 1, 1)                \
  F(DynamicCheckMapsEnabled, 0, 1)            \
  F(EnableCodeLoggingForTesting, 0, 1)        \
  F(EnsureFeedbackVectorForFunction, 1, 1)    \
487 488
  F(DisableOptimizationFinalization, 0, 1)    \
  F(FinalizeOptimization, 0, 1)               \
489 490
  F(GetCallable, 0, 1)                        \
  F(GetInitializerFunction, 1, 1)             \
491
  F(GetOptimizationStatus, 1, 1)              \
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
  F(GetUndetectable, 0, 1)                    \
  F(GlobalPrint, 1, 1)                        \
  F(HasDictionaryElements, 1, 1)              \
  F(HasDoubleElements, 1, 1)                  \
  F(HasElementsInALargeObjectSpace, 1, 1)     \
  F(HasFastElements, 1, 1)                    \
  F(HasFastProperties, 1, 1)                  \
  F(HasFixedBigInt64Elements, 1, 1)           \
  F(HasFixedBigUint64Elements, 1, 1)          \
  F(HasFixedFloat32Elements, 1, 1)            \
  F(HasFixedFloat64Elements, 1, 1)            \
  F(HasFixedInt16Elements, 1, 1)              \
  F(HasFixedInt32Elements, 1, 1)              \
  F(HasFixedInt8Elements, 1, 1)               \
  F(HasFixedUint16Elements, 1, 1)             \
  F(HasFixedUint32Elements, 1, 1)             \
  F(HasFixedUint8ClampedElements, 1, 1)       \
  F(HasFixedUint8Elements, 1, 1)              \
  F(HasHoleyElements, 1, 1)                   \
  F(HasObjectElements, 1, 1)                  \
512
  F(HasOwnConstDataProperty, 2, 1)            \
513 514 515 516 517 518 519 520 521
  F(HasPackedElements, 1, 1)                  \
  F(HasSloppyArgumentsElements, 1, 1)         \
  F(HasSmiElements, 1, 1)                     \
  F(HasSmiOrObjectElements, 1, 1)             \
  F(HaveSameMap, 2, 1)                        \
  F(HeapObjectVerify, 1, 1)                   \
  F(ICsAreEnabled, 0, 1)                      \
  F(InLargeObjectSpace, 1, 1)                 \
  F(InYoungGeneration, 1, 1)                  \
522 523
  F(Is64Bit, 0, 1)                            \
  F(IsAtomicsWaitAllowed, 0, 1)               \
524
  F(IsBeingInterpreted, 0, 1)                 \
525
  F(IsConcatSpreadableProtector, 0, 1)        \
526 527
  F(IsConcurrentRecompilationSupported, 0, 1) \
  F(IsDictPropertyConstTrackingEnabled, 0, 1) \
528 529
  F(IsMidTierTurboprop, 0, 1)                 \
  F(IsTopTierTurboprop, 0, 1)                 \
530 531
  F(MapIteratorProtector, 0, 1)               \
  F(NeverOptimizeFunction, 1, 1)              \
532
  F(NewRegExpWithBacktrackLimit, 3, 1)        \
533
  F(NotifyContextDisposed, 0, 1)              \
534
  F(OptimizeFunctionForTopTier, 1, 1)         \
535
  F(OptimizeFunctionOnNextCall, -1, 1)        \
536 537
  F(OptimizeOsr, -1, 1)                       \
  F(PrepareFunctionForOptimization, -1, 1)    \
538
  F(PretenureAllocationSite, 1, 1)            \
539
  F(PrintWithNameForAssert, 2, 1)             \
540 541 542 543 544 545
  F(PromiseSpeciesProtector, 0, 1)            \
  F(RegexpHasBytecode, 2, 1)                  \
  F(RegexpHasNativeCode, 2, 1)                \
  F(RegexpIsUnmodified, 1, 1)                 \
  F(RegExpSpeciesProtector, 0, 1)             \
  F(RegexpTypeTag, 1, 1)                      \
546 547
  F(RunningInSimulator, 0, 1)                 \
  F(RuntimeEvaluateREPL, 1, 1)                \
548
  F(ScheduleGCInStackCheck, 0, 1)             \
549 550 551 552 553 554 555
  F(SerializeDeserializeNow, 0, 1)            \
  F(SetAllocationTimeout, -1 /* 2 || 3 */, 1) \
  F(SetForceSlowPath, 1, 1)                   \
  F(SetIteratorProtector, 0, 1)               \
  F(SimulateNewspaceFull, 0, 1)               \
  F(StringIteratorProtector, 0, 1)            \
  F(SystemBreak, 0, 1)                        \
556
  F(TierupFunctionOnNextCall, -1, 1)          \
557 558 559 560
  F(TraceEnter, 0, 1)                         \
  F(TraceExit, 1, 1)                          \
  F(TurbofanStaticAssert, 1, 1)               \
  F(TypedArraySpeciesProtector, 0, 1)         \
561 562
  F(WaitForBackgroundOptimization, 0, 1)      \
  I(DeoptimizeNow, 0, 1)
563

564 565 566 567 568 569
#define FOR_EACH_INTRINSIC_TYPEDARRAY(F, I)    \
  F(ArrayBufferDetach, 1, 1)                   \
  F(GrowableSharedArrayBufferByteLength, 1, 1) \
  F(TypedArrayCopyElements, 3, 1)              \
  F(TypedArrayGetBuffer, 1, 1)                 \
  F(TypedArraySet, 2, 1)                       \
570
  F(TypedArraySortFast, 1, 1)
571

572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
#define FOR_EACH_INTRINSIC_WASM(F, I) \
  F(ThrowWasmError, 1, 1)             \
  F(ThrowWasmStackOverflow, 0, 1)     \
  F(WasmI32AtomicWait, 4, 1)          \
  F(WasmI64AtomicWait, 5, 1)          \
  F(WasmAtomicNotify, 3, 1)           \
  F(WasmMemoryGrow, 2, 1)             \
  F(WasmStackGuard, 0, 1)             \
  F(WasmThrow, 2, 1)                  \
  F(WasmReThrow, 1, 1)                \
  F(WasmThrowJSTypeError, 0, 1)       \
  F(WasmRefFunc, 1, 1)                \
  F(WasmFunctionTableGet, 3, 1)       \
  F(WasmFunctionTableSet, 4, 1)       \
  F(WasmTableInit, 6, 1)              \
  F(WasmTableCopy, 6, 1)              \
  F(WasmTableGrow, 3, 1)              \
  F(WasmTableFill, 5, 1)              \
  F(WasmIsValidRefValue, 3, 1)        \
  F(WasmCompileLazy, 2, 1)            \
  F(WasmCompileWrapper, 2, 1)         \
  F(WasmTriggerTierUp, 1, 1)          \
  F(WasmDebugBreak, 0, 1)             \
595
  F(WasmAllocateRtt, 3, 1)            \
596
  F(WasmArrayCopy, 5, 1)
597

598 599 600 601
#define FOR_EACH_INTRINSIC_WASM_TEST(F, I) \
  F(DeserializeWasmModule, 2, 1)           \
  F(DisallowWasmCodegen, 1, 1)             \
  F(FreezeWasmLazyCompilation, 1, 1)       \
602
  F(GetWasmExceptionTagId, 2, 1)           \
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
  F(GetWasmExceptionValues, 1, 1)          \
  F(GetWasmRecoveredTrapCount, 0, 1)       \
  F(IsAsmWasmCode, 1, 1)                   \
  F(IsLiftoffFunction, 1, 1)               \
  F(IsThreadInWasm, 0, 1)                  \
  F(IsWasmCode, 1, 1)                      \
  F(IsWasmTrapHandlerEnabled, 0, 1)        \
  F(SerializeWasmModule, 1, 1)             \
  F(SetWasmCompileControls, 2, 1)          \
  F(SetWasmInstantiateControls, 0, 1)      \
  F(WasmGetNumberOfInstances, 1, 1)        \
  F(WasmNumCodeSpaces, 1, 1)               \
  F(WasmTierDown, 0, 1)                    \
  F(WasmTierUp, 0, 1)                      \
  F(WasmTierUpFunction, 2, 1)              \
  F(WasmTraceEnter, 0, 1)                  \
  F(WasmTraceExit, 1, 1)                   \
  F(WasmTraceMemory, 1, 1)

622 623 624
#define FOR_EACH_INTRINSIC_WEAKREF(F, I)                             \
  F(JSFinalizationRegistryRegisterWeakCellWithUnregisterToken, 4, 1) \
  F(JSWeakRefAddToKeptObjects, 1, 1)                                 \
625 626
  F(ShrinkFinalizationRegistryUnregisterTokenMap, 1, 1)

627 628
#define FOR_EACH_INTRINSIC_RETURN_PAIR_IMPL(F, I) \
  F(DebugBreakOnBytecode, 1, 2)                   \
629
  F(LoadLookupSlotForCall, 1, 2)
630

631 632
// Most intrinsics are implemented in the runtime/ directory, but ICs are
// implemented in ic.cc for now.
633
#define FOR_EACH_INTRINSIC_IC(F, I)          \
634 635 636
  F(ElementsTransitionAndStoreIC_Miss, 6, 1) \
  F(KeyedLoadIC_Miss, 4, 1)                  \
  F(KeyedStoreIC_Miss, 5, 1)                 \
637
  F(StoreInArrayLiteralIC_Miss, 5, 1)        \
638
  F(KeyedStoreIC_Slow, 3, 1)                 \
639
  F(LoadElementWithInterceptor, 2, 1)        \
640
  F(LoadGlobalIC_Miss, 4, 1)                 \
641
  F(LoadGlobalIC_Slow, 3, 1)                 \
642
  F(LoadIC_Miss, 4, 1)                       \
643
  F(LoadNoFeedbackIC_Miss, 4, 1)             \
644 645
  F(LoadWithReceiverIC_Miss, 5, 1)           \
  F(LoadWithReceiverNoFeedbackIC_Miss, 3, 1) \
646
  F(LoadPropertyWithInterceptor, 5, 1)       \
647
  F(StoreCallbackProperty, 5, 1)             \
648
  F(StoreGlobalIC_Miss, 4, 1)                \
649
  F(StoreGlobalICNoFeedback_Miss, 2, 1)      \
650
  F(StoreGlobalIC_Slow, 5, 1)                \
651
  F(StoreIC_Miss, 5, 1)                      \
652
  F(StoreInArrayLiteralIC_Slow, 5, 1)        \
653
  F(StorePropertyWithInterceptor, 5, 1)      \
654 655 656
  F(CloneObjectIC_Miss, 4, 1)                \
  F(KeyedHasIC_Miss, 4, 1)                   \
  F(HasElementWithInterceptor, 2, 1)
657

658 659 660 661 662 663 664 665 666 667 668 669 670 671
#define FOR_EACH_INTRINSIC_RETURN_OBJECT_IMPL(F, I) \
  FOR_EACH_INTRINSIC_ARRAY(F, I)                    \
  FOR_EACH_INTRINSIC_ATOMICS(F, I)                  \
  FOR_EACH_INTRINSIC_BIGINT(F, I)                   \
  FOR_EACH_INTRINSIC_CLASSES(F, I)                  \
  FOR_EACH_INTRINSIC_COLLECTIONS(F, I)              \
  FOR_EACH_INTRINSIC_COMPILER(F, I)                 \
  FOR_EACH_INTRINSIC_DATE(F, I)                     \
  FOR_EACH_INTRINSIC_DEBUG(F, I)                    \
  FOR_EACH_INTRINSIC_FORIN(F, I)                    \
  FOR_EACH_INTRINSIC_FUNCTION(F, I)                 \
  FOR_EACH_INTRINSIC_GENERATOR(F, I)                \
  FOR_EACH_INTRINSIC_IC(F, I)                       \
  FOR_EACH_INTRINSIC_INTERNAL(F, I)                 \
672
  FOR_EACH_INTRINSIC_TRACE(F, I)                    \
673 674 675 676 677 678 679 680 681 682 683 684 685 686
  FOR_EACH_INTRINSIC_INTL(F, I)                     \
  FOR_EACH_INTRINSIC_LITERALS(F, I)                 \
  FOR_EACH_INTRINSIC_MODULE(F, I)                   \
  FOR_EACH_INTRINSIC_NUMBERS(F, I)                  \
  FOR_EACH_INTRINSIC_OBJECT(F, I)                   \
  FOR_EACH_INTRINSIC_OPERATORS(F, I)                \
  FOR_EACH_INTRINSIC_PROMISE(F, I)                  \
  FOR_EACH_INTRINSIC_PROXY(F, I)                    \
  FOR_EACH_INTRINSIC_REGEXP(F, I)                   \
  FOR_EACH_INTRINSIC_SCOPES(F, I)                   \
  FOR_EACH_INTRINSIC_STRINGS(F, I)                  \
  FOR_EACH_INTRINSIC_SYMBOL(F, I)                   \
  FOR_EACH_INTRINSIC_TEST(F, I)                     \
  FOR_EACH_INTRINSIC_TYPEDARRAY(F, I)               \
687
  IF_WASM(FOR_EACH_INTRINSIC_WASM, F, I)            \
688
  IF_WASM(FOR_EACH_INTRINSIC_WASM_TEST, F, I)       \
689
  FOR_EACH_INTRINSIC_WEAKREF(F, I)
690 691 692 693 694 695 696

// Defines the list of all intrinsics, coming in 2 flavors, either returning an
// object or a pair.
#define FOR_EACH_INTRINSIC_IMPL(F, I)       \
  FOR_EACH_INTRINSIC_RETURN_PAIR_IMPL(F, I) \
  FOR_EACH_INTRINSIC_RETURN_OBJECT_IMPL(F, I)

697
#define FOR_EACH_INTRINSIC_RETURN_OBJECT(F) \
698
  FOR_EACH_INTRINSIC_RETURN_OBJECT_IMPL(F, F)
699

700 701 702 703 704 705 706 707 708
#define FOR_EACH_INTRINSIC_RETURN_PAIR(F) \
  FOR_EACH_INTRINSIC_RETURN_PAIR_IMPL(F, F)

// The list of all intrinsics, including those that have inline versions, but
// not the inline versions themselves.
#define FOR_EACH_INTRINSIC(F) FOR_EACH_INTRINSIC_IMPL(F, F)

// The list of all inline intrinsics only.
#define FOR_EACH_INLINE_INTRINSIC(I) FOR_EACH_INTRINSIC_IMPL(NOTHING, I)
709

710
#define F(name, nargs, ressize)                                 \
711
  Address Runtime_##name(int args_length, Address* args_object, \
712 713 714 715
                         Isolate* isolate);
FOR_EACH_INTRINSIC_RETURN_OBJECT(F)
#undef F

716
//---------------------------------------------------------------------------
717 718 719 720
// Runtime provides access to all C++ runtime functions.

class Runtime : public AllStatic {
 public:
721
  enum FunctionId : int32_t {
722
#define F(name, nargs, ressize) k##name,
723
#define I(name, nargs, ressize) kInline##name,
724
    FOR_EACH_INTRINSIC(F) FOR_EACH_INLINE_INTRINSIC(I)
725
#undef I
726
#undef F
727
        kNumFunctions,
728 729
  };

730 731 732 733 734
  static constexpr int kNumInlineFunctions =
#define COUNT(...) +1
      FOR_EACH_INLINE_INTRINSIC(COUNT);
#undef COUNT

735
  enum IntrinsicType { RUNTIME, INLINE };
736

737
  // Intrinsic function descriptor.
738
  struct Function {
739 740
    FunctionId function_id;
    IntrinsicType intrinsic_type;
741 742 743
    // The JS name of the function.
    const char* name;

744 745 746
    // For RUNTIME functions, this is the C++ entry point.
    // For INLINE functions this is the C++ entry point of the fall back.
    Address entry;
747

748 749
    // The number of arguments expected. nargs is -1 if the function takes
    // a variable number of arguments.
750
    int8_t nargs;
751
    // Size of result.  Most functions return a single pointer, size 1.
752
    int8_t result_size;
753 754
  };

755 756
  static const int kNotFound = -1;

757 758 759 760 761
  // Checks whether the runtime function with the given {id} depends on the
  // "current context", i.e. because it does scoped lookups, or whether it's
  // fine to just pass any context within the same "native context".
  static bool NeedsExactContext(FunctionId id);

762 763 764 765 766 767
  // Checks whether the runtime function with the given {id} never returns
  // to it's caller normally, i.e. whether it'll always raise an exception.
  // More specifically: The C++ implementation returns the Heap::exception
  // sentinel, always.
  static bool IsNonReturning(FunctionId id);

768
  // Check if a runtime function with the given {id} may trigger a heap
769 770 771
  // allocation.
  static bool MayAllocate(FunctionId id);

Dan Elphick's avatar
Dan Elphick committed
772
  // Check if a runtime function with the given {id} is allowlisted for
773
  // using it with fuzzers.
Dan Elphick's avatar
Dan Elphick committed
774
  static bool IsAllowListedForFuzzing(FunctionId id);
775

776 777
  // Get the intrinsic function with the given name.
  static const Function* FunctionForName(const unsigned char* name, int length);
778

779
  // Get the intrinsic function with the given FunctionId.
780
  V8_EXPORT_PRIVATE static const Function* FunctionForId(FunctionId id);
781

782 783 784
  // Get the intrinsic function with the given function entry address.
  static const Function* FunctionForEntry(Address ref);

785 786 787
  // Get the runtime intrinsic function table.
  static const Function* RuntimeFunctionTable(Isolate* isolate);

788 789 790
  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static Maybe<bool>
  DeleteObjectProperty(Isolate* isolate, Handle<JSReceiver> receiver,
                       Handle<Object> key, LanguageMode language_mode);
791

792 793 794 795 796
  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
  SetObjectProperty(Isolate* isolate, Handle<Object> object, Handle<Object> key,
                    Handle<Object> value, StoreOrigin store_origin,
                    Maybe<ShouldThrow> should_throw = Nothing<ShouldThrow>());

797
  // When "receiver" is not passed, it defaults to "lookup_start_object".
798
  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
799 800
  GetObjectProperty(Isolate* isolate, Handle<Object> lookup_start_object,
                    Handle<Object> key,
801 802
                    Handle<Object> receiver = Handle<Object>(),
                    bool* is_found = nullptr);
803

804 805 806
  V8_WARN_UNUSED_RESULT static MaybeHandle<Object> HasProperty(
      Isolate* isolate, Handle<Object> object, Handle<Object> key);

807 808
  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<JSArray>
  GetInternalProperties(Isolate* isolate, Handle<Object>);
809

810
  V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ThrowIteratorError(
811
      Isolate* isolate, Handle<Object> object);
812 813
};

814 815
class RuntimeState {
 public:
816 817
  RuntimeState(const RuntimeState&) = delete;
  RuntimeState& operator=(const RuntimeState&) = delete;
818
#ifndef V8_INTL_SUPPORT
819 820 821 822 823 824
  unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
    return &to_upper_mapping_;
  }
  unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
    return &to_lower_mapping_;
  }
825
#endif
826 827 828 829 830 831 832

  Runtime::Function* redirected_intrinsic_functions() {
    return redirected_intrinsic_functions_.get();
  }

  void set_redirected_intrinsic_functions(
      Runtime::Function* redirected_intrinsic_functions) {
833
    redirected_intrinsic_functions_.reset(redirected_intrinsic_functions);
834 835 836
  }

 private:
837
  RuntimeState() = default;
838
#ifndef V8_INTL_SUPPORT
839 840
  unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
  unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
841
#endif
842

843
  std::unique_ptr<Runtime::Function[]> redirected_intrinsic_functions_;
844 845 846 847 848

  friend class Isolate;
  friend class Runtime;
};

849
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, Runtime::FunctionId);
850

851 852 853
//---------------------------------------------------------------------------
// Constants used by interface to runtime functions.

854
using AllocateDoubleAlignFlag = base::BitField<bool, 0, 1>;
855

856
using AllowLargeObjectAllocationFlag = base::BitField<bool, 1, 1>;
857

858 859 860 861 862 863 864 865 866 867
// A set of bits returned by Runtime_GetOptimizationStatus.
// These bits must be in sync with bits defined in test/mjsunit/mjsunit.js
enum class OptimizationStatus {
  kIsFunction = 1 << 0,
  kNeverOptimize = 1 << 1,
  kAlwaysOptimize = 1 << 2,
  kMaybeDeopted = 1 << 3,
  kOptimized = 1 << 4,
  kTurboFanned = 1 << 5,
  kInterpreted = 1 << 6,
868 869 870 871 872
  kMarkedForOptimization = 1 << 7,
  kMarkedForConcurrentOptimization = 1 << 8,
  kOptimizingConcurrently = 1 << 9,
  kIsExecuting = 1 << 10,
  kTopmostFrameIsTurboFanned = 1 << 11,
873
  kLiteMode = 1 << 12,
874
  kMarkedForDeoptimization = 1 << 13,
875
  kBaseline = 1 << 14,
876 877
  kTopmostFrameIsInterpreted = 1 << 15,
  kTopmostFrameIsBaseline = 1 << 16,
878 879
};

880 881
}  // namespace internal
}  // namespace v8
882

883
#endif  // V8_RUNTIME_RUNTIME_H_