10e3dd970a2cbe0c54937adf1d6364c354cf36bd
[platform/upstream/v8.git] / src / runtime / runtime.h
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 "src/allocation.h"
9 #include "src/objects.h"
10 #include "src/unicode.h"
11 #include "src/zone.h"
12
13 namespace v8 {
14 namespace internal {
15
16 // * Each intrinsic is consistently exposed in JavaScript via 2 names:
17 //    * %#name, which is always a runtime call.
18 //    * %_#name, which can be inlined or just a runtime call, the compiler in
19 //      question decides.
20 //
21 // * IntrinsicTypes are Runtime::RUNTIME and Runtime::INLINE, respectively.
22 //
23 // * IDs are Runtime::k##name and Runtime::kInline##name, respectively.
24 //
25 // * All intrinsics have a C++ implementation Runtime_##name.
26 //
27 // * Each compiler has an explicit list of intrisics it supports, falling back
28 //   to a simple runtime call if necessary.
29
30
31 // Entries have the form F(name, number of arguments, number of values):
32
33 #define FOR_EACH_INTRINSIC_ARRAY(F)         \
34   F(FinishArrayPrototypeSetup, 1, 1)        \
35   F(SpecialArrayFunctions, 0, 1)            \
36   F(TransitionElementsKind, 2, 1)           \
37   F(PushIfAbsent, 2, 1)                     \
38   F(ArrayConcat, 1, 1)                      \
39   F(RemoveArrayHoles, 2, 1)                 \
40   F(MoveArrayContents, 2, 1)                \
41   F(EstimateNumberOfElements, 1, 1)         \
42   F(GetArrayKeys, 2, 1)                     \
43   F(ArrayConstructor, -1, 1)                \
44   F(ArrayConstructorWithSubclassing, -1, 1) \
45   F(InternalArrayConstructor, -1, 1)        \
46   F(NormalizeElements, 1, 1)                \
47   F(GrowArrayElements, 2, 1)                \
48   F(HasComplexElements, 1, 1)               \
49   F(IsArray, 1, 1)                          \
50   F(HasCachedArrayIndex, 1, 1)              \
51   F(GetCachedArrayIndex, 1, 1)              \
52   F(FixedArrayGet, 2, 1)                    \
53   F(FixedArraySet, 3, 1)                    \
54   F(FastOneByteArrayJoin, 2, 1)
55
56
57 #define FOR_EACH_INTRINSIC_ATOMICS(F) \
58   F(AtomicsCompareExchange, 4, 1)     \
59   F(AtomicsLoad, 2, 1)                \
60   F(AtomicsStore, 3, 1)               \
61   F(AtomicsAdd, 3, 1)                 \
62   F(AtomicsSub, 3, 1)                 \
63   F(AtomicsAnd, 3, 1)                 \
64   F(AtomicsOr, 3, 1)                  \
65   F(AtomicsXor, 3, 1)                 \
66   F(AtomicsExchange, 3, 1)            \
67   F(AtomicsIsLockFree, 1, 1)
68
69
70 #define FOR_EACH_INTRINSIC_FUTEX(F)  \
71   F(AtomicsFutexWait, 4, 1)          \
72   F(AtomicsFutexWake, 3, 1)          \
73   F(AtomicsFutexWakeOrRequeue, 5, 1) \
74   F(AtomicsFutexNumWaitersForTesting, 2, 1)
75
76
77 #define FOR_EACH_INTRINSIC_CLASSES(F)         \
78   F(ThrowNonMethodError, 0, 1)                \
79   F(ThrowUnsupportedSuperError, 0, 1)         \
80   F(ThrowConstructorNonCallableError, 0, 1)   \
81   F(ThrowArrayNotSubclassableError, 0, 1)     \
82   F(ThrowStaticPrototypeError, 0, 1)          \
83   F(ThrowIfStaticPrototype, 1, 1)             \
84   F(ToMethod, 2, 1)                           \
85   F(HomeObjectSymbol, 0, 1)                   \
86   F(DefineClass, 5, 1)                        \
87   F(DefineClassStrong, 5, 1)                  \
88   F(FinalizeClassDefinition, 2, 1)            \
89   F(DefineClassMethod, 3, 1)                  \
90   F(ClassGetSourceCode, 1, 1)                 \
91   F(LoadFromSuper, 4, 1)                      \
92   F(LoadKeyedFromSuper, 4, 1)                 \
93   F(StoreToSuper_Strict, 4, 1)                \
94   F(StoreToSuper_Sloppy, 4, 1)                \
95   F(StoreKeyedToSuper_Strict, 4, 1)           \
96   F(StoreKeyedToSuper_Sloppy, 4, 1)           \
97   F(HandleStepInForDerivedConstructors, 1, 1) \
98   F(DefaultConstructorCallSuper, 2, 1)
99
100
101 #define FOR_EACH_INTRINSIC_COLLECTIONS(F) \
102   F(StringGetRawHashField, 1, 1)          \
103   F(TheHole, 0, 1)                        \
104   F(JSCollectionGetTable, 1, 1)           \
105   F(GenericHash, 1, 1)                    \
106   F(SetInitialize, 1, 1)                  \
107   F(SetGrow, 1, 1)                        \
108   F(SetShrink, 1, 1)                      \
109   F(SetClear, 1, 1)                       \
110   F(SetIteratorInitialize, 3, 1)          \
111   F(SetIteratorClone, 1, 1)               \
112   F(SetIteratorNext, 2, 1)                \
113   F(SetIteratorDetails, 1, 1)             \
114   F(MapInitialize, 1, 1)                  \
115   F(MapShrink, 1, 1)                      \
116   F(MapClear, 1, 1)                       \
117   F(MapGrow, 1, 1)                        \
118   F(MapIteratorInitialize, 3, 1)          \
119   F(MapIteratorClone, 1, 1)               \
120   F(MapIteratorDetails, 1, 1)             \
121   F(GetWeakMapEntries, 2, 1)              \
122   F(MapIteratorNext, 2, 1)                \
123   F(WeakCollectionInitialize, 1, 1)       \
124   F(WeakCollectionGet, 3, 1)              \
125   F(WeakCollectionHas, 3, 1)              \
126   F(WeakCollectionDelete, 3, 1)           \
127   F(WeakCollectionSet, 4, 1)              \
128   F(GetWeakSetValues, 2, 1)               \
129   F(ObservationWeakMapCreate, 0, 1)
130
131
132 #define FOR_EACH_INTRINSIC_COMPILER(F)  \
133   F(CompileLazy, 1, 1)                  \
134   F(CompileOptimized, 2, 1)             \
135   F(NotifyStubFailure, 0, 1)            \
136   F(NotifyDeoptimized, 1, 1)            \
137   F(CompileForOnStackReplacement, 1, 1) \
138   F(TryInstallOptimizedCode, 1, 1)      \
139   F(CompileString, 2, 1)                \
140   F(ResolvePossiblyDirectEval, 5, 1)
141
142
143 #define FOR_EACH_INTRINSIC_DATE(F) \
144   F(DateMakeDay, 2, 1)             \
145   F(DateSetValue, 3, 1)            \
146   F(IsDate, 1, 1)                  \
147   F(ThrowNotDateError, 0, 1)       \
148   F(DateCurrentTime, 0, 1)         \
149   F(DateParseString, 2, 1)         \
150   F(DateLocalTimezone, 1, 1)       \
151   F(DateToUTC, 1, 1)               \
152   F(DateCacheVersion, 0, 1)        \
153   F(DateField, 2 /* date object, field index */, 1)
154
155
156 #define FOR_EACH_INTRINSIC_DEBUG(F)            \
157   F(HandleDebuggerStatement, 0, 1)             \
158   F(DebugBreak, 0, 1)                          \
159   F(SetDebugEventListener, 2, 1)               \
160   F(ScheduleBreak, 0, 1)                       \
161   F(DebugGetInternalProperties, 1, 1)          \
162   F(DebugGetPropertyDetails, 2, 1)             \
163   F(DebugGetProperty, 2, 1)                    \
164   F(DebugPropertyTypeFromDetails, 1, 1)        \
165   F(DebugPropertyAttributesFromDetails, 1, 1)  \
166   F(DebugPropertyIndexFromDetails, 1, 1)       \
167   F(DebugNamedInterceptorPropertyValue, 2, 1)  \
168   F(DebugIndexedInterceptorElementValue, 2, 1) \
169   F(CheckExecutionState, 1, 1)                 \
170   F(GetFrameCount, 1, 1)                       \
171   F(GetFrameDetails, 2, 1)                     \
172   F(GetScopeCount, 2, 1)                       \
173   F(GetStepInPositions, 2, 1)                  \
174   F(GetScopeDetails, 4, 1)                     \
175   F(GetAllScopesDetails, 4, 1)                 \
176   F(GetFunctionScopeCount, 1, 1)               \
177   F(GetFunctionScopeDetails, 2, 1)             \
178   F(SetScopeVariableValue, 6, 1)               \
179   F(DebugPrintScopes, 0, 1)                    \
180   F(GetThreadCount, 1, 1)                      \
181   F(GetThreadDetails, 2, 1)                    \
182   F(SetDisableBreak, 1, 1)                     \
183   F(GetBreakLocations, 2, 1)                   \
184   F(SetFunctionBreakPoint, 3, 1)               \
185   F(SetScriptBreakPoint, 4, 1)                 \
186   F(ClearBreakPoint, 1, 1)                     \
187   F(ChangeBreakOnException, 2, 1)              \
188   F(IsBreakOnException, 1, 1)                  \
189   F(PrepareStep, 4, 1)                         \
190   F(ClearStepping, 0, 1)                       \
191   F(DebugEvaluate, 6, 1)                       \
192   F(DebugEvaluateGlobal, 4, 1)                 \
193   F(DebugGetLoadedScripts, 0, 1)               \
194   F(DebugReferencedBy, 3, 1)                   \
195   F(DebugConstructedBy, 2, 1)                  \
196   F(DebugGetPrototype, 1, 1)                   \
197   F(DebugSetScriptSource, 2, 1)                \
198   F(FunctionGetInferredName, 1, 1)             \
199   F(GetFunctionCodePositionFromSource, 2, 1)   \
200   F(ExecuteInDebugContext, 1, 1)               \
201   F(GetDebugContext, 0, 1)                     \
202   F(CollectGarbage, 1, 1)                      \
203   F(GetHeapUsage, 0, 1)                        \
204   F(GetScript, 1, 1)                           \
205   F(DebugCallbackSupportsStepping, 1, 1)       \
206   F(DebugPrepareStepInIfStepping, 1, 1)        \
207   F(DebugPushPromise, 2, 1)                    \
208   F(DebugPopPromise, 0, 1)                     \
209   F(DebugPromiseEvent, 1, 1)                   \
210   F(DebugAsyncTaskEvent, 1, 1)                 \
211   F(DebugIsActive, 0, 1)                       \
212   F(DebugBreakInOptimizedCode, 0, 1)
213
214
215 #define FOR_EACH_INTRINSIC_FORIN(F) \
216   F(ForInDone, 2, 1)                \
217   F(ForInFilter, 2, 1)              \
218   F(ForInNext, 4, 1)                \
219   F(ForInStep, 1, 1)
220
221
222 #define FOR_EACH_INTRINSIC_FUNCTION(F)                      \
223   F(IsSloppyModeFunction, 1, 1)                             \
224   F(FunctionGetName, 1, 1)                                  \
225   F(FunctionSetName, 2, 1)                                  \
226   F(FunctionNameShouldPrintAsAnonymous, 1, 1)               \
227   F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1)           \
228   F(FunctionIsArrow, 1, 1)                                  \
229   F(FunctionIsConciseMethod, 1, 1)                          \
230   F(FunctionRemovePrototype, 1, 1)                          \
231   F(FunctionGetScript, 1, 1)                                \
232   F(FunctionGetSourceCode, 1, 1)                            \
233   F(FunctionGetScriptSourcePosition, 1, 1)                  \
234   F(FunctionGetPositionForOffset, 2, 1)                     \
235   F(FunctionSetInstanceClassName, 2, 1)                     \
236   F(FunctionSetLength, 2, 1)                                \
237   F(FunctionSetPrototype, 2, 1)                             \
238   F(FunctionIsAPIFunction, 1, 1)                            \
239   F(FunctionHidesSource, 1, 1)                              \
240   F(SetCode, 2, 1)                                          \
241   F(SetNativeFlag, 1, 1)                                    \
242   F(ThrowStrongModeTooFewArguments, 0, 1)                   \
243   F(IsConstructor, 1, 1)                                    \
244   F(SetForceInlineFlag, 1, 1)                               \
245   F(FunctionBindArguments, 4, 1)                            \
246   F(BoundFunctionGetBindings, 1, 1)                         \
247   F(NewObjectFromBound, 1, 1)                               \
248   F(Call, -1 /* >= 2 */, 1)                                 \
249   F(Apply, 5, 1)                                            \
250   F(GetFunctionDelegate, 1, 1)                              \
251   F(GetConstructorDelegate, 1, 1)                           \
252   F(GetOriginalConstructor, 0, 1)                           \
253   F(CallFunction, -1 /* receiver + n args + function */, 1) \
254   F(IsConstructCall, 0, 1)                                  \
255   F(IsFunction, 1, 1)
256
257
258 #define FOR_EACH_INTRINSIC_GENERATOR(F) \
259   F(CreateJSGeneratorObject, 0, 1)      \
260   F(SuspendJSGeneratorObject, -1, 1)    \
261   F(ResumeJSGeneratorObject, 3, 1)      \
262   F(GeneratorClose, 1, 1)               \
263   F(GeneratorGetFunction, 1, 1)         \
264   F(GeneratorGetContext, 1, 1)          \
265   F(GeneratorGetReceiver, 1, 1)         \
266   F(GeneratorGetContinuation, 1, 1)     \
267   F(GeneratorGetSourcePosition, 1, 1)   \
268   F(FunctionIsGenerator, 1, 1)          \
269   F(GeneratorNext, 2, 1)                \
270   F(GeneratorThrow, 2, 1)
271
272
273 #ifdef V8_I18N_SUPPORT
274 #define FOR_EACH_INTRINSIC_I18N(F)           \
275   F(CanonicalizeLanguageTag, 1, 1)           \
276   F(AvailableLocalesOf, 1, 1)                \
277   F(GetDefaultICULocale, 0, 1)               \
278   F(GetLanguageTagVariants, 1, 1)            \
279   F(IsInitializedIntlObject, 1, 1)           \
280   F(IsInitializedIntlObjectOfType, 2, 1)     \
281   F(MarkAsInitializedIntlObjectOfType, 3, 1) \
282   F(GetImplFromInitializedIntlObject, 1, 1)  \
283   F(CreateDateTimeFormat, 3, 1)              \
284   F(InternalDateFormat, 2, 1)                \
285   F(InternalDateParse, 2, 1)                 \
286   F(CreateNumberFormat, 3, 1)                \
287   F(InternalNumberFormat, 2, 1)              \
288   F(InternalNumberParse, 2, 1)               \
289   F(CreateCollator, 3, 1)                    \
290   F(InternalCompare, 3, 1)                   \
291   F(StringNormalize, 2, 1)                   \
292   F(CreateBreakIterator, 3, 1)               \
293   F(BreakIteratorAdoptText, 2, 1)            \
294   F(BreakIteratorFirst, 1, 1)                \
295   F(BreakIteratorNext, 1, 1)                 \
296   F(BreakIteratorCurrent, 1, 1)              \
297   F(BreakIteratorBreakType, 1, 1)
298 #else
299 #define FOR_EACH_INTRINSIC_I18N(F)
300 #endif
301
302
303 #define FOR_EACH_INTRINSIC_INTERNAL(F)        \
304   F(CheckIsBootstrapping, 0, 1)               \
305   F(ExportPrivateSymbols, 1, 1)               \
306   F(ImportToRuntime, 1, 1)                    \
307   F(ImportExperimentalToRuntime, 1, 1)        \
308   F(InstallJSBuiltins, 1, 1)                  \
309   F(Throw, 1, 1)                              \
310   F(ReThrow, 1, 1)                            \
311   F(UnwindAndFindExceptionHandler, 0, 1)      \
312   F(PromoteScheduledException, 0, 1)          \
313   F(ThrowReferenceError, 1, 1)                \
314   F(NewTypeError, 2, 1)                       \
315   F(NewSyntaxError, 2, 1)                     \
316   F(NewReferenceError, 2, 1)                  \
317   F(ThrowIteratorResultNotAnObject, 1, 1)     \
318   F(ThrowStrongModeImplicitConversion, 0, 1)  \
319   F(PromiseRejectEvent, 3, 1)                 \
320   F(PromiseRevokeReject, 1, 1)                \
321   F(StackGuard, 0, 1)                         \
322   F(Interrupt, 0, 1)                          \
323   F(AllocateInNewSpace, 1, 1)                 \
324   F(AllocateInTargetSpace, 2, 1)              \
325   F(CollectStackTrace, 2, 1)                  \
326   F(RenderCallSite, 0, 1)                     \
327   F(MessageGetStartPosition, 1, 1)            \
328   F(MessageGetScript, 1, 1)                   \
329   F(ErrorToStringRT, 1, 1)                    \
330   F(FormatMessageString, 4, 1)                \
331   F(CallSiteGetFileNameRT, 1, 1)              \
332   F(CallSiteGetFunctionNameRT, 1, 1)          \
333   F(CallSiteGetScriptNameOrSourceUrlRT, 1, 1) \
334   F(CallSiteGetMethodNameRT, 1, 1)            \
335   F(CallSiteGetLineNumberRT, 1, 1)            \
336   F(CallSiteGetColumnNumberRT, 1, 1)          \
337   F(CallSiteIsNativeRT, 1, 1)                 \
338   F(CallSiteIsToplevelRT, 1, 1)               \
339   F(CallSiteIsEvalRT, 1, 1)                   \
340   F(CallSiteIsConstructorRT, 1, 1)            \
341   F(IS_VAR, 1, 1)                             \
342   F(IncrementStatsCounter, 1, 1)              \
343   F(Likely, 1, 1)                             \
344   F(Unlikely, 1, 1)                           \
345   F(HarmonyToString, 0, 1)                    \
346   F(GetTypeFeedbackVector, 1, 1)              \
347   F(GetCallerJSFunction, 0, 1)                \
348   F(GetCodeStubExportsObject, 0, 1)
349
350
351 #define FOR_EACH_INTRINSIC_JSON(F) \
352   F(QuoteJSONString, 1, 1)         \
353   F(BasicJSONStringify, 1, 1)      \
354   F(ParseJson, 1, 1)
355
356
357 #define FOR_EACH_INTRINSIC_LITERALS(F)   \
358   F(CreateObjectLiteral, 4, 1)           \
359   F(CreateArrayLiteral, 4, 1)            \
360   F(CreateArrayLiteralStubBailout, 3, 1) \
361   F(StoreArrayLiteralElement, 5, 1)
362
363
364 #define FOR_EACH_INTRINSIC_LIVEEDIT(F)              \
365   F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
366   F(LiveEditGatherCompileInfo, 2, 1)                \
367   F(LiveEditReplaceScript, 3, 1)                    \
368   F(LiveEditFunctionSourceUpdated, 1, 1)            \
369   F(LiveEditReplaceFunctionCode, 2, 1)              \
370   F(LiveEditFunctionSetScript, 2, 1)                \
371   F(LiveEditReplaceRefToNestedFunction, 3, 1)       \
372   F(LiveEditPatchFunctionPositions, 2, 1)           \
373   F(LiveEditCheckAndDropActivations, 2, 1)          \
374   F(LiveEditCompareStrings, 2, 1)                   \
375   F(LiveEditRestartFrame, 2, 1)
376
377
378 #define FOR_EACH_INTRINSIC_MATHS(F) \
379   F(MathAcos, 1, 1)                 \
380   F(MathAsin, 1, 1)                 \
381   F(MathAtan, 1, 1)                 \
382   F(MathLogRT, 1, 1)                \
383   F(DoubleHi, 1, 1)                 \
384   F(DoubleLo, 1, 1)                 \
385   F(ConstructDouble, 2, 1)          \
386   F(RemPiO2, 2, 1)                  \
387   F(MathAtan2, 2, 1)                \
388   F(MathExpRT, 1, 1)                \
389   F(MathClz32, 1, 1)                \
390   F(MathFloor, 1, 1)                \
391   F(MathPow, 2, 1)                  \
392   F(MathPowRT, 2, 1)                \
393   F(RoundNumber, 1, 1)              \
394   F(MathSqrt, 1, 1)                 \
395   F(MathFround, 1, 1)               \
396   F(IsMinusZero, 1, 1)
397
398
399 #define FOR_EACH_INTRINSIC_NUMBERS(F)  \
400   F(NumberToRadixString, 2, 1)         \
401   F(NumberToFixed, 2, 1)               \
402   F(NumberToExponential, 2, 1)         \
403   F(NumberToPrecision, 2, 1)           \
404   F(IsValidSmi, 1, 1)                  \
405   F(StringToNumber, 1, 1)              \
406   F(StringParseInt, 2, 1)              \
407   F(StringParseFloat, 1, 1)            \
408   F(NumberToString, 1, 1)              \
409   F(NumberToStringSkipCache, 1, 1)     \
410   F(NumberToInteger, 1, 1)             \
411   F(NumberToIntegerMapMinusZero, 1, 1) \
412   F(NumberToSmi, 1, 1)                 \
413   F(NumberAdd, 2, 1)                   \
414   F(NumberSub, 2, 1)                   \
415   F(NumberMul, 2, 1)                   \
416   F(NumberUnaryMinus, 1, 1)            \
417   F(NumberDiv, 2, 1)                   \
418   F(NumberMod, 2, 1)                   \
419   F(NumberImul, 2, 1)                  \
420   F(NumberOr, 2, 1)                    \
421   F(NumberAnd, 2, 1)                   \
422   F(NumberXor, 2, 1)                   \
423   F(NumberShl, 2, 1)                   \
424   F(NumberShr, 2, 1)                   \
425   F(NumberSar, 2, 1)                   \
426   F(NumberEquals, 2, 1)                \
427   F(NumberCompare, 3, 1)               \
428   F(SmiLexicographicCompare, 2, 1)     \
429   F(MaxSmi, 0, 1)                      \
430   F(IsSmi, 1, 1)                       \
431   F(IsNonNegativeSmi, 1, 1)            \
432   F(GetRootNaN, 0, 1)
433
434
435 #define FOR_EACH_INTRINSIC_OBJECT(F)                 \
436   F(GetPrototype, 1, 1)                              \
437   F(InternalSetPrototype, 2, 1)                      \
438   F(SetPrototype, 2, 1)                              \
439   F(IsInPrototypeChain, 2, 1)                        \
440   F(GetOwnProperty, 2, 1)                            \
441   F(PreventExtensions, 1, 1)                         \
442   F(IsExtensible, 1, 1)                              \
443   F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
444   F(ObjectFreeze, 1, 1)                              \
445   F(ObjectSeal, 1, 1)                                \
446   F(GetProperty, 2, 1)                               \
447   F(GetPropertyStrong, 2, 1)                         \
448   F(KeyedGetProperty, 2, 1)                          \
449   F(KeyedGetPropertyStrong, 2, 1)                    \
450   F(LoadGlobalViaContext, 1, 1)                      \
451   F(StoreGlobalViaContext_Sloppy, 2, 1)              \
452   F(StoreGlobalViaContext_Strict, 2, 1)              \
453   F(AddNamedProperty, 4, 1)                          \
454   F(SetProperty, 4, 1)                               \
455   F(AddElement, 3, 1)                                \
456   F(AppendElement, 2, 1)                             \
457   F(DeleteProperty_Sloppy, 2, 1)                     \
458   F(DeleteProperty_Strict, 2, 1)                     \
459   F(HasOwnProperty, 2, 1)                            \
460   F(HasProperty, 2, 1)                               \
461   F(HasElement, 2, 1)                                \
462   F(IsPropertyEnumerable, 2, 1)                      \
463   F(GetPropertyNamesFast, 1, 1)                      \
464   F(GetOwnPropertyNames, 2, 1)                       \
465   F(GetOwnElementNames, 1, 1)                        \
466   F(GetInterceptorInfo, 1, 1)                        \
467   F(GetNamedInterceptorPropertyNames, 1, 1)          \
468   F(GetIndexedInterceptorElementNames, 1, 1)         \
469   F(OwnKeys, 1, 1)                                   \
470   F(ToFastProperties, 1, 1)                          \
471   F(NewStringWrapper, 1, 1)                          \
472   F(AllocateHeapNumber, 0, 1)                        \
473   F(NewObject, 2, 1)                                 \
474   F(NewObjectWithAllocationSite, 3, 1)               \
475   F(FinalizeInstanceSize, 1, 1)                      \
476   F(GlobalProxy, 1, 1)                               \
477   F(LookupAccessor, 3, 1)                            \
478   F(LoadMutableDouble, 2, 1)                         \
479   F(TryMigrateInstance, 1, 1)                        \
480   F(IsJSGlobalProxy, 1, 1)                           \
481   F(DefineAccessorPropertyUnchecked, 5, 1)           \
482   F(DefineDataPropertyUnchecked, 4, 1)               \
483   F(GetDataProperty, 2, 1)                           \
484   F(HasFastPackedElements, 1, 1)                     \
485   F(ValueOf, 1, 1)                                   \
486   F(SetValueOf, 2, 1)                                \
487   F(JSValueGetValue, 1, 1)                           \
488   F(HeapObjectGetMap, 1, 1)                          \
489   F(MapGetInstanceType, 1, 1)                        \
490   F(ObjectEquals, 2, 1)                              \
491   F(IsObject, 1, 1)                                  \
492   F(IsSpecObject, 1, 1)                              \
493   F(IsStrong, 1, 1)                                  \
494   F(ClassOf, 1, 1)                                   \
495   F(DefineGetterPropertyUnchecked, 4, 1)             \
496   F(DefineSetterPropertyUnchecked, 4, 1)             \
497   F(ToObject, 1, 1)                                  \
498   F(StrictEquals, 2, 1)
499
500
501 #define FOR_EACH_INTRINSIC_OBSERVE(F)            \
502   F(IsObserved, 1, 1)                            \
503   F(SetIsObserved, 1, 1)                         \
504   F(EnqueueMicrotask, 1, 1)                      \
505   F(RunMicrotasks, 0, 1)                         \
506   F(DeliverObservationChangeRecords, 2, 1)       \
507   F(GetObservationState, 0, 1)                   \
508   F(ObserverObjectAndRecordHaveSameOrigin, 3, 1) \
509   F(ObjectWasCreatedInCurrentOrigin, 1, 1)       \
510   F(GetObjectContextObjectObserve, 1, 1)         \
511   F(GetObjectContextObjectGetNotifier, 1, 1)     \
512   F(GetObjectContextNotifierPerformChange, 1, 1)
513
514
515 #define FOR_EACH_INTRINSIC_PROXY(F) \
516   F(CreateJSProxy, 2, 1)            \
517   F(CreateJSFunctionProxy, 4, 1)    \
518   F(IsJSProxy, 1, 1)                \
519   F(IsJSFunctionProxy, 1, 1)        \
520   F(GetHandler, 1, 1)               \
521   F(GetCallTrap, 1, 1)              \
522   F(GetConstructTrap, 1, 1)         \
523   F(Fix, 1, 1)
524
525
526 #define FOR_EACH_INTRINSIC_REGEXP(F)           \
527   F(StringReplaceGlobalRegExpWithString, 4, 1) \
528   F(StringSplit, 3, 1)                         \
529   F(RegExpExec, 4, 1)                          \
530   F(RegExpConstructResult, 3, 1)               \
531   F(RegExpInitializeAndCompile, 3, 1)          \
532   F(MaterializeRegExpLiteral, 4, 1)            \
533   F(RegExpExecMultiple, 4, 1)                  \
534   F(RegExpExecReThrow, 4, 1)                   \
535   F(IsRegExp, 1, 1)
536
537
538 #define FOR_EACH_INTRINSIC_SCOPES(F)                         \
539   F(ThrowConstAssignError, 0, 1)                             \
540   F(DeclareGlobals, 2, 1)                                    \
541   F(InitializeVarGlobal, 3, 1)                               \
542   F(InitializeConstGlobal, 2, 1)                             \
543   F(DeclareLookupSlot, 2, 1)                                 \
544   F(DeclareReadOnlyLookupSlot, 2, 1)                         \
545   F(InitializeLegacyConstLookupSlot, 3, 1)                   \
546   F(NewArguments, 1, 1) /* TODO(turbofan): Only temporary */ \
547   F(NewSloppyArguments, 3, 1)                                \
548   F(NewStrictArguments, 3, 1)                                \
549   F(NewRestParam, 4, 1)                                      \
550   F(NewRestParamSlow, 2, 1)                                  \
551   F(NewClosureFromStubFailure, 1, 1)                         \
552   F(NewClosure, 3, 1)                                        \
553   F(NewScriptContext, 2, 1)                                  \
554   F(NewFunctionContext, 1, 1)                                \
555   F(PushWithContext, 2, 1)                                   \
556   F(PushCatchContext, 3, 1)                                  \
557   F(PushBlockContext, 2, 1)                                  \
558   F(IsJSModule, 1, 1)                                        \
559   F(PushModuleContext, 2, 1)                                 \
560   F(DeclareModules, 1, 1)                                    \
561   F(DeleteLookupSlot, 2, 1)                                  \
562   F(StoreLookupSlot, 4, 1)                                   \
563   F(ArgumentsLength, 0, 1)                                   \
564   F(Arguments, 1, 1)
565
566
567 #define FOR_EACH_INTRINSIC_SIMD(F)             \
568   F(IsSimdValue, 1, 1)                         \
569   F(SimdToObject, 1, 1)                        \
570   F(SimdEquals, 2, 1)                          \
571   F(SimdSameValue, 2, 1)                       \
572   F(SimdSameValueZero, 2, 1)                   \
573   F(CreateFloat32x4, 4, 1)                     \
574   F(CreateInt32x4, 4, 1)                       \
575   F(CreateUint32x4, 4, 1)                      \
576   F(CreateBool32x4, 4, 1)                      \
577   F(CreateInt16x8, 8, 1)                       \
578   F(CreateUint16x8, 8, 1)                      \
579   F(CreateBool16x8, 8, 1)                      \
580   F(CreateInt8x16, 16, 1)                      \
581   F(CreateUint8x16, 16, 1)                     \
582   F(CreateBool8x16, 16, 1)                     \
583   F(Float32x4Check, 1, 1)                      \
584   F(Float32x4ExtractLane, 2, 1)                \
585   F(Float32x4ReplaceLane, 3, 1)                \
586   F(Float32x4Abs, 1, 1)                        \
587   F(Float32x4Neg, 1, 1)                        \
588   F(Float32x4Sqrt, 1, 1)                       \
589   F(Float32x4RecipApprox, 1, 1)                \
590   F(Float32x4RecipSqrtApprox, 1, 1)            \
591   F(Float32x4Add, 2, 1)                        \
592   F(Float32x4Sub, 2, 1)                        \
593   F(Float32x4Mul, 2, 1)                        \
594   F(Float32x4Div, 2, 1)                        \
595   F(Float32x4Min, 2, 1)                        \
596   F(Float32x4Max, 2, 1)                        \
597   F(Float32x4MinNum, 2, 1)                     \
598   F(Float32x4MaxNum, 2, 1)                     \
599   F(Float32x4Equal, 2, 1)                      \
600   F(Float32x4NotEqual, 2, 1)                   \
601   F(Float32x4LessThan, 2, 1)                   \
602   F(Float32x4LessThanOrEqual, 2, 1)            \
603   F(Float32x4GreaterThan, 2, 1)                \
604   F(Float32x4GreaterThanOrEqual, 2, 1)         \
605   F(Float32x4Select, 3, 1)                     \
606   F(Float32x4Swizzle, 5, 1)                    \
607   F(Float32x4Shuffle, 6, 1)                    \
608   F(Float32x4FromInt32x4, 1, 1)                \
609   F(Float32x4FromUint32x4, 1, 1)               \
610   F(Float32x4FromInt32x4Bits, 1, 1)            \
611   F(Float32x4FromUint32x4Bits, 1, 1)           \
612   F(Float32x4FromInt16x8Bits, 1, 1)            \
613   F(Float32x4FromUint16x8Bits, 1, 1)           \
614   F(Float32x4FromInt8x16Bits, 1, 1)            \
615   F(Float32x4FromUint8x16Bits, 1, 1)           \
616   F(Int32x4Check, 1, 1)                        \
617   F(Int32x4ExtractLane, 2, 1)                  \
618   F(Int32x4ReplaceLane, 3, 1)                  \
619   F(Int32x4Neg, 1, 1)                          \
620   F(Int32x4Add, 2, 1)                          \
621   F(Int32x4Sub, 2, 1)                          \
622   F(Int32x4Mul, 2, 1)                          \
623   F(Int32x4Min, 2, 1)                          \
624   F(Int32x4Max, 2, 1)                          \
625   F(Int32x4And, 2, 1)                          \
626   F(Int32x4Or, 2, 1)                           \
627   F(Int32x4Xor, 2, 1)                          \
628   F(Int32x4Not, 1, 1)                          \
629   F(Int32x4ShiftLeftByScalar, 2, 1)            \
630   F(Int32x4ShiftRightArithmeticByScalar, 2, 1) \
631   F(Int32x4Equal, 2, 1)                        \
632   F(Int32x4NotEqual, 2, 1)                     \
633   F(Int32x4LessThan, 2, 1)                     \
634   F(Int32x4LessThanOrEqual, 2, 1)              \
635   F(Int32x4GreaterThan, 2, 1)                  \
636   F(Int32x4GreaterThanOrEqual, 2, 1)           \
637   F(Int32x4Select, 3, 1)                       \
638   F(Int32x4Swizzle, 5, 1)                      \
639   F(Int32x4Shuffle, 6, 1)                      \
640   F(Int32x4FromFloat32x4, 1, 1)                \
641   F(Int32x4FromUint32x4, 1, 1)                 \
642   F(Int32x4FromFloat32x4Bits, 1, 1)            \
643   F(Int32x4FromUint32x4Bits, 1, 1)             \
644   F(Int32x4FromInt16x8Bits, 1, 1)              \
645   F(Int32x4FromUint16x8Bits, 1, 1)             \
646   F(Int32x4FromInt8x16Bits, 1, 1)              \
647   F(Int32x4FromUint8x16Bits, 1, 1)             \
648   F(Uint32x4Check, 1, 1)                       \
649   F(Uint32x4ExtractLane, 2, 1)                 \
650   F(Uint32x4ReplaceLane, 3, 1)                 \
651   F(Uint32x4Add, 2, 1)                         \
652   F(Uint32x4Sub, 2, 1)                         \
653   F(Uint32x4Mul, 2, 1)                         \
654   F(Uint32x4Min, 2, 1)                         \
655   F(Uint32x4Max, 2, 1)                         \
656   F(Uint32x4And, 2, 1)                         \
657   F(Uint32x4Or, 2, 1)                          \
658   F(Uint32x4Xor, 2, 1)                         \
659   F(Uint32x4Not, 1, 1)                         \
660   F(Uint32x4ShiftLeftByScalar, 2, 1)           \
661   F(Uint32x4ShiftRightLogicalByScalar, 2, 1)   \
662   F(Uint32x4HorizontalSum, 1, 1)               \
663   F(Uint32x4Equal, 2, 1)                       \
664   F(Uint32x4NotEqual, 2, 1)                    \
665   F(Uint32x4LessThan, 2, 1)                    \
666   F(Uint32x4LessThanOrEqual, 2, 1)             \
667   F(Uint32x4GreaterThan, 2, 1)                 \
668   F(Uint32x4GreaterThanOrEqual, 2, 1)          \
669   F(Uint32x4Select, 3, 1)                      \
670   F(Uint32x4Swizzle, 5, 1)                     \
671   F(Uint32x4Shuffle, 6, 1)                     \
672   F(Uint32x4FromFloat32x4, 1, 1)               \
673   F(Uint32x4FromInt32x4, 1, 1)                 \
674   F(Uint32x4FromFloat32x4Bits, 1, 1)           \
675   F(Uint32x4FromInt32x4Bits, 1, 1)             \
676   F(Uint32x4FromInt16x8Bits, 1, 1)             \
677   F(Uint32x4FromUint16x8Bits, 1, 1)            \
678   F(Uint32x4FromInt8x16Bits, 1, 1)             \
679   F(Uint32x4FromUint8x16Bits, 1, 1)            \
680   F(Bool32x4Check, 1, 1)                       \
681   F(Bool32x4ExtractLane, 2, 1)                 \
682   F(Bool32x4ReplaceLane, 3, 1)                 \
683   F(Bool32x4And, 2, 1)                         \
684   F(Bool32x4Or, 2, 1)                          \
685   F(Bool32x4Xor, 2, 1)                         \
686   F(Bool32x4Not, 1, 1)                         \
687   F(Bool32x4AnyTrue, 1, 1)                     \
688   F(Bool32x4AllTrue, 1, 1)                     \
689   F(Bool32x4Swizzle, 5, 1)                     \
690   F(Bool32x4Shuffle, 6, 1)                     \
691   F(Int16x8Check, 1, 1)                        \
692   F(Int16x8ExtractLane, 2, 1)                  \
693   F(Int16x8ReplaceLane, 3, 1)                  \
694   F(Int16x8Neg, 1, 1)                          \
695   F(Int16x8Add, 2, 1)                          \
696   F(Int16x8AddSaturate, 2, 1)                  \
697   F(Int16x8Sub, 2, 1)                          \
698   F(Int16x8SubSaturate, 2, 1)                  \
699   F(Int16x8Mul, 2, 1)                          \
700   F(Int16x8Min, 2, 1)                          \
701   F(Int16x8Max, 2, 1)                          \
702   F(Int16x8And, 2, 1)                          \
703   F(Int16x8Or, 2, 1)                           \
704   F(Int16x8Xor, 2, 1)                          \
705   F(Int16x8Not, 1, 1)                          \
706   F(Int16x8ShiftLeftByScalar, 2, 1)            \
707   F(Int16x8ShiftRightArithmeticByScalar, 2, 1) \
708   F(Int16x8Equal, 2, 1)                        \
709   F(Int16x8NotEqual, 2, 1)                     \
710   F(Int16x8LessThan, 2, 1)                     \
711   F(Int16x8LessThanOrEqual, 2, 1)              \
712   F(Int16x8GreaterThan, 2, 1)                  \
713   F(Int16x8GreaterThanOrEqual, 2, 1)           \
714   F(Int16x8Select, 3, 1)                       \
715   F(Int16x8Swizzle, 9, 1)                      \
716   F(Int16x8Shuffle, 10, 1)                     \
717   F(Int16x8FromUint16x8, 1, 1)                 \
718   F(Int16x8FromFloat32x4Bits, 1, 1)            \
719   F(Int16x8FromInt32x4Bits, 1, 1)              \
720   F(Int16x8FromUint32x4Bits, 1, 1)             \
721   F(Int16x8FromUint16x8Bits, 1, 1)             \
722   F(Int16x8FromInt8x16Bits, 1, 1)              \
723   F(Int16x8FromUint8x16Bits, 1, 1)             \
724   F(Uint16x8Check, 1, 1)                       \
725   F(Uint16x8ExtractLane, 2, 1)                 \
726   F(Uint16x8ReplaceLane, 3, 1)                 \
727   F(Uint16x8Add, 2, 1)                         \
728   F(Uint16x8AddSaturate, 2, 1)                 \
729   F(Uint16x8Sub, 2, 1)                         \
730   F(Uint16x8SubSaturate, 2, 1)                 \
731   F(Uint16x8Mul, 2, 1)                         \
732   F(Uint16x8Min, 2, 1)                         \
733   F(Uint16x8Max, 2, 1)                         \
734   F(Uint16x8And, 2, 1)                         \
735   F(Uint16x8Or, 2, 1)                          \
736   F(Uint16x8Xor, 2, 1)                         \
737   F(Uint16x8Not, 1, 1)                         \
738   F(Uint16x8ShiftLeftByScalar, 2, 1)           \
739   F(Uint16x8ShiftRightLogicalByScalar, 2, 1)   \
740   F(Uint16x8HorizontalSum, 1, 1)               \
741   F(Uint16x8AbsoluteDifference, 2, 1)          \
742   F(Uint16x8WidenedAbsoluteDifference, 2, 1)   \
743   F(Uint16x8Equal, 2, 1)                       \
744   F(Uint16x8NotEqual, 2, 1)                    \
745   F(Uint16x8LessThan, 2, 1)                    \
746   F(Uint16x8LessThanOrEqual, 2, 1)             \
747   F(Uint16x8GreaterThan, 2, 1)                 \
748   F(Uint16x8GreaterThanOrEqual, 2, 1)          \
749   F(Uint16x8Select, 3, 1)                      \
750   F(Uint16x8Swizzle, 9, 1)                     \
751   F(Uint16x8Shuffle, 10, 1)                    \
752   F(Uint16x8FromInt16x8, 1, 1)                 \
753   F(Uint16x8FromFloat32x4Bits, 1, 1)           \
754   F(Uint16x8FromInt32x4Bits, 1, 1)             \
755   F(Uint16x8FromUint32x4Bits, 1, 1)            \
756   F(Uint16x8FromInt16x8Bits, 1, 1)             \
757   F(Uint16x8FromInt8x16Bits, 1, 1)             \
758   F(Uint16x8FromUint8x16Bits, 1, 1)            \
759   F(Bool16x8Check, 1, 1)                       \
760   F(Bool16x8ExtractLane, 2, 1)                 \
761   F(Bool16x8ReplaceLane, 3, 1)                 \
762   F(Bool16x8And, 2, 1)                         \
763   F(Bool16x8Or, 2, 1)                          \
764   F(Bool16x8Xor, 2, 1)                         \
765   F(Bool16x8Not, 1, 1)                         \
766   F(Bool16x8AnyTrue, 1, 1)                     \
767   F(Bool16x8AllTrue, 1, 1)                     \
768   F(Bool16x8Swizzle, 9, 1)                     \
769   F(Bool16x8Shuffle, 10, 1)                    \
770   F(Int8x16Check, 1, 1)                        \
771   F(Int8x16ExtractLane, 2, 1)                  \
772   F(Int8x16ReplaceLane, 3, 1)                  \
773   F(Int8x16Neg, 1, 1)                          \
774   F(Int8x16Add, 2, 1)                          \
775   F(Int8x16AddSaturate, 2, 1)                  \
776   F(Int8x16Sub, 2, 1)                          \
777   F(Int8x16SubSaturate, 2, 1)                  \
778   F(Int8x16Mul, 2, 1)                          \
779   F(Int8x16Min, 2, 1)                          \
780   F(Int8x16Max, 2, 1)                          \
781   F(Int8x16And, 2, 1)                          \
782   F(Int8x16Or, 2, 1)                           \
783   F(Int8x16Xor, 2, 1)                          \
784   F(Int8x16Not, 1, 1)                          \
785   F(Int8x16ShiftLeftByScalar, 2, 1)            \
786   F(Int8x16ShiftRightArithmeticByScalar, 2, 1) \
787   F(Int8x16Equal, 2, 1)                        \
788   F(Int8x16NotEqual, 2, 1)                     \
789   F(Int8x16LessThan, 2, 1)                     \
790   F(Int8x16LessThanOrEqual, 2, 1)              \
791   F(Int8x16GreaterThan, 2, 1)                  \
792   F(Int8x16GreaterThanOrEqual, 2, 1)           \
793   F(Int8x16Select, 3, 1)                       \
794   F(Int8x16Swizzle, 17, 1)                     \
795   F(Int8x16Shuffle, 18, 1)                     \
796   F(Int8x16FromUint8x16, 1, 1)                 \
797   F(Int8x16FromFloat32x4Bits, 1, 1)            \
798   F(Int8x16FromInt32x4Bits, 1, 1)              \
799   F(Int8x16FromUint32x4Bits, 1, 1)             \
800   F(Int8x16FromInt16x8Bits, 1, 1)              \
801   F(Int8x16FromUint16x8Bits, 1, 1)             \
802   F(Int8x16FromUint8x16Bits, 1, 1)             \
803   F(Uint8x16Check, 1, 1)                       \
804   F(Uint8x16ExtractLane, 2, 1)                 \
805   F(Uint8x16ReplaceLane, 3, 1)                 \
806   F(Uint8x16Add, 2, 1)                         \
807   F(Uint8x16AddSaturate, 2, 1)                 \
808   F(Uint8x16Sub, 2, 1)                         \
809   F(Uint8x16SubSaturate, 2, 1)                 \
810   F(Uint8x16Mul, 2, 1)                         \
811   F(Uint8x16Min, 2, 1)                         \
812   F(Uint8x16Max, 2, 1)                         \
813   F(Uint8x16And, 2, 1)                         \
814   F(Uint8x16Or, 2, 1)                          \
815   F(Uint8x16Xor, 2, 1)                         \
816   F(Uint8x16Not, 1, 1)                         \
817   F(Uint8x16ShiftLeftByScalar, 2, 1)           \
818   F(Uint8x16ShiftRightLogicalByScalar, 2, 1)   \
819   F(Uint8x16HorizontalSum, 1, 1)               \
820   F(Uint8x16AbsoluteDifference, 2, 1)          \
821   F(Uint8x16WidenedAbsoluteDifference, 2, 1)   \
822   F(Uint8x16Equal, 2, 1)                       \
823   F(Uint8x16NotEqual, 2, 1)                    \
824   F(Uint8x16LessThan, 2, 1)                    \
825   F(Uint8x16LessThanOrEqual, 2, 1)             \
826   F(Uint8x16GreaterThan, 2, 1)                 \
827   F(Uint8x16GreaterThanOrEqual, 2, 1)          \
828   F(Uint8x16Select, 3, 1)                      \
829   F(Uint8x16Swizzle, 17, 1)                    \
830   F(Uint8x16Shuffle, 18, 1)                    \
831   F(Uint8x16FromInt8x16, 1, 1)                 \
832   F(Uint8x16FromFloat32x4Bits, 1, 1)           \
833   F(Uint8x16FromInt32x4Bits, 1, 1)             \
834   F(Uint8x16FromUint32x4Bits, 1, 1)            \
835   F(Uint8x16FromInt16x8Bits, 1, 1)             \
836   F(Uint8x16FromUint16x8Bits, 1, 1)            \
837   F(Uint8x16FromInt8x16Bits, 1, 1)             \
838   F(Bool8x16Check, 1, 1)                       \
839   F(Bool8x16ExtractLane, 2, 1)                 \
840   F(Bool8x16ReplaceLane, 3, 1)                 \
841   F(Bool8x16And, 2, 1)                         \
842   F(Bool8x16Or, 2, 1)                          \
843   F(Bool8x16Xor, 2, 1)                         \
844   F(Bool8x16Not, 1, 1)                         \
845   F(Bool8x16AnyTrue, 1, 1)                     \
846   F(Bool8x16AllTrue, 1, 1)                     \
847   F(Bool8x16Swizzle, 17, 1)                    \
848   F(Bool8x16Shuffle, 18, 1)
849
850
851 #define FOR_EACH_INTRINSIC_STRINGS(F)           \
852   F(StringReplaceOneCharWithString, 3, 1)       \
853   F(StringIndexOf, 3, 1)                        \
854   F(StringLastIndexOf, 3, 1)                    \
855   F(StringLocaleCompare, 2, 1)                  \
856   F(SubString, 3, 1)                            \
857   F(StringAdd, 2, 1)                            \
858   F(InternalizeString, 1, 1)                    \
859   F(StringMatch, 3, 1)                          \
860   F(StringCharCodeAtRT, 2, 1)                   \
861   F(CharFromCode, 1, 1)                         \
862   F(StringCompare, 2, 1)                        \
863   F(StringBuilderConcat, 3, 1)                  \
864   F(StringBuilderJoin, 3, 1)                    \
865   F(SparseJoinWithSeparator, 3, 1)              \
866   F(StringToArray, 2, 1)                        \
867   F(StringToLowerCase, 1, 1)                    \
868   F(StringToUpperCase, 1, 1)                    \
869   F(StringTrim, 3, 1)                           \
870   F(TruncateString, 2, 1)                       \
871   F(NewString, 2, 1)                            \
872   F(NewConsString, 4, 1)                        \
873   F(StringEquals, 2, 1)                         \
874   F(FlattenString, 1, 1)                        \
875   F(StringCharFromCode, 1, 1)                   \
876   F(StringCharAt, 2, 1)                         \
877   F(OneByteSeqStringGetChar, 2, 1)              \
878   F(OneByteSeqStringSetChar, 3, 1)              \
879   F(TwoByteSeqStringGetChar, 2, 1)              \
880   F(TwoByteSeqStringSetChar, 3, 1)              \
881   F(StringCharCodeAt, 2, 1)                     \
882   F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
883   F(StringGetLength, 1, 1)
884
885
886 #define FOR_EACH_INTRINSIC_SYMBOL(F) \
887   F(CreateSymbol, 1, 1)              \
888   F(CreatePrivateSymbol, 1, 1)       \
889   F(SymbolDescription, 1, 1)         \
890   F(SymbolRegistry, 0, 1)            \
891   F(SymbolIsPrivate, 1, 1)
892
893
894 #define FOR_EACH_INTRINSIC_TEST(F)            \
895   F(DeoptimizeFunction, 1, 1)                 \
896   F(DeoptimizeNow, 0, 1)                      \
897   F(RunningInSimulator, 0, 1)                 \
898   F(IsConcurrentRecompilationSupported, 0, 1) \
899   F(OptimizeFunctionOnNextCall, -1, 1)        \
900   F(OptimizeOsr, -1, 1)                       \
901   F(NeverOptimizeFunction, 1, 1)              \
902   F(GetOptimizationStatus, -1, 1)             \
903   F(UnblockConcurrentRecompilation, 0, 1)     \
904   F(GetOptimizationCount, 1, 1)               \
905   F(GetUndetectable, 0, 1)                    \
906   F(ClearFunctionTypeFeedback, 1, 1)          \
907   F(NotifyContextDisposed, 0, 1)              \
908   F(SetAllocationTimeout, -1 /* 2 || 3 */, 1) \
909   F(DebugPrint, 1, 1)                         \
910   F(DebugTrace, 0, 1)                         \
911   F(GlobalPrint, 1, 1)                        \
912   F(SystemBreak, 0, 1)                        \
913   F(SetFlags, 1, 1)                           \
914   F(Abort, 1, 1)                              \
915   F(AbortJS, 1, 1)                            \
916   F(NativeScriptsCount, 0, 1)                 \
917   F(GetV8Version, 0, 1)                       \
918   F(DisassembleFunction, 1, 1)                \
919   F(TraceEnter, 0, 1)                         \
920   F(TraceExit, 1, 1)                          \
921   F(HaveSameMap, 2, 1)                        \
922   F(HasFastSmiElements, 1, 1)                 \
923   F(HasFastObjectElements, 1, 1)              \
924   F(HasFastSmiOrObjectElements, 1, 1)         \
925   F(HasFastDoubleElements, 1, 1)              \
926   F(HasFastHoleyElements, 1, 1)               \
927   F(HasDictionaryElements, 1, 1)              \
928   F(HasSloppyArgumentsElements, 1, 1)         \
929   F(HasFixedTypedArrayElements, 1, 1)         \
930   F(HasFastProperties, 1, 1)                  \
931   F(HasFixedUint8Elements, 1, 1)              \
932   F(HasFixedInt8Elements, 1, 1)               \
933   F(HasFixedUint16Elements, 1, 1)             \
934   F(HasFixedInt16Elements, 1, 1)              \
935   F(HasFixedUint32Elements, 1, 1)             \
936   F(HasFixedInt32Elements, 1, 1)              \
937   F(HasFixedFloat32Elements, 1, 1)            \
938   F(HasFixedFloat64Elements, 1, 1)            \
939   F(HasFixedUint8ClampedElements, 1, 1)
940
941
942 #define FOR_EACH_INTRINSIC_TYPEDARRAY(F)     \
943   F(ArrayBufferInitialize, 3, 1)             \
944   F(ArrayBufferGetByteLength, 1, 1)          \
945   F(ArrayBufferSliceImpl, 3, 1)              \
946   F(ArrayBufferIsView, 1, 1)                 \
947   F(ArrayBufferNeuter, 1, 1)                 \
948   F(TypedArrayInitialize, 6, 1)              \
949   F(TypedArrayInitializeFromArrayLike, 4, 1) \
950   F(ArrayBufferViewGetByteLength, 1, 1)      \
951   F(ArrayBufferViewGetByteOffset, 1, 1)      \
952   F(TypedArrayGetLength, 1, 1)               \
953   F(DataViewGetBuffer, 1, 1)                 \
954   F(TypedArrayGetBuffer, 1, 1)               \
955   F(TypedArraySetFastCases, 3, 1)            \
956   F(TypedArrayMaxSizeInHeap, 0, 1)           \
957   F(IsTypedArray, 1, 1)                      \
958   F(IsSharedTypedArray, 1, 1)                \
959   F(IsSharedIntegerTypedArray, 1, 1)         \
960   F(DataViewInitialize, 4, 1)                \
961   F(DataViewGetUint8, 3, 1)                  \
962   F(DataViewGetInt8, 3, 1)                   \
963   F(DataViewGetUint16, 3, 1)                 \
964   F(DataViewGetInt16, 3, 1)                  \
965   F(DataViewGetUint32, 3, 1)                 \
966   F(DataViewGetInt32, 3, 1)                  \
967   F(DataViewGetFloat32, 3, 1)                \
968   F(DataViewGetFloat64, 3, 1)                \
969   F(DataViewSetUint8, 4, 1)                  \
970   F(DataViewSetInt8, 4, 1)                   \
971   F(DataViewSetUint16, 4, 1)                 \
972   F(DataViewSetInt16, 4, 1)                  \
973   F(DataViewSetUint32, 4, 1)                 \
974   F(DataViewSetInt32, 4, 1)                  \
975   F(DataViewSetFloat32, 4, 1)                \
976   F(DataViewSetFloat64, 4, 1)
977
978
979 #define FOR_EACH_INTRINSIC_URI(F) \
980   F(URIEscape, 1, 1)              \
981   F(URIUnescape, 1, 1)
982
983
984 #define FOR_EACH_INTRINSIC_RETURN_PAIR(F) \
985   F(LoadLookupSlot, 2, 2)                 \
986   F(LoadLookupSlotNoReferenceError, 2, 2)
987
988
989 // Most intrinsics are implemented in the runtime/ directory, but ICs are
990 // implemented in ic.cc for now.
991 #define FOR_EACH_INTRINSIC_IC(F)             \
992   F(LoadIC_Miss, 3, 1)                       \
993   F(KeyedLoadIC_Miss, 3, 1)                  \
994   F(CallIC_Miss, 3, 1)                       \
995   F(CallIC_Customization_Miss, 3, 1)         \
996   F(StoreIC_Miss, 3, 1)                      \
997   F(StoreIC_Slow, 3, 1)                      \
998   F(KeyedStoreIC_Miss, 3, 1)                 \
999   F(KeyedStoreIC_Slow, 3, 1)                 \
1000   F(StoreCallbackProperty, 5, 1)             \
1001   F(LoadPropertyWithInterceptorOnly, 3, 1)   \
1002   F(LoadPropertyWithInterceptor, 3, 1)       \
1003   F(LoadElementWithInterceptor, 2, 1)        \
1004   F(StorePropertyWithInterceptor, 3, 1)      \
1005   F(CompareIC_Miss, 3, 1)                    \
1006   F(BinaryOpIC_Miss, 2, 1)                   \
1007   F(CompareNilIC_Miss, 1, 1)                 \
1008   F(Unreachable, 0, 1)                       \
1009   F(ToBooleanIC_Miss, 1, 1)                  \
1010   F(KeyedLoadIC_MissFromStubFailure, 4, 1)   \
1011   F(KeyedStoreIC_MissFromStubFailure, 3, 1)  \
1012   F(StoreIC_MissFromStubFailure, 3, 1)       \
1013   F(ElementsTransitionAndStoreIC_Miss, 4, 1) \
1014   F(BinaryOpIC_MissWithAllocationSite, 3, 1) \
1015   F(LoadIC_MissFromStubFailure, 0, 1)
1016
1017
1018 #define FOR_EACH_INTRINSIC_RETURN_OBJECT(F) \
1019   FOR_EACH_INTRINSIC_IC(F)                  \
1020   FOR_EACH_INTRINSIC_ARRAY(F)               \
1021   FOR_EACH_INTRINSIC_ATOMICS(F)             \
1022   FOR_EACH_INTRINSIC_CLASSES(F)             \
1023   FOR_EACH_INTRINSIC_COLLECTIONS(F)         \
1024   FOR_EACH_INTRINSIC_COMPILER(F)            \
1025   FOR_EACH_INTRINSIC_DATE(F)                \
1026   FOR_EACH_INTRINSIC_DEBUG(F)               \
1027   FOR_EACH_INTRINSIC_FORIN(F)               \
1028   FOR_EACH_INTRINSIC_FUNCTION(F)            \
1029   FOR_EACH_INTRINSIC_FUTEX(F)               \
1030   FOR_EACH_INTRINSIC_GENERATOR(F)           \
1031   FOR_EACH_INTRINSIC_I18N(F)                \
1032   FOR_EACH_INTRINSIC_INTERNAL(F)            \
1033   FOR_EACH_INTRINSIC_JSON(F)                \
1034   FOR_EACH_INTRINSIC_LITERALS(F)            \
1035   FOR_EACH_INTRINSIC_LIVEEDIT(F)            \
1036   FOR_EACH_INTRINSIC_MATHS(F)               \
1037   FOR_EACH_INTRINSIC_NUMBERS(F)             \
1038   FOR_EACH_INTRINSIC_OBJECT(F)              \
1039   FOR_EACH_INTRINSIC_OBSERVE(F)             \
1040   FOR_EACH_INTRINSIC_PROXY(F)               \
1041   FOR_EACH_INTRINSIC_REGEXP(F)              \
1042   FOR_EACH_INTRINSIC_SCOPES(F)              \
1043   FOR_EACH_INTRINSIC_SIMD(F)                \
1044   FOR_EACH_INTRINSIC_STRINGS(F)             \
1045   FOR_EACH_INTRINSIC_SYMBOL(F)              \
1046   FOR_EACH_INTRINSIC_TEST(F)                \
1047   FOR_EACH_INTRINSIC_TYPEDARRAY(F)          \
1048   FOR_EACH_INTRINSIC_URI(F)
1049
1050 // FOR_EACH_INTRINSIC defines the list of all intrinsics, coming in 2 flavors,
1051 // either returning an object or a pair.
1052 #define FOR_EACH_INTRINSIC(F)       \
1053   FOR_EACH_INTRINSIC_RETURN_PAIR(F) \
1054   FOR_EACH_INTRINSIC_RETURN_OBJECT(F)
1055
1056
1057 #define F(name, nargs, ressize)                                 \
1058   Object* Runtime_##name(int args_length, Object** args_object, \
1059                          Isolate* isolate);
1060 FOR_EACH_INTRINSIC_RETURN_OBJECT(F)
1061 #undef F
1062
1063 //---------------------------------------------------------------------------
1064 // Runtime provides access to all C++ runtime functions.
1065
1066 class RuntimeState {
1067  public:
1068   unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
1069     return &to_upper_mapping_;
1070   }
1071   unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
1072     return &to_lower_mapping_;
1073   }
1074
1075  private:
1076   RuntimeState() {}
1077   unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
1078   unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
1079
1080   friend class Isolate;
1081   friend class Runtime;
1082
1083   DISALLOW_COPY_AND_ASSIGN(RuntimeState);
1084 };
1085
1086
1087 class JavaScriptFrameIterator;  // Forward declaration.
1088
1089
1090 class Runtime : public AllStatic {
1091  public:
1092   enum FunctionId {
1093 #define F(name, nargs, ressize) k##name,
1094 #define I(name, nargs, ressize) kInline##name,
1095     FOR_EACH_INTRINSIC(F) FOR_EACH_INTRINSIC(I)
1096 #undef I
1097 #undef F
1098         kNumFunctions,
1099   };
1100
1101   enum IntrinsicType { RUNTIME, INLINE };
1102
1103   // Intrinsic function descriptor.
1104   struct Function {
1105     FunctionId function_id;
1106     IntrinsicType intrinsic_type;
1107     // The JS name of the function.
1108     const char* name;
1109
1110     // The C++ (native) entry point.  NULL if the function is inlined.
1111     byte* entry;
1112
1113     // The number of arguments expected. nargs is -1 if the function takes
1114     // a variable number of arguments.
1115     int nargs;
1116     // Size of result.  Most functions return a single pointer, size 1.
1117     int result_size;
1118   };
1119
1120   static const int kNotFound = -1;
1121
1122   // Add internalized strings for all the intrinsic function names to a
1123   // StringDictionary.
1124   static void InitializeIntrinsicFunctionNames(Isolate* isolate,
1125                                                Handle<NameDictionary> dict);
1126
1127   // Get the intrinsic function with the given name, which must be internalized.
1128   static const Function* FunctionForName(Handle<String> name);
1129
1130   // Get the intrinsic function with the given FunctionId.
1131   static const Function* FunctionForId(FunctionId id);
1132
1133   // Get the intrinsic function with the given function entry address.
1134   static const Function* FunctionForEntry(Address ref);
1135
1136   MUST_USE_RESULT static MaybeHandle<Object> DeleteObjectProperty(
1137       Isolate* isolate, Handle<JSReceiver> receiver, Handle<Object> key,
1138       LanguageMode language_mode);
1139
1140   MUST_USE_RESULT static MaybeHandle<Object> SetObjectProperty(
1141       Isolate* isolate, Handle<Object> object, Handle<Object> key,
1142       Handle<Object> value, LanguageMode language_mode);
1143
1144   MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
1145       Isolate* isolate, Handle<Object> object, Handle<Object> key,
1146       LanguageMode language_mode = SLOPPY);
1147
1148   MUST_USE_RESULT static MaybeHandle<Object> KeyedGetObjectProperty(
1149       Isolate* isolate, Handle<Object> receiver_obj, Handle<Object> key_obj,
1150       LanguageMode language_mode);
1151
1152   MUST_USE_RESULT static MaybeHandle<Object> GetPrototype(
1153       Isolate* isolate, Handle<Object> object);
1154
1155   MUST_USE_RESULT static MaybeHandle<Name> ToName(Isolate* isolate,
1156                                                   Handle<Object> key);
1157
1158   static void SetupArrayBuffer(Isolate* isolate,
1159                                Handle<JSArrayBuffer> array_buffer,
1160                                bool is_external, void* data,
1161                                size_t allocated_length,
1162                                SharedFlag shared = SharedFlag::kNotShared);
1163
1164   static bool SetupArrayBufferAllocatingData(
1165       Isolate* isolate, Handle<JSArrayBuffer> array_buffer,
1166       size_t allocated_length, bool initialize = true,
1167       SharedFlag shared = SharedFlag::kNotShared);
1168
1169   static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
1170
1171   enum TypedArrayId {
1172     // arrayIds below should be synchromized with typedarray.js natives.
1173     ARRAY_ID_UINT8 = 1,
1174     ARRAY_ID_INT8 = 2,
1175     ARRAY_ID_UINT16 = 3,
1176     ARRAY_ID_INT16 = 4,
1177     ARRAY_ID_UINT32 = 5,
1178     ARRAY_ID_INT32 = 6,
1179     ARRAY_ID_FLOAT32 = 7,
1180     ARRAY_ID_FLOAT64 = 8,
1181     ARRAY_ID_UINT8_CLAMPED = 9,
1182     ARRAY_ID_FIRST = ARRAY_ID_UINT8,
1183     ARRAY_ID_LAST = ARRAY_ID_UINT8_CLAMPED
1184   };
1185
1186   static void ArrayIdToTypeAndSize(int array_id, ExternalArrayType* type,
1187                                    ElementsKind* fixed_elements_kind,
1188                                    size_t* element_size);
1189
1190   // Used in runtime.cc and hydrogen's VisitArrayLiteral.
1191   MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
1192       Isolate* isolate, Handle<FixedArray> literals,
1193       Handle<FixedArray> elements, bool is_strong);
1194
1195
1196   static void JSMapInitialize(Isolate* isolate, Handle<JSMap> map);
1197   static void JSMapClear(Isolate* isolate, Handle<JSMap> map);
1198   static void JSSetInitialize(Isolate* isolate, Handle<JSSet> set);
1199   static void JSSetClear(Isolate* isolate, Handle<JSSet> set);
1200
1201   static void WeakCollectionInitialize(
1202       Isolate* isolate, Handle<JSWeakCollection> weak_collection);
1203   static void WeakCollectionSet(Handle<JSWeakCollection> weak_collection,
1204                                 Handle<Object> key, Handle<Object> value,
1205                                 int32_t hash);
1206   static bool WeakCollectionDelete(Handle<JSWeakCollection> weak_collection,
1207                                    Handle<Object> key);
1208   static bool WeakCollectionDelete(Handle<JSWeakCollection> weak_collection,
1209                                    Handle<Object> key, int32_t hash);
1210
1211   static MaybeHandle<JSArray> GetInternalProperties(Isolate* isolate,
1212                                                     Handle<Object>);
1213
1214   static bool AtomicIsLockFree(uint32_t size);
1215 };
1216
1217
1218 std::ostream& operator<<(std::ostream&, Runtime::FunctionId);
1219
1220 //---------------------------------------------------------------------------
1221 // Constants used by interface to runtime functions.
1222
1223 class AllocateDoubleAlignFlag : public BitField<bool, 0, 1> {};
1224 class AllocateTargetSpace : public BitField<AllocationSpace, 1, 3> {};
1225
1226 class DeclareGlobalsEvalFlag : public BitField<bool, 0, 1> {};
1227 class DeclareGlobalsNativeFlag : public BitField<bool, 1, 1> {};
1228 STATIC_ASSERT(LANGUAGE_END == 3);
1229 class DeclareGlobalsLanguageMode : public BitField<LanguageMode, 2, 2> {};
1230
1231 //---------------------------------------------------------------------------
1232 // Inline functions
1233
1234 // Assume that 32-bit architectures don't have 64-bit atomic ops.
1235 // TODO(binji): can we do better here?
1236 #if V8_TARGET_ARCH_64_BIT && V8_HOST_ARCH_64_BIT
1237
1238 #define ATOMICS_REQUIRE_LOCK_64_BIT 0
1239
1240 inline bool Runtime::AtomicIsLockFree(uint32_t size) {
1241   return size == 1 || size == 2 || size == 4 || size == 8;
1242 }
1243
1244 #else
1245
1246 #define ATOMICS_REQUIRE_LOCK_64_BIT 1
1247
1248 inline bool Runtime::AtomicIsLockFree(uint32_t size) {
1249   return size == 1 || size == 2 || size == 4;
1250 }
1251
1252 #endif
1253
1254 }  // namespace internal
1255 }  // namespace v8
1256
1257 #endif  // V8_RUNTIME_RUNTIME_H_