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.
5 #ifndef V8_RUNTIME_RUNTIME_H_
6 #define V8_RUNTIME_RUNTIME_H_
8 #include "src/allocation.h"
9 #include "src/objects.h"
15 // The interface to C++ runtime functions.
17 // ----------------------------------------------------------------------------
18 // RUNTIME_FUNCTION_LIST_ALWAYS defines runtime calls available in both
19 // release and debug mode.
20 // This macro should only be used by the macro RUNTIME_FUNCTION_LIST.
22 // WARNING: RUNTIME_FUNCTION_LIST_ALWAYS_* is a very large macro that caused
23 // MSVC Intellisense to crash. It was broken into two macros to work around
24 // this problem. Please avoid large recursive macros whenever possible.
25 #define RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
26 /* Property access */ \
27 F(GetProperty, 2, 1) \
28 F(KeyedGetProperty, 2, 1) \
29 F(DeleteProperty, 3, 1) \
30 F(HasOwnProperty, 2, 1) \
31 F(HasProperty, 2, 1) \
33 F(IsPropertyEnumerable, 2, 1) \
34 F(GetPropertyNames, 1, 1) \
35 F(GetPropertyNamesFast, 1, 1) \
36 F(GetOwnPropertyNames, 2, 1) \
37 F(GetOwnElementNames, 1, 1) \
38 F(GetInterceptorInfo, 1, 1) \
39 F(GetNamedInterceptorPropertyNames, 1, 1) \
40 F(GetIndexedInterceptorElementNames, 1, 1) \
41 F(GetArgumentsProperty, 1, 1) \
42 F(ToFastProperties, 1, 1) \
43 F(FinishArrayPrototypeSetup, 1, 1) \
44 F(SpecialArrayFunctions, 0, 1) \
45 F(IsSloppyModeFunction, 1, 1) \
46 F(GetDefaultReceiver, 1, 1) \
48 F(GetPrototype, 1, 1) \
49 F(SetPrototype, 2, 1) \
50 F(InternalSetPrototype, 2, 1) \
51 F(IsInPrototypeChain, 2, 1) \
53 F(GetOwnProperty, 2, 1) \
55 F(IsExtensible, 1, 1) \
56 F(PreventExtensions, 1, 1) \
59 F(CheckIsBootstrapping, 0, 1) \
61 F(Call, -1 /* >= 2 */, 1) \
63 F(GetFunctionDelegate, 1, 1) \
64 F(GetConstructorDelegate, 1, 1) \
65 F(DeoptimizeFunction, 1, 1) \
66 F(ClearFunctionTypeFeedback, 1, 1) \
67 F(RunningInSimulator, 0, 1) \
68 F(IsConcurrentRecompilationSupported, 0, 1) \
69 F(OptimizeFunctionOnNextCall, -1, 1) \
70 F(NeverOptimizeFunction, 1, 1) \
71 F(GetOptimizationStatus, -1, 1) \
72 F(GetOptimizationCount, 1, 1) \
73 F(UnblockConcurrentRecompilation, 0, 1) \
74 F(CompileForOnStackReplacement, 1, 1) \
75 F(SetAllocationTimeout, -1 /* 2 || 3 */, 1) \
76 F(SetNativeFlag, 1, 1) \
77 F(SetInlineBuiltinFlag, 1, 1) \
78 F(StoreArrayLiteralElement, 5, 1) \
79 F(DebugPrepareStepInIfStepping, 1, 1) \
80 F(DebugPushPromise, 1, 1) \
81 F(DebugPopPromise, 0, 1) \
82 F(DebugPromiseEvent, 1, 1) \
83 F(DebugAsyncTaskEvent, 1, 1) \
84 F(PromiseRejectEvent, 3, 1) \
85 F(PromiseRevokeReject, 1, 1) \
86 F(PromiseHasHandlerSymbol, 0, 1) \
87 F(FlattenString, 1, 1) \
88 F(LoadMutableDouble, 2, 1) \
89 F(TryMigrateInstance, 1, 1) \
90 F(NotifyContextDisposed, 0, 1) \
92 /* Array join support */ \
93 F(PushIfAbsent, 2, 1) \
94 F(ArrayConcat, 1, 1) \
100 F(Booleanize, 2, 1) /* TODO(turbofan): Only temporary */ \
102 F(StringToNumber, 1, 1) \
103 F(StringParseInt, 2, 1) \
104 F(StringParseFloat, 1, 1) \
105 F(StringToLowerCase, 1, 1) \
106 F(StringToUpperCase, 1, 1) \
107 F(StringSplit, 3, 1) \
108 F(CharFromCode, 1, 1) \
110 F(URIUnescape, 1, 1) \
112 F(NumberToInteger, 1, 1) \
113 F(NumberToIntegerMapMinusZero, 1, 1) \
114 F(NumberToJSUint32, 1, 1) \
115 F(NumberToJSInt32, 1, 1) \
117 /* Arithmetic operations */ \
123 F(NumberUnaryMinus, 1, 1) \
124 F(NumberImul, 2, 1) \
126 F(StringBuilderConcat, 3, 1) \
127 F(StringBuilderJoin, 3, 1) \
128 F(SparseJoinWithSeparator, 3, 1) \
130 /* Bit operations */ \
140 F(NumberEquals, 2, 1) \
141 F(StringEquals, 2, 1) \
143 F(NumberCompare, 3, 1) \
144 F(SmiLexicographicCompare, 2, 1) \
150 F(MathFloorRT, 1, 1) \
153 F(RoundNumber, 1, 1) \
154 F(MathFround, 1, 1) \
157 /* Regular expressions */ \
158 F(RegExpCompile, 3, 1) \
159 F(RegExpExecMultiple, 4, 1) \
160 F(RegExpInitializeObject, 6, 1) \
164 F(BasicJSONStringify, 1, 1) \
165 F(QuoteJSONString, 1, 1) \
168 F(StringIndexOf, 3, 1) \
169 F(StringLastIndexOf, 3, 1) \
170 F(StringLocaleCompare, 2, 1) \
171 F(StringReplaceGlobalRegExpWithString, 4, 1) \
172 F(StringReplaceOneCharWithString, 3, 1) \
173 F(StringMatch, 3, 1) \
174 F(StringTrim, 3, 1) \
175 F(StringToArray, 2, 1) \
176 F(NewStringWrapper, 1, 1) \
178 F(TruncateString, 2, 1) \
181 F(NumberToRadixString, 2, 1) \
182 F(NumberToFixed, 2, 1) \
183 F(NumberToExponential, 2, 1) \
184 F(NumberToPrecision, 2, 1) \
185 F(IsValidSmi, 1, 1) \
188 F(AllocateFloat32x4, 0, 1) \
189 F(AllocateFloat64x2, 0, 1) \
190 F(AllocateInt32x4, 0, 1) \
191 F(Float32x4LoadX, 2, 1) \
192 F(Float32x4LoadXY, 2, 1) \
193 F(Float32x4LoadXYZ, 2, 1) \
194 F(Float32x4LoadXYZW, 2, 1) \
195 F(Float32x4StoreX, 3, 1) \
196 F(Float32x4StoreXY, 3, 1) \
197 F(Float32x4StoreXYZ, 3, 1) \
198 F(Float32x4StoreXYZW, 3, 1) \
199 F(Float32x4Abs, 1, 1) \
200 F(Float32x4BitsToInt32x4, 1, 1) \
201 F(Float32x4Neg, 1, 1) \
202 F(Float32x4Reciprocal, 1, 1) \
203 F(Float32x4ReciprocalSqrt, 1, 1) \
204 F(Float32x4Sqrt, 1, 1) \
205 F(Float32x4ToInt32x4, 1, 1) \
206 F(Float32x4Add, 2, 1) \
207 F(Float32x4Div, 2, 1) \
208 F(Float32x4Max, 2, 1) \
209 F(Float32x4Min, 2, 1) \
210 F(Float32x4Mul, 2, 1) \
211 F(Float32x4Sub, 2, 1) \
212 F(Float32x4Equal, 2, 1) \
213 F(Float32x4NotEqual, 2, 1) \
214 F(Float32x4GreaterThanOrEqual, 2, 1) \
215 F(Float32x4GreaterThan, 2, 1) \
216 F(Float32x4LessThan, 2, 1) \
217 F(Float32x4LessThanOrEqual, 2, 1) \
218 F(Float32x4Shuffle, 2, 1) \
219 F(Float32x4Scale, 2, 1) \
220 F(Float32x4WithX, 2, 1) \
221 F(Float32x4WithY, 2, 1) \
222 F(Float32x4WithZ, 2, 1) \
223 F(Float32x4WithW, 2, 1) \
224 F(Float32x4Clamp, 3, 1) \
225 F(Float32x4ShuffleMix, 3, 1) \
226 F(Float32x4Select, 3, 1) \
227 F(Float64x2LoadX, 2, 1) \
228 F(Float64x2LoadXY, 2, 1) \
229 F(Float64x2StoreX, 3, 1) \
230 F(Float64x2StoreXY, 3, 1) \
231 F(Float64x2Abs, 1, 1) \
232 F(Float64x2Neg, 1, 1) \
233 F(Float64x2Sqrt, 1, 1) \
234 F(Float64x2Add, 2, 1) \
235 F(Float64x2Div, 2, 1) \
236 F(Float64x2Max, 2, 1) \
237 F(Float64x2Min, 2, 1) \
238 F(Float64x2Mul, 2, 1) \
239 F(Float64x2Sub, 2, 1) \
240 F(Float64x2Scale, 2, 1) \
241 F(Float64x2WithX, 2, 1) \
242 F(Float64x2WithY, 2, 1) \
243 F(Float64x2Clamp, 3, 1) \
244 F(Int32x4LoadX, 2, 1) \
245 F(Int32x4LoadXY, 2, 1) \
246 F(Int32x4LoadXYZ, 2, 1) \
247 F(Int32x4LoadXYZW, 2, 1) \
248 F(Int32x4StoreX, 3, 1) \
249 F(Int32x4StoreXY, 3, 1) \
250 F(Int32x4StoreXYZ, 3, 1) \
251 F(Int32x4StoreXYZW, 3, 1) \
252 F(Int32x4BitsToFloat32x4, 1, 1) \
253 F(Int32x4Neg, 1, 1) \
254 F(Int32x4Not, 1, 1) \
255 F(Int32x4ToFloat32x4, 1, 1) \
256 F(Int32x4And, 2, 1) \
258 F(Int32x4Xor, 2, 1) \
259 F(Int32x4Add, 2, 1) \
260 F(Int32x4Sub, 2, 1) \
261 F(Int32x4Mul, 2, 1) \
262 F(Int32x4Shuffle, 2, 1) \
263 F(Int32x4WithX, 2, 1) \
264 F(Int32x4WithY, 2, 1) \
265 F(Int32x4WithZ, 2, 1) \
266 F(Int32x4WithW, 2, 1) \
267 F(Int32x4WithFlagX, 2, 1) \
268 F(Int32x4WithFlagY, 2, 1) \
269 F(Int32x4WithFlagZ, 2, 1) \
270 F(Int32x4WithFlagW, 2, 1) \
271 F(Int32x4GreaterThan, 2, 1) \
272 F(Int32x4Equal, 2, 1) \
273 F(Int32x4LessThan, 2, 1) \
274 F(Int32x4Select, 3, 1) \
275 F(CreateFloat32x4, 4, 1) \
276 F(Float32x4GetX, 1, 1) \
277 F(Float32x4GetY, 1, 1) \
278 F(Float32x4GetZ, 1, 1) \
279 F(Float32x4GetW, 1, 1) \
280 F(Float32x4GetSignMask, 1, 1) \
281 F(CreateFloat64x2, 2, 1) \
282 F(Float64x2GetX, 1, 1) \
283 F(Float64x2GetY, 1, 1) \
284 F(Float64x2GetSignMask, 1, 1) \
285 F(CreateInt32x4, 4, 1) \
286 F(Int32x4GetX, 1, 1) \
287 F(Int32x4GetY, 1, 1) \
288 F(Int32x4GetZ, 1, 1) \
289 F(Int32x4GetW, 1, 1) \
290 F(Int32x4GetFlagX, 1, 1) \
291 F(Int32x4GetFlagY, 1, 1) \
292 F(Int32x4GetFlagZ, 1, 1) \
293 F(Int32x4GetFlagW, 1, 1) \
294 F(Int32x4GetSignMask, 1, 1) \
296 /* Classes support */ \
298 F(HomeObjectSymbol, 0, 1) \
299 F(DefineClass, 6, 1) \
300 F(DefineClassMethod, 3, 1) \
301 F(DefineClassGetter, 3, 1) \
302 F(DefineClassSetter, 3, 1) \
303 F(ClassGetSourceCode, 1, 1) \
304 F(ThrowNonMethodError, 0, 1) \
305 F(ThrowUnsupportedSuperError, 0, 1) \
306 F(LoadFromSuper, 3, 1) \
307 F(LoadKeyedFromSuper, 3, 1) \
308 F(StoreToSuper_Strict, 4, 1) \
309 F(StoreToSuper_Sloppy, 4, 1) \
310 F(StoreKeyedToSuper_Strict, 4, 1) \
311 F(StoreKeyedToSuper_Sloppy, 4, 1)
314 #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
316 F(FunctionSetInstanceClassName, 2, 1) \
317 F(FunctionSetLength, 2, 1) \
318 F(FunctionSetPrototype, 2, 1) \
319 F(FunctionGetName, 1, 1) \
320 F(FunctionSetName, 2, 1) \
321 F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
322 F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
323 F(FunctionIsGenerator, 1, 1) \
324 F(FunctionIsArrow, 1, 1) \
325 F(FunctionIsConciseMethod, 1, 1) \
326 F(FunctionBindArguments, 4, 1) \
327 F(BoundFunctionGetBindings, 1, 1) \
328 F(FunctionRemovePrototype, 1, 1) \
329 F(FunctionGetSourceCode, 1, 1) \
330 F(FunctionGetScript, 1, 1) \
331 F(FunctionGetScriptSourcePosition, 1, 1) \
332 F(FunctionGetPositionForOffset, 2, 1) \
333 F(FunctionIsAPIFunction, 1, 1) \
334 F(FunctionIsBuiltin, 1, 1) \
336 F(CollectStackTrace, 2, 1) \
337 F(GetV8Version, 0, 1) \
338 F(GeneratorGetFunction, 1, 1) \
339 F(GeneratorGetContext, 1, 1) \
340 F(GeneratorGetReceiver, 1, 1) \
341 F(GeneratorGetContinuation, 1, 1) \
342 F(GeneratorGetSourcePosition, 1, 1) \
346 F(CreateApiFunction, 2, 1) \
347 F(IsTemplate, 1, 1) \
348 F(GetTemplateField, 2, 1) \
349 F(DisableAccessChecks, 1, 1) \
350 F(EnableAccessChecks, 1, 1) \
353 F(DateCurrentTime, 0, 1) \
354 F(DateParseString, 2, 1) \
355 F(DateLocalTimezone, 1, 1) \
357 F(DateMakeDay, 2, 1) \
358 F(DateSetValue, 3, 1) \
359 F(DateCacheVersion, 0, 1) \
362 F(CompileString, 2, 1) \
365 F(GlobalProxy, 1, 1) \
366 F(IsAttachedGlobal, 1, 1) \
368 F(AddNamedProperty, 4, 1) \
369 F(AddPropertyForTemplate, 4, 1) \
370 F(SetProperty, 4, 1) \
371 F(AddElement, 4, 1) \
372 F(DefineApiAccessorProperty, 5, 1) \
373 F(DefineDataPropertyUnchecked, 4, 1) \
374 F(DefineAccessorPropertyUnchecked, 5, 1) \
375 F(GetDataProperty, 2, 1) \
378 F(RemoveArrayHoles, 2, 1) \
379 F(GetArrayKeys, 2, 1) \
380 F(MoveArrayContents, 2, 1) \
381 F(EstimateNumberOfElements, 1, 1) \
382 F(NormalizeElements, 1, 1) \
383 F(HasComplexElements, 1, 1) \
385 /* Getters and Setters */ \
386 F(LookupAccessor, 3, 1) \
389 F(ObjectFreeze, 1, 1) \
391 /* Harmony modules */ \
392 F(IsJSModule, 1, 1) \
394 /* Harmony symbols */ \
395 F(CreateSymbol, 1, 1) \
396 F(CreatePrivateSymbol, 1, 1) \
397 F(CreateGlobalPrivateOwnSymbol, 1, 1) \
398 F(CreatePrivateOwnSymbol, 1, 1) \
399 F(NewSymbolWrapper, 1, 1) \
400 F(SymbolDescription, 1, 1) \
401 F(SymbolRegistry, 0, 1) \
402 F(SymbolIsPrivate, 1, 1) \
404 /* Harmony proxies */ \
405 F(CreateJSProxy, 2, 1) \
406 F(CreateJSFunctionProxy, 4, 1) \
407 F(IsJSFunctionProxy, 1, 1) \
408 F(GetHandler, 1, 1) \
409 F(GetCallTrap, 1, 1) \
410 F(GetConstructTrap, 1, 1) \
414 F(SetInitialize, 1, 1) \
419 F(SetGetSize, 1, 1) \
421 F(SetIteratorInitialize, 3, 1) \
422 F(SetIteratorClone, 1, 1) \
423 F(SetIteratorNext, 2, 1) \
426 F(MapInitialize, 1, 1) \
432 F(MapGetSize, 1, 1) \
434 F(MapIteratorInitialize, 3, 1) \
435 F(MapIteratorClone, 1, 1) \
436 F(MapIteratorNext, 2, 1) \
438 /* Harmony weak maps and sets */ \
439 F(WeakCollectionInitialize, 1, 1) \
440 F(WeakCollectionGet, 2, 1) \
441 F(WeakCollectionHas, 2, 1) \
442 F(WeakCollectionDelete, 2, 1) \
443 F(WeakCollectionSet, 3, 1) \
445 F(GetWeakMapEntries, 1, 1) \
446 F(GetWeakSetValues, 1, 1) \
448 /* Harmony events */ \
449 F(EnqueueMicrotask, 1, 1) \
450 F(RunMicrotasks, 0, 1) \
452 /* Harmony observe */ \
453 F(IsObserved, 1, 1) \
454 F(SetIsObserved, 1, 1) \
455 F(GetObservationState, 0, 1) \
456 F(ObservationWeakMapCreate, 0, 1) \
457 F(ObserverObjectAndRecordHaveSameOrigin, 3, 1) \
458 F(ObjectWasCreatedInCurrentOrigin, 1, 1) \
459 F(GetObjectContextObjectObserve, 1, 1) \
460 F(GetObjectContextObjectGetNotifier, 1, 1) \
461 F(GetObjectContextNotifierPerformChange, 1, 1) \
463 /* Harmony typed arrays */ \
464 F(ArrayBufferInitialize, 2, 1) \
465 F(ArrayBufferSliceImpl, 3, 1) \
466 F(ArrayBufferIsView, 1, 1) \
467 F(ArrayBufferNeuter, 1, 1) \
469 F(IsTypedArray, 1, 1) \
470 F(TypedArrayInitializeFromArrayLike, 4, 1) \
471 F(TypedArrayGetBuffer, 1, 1) \
472 F(TypedArraySetFastCases, 3, 1) \
474 F(DataViewGetBuffer, 1, 1) \
475 F(DataViewGetInt8, 3, 1) \
476 F(DataViewGetUint8, 3, 1) \
477 F(DataViewGetInt16, 3, 1) \
478 F(DataViewGetUint16, 3, 1) \
479 F(DataViewGetInt32, 3, 1) \
480 F(DataViewGetUint32, 3, 1) \
481 F(DataViewGetFloat32, 3, 1) \
482 F(DataViewGetFloat64, 3, 1) \
484 F(DataViewSetInt8, 4, 1) \
485 F(DataViewSetUint8, 4, 1) \
486 F(DataViewSetInt16, 4, 1) \
487 F(DataViewSetUint16, 4, 1) \
488 F(DataViewSetInt32, 4, 1) \
489 F(DataViewSetUint32, 4, 1) \
490 F(DataViewSetFloat32, 4, 1) \
491 F(DataViewSetFloat64, 4, 1) \
494 F(NewObjectFromBound, 1, 1) \
496 /* Declarations and initialization */ \
497 F(InitializeVarGlobal, 3, 1) \
498 F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
501 F(DebugPrint, 1, 1) \
502 F(GlobalPrint, 1, 1) \
503 F(DebugTrace, 0, 1) \
504 F(TraceEnter, 0, 1) \
508 F(NativeScriptsCount, 0, 1) \
512 /* Message objects */ \
513 F(MessageGetStartPosition, 1, 1) \
514 F(MessageGetScript, 1, 1) \
516 /* Pseudo functions - handled as macros by parser */ \
519 /* expose boolean functions from objects-inl.h */ \
520 F(HasFastSmiElements, 1, 1) \
521 F(HasFastSmiOrObjectElements, 1, 1) \
522 F(HasFastObjectElements, 1, 1) \
523 F(HasFastDoubleElements, 1, 1) \
524 F(HasFastHoleyElements, 1, 1) \
525 F(HasDictionaryElements, 1, 1) \
526 F(HasSloppyArgumentsElements, 1, 1) \
527 F(HasExternalUint8ClampedElements, 1, 1) \
528 F(HasExternalArrayElements, 1, 1) \
529 F(HasExternalInt8Elements, 1, 1) \
530 F(HasExternalUint8Elements, 1, 1) \
531 F(HasExternalInt16Elements, 1, 1) \
532 F(HasExternalUint16Elements, 1, 1) \
533 F(HasExternalInt32Elements, 1, 1) \
534 F(HasExternalUint32Elements, 1, 1) \
535 F(HasExternalFloat32Elements, 1, 1) \
536 F(HasExternalFloat32x4Elements, 1, 1) \
537 F(HasExternalInt32x4Elements, 1, 1) \
538 F(HasExternalFloat64x2Elements, 1, 1) \
539 F(HasExternalFloat64Elements, 1, 1) \
540 F(HasFixedUint8ClampedElements, 1, 1) \
541 F(HasFixedInt8Elements, 1, 1) \
542 F(HasFixedUint8Elements, 1, 1) \
543 F(HasFixedInt16Elements, 1, 1) \
544 F(HasFixedUint16Elements, 1, 1) \
545 F(HasFixedInt32Elements, 1, 1) \
546 F(HasFixedUint32Elements, 1, 1) \
547 F(HasFixedFloat32Elements, 1, 1) \
548 F(HasFixedFloat64Elements, 1, 1) \
549 F(HasFastProperties, 1, 1) \
550 F(TransitionElementsKind, 2, 1) \
551 F(HaveSameMap, 2, 1) \
552 F(IsJSGlobalProxy, 1, 1) \
553 F(ForInCacheArrayLength, 2, 1) /* TODO(turbofan): Only temporary */
556 #define RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
557 /* String and Regexp */ \
558 F(NumberToStringRT, 1, 1) \
559 F(RegExpConstructResult, 3, 1) \
560 F(RegExpExecRT, 4, 1) \
563 F(InternalizeString, 1, 1) \
564 F(StringCompare, 2, 1) \
565 F(StringCharCodeAtRT, 2, 1) \
566 F(GetFromCache, 2, 1) \
569 F(CompileLazy, 1, 1) \
570 F(CompileOptimized, 2, 1) \
571 F(TryInstallOptimizedCode, 1, 1) \
572 F(NotifyDeoptimized, 1, 1) \
573 F(NotifyStubFailure, 0, 1) \
576 F(AllocateInNewSpace, 1, 1) \
577 F(AllocateInTargetSpace, 2, 1) \
578 F(AllocateHeapNumber, 0, 1) \
579 F(NumberToSmi, 1, 1) \
580 F(NumberToStringSkipCache, 1, 1) \
582 F(NewArguments, 1, 1) /* TODO(turbofan): Only temporary */ \
583 F(NewSloppyArguments, 3, 1) \
584 F(NewStrictArguments, 3, 1) \
586 /* Harmony generators */ \
587 F(CreateJSGeneratorObject, 0, 1) \
588 F(SuspendJSGeneratorObject, 1, 1) \
589 F(ResumeJSGeneratorObject, 3, 1) \
590 F(ThrowGeneratorStateError, 1, 1) \
593 F(ArrayConstructor, -1, 1) \
594 F(InternalArrayConstructor, -1, 1) \
597 F(MaterializeRegExpLiteral, 4, 1) \
598 F(CreateObjectLiteral, 4, 1) \
599 F(CreateArrayLiteral, 4, 1) \
600 F(CreateArrayLiteralStubBailout, 3, 1) \
603 F(NewClosure, 3, 1) \
604 F(NewClosureFromStubFailure, 1, 1) \
606 F(NewObjectWithAllocationSite, 2, 1) \
607 F(FinalizeInstanceSize, 1, 1) \
610 F(ThrowReferenceError, 1, 1) \
611 F(ThrowNotDateError, 0, 1) \
612 F(StackGuard, 0, 1) \
614 F(PromoteScheduledException, 0, 1) \
617 F(NewGlobalContext, 2, 1) \
618 F(NewFunctionContext, 1, 1) \
619 F(PushWithContext, 2, 1) \
620 F(PushCatchContext, 3, 1) \
621 F(PushBlockContext, 2, 1) \
622 F(PushModuleContext, 2, 1) \
623 F(DeleteLookupSlot, 2, 1) \
624 F(StoreLookupSlot, 4, 1) \
626 /* Declarations and initialization */ \
627 F(DeclareGlobals, 3, 1) \
628 F(DeclareModules, 1, 1) \
629 F(DeclareLookupSlot, 4, 1) \
630 F(InitializeConstGlobal, 2, 1) \
631 F(InitializeLegacyConstLookupSlot, 3, 1) \
634 F(MathPowSlow, 2, 1) \
638 #define RUNTIME_FUNCTION_LIST_RETURN_PAIR(F) \
639 F(LoadLookupSlot, 2, 2) \
640 F(LoadLookupSlotNoReferenceError, 2, 2) \
641 F(ResolvePossiblyDirectEval, 6, 2) \
642 F(ForInInit, 2, 2) /* TODO(turbofan): Only temporary */ \
643 F(ForInNext, 4, 2) /* TODO(turbofan): Only temporary */
646 #define RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
647 /* Debugger support*/ \
648 F(DebugBreak, 0, 1) \
649 F(SetDebugEventListener, 2, 1) \
651 F(DebugGetPropertyDetails, 2, 1) \
652 F(DebugGetProperty, 2, 1) \
653 F(DebugPropertyTypeFromDetails, 1, 1) \
654 F(DebugPropertyAttributesFromDetails, 1, 1) \
655 F(DebugPropertyIndexFromDetails, 1, 1) \
656 F(DebugNamedInterceptorPropertyValue, 2, 1) \
657 F(DebugIndexedInterceptorElementValue, 2, 1) \
658 F(CheckExecutionState, 1, 1) \
659 F(GetFrameCount, 1, 1) \
660 F(GetFrameDetails, 2, 1) \
661 F(GetScopeCount, 2, 1) \
662 F(GetStepInPositions, 2, 1) \
663 F(GetScopeDetails, 4, 1) \
664 F(GetAllScopesDetails, 4, 1) \
665 F(GetFunctionScopeCount, 1, 1) \
666 F(GetFunctionScopeDetails, 2, 1) \
667 F(SetScopeVariableValue, 6, 1) \
668 F(DebugPrintScopes, 0, 1) \
669 F(GetThreadCount, 1, 1) \
670 F(GetThreadDetails, 2, 1) \
671 F(SetDisableBreak, 1, 1) \
672 F(GetBreakLocations, 2, 1) \
673 F(SetFunctionBreakPoint, 3, 1) \
674 F(SetScriptBreakPoint, 4, 1) \
675 F(ClearBreakPoint, 1, 1) \
676 F(ChangeBreakOnException, 2, 1) \
677 F(IsBreakOnException, 1, 1) \
678 F(PrepareStep, 4, 1) \
679 F(ClearStepping, 0, 1) \
680 F(DebugEvaluate, 6, 1) \
681 F(DebugEvaluateGlobal, 4, 1) \
682 F(DebugGetLoadedScripts, 0, 1) \
683 F(DebugReferencedBy, 3, 1) \
684 F(DebugConstructedBy, 2, 1) \
685 F(DebugGetPrototype, 1, 1) \
686 F(DebugSetScriptSource, 2, 1) \
687 F(DebugCallbackSupportsStepping, 1, 1) \
688 F(SystemBreak, 0, 1) \
689 F(DebugDisassembleFunction, 1, 1) \
690 F(DebugDisassembleConstructor, 1, 1) \
691 F(FunctionGetInferredName, 1, 1) \
692 F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
693 F(LiveEditGatherCompileInfo, 2, 1) \
694 F(LiveEditReplaceScript, 3, 1) \
695 F(LiveEditReplaceFunctionCode, 2, 1) \
696 F(LiveEditFunctionSourceUpdated, 1, 1) \
697 F(LiveEditFunctionSetScript, 2, 1) \
698 F(LiveEditReplaceRefToNestedFunction, 3, 1) \
699 F(LiveEditPatchFunctionPositions, 2, 1) \
700 F(LiveEditCheckAndDropActivations, 2, 1) \
701 F(LiveEditCompareStrings, 2, 1) \
702 F(LiveEditRestartFrame, 2, 1) \
703 F(GetFunctionCodePositionFromSource, 2, 1) \
704 F(ExecuteInDebugContext, 2, 1) \
707 F(CollectGarbage, 1, 1) \
708 F(GetHeapUsage, 0, 1)
711 #ifdef V8_I18N_SUPPORT
712 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
714 /* Standalone, helper methods. */ \
715 F(CanonicalizeLanguageTag, 1, 1) \
716 F(AvailableLocalesOf, 1, 1) \
717 F(GetDefaultICULocale, 0, 1) \
718 F(GetLanguageTagVariants, 1, 1) \
719 F(IsInitializedIntlObject, 1, 1) \
720 F(IsInitializedIntlObjectOfType, 2, 1) \
721 F(MarkAsInitializedIntlObjectOfType, 3, 1) \
722 F(GetImplFromInitializedIntlObject, 1, 1) \
724 /* Date format and parse. */ \
725 F(CreateDateTimeFormat, 3, 1) \
726 F(InternalDateFormat, 2, 1) \
727 F(InternalDateParse, 2, 1) \
729 /* Number format and parse. */ \
730 F(CreateNumberFormat, 3, 1) \
731 F(InternalNumberFormat, 2, 1) \
732 F(InternalNumberParse, 2, 1) \
735 F(CreateCollator, 3, 1) \
736 F(InternalCompare, 3, 1) \
738 /* String.prototype.normalize. */ \
739 F(StringNormalize, 2, 1) \
741 /* Break iterator. */ \
742 F(CreateBreakIterator, 3, 1) \
743 F(BreakIteratorAdoptText, 2, 1) \
744 F(BreakIteratorFirst, 1, 1) \
745 F(BreakIteratorNext, 1, 1) \
746 F(BreakIteratorCurrent, 1, 1) \
747 F(BreakIteratorBreakType, 1, 1)
750 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
754 // ----------------------------------------------------------------------------
755 // RUNTIME_FUNCTION_LIST defines all runtime functions accessed
756 // either directly by id (via the code generator), or indirectly
757 // via a native call by name (from within JS code).
758 // Entries have the form F(name, number of arguments, number of return values).
760 #define RUNTIME_FUNCTION_LIST_RETURN_OBJECT(F) \
761 RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
762 RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
763 RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
764 RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
765 RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
768 #define RUNTIME_FUNCTION_LIST(F) \
769 RUNTIME_FUNCTION_LIST_RETURN_OBJECT(F) \
770 RUNTIME_FUNCTION_LIST_RETURN_PAIR(F)
772 // ----------------------------------------------------------------------------
773 // INLINE_FUNCTION_LIST defines all inlined functions accessed
774 // with a native call of the form %_name from within JS code.
775 // Entries have the form F(name, number of arguments, number of return values).
776 #define INLINE_FUNCTION_LIST(F) \
778 F(IsNonNegativeSmi, 1, 1) \
782 F(IsConstructCall, 0, 1) \
783 F(CallFunction, -1 /* receiver + n args + function */, 1) \
784 F(ArgumentsLength, 0, 1) \
787 F(SetValueOf, 2, 1) \
788 F(DateField, 2 /* date object, field index */, 1) \
789 F(StringCharFromCode, 1, 1) \
790 F(StringCharAt, 2, 1) \
791 F(OneByteSeqStringSetChar, 3, 1) \
792 F(TwoByteSeqStringSetChar, 3, 1) \
793 F(ObjectEquals, 2, 1) \
795 F(IsFunction, 1, 1) \
796 F(IsUndetectableObject, 1, 1) \
797 F(IsSpecObject, 1, 1) \
798 F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
800 F(IsMinusZero, 1, 1) \
801 F(HasCachedArrayIndex, 1, 1) \
802 F(GetCachedArrayIndex, 1, 1) \
803 F(FastOneByteArrayJoin, 2, 1) \
804 F(GeneratorNext, 2, 1) \
805 F(GeneratorThrow, 2, 1) \
806 F(DebugBreakInOptimizedCode, 0, 1) \
808 F(StringCharCodeAt, 2, 1) \
811 F(StringCompare, 2, 1) \
812 F(RegExpExec, 4, 1) \
813 F(RegExpConstructResult, 3, 1) \
814 F(GetFromCache, 2, 1) \
815 F(NumberToString, 1, 1) \
816 F(DebugIsActive, 0, 1)
819 // ----------------------------------------------------------------------------
820 // INLINE_OPTIMIZED_FUNCTION_LIST defines all inlined functions accessed
821 // with a native call of the form %_name from within JS code that also have
822 // a corresponding runtime function, that is called from non-optimized code.
823 // For the benefit of (fuzz) tests, the runtime version can also be called
824 // directly as %name (i.e. without the leading underscore).
825 // Entries have the form F(name, number of arguments, number of return values).
826 #define INLINE_OPTIMIZED_FUNCTION_LIST(F) \
828 F(TypedArrayInitialize, 5, 1) \
829 F(DataViewInitialize, 4, 1) \
831 F(TypedArrayMaxSizeInHeap, 0, 1) \
832 F(ArrayBufferViewGetByteLength, 1, 1) \
833 F(ArrayBufferViewGetByteOffset, 1, 1) \
834 F(TypedArrayGetLength, 1, 1) \
836 F(ArrayBufferGetByteLength, 1, 1) \
838 F(ConstructDouble, 2, 1) \
841 F(MathSqrtRT, 1, 1) \
845 //---------------------------------------------------------------------------
846 // Runtime provides access to all C++ runtime functions.
850 unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
851 return &to_upper_mapping_;
853 unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
854 return &to_lower_mapping_;
859 unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
860 unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
862 friend class Isolate;
863 friend class Runtime;
865 DISALLOW_COPY_AND_ASSIGN(RuntimeState);
869 class JavaScriptFrameIterator; // Forward declaration.
872 class Runtime : public AllStatic {
875 #define F(name, nargs, ressize) k##name,
876 RUNTIME_FUNCTION_LIST(F) INLINE_OPTIMIZED_FUNCTION_LIST(F)
878 #define F(name, nargs, ressize) kInline##name,
879 INLINE_FUNCTION_LIST(F)
881 #define F(name, nargs, ressize) kInlineOptimized##name,
882 INLINE_OPTIMIZED_FUNCTION_LIST(F)
885 kFirstInlineFunction = kInlineIsSmi
888 enum IntrinsicType { RUNTIME, INLINE, INLINE_OPTIMIZED };
890 // Intrinsic function descriptor.
892 FunctionId function_id;
893 IntrinsicType intrinsic_type;
894 // The JS name of the function.
897 // The C++ (native) entry point. NULL if the function is inlined.
900 // The number of arguments expected. nargs is -1 if the function takes
901 // a variable number of arguments.
903 // Size of result. Most functions return a single pointer, size 1.
907 static const int kNotFound = -1;
909 // Add internalized strings for all the intrinsic function names to a
911 static void InitializeIntrinsicFunctionNames(Isolate* isolate,
912 Handle<NameDictionary> dict);
914 // Get the intrinsic function with the given name, which must be internalized.
915 static const Function* FunctionForName(Handle<String> name);
917 // Get the intrinsic function with the given FunctionId.
918 static const Function* FunctionForId(FunctionId id);
920 // Get the intrinsic function with the given function entry address.
921 static const Function* FunctionForEntry(Address ref);
923 // TODO(1240886): Some of the following methods are *not* handle safe, but
924 // accept handle arguments. This seems fragile.
926 // Support getting the characters in a string using [] notation as
927 // in Firefox/SpiderMonkey, Safari and Opera.
928 MUST_USE_RESULT static MaybeHandle<Object> GetElementOrCharAt(
929 Isolate* isolate, Handle<Object> object, uint32_t index);
931 MUST_USE_RESULT static MaybeHandle<Object> SetObjectProperty(
932 Isolate* isolate, Handle<Object> object, Handle<Object> key,
933 Handle<Object> value, StrictMode strict_mode);
935 MUST_USE_RESULT static MaybeHandle<Object> DefineObjectProperty(
936 Handle<JSObject> object, Handle<Object> key, Handle<Object> value,
937 PropertyAttributes attr);
939 MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
940 Isolate* isolate, Handle<Object> object, Handle<Object> key);
942 MUST_USE_RESULT static MaybeHandle<Name> ToName(Isolate* isolate,
945 static void SetupArrayBuffer(Isolate* isolate,
946 Handle<JSArrayBuffer> array_buffer,
947 bool is_external, void* data,
948 size_t allocated_length);
950 static bool SetupArrayBufferAllocatingData(Isolate* isolate,
951 Handle<JSArrayBuffer> array_buffer,
952 size_t allocated_length,
953 bool initialize = true);
955 static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
957 static void FreeArrayBuffer(Isolate* isolate,
958 JSArrayBuffer* phantom_array_buffer);
960 static int FindIndexedNonNativeFrame(JavaScriptFrameIterator* it, int index);
963 // arrayIds below should be synchromized with typedarray.js natives.
970 ARRAY_ID_FLOAT32 = 7,
971 ARRAY_ID_FLOAT64 = 8,
972 ARRAY_ID_UINT8_CLAMPED = 9,
973 ARRAY_ID_FLOAT32x4 = 10,
974 ARRAY_ID_FLOAT64x2 = 11,
975 ARRAY_ID_INT32x4 = 12,
976 ARRAY_ID_FIRST = ARRAY_ID_UINT8,
977 ARRAY_ID_LAST = ARRAY_ID_INT32x4
980 static void ArrayIdToTypeAndSize(int array_id, ExternalArrayType* type,
981 ElementsKind* external_elements_kind,
982 ElementsKind* fixed_elements_kind,
983 size_t* element_size);
985 // Used in runtime.cc and hydrogen's VisitArrayLiteral.
986 MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
987 Isolate* isolate, Handle<FixedArray> literals,
988 Handle<FixedArray> elements);
992 std::ostream& operator<<(std::ostream&, Runtime::FunctionId);
994 //---------------------------------------------------------------------------
995 // Constants used by interface to runtime functions.
997 class AllocateDoubleAlignFlag : public BitField<bool, 0, 1> {};
998 class AllocateTargetSpace : public BitField<AllocationSpace, 1, 3> {};
1000 class DeclareGlobalsEvalFlag : public BitField<bool, 0, 1> {};
1001 class DeclareGlobalsNativeFlag : public BitField<bool, 1, 1> {};
1002 class DeclareGlobalsStrictMode : public BitField<StrictMode, 2, 1> {};
1004 } // namespace internal
1007 #endif // V8_RUNTIME_RUNTIME_H_