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(SetPrototype, 2, 1) \
49 F(InternalSetPrototype, 2, 1) \
50 F(IsInPrototypeChain, 2, 1) \
52 F(GetOwnProperty, 2, 1) \
54 F(IsExtensible, 1, 1) \
55 F(PreventExtensions, 1, 1) \
58 F(CheckIsBootstrapping, 0, 1) \
60 F(Call, -1 /* >= 2 */, 1) \
62 F(GetFunctionDelegate, 1, 1) \
63 F(GetConstructorDelegate, 1, 1) \
64 F(DeoptimizeFunction, 1, 1) \
65 F(ClearFunctionTypeFeedback, 1, 1) \
66 F(RunningInSimulator, 0, 1) \
67 F(IsConcurrentRecompilationSupported, 0, 1) \
68 F(OptimizeFunctionOnNextCall, -1, 1) \
69 F(OptimizeOsr, 0, 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(IsConstructor, 1, 1) \
78 F(SetInlineBuiltinFlag, 1, 1) \
79 F(StoreArrayLiteralElement, 5, 1) \
80 F(DebugPrepareStepInIfStepping, 1, 1) \
81 F(DebugPushPromise, 1, 1) \
82 F(DebugPopPromise, 0, 1) \
83 F(DebugPromiseEvent, 1, 1) \
84 F(DebugAsyncTaskEvent, 1, 1) \
85 F(PromiseRejectEvent, 3, 1) \
86 F(PromiseRevokeReject, 1, 1) \
87 F(PromiseHasHandlerSymbol, 0, 1) \
88 F(FlattenString, 1, 1) \
89 F(LoadMutableDouble, 2, 1) \
90 F(TryMigrateInstance, 1, 1) \
91 F(NotifyContextDisposed, 0, 1) \
93 /* Array join support */ \
94 F(PushIfAbsent, 2, 1) \
95 F(ArrayConcat, 1, 1) \
101 F(StringToNumber, 1, 1) \
102 F(StringParseInt, 2, 1) \
103 F(StringParseFloat, 1, 1) \
104 F(StringToLowerCase, 1, 1) \
105 F(StringToUpperCase, 1, 1) \
106 F(StringSplit, 3, 1) \
107 F(CharFromCode, 1, 1) \
109 F(URIUnescape, 1, 1) \
111 F(NumberToInteger, 1, 1) \
112 F(NumberToIntegerMapMinusZero, 1, 1) \
113 F(NumberToJSUint32, 1, 1) \
114 F(NumberToJSInt32, 1, 1) \
116 /* Arithmetic operations */ \
122 F(NumberUnaryMinus, 1, 1) \
123 F(NumberImul, 2, 1) \
125 F(StringBuilderConcat, 3, 1) \
126 F(StringBuilderJoin, 3, 1) \
127 F(SparseJoinWithSeparator, 3, 1) \
129 /* Bit operations */ \
139 F(NumberEquals, 2, 1) \
140 F(StringEquals, 2, 1) \
142 F(NumberCompare, 3, 1) \
143 F(SmiLexicographicCompare, 2, 1) \
149 F(MathFloorRT, 1, 1) \
152 F(RoundNumber, 1, 1) \
153 F(MathFround, 1, 1) \
156 /* Regular expressions */ \
157 F(RegExpInitializeAndCompile, 3, 1) \
158 F(RegExpExecMultiple, 4, 1) \
162 F(BasicJSONStringify, 1, 1) \
163 F(QuoteJSONString, 1, 1) \
166 F(StringIndexOf, 3, 1) \
167 F(StringLastIndexOf, 3, 1) \
168 F(StringLocaleCompare, 2, 1) \
169 F(StringReplaceGlobalRegExpWithString, 4, 1) \
170 F(StringReplaceOneCharWithString, 3, 1) \
171 F(StringMatch, 3, 1) \
172 F(StringTrim, 3, 1) \
173 F(StringToArray, 2, 1) \
174 F(NewStringWrapper, 1, 1) \
176 F(TruncateString, 2, 1) \
179 F(NumberToRadixString, 2, 1) \
180 F(NumberToFixed, 2, 1) \
181 F(NumberToExponential, 2, 1) \
182 F(NumberToPrecision, 2, 1) \
183 F(IsValidSmi, 1, 1) \
185 /* Classes support */ \
187 F(HomeObjectSymbol, 0, 1) \
188 F(DefineClass, 6, 1) \
189 F(DefineClassMethod, 3, 1) \
190 F(ClassGetSourceCode, 1, 1) \
191 F(LoadFromSuper, 3, 1) \
192 F(LoadKeyedFromSuper, 3, 1) \
193 F(ThrowConstructorNonCallableError, 0, 1) \
194 F(ThrowArrayNotSubclassableError, 0, 1) \
195 F(ThrowNonMethodError, 0, 1) \
196 F(ThrowUnsupportedSuperError, 0, 1) \
197 F(HandleStepInForDerivedConstructors, 1, 1) \
198 F(StoreToSuper_Strict, 4, 1) \
199 F(StoreToSuper_Sloppy, 4, 1) \
200 F(StoreKeyedToSuper_Strict, 4, 1) \
201 F(StoreKeyedToSuper_Sloppy, 4, 1)
204 #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
206 F(FunctionSetInstanceClassName, 2, 1) \
207 F(FunctionSetLength, 2, 1) \
208 F(FunctionSetPrototype, 2, 1) \
209 F(FunctionGetName, 1, 1) \
210 F(FunctionSetName, 2, 1) \
211 F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
212 F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
213 F(FunctionIsGenerator, 1, 1) \
214 F(FunctionIsArrow, 1, 1) \
215 F(FunctionIsConciseMethod, 1, 1) \
216 F(FunctionBindArguments, 4, 1) \
217 F(BoundFunctionGetBindings, 1, 1) \
218 F(FunctionRemovePrototype, 1, 1) \
219 F(FunctionGetSourceCode, 1, 1) \
220 F(FunctionGetScript, 1, 1) \
221 F(FunctionGetScriptSourcePosition, 1, 1) \
222 F(FunctionGetPositionForOffset, 2, 1) \
223 F(FunctionIsAPIFunction, 1, 1) \
224 F(FunctionIsBuiltin, 1, 1) \
226 F(CollectStackTrace, 2, 1) \
227 F(GetV8Version, 0, 1) \
228 F(GeneratorGetFunction, 1, 1) \
229 F(GeneratorGetContext, 1, 1) \
230 F(GeneratorGetReceiver, 1, 1) \
231 F(GeneratorGetContinuation, 1, 1) \
232 F(GeneratorGetSourcePosition, 1, 1) \
236 F(DisableAccessChecks, 1, 1) \
237 F(EnableAccessChecks, 1, 1) \
240 F(DateCurrentTime, 0, 1) \
241 F(DateParseString, 2, 1) \
242 F(DateLocalTimezone, 1, 1) \
244 F(DateMakeDay, 2, 1) \
245 F(DateSetValue, 3, 1) \
246 F(DateCacheVersion, 0, 1) \
249 F(CompileString, 3, 1) \
252 F(GlobalProxy, 1, 1) \
254 F(AddNamedProperty, 4, 1) \
255 F(SetProperty, 4, 1) \
256 F(AddElement, 4, 1) \
257 F(DefineDataPropertyUnchecked, 4, 1) \
258 F(DefineAccessorPropertyUnchecked, 5, 1) \
259 F(GetDataProperty, 2, 1) \
260 F(DefineGetterPropertyUnchecked, 4, 1) \
261 F(DefineSetterPropertyUnchecked, 4, 1) \
264 F(RemoveArrayHoles, 2, 1) \
265 F(GetArrayKeys, 2, 1) \
266 F(MoveArrayContents, 2, 1) \
267 F(EstimateNumberOfElements, 1, 1) \
268 F(NormalizeElements, 1, 1) \
269 F(HasComplexElements, 1, 1) \
271 /* Getters and Setters */ \
272 F(LookupAccessor, 3, 1) \
275 F(ObjectSeal, 1, 1) \
276 F(ObjectFreeze, 1, 1) \
278 /* Harmony modules */ \
279 F(IsJSModule, 1, 1) \
281 /* Harmony symbols */ \
282 F(CreateSymbol, 1, 1) \
283 F(CreatePrivateSymbol, 1, 1) \
284 F(CreateGlobalPrivateOwnSymbol, 1, 1) \
285 F(CreatePrivateOwnSymbol, 1, 1) \
286 F(NewSymbolWrapper, 1, 1) \
287 F(SymbolDescription, 1, 1) \
288 F(SymbolRegistry, 0, 1) \
289 F(SymbolIsPrivate, 1, 1) \
291 /* Harmony proxies */ \
292 F(CreateJSProxy, 2, 1) \
293 F(CreateJSFunctionProxy, 4, 1) \
294 F(IsJSFunctionProxy, 1, 1) \
295 F(GetHandler, 1, 1) \
296 F(GetCallTrap, 1, 1) \
297 F(GetConstructTrap, 1, 1) \
300 /* ES6 collection iterators */ \
301 F(SetIteratorInitialize, 3, 1) \
302 F(SetIteratorClone, 1, 1) \
303 F(SetIteratorNext, 2, 1) \
304 F(SetIteratorDetails, 1, 1) \
305 F(MapIteratorInitialize, 3, 1) \
306 F(MapIteratorClone, 1, 1) \
307 F(MapIteratorNext, 2, 1) \
308 F(MapIteratorDetails, 1, 1) \
310 /* Harmony weak maps and sets */ \
311 F(WeakCollectionInitialize, 1, 1) \
312 F(WeakCollectionGet, 2, 1) \
313 F(WeakCollectionHas, 2, 1) \
314 F(WeakCollectionDelete, 2, 1) \
315 F(WeakCollectionSet, 3, 1) \
317 F(GetWeakMapEntries, 2, 1) \
318 F(GetWeakSetValues, 2, 1) \
320 /* Harmony events */ \
321 F(EnqueueMicrotask, 1, 1) \
322 F(RunMicrotasks, 0, 1) \
324 /* Harmony observe */ \
325 F(IsObserved, 1, 1) \
326 F(SetIsObserved, 1, 1) \
327 F(GetObservationState, 0, 1) \
328 F(ObservationWeakMapCreate, 0, 1) \
329 F(ObserverObjectAndRecordHaveSameOrigin, 3, 1) \
330 F(ObjectWasCreatedInCurrentOrigin, 1, 1) \
331 F(GetObjectContextObjectObserve, 1, 1) \
332 F(GetObjectContextObjectGetNotifier, 1, 1) \
333 F(GetObjectContextNotifierPerformChange, 1, 1) \
334 F(DeliverObservationChangeRecords, 2, 1) \
336 /* Harmony typed arrays */ \
337 F(ArrayBufferInitialize, 2, 1) \
338 F(ArrayBufferSliceImpl, 3, 1) \
339 F(ArrayBufferIsView, 1, 1) \
340 F(ArrayBufferNeuter, 1, 1) \
342 F(IsTypedArray, 1, 1) \
343 F(TypedArrayInitializeFromArrayLike, 4, 1) \
344 F(TypedArrayGetBuffer, 1, 1) \
345 F(TypedArraySetFastCases, 3, 1) \
347 F(DataViewGetBuffer, 1, 1) \
348 F(DataViewGetInt8, 3, 1) \
349 F(DataViewGetUint8, 3, 1) \
350 F(DataViewGetInt16, 3, 1) \
351 F(DataViewGetUint16, 3, 1) \
352 F(DataViewGetInt32, 3, 1) \
353 F(DataViewGetUint32, 3, 1) \
354 F(DataViewGetFloat32, 3, 1) \
355 F(DataViewGetFloat64, 3, 1) \
357 F(DataViewSetInt8, 4, 1) \
358 F(DataViewSetUint8, 4, 1) \
359 F(DataViewSetInt16, 4, 1) \
360 F(DataViewSetUint16, 4, 1) \
361 F(DataViewSetInt32, 4, 1) \
362 F(DataViewSetUint32, 4, 1) \
363 F(DataViewSetFloat32, 4, 1) \
364 F(DataViewSetFloat64, 4, 1) \
367 F(NewObjectFromBound, 1, 1) \
369 /* Declarations and initialization */ \
370 F(InitializeVarGlobal, 3, 1) \
371 F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
374 F(DebugPrint, 1, 1) \
375 F(GlobalPrint, 1, 1) \
376 F(DebugTrace, 0, 1) \
377 F(TraceEnter, 0, 1) \
381 F(NativeScriptsCount, 0, 1) \
382 F(RenderCallSite, 0, 1) \
386 /* Message objects */ \
387 F(MessageGetStartPosition, 1, 1) \
388 F(MessageGetScript, 1, 1) \
390 /* Pseudo functions - handled as macros by parser */ \
393 /* expose boolean functions from objects-inl.h */ \
394 F(HasFastSmiElements, 1, 1) \
395 F(HasFastSmiOrObjectElements, 1, 1) \
396 F(HasFastObjectElements, 1, 1) \
397 F(HasFastDoubleElements, 1, 1) \
398 F(HasFastHoleyElements, 1, 1) \
399 F(HasDictionaryElements, 1, 1) \
400 F(HasSloppyArgumentsElements, 1, 1) \
401 F(HasExternalUint8ClampedElements, 1, 1) \
402 F(HasExternalArrayElements, 1, 1) \
403 F(HasExternalInt8Elements, 1, 1) \
404 F(HasExternalUint8Elements, 1, 1) \
405 F(HasExternalInt16Elements, 1, 1) \
406 F(HasExternalUint16Elements, 1, 1) \
407 F(HasExternalInt32Elements, 1, 1) \
408 F(HasExternalUint32Elements, 1, 1) \
409 F(HasExternalFloat32Elements, 1, 1) \
410 F(HasExternalFloat64Elements, 1, 1) \
411 F(HasFixedUint8ClampedElements, 1, 1) \
412 F(HasFixedInt8Elements, 1, 1) \
413 F(HasFixedUint8Elements, 1, 1) \
414 F(HasFixedInt16Elements, 1, 1) \
415 F(HasFixedUint16Elements, 1, 1) \
416 F(HasFixedInt32Elements, 1, 1) \
417 F(HasFixedUint32Elements, 1, 1) \
418 F(HasFixedFloat32Elements, 1, 1) \
419 F(HasFixedFloat64Elements, 1, 1) \
420 F(HasFastProperties, 1, 1) \
421 F(TransitionElementsKind, 2, 1) \
422 F(HaveSameMap, 2, 1) \
423 F(IsJSGlobalProxy, 1, 1) \
424 F(ForInCacheArrayLength, 2, 1) /* TODO(turbofan): Only temporary */
427 #define RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
428 /* String and Regexp */ \
429 F(NumberToStringRT, 1, 1) \
430 F(RegExpConstructResult, 3, 1) \
431 F(RegExpExecRT, 4, 1) \
434 F(InternalizeString, 1, 1) \
435 F(StringCompare, 2, 1) \
436 F(StringCharCodeAtRT, 2, 1) \
437 F(GetFromCache, 2, 1) \
440 F(CompileLazy, 1, 1) \
441 F(CompileOptimized, 2, 1) \
442 F(TryInstallOptimizedCode, 1, 1) \
443 F(NotifyDeoptimized, 1, 1) \
444 F(NotifyStubFailure, 0, 1) \
447 F(AllocateInNewSpace, 1, 1) \
448 F(AllocateInTargetSpace, 2, 1) \
449 F(AllocateHeapNumber, 0, 1) \
450 F(NumberToSmi, 1, 1) \
451 F(NumberToStringSkipCache, 1, 1) \
453 F(NewArguments, 1, 1) /* TODO(turbofan): Only temporary */ \
454 F(NewSloppyArguments, 3, 1) \
455 F(NewStrictArguments, 3, 1) \
456 F(NewRestParam, 3, 1) \
457 F(NewRestParamSlow, 1, 1) \
459 /* Harmony generators */ \
460 F(CreateJSGeneratorObject, 0, 1) \
461 F(SuspendJSGeneratorObject, 1, 1) \
462 F(ResumeJSGeneratorObject, 3, 1) \
463 F(GeneratorClose, 1, 1) \
466 F(ArrayConstructor, -1, 1) \
467 F(ArrayConstructorWithSubclassing, -1, 1) \
468 F(InternalArrayConstructor, -1, 1) \
471 F(MaterializeRegExpLiteral, 4, 1) \
472 F(CreateObjectLiteral, 4, 1) \
473 F(CreateArrayLiteral, 4, 1) \
474 F(CreateArrayLiteralStubBailout, 3, 1) \
477 F(NewClosure, 3, 1) \
478 F(NewClosureFromStubFailure, 1, 1) \
480 F(NewObjectWithAllocationSite, 3, 1) \
481 F(FinalizeInstanceSize, 1, 1) \
484 F(ThrowReferenceError, 1, 1) \
485 F(ThrowNotDateError, 0, 1) \
486 F(ThrowConstAssignError, 0, 1) \
487 F(StackGuard, 0, 1) \
489 F(PromoteScheduledException, 0, 1) \
492 F(NewScriptContext, 2, 1) \
493 F(NewFunctionContext, 1, 1) \
494 F(PushWithContext, 2, 1) \
495 F(PushCatchContext, 3, 1) \
496 F(PushBlockContext, 2, 1) \
497 F(PushModuleContext, 2, 1) \
498 F(DeleteLookupSlot, 2, 1) \
499 F(StoreLookupSlot, 4, 1) \
501 /* Declarations and initialization */ \
502 F(DeclareGlobals, 3, 1) \
503 F(DeclareModules, 1, 1) \
504 F(DeclareLookupSlot, 4, 1) \
505 F(InitializeConstGlobal, 2, 1) \
506 F(InitializeLegacyConstLookupSlot, 3, 1) \
509 F(MathPowSlow, 2, 1) \
513 #define RUNTIME_FUNCTION_LIST_RETURN_PAIR(F) \
514 F(LoadLookupSlot, 2, 2) \
515 F(LoadLookupSlotNoReferenceError, 2, 2) \
516 F(ResolvePossiblyDirectEval, 6, 2) \
517 F(ForInInit, 2, 2) /* TODO(turbofan): Only temporary */ \
518 F(ForInNext, 4, 2) /* TODO(turbofan): Only temporary */
521 #define RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
522 /* Debugger support*/ \
523 F(DebugBreak, 0, 1) \
524 F(SetDebugEventListener, 2, 1) \
526 F(DebugGetPropertyDetails, 2, 1) \
527 F(DebugGetProperty, 2, 1) \
528 F(DebugPropertyTypeFromDetails, 1, 1) \
529 F(DebugPropertyAttributesFromDetails, 1, 1) \
530 F(DebugPropertyIndexFromDetails, 1, 1) \
531 F(DebugNamedInterceptorPropertyValue, 2, 1) \
532 F(DebugIndexedInterceptorElementValue, 2, 1) \
533 F(CheckExecutionState, 1, 1) \
534 F(GetFrameCount, 1, 1) \
535 F(GetFrameDetails, 2, 1) \
536 F(GetScopeCount, 2, 1) \
537 F(GetStepInPositions, 2, 1) \
538 F(GetScopeDetails, 4, 1) \
539 F(GetAllScopesDetails, 4, 1) \
540 F(GetFunctionScopeCount, 1, 1) \
541 F(GetFunctionScopeDetails, 2, 1) \
542 F(SetScopeVariableValue, 6, 1) \
543 F(DebugPrintScopes, 0, 1) \
544 F(GetThreadCount, 1, 1) \
545 F(GetThreadDetails, 2, 1) \
546 F(SetDisableBreak, 1, 1) \
547 F(GetBreakLocations, 2, 1) \
548 F(SetFunctionBreakPoint, 3, 1) \
549 F(SetScriptBreakPoint, 4, 1) \
550 F(ClearBreakPoint, 1, 1) \
551 F(ChangeBreakOnException, 2, 1) \
552 F(IsBreakOnException, 1, 1) \
553 F(PrepareStep, 4, 1) \
554 F(ClearStepping, 0, 1) \
555 F(DebugEvaluate, 6, 1) \
556 F(DebugEvaluateGlobal, 4, 1) \
557 F(DebugGetLoadedScripts, 0, 1) \
558 F(DebugReferencedBy, 3, 1) \
559 F(DebugConstructedBy, 2, 1) \
560 F(DebugGetPrototype, 1, 1) \
561 F(DebugSetScriptSource, 2, 1) \
562 F(DebugCallbackSupportsStepping, 1, 1) \
563 F(SystemBreak, 0, 1) \
564 F(DebugDisassembleFunction, 1, 1) \
565 F(DebugDisassembleConstructor, 1, 1) \
566 F(FunctionGetInferredName, 1, 1) \
567 F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
568 F(LiveEditGatherCompileInfo, 2, 1) \
569 F(LiveEditReplaceScript, 3, 1) \
570 F(LiveEditReplaceFunctionCode, 2, 1) \
571 F(LiveEditFunctionSourceUpdated, 1, 1) \
572 F(LiveEditFunctionSetScript, 2, 1) \
573 F(LiveEditReplaceRefToNestedFunction, 3, 1) \
574 F(LiveEditPatchFunctionPositions, 2, 1) \
575 F(LiveEditCheckAndDropActivations, 2, 1) \
576 F(LiveEditCompareStrings, 2, 1) \
577 F(LiveEditRestartFrame, 2, 1) \
578 F(GetFunctionCodePositionFromSource, 2, 1) \
579 F(ExecuteInDebugContext, 2, 1) \
580 F(GetDebugContext, 0, 1) \
582 F(CollectGarbage, 1, 1) \
583 F(GetHeapUsage, 0, 1)
586 #ifdef V8_I18N_SUPPORT
587 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
589 /* Standalone, helper methods. */ \
590 F(CanonicalizeLanguageTag, 1, 1) \
591 F(AvailableLocalesOf, 1, 1) \
592 F(GetDefaultICULocale, 0, 1) \
593 F(GetLanguageTagVariants, 1, 1) \
594 F(IsInitializedIntlObject, 1, 1) \
595 F(IsInitializedIntlObjectOfType, 2, 1) \
596 F(MarkAsInitializedIntlObjectOfType, 3, 1) \
597 F(GetImplFromInitializedIntlObject, 1, 1) \
599 /* Date format and parse. */ \
600 F(CreateDateTimeFormat, 3, 1) \
601 F(InternalDateFormat, 2, 1) \
602 F(InternalDateParse, 2, 1) \
604 /* Number format and parse. */ \
605 F(CreateNumberFormat, 3, 1) \
606 F(InternalNumberFormat, 2, 1) \
607 F(InternalNumberParse, 2, 1) \
610 F(CreateCollator, 3, 1) \
611 F(InternalCompare, 3, 1) \
613 /* String.prototype.normalize. */ \
614 F(StringNormalize, 2, 1) \
616 /* Break iterator. */ \
617 F(CreateBreakIterator, 3, 1) \
618 F(BreakIteratorAdoptText, 2, 1) \
619 F(BreakIteratorFirst, 1, 1) \
620 F(BreakIteratorNext, 1, 1) \
621 F(BreakIteratorCurrent, 1, 1) \
622 F(BreakIteratorBreakType, 1, 1)
625 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
629 // ----------------------------------------------------------------------------
630 // RUNTIME_FUNCTION_LIST defines all runtime functions accessed
631 // either directly by id (via the code generator), or indirectly
632 // via a native call by name (from within JS code).
633 // Entries have the form F(name, number of arguments, number of return values).
635 #define RUNTIME_FUNCTION_LIST_RETURN_OBJECT(F) \
636 RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
637 RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
638 RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
639 RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
640 RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
643 #define RUNTIME_FUNCTION_LIST(F) \
644 RUNTIME_FUNCTION_LIST_RETURN_OBJECT(F) \
645 RUNTIME_FUNCTION_LIST_RETURN_PAIR(F)
647 // ----------------------------------------------------------------------------
648 // INLINE_FUNCTION_LIST defines all inlined functions accessed
649 // with a native call of the form %_name from within JS code.
650 // Entries have the form F(name, number of arguments, number of return values).
651 #define INLINE_FUNCTION_LIST(F) \
653 F(IsNonNegativeSmi, 1, 1) \
657 F(IsConstructCall, 0, 1) \
658 F(CallFunction, -1 /* receiver + n args + function */, 1) \
659 F(DefaultConstructorCallSuper, 0, 1) \
660 F(ArgumentsLength, 0, 1) \
663 F(SetValueOf, 2, 1) \
664 F(DateField, 2 /* date object, field index */, 1) \
665 F(StringCharFromCode, 1, 1) \
666 F(StringCharAt, 2, 1) \
667 F(OneByteSeqStringSetChar, 3, 1) \
668 F(TwoByteSeqStringSetChar, 3, 1) \
669 F(ObjectEquals, 2, 1) \
671 F(IsFunction, 1, 1) \
672 F(IsUndetectableObject, 1, 1) \
673 F(IsSpecObject, 1, 1) \
674 F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
676 F(IsMinusZero, 1, 1) \
677 F(HasCachedArrayIndex, 1, 1) \
678 F(GetCachedArrayIndex, 1, 1) \
679 F(FastOneByteArrayJoin, 2, 1) \
680 F(GeneratorNext, 2, 1) \
681 F(GeneratorThrow, 2, 1) \
682 F(DebugBreakInOptimizedCode, 0, 1) \
684 F(StringCharCodeAt, 2, 1) \
687 F(StringCompare, 2, 1) \
688 F(RegExpExec, 4, 1) \
689 F(RegExpConstructResult, 3, 1) \
690 F(GetFromCache, 2, 1) \
691 F(NumberToString, 1, 1) \
692 F(DebugIsActive, 0, 1)
695 // ----------------------------------------------------------------------------
696 // INLINE_OPTIMIZED_FUNCTION_LIST defines all inlined functions accessed
697 // with a native call of the form %_name from within JS code that also have
698 // a corresponding runtime function, that is called from non-optimized code.
699 // For the benefit of (fuzz) tests, the runtime version can also be called
700 // directly as %name (i.e. without the leading underscore).
701 // Entries have the form F(name, number of arguments, number of return values).
702 #define INLINE_OPTIMIZED_FUNCTION_LIST(F) \
704 F(TypedArrayInitialize, 5, 1) \
705 F(DataViewInitialize, 4, 1) \
707 F(TypedArrayMaxSizeInHeap, 0, 1) \
708 F(ArrayBufferViewGetByteLength, 1, 1) \
709 F(ArrayBufferViewGetByteOffset, 1, 1) \
710 F(TypedArrayGetLength, 1, 1) \
712 F(ArrayBufferGetByteLength, 1, 1) \
714 F(ConstructDouble, 2, 1) \
717 F(MathSqrtRT, 1, 1) \
719 /* ES6 Collections */ \
723 F(MapGetSize, 1, 1) \
725 F(MapInitialize, 1, 1) \
730 F(SetGetSize, 1, 1) \
732 F(SetInitialize, 1, 1) \
734 F(HasFastPackedElements, 1, 1) \
735 F(GetPrototype, 1, 1)
738 //---------------------------------------------------------------------------
739 // Runtime provides access to all C++ runtime functions.
743 unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
744 return &to_upper_mapping_;
746 unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
747 return &to_lower_mapping_;
752 unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
753 unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
755 friend class Isolate;
756 friend class Runtime;
758 DISALLOW_COPY_AND_ASSIGN(RuntimeState);
762 class JavaScriptFrameIterator; // Forward declaration.
765 class Runtime : public AllStatic {
768 #define F(name, nargs, ressize) k##name,
769 RUNTIME_FUNCTION_LIST(F) INLINE_OPTIMIZED_FUNCTION_LIST(F)
771 #define F(name, nargs, ressize) kInline##name,
772 INLINE_FUNCTION_LIST(F)
774 #define F(name, nargs, ressize) kInlineOptimized##name,
775 INLINE_OPTIMIZED_FUNCTION_LIST(F)
778 kFirstInlineFunction = kInlineIsSmi
781 enum IntrinsicType { RUNTIME, INLINE, INLINE_OPTIMIZED };
783 // Intrinsic function descriptor.
785 FunctionId function_id;
786 IntrinsicType intrinsic_type;
787 // The JS name of the function.
790 // The C++ (native) entry point. NULL if the function is inlined.
793 // The number of arguments expected. nargs is -1 if the function takes
794 // a variable number of arguments.
796 // Size of result. Most functions return a single pointer, size 1.
800 static const int kNotFound = -1;
802 // Add internalized strings for all the intrinsic function names to a
804 static void InitializeIntrinsicFunctionNames(Isolate* isolate,
805 Handle<NameDictionary> dict);
807 // Get the intrinsic function with the given name, which must be internalized.
808 static const Function* FunctionForName(Handle<String> name);
810 // Get the intrinsic function with the given FunctionId.
811 static const Function* FunctionForId(FunctionId id);
813 // Get the intrinsic function with the given function entry address.
814 static const Function* FunctionForEntry(Address ref);
816 // TODO(1240886): Some of the following methods are *not* handle safe, but
817 // accept handle arguments. This seems fragile.
819 // Support getting the characters in a string using [] notation as
820 // in Firefox/SpiderMonkey, Safari and Opera.
821 MUST_USE_RESULT static MaybeHandle<Object> GetElementOrCharAt(
822 Isolate* isolate, Handle<Object> object, uint32_t index);
824 MUST_USE_RESULT static MaybeHandle<Object> SetObjectProperty(
825 Isolate* isolate, Handle<Object> object, Handle<Object> key,
826 Handle<Object> value, LanguageMode language_mode);
828 MUST_USE_RESULT static MaybeHandle<Object> DefineObjectProperty(
829 Handle<JSObject> object, Handle<Object> key, Handle<Object> value,
830 PropertyAttributes attr);
832 MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
833 Isolate* isolate, Handle<Object> object, Handle<Object> key);
835 MUST_USE_RESULT static MaybeHandle<Object> GetPrototype(
836 Isolate* isolate, Handle<Object> object);
838 MUST_USE_RESULT static MaybeHandle<Name> ToName(Isolate* isolate,
841 static void SetupArrayBuffer(Isolate* isolate,
842 Handle<JSArrayBuffer> array_buffer,
843 bool is_external, void* data,
844 size_t allocated_length);
846 static bool SetupArrayBufferAllocatingData(Isolate* isolate,
847 Handle<JSArrayBuffer> array_buffer,
848 size_t allocated_length,
849 bool initialize = true);
851 static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
853 static void FreeArrayBuffer(Isolate* isolate,
854 JSArrayBuffer* phantom_array_buffer);
856 static int FindIndexedNonNativeFrame(JavaScriptFrameIterator* it, int index);
859 // arrayIds below should be synchromized with typedarray.js natives.
866 ARRAY_ID_FLOAT32 = 7,
867 ARRAY_ID_FLOAT64 = 8,
868 ARRAY_ID_UINT8_CLAMPED = 9,
869 ARRAY_ID_FIRST = ARRAY_ID_UINT8,
870 ARRAY_ID_LAST = ARRAY_ID_UINT8_CLAMPED
873 static void ArrayIdToTypeAndSize(int array_id, ExternalArrayType* type,
874 ElementsKind* external_elements_kind,
875 ElementsKind* fixed_elements_kind,
876 size_t* element_size);
878 // Used in runtime.cc and hydrogen's VisitArrayLiteral.
879 MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
880 Isolate* isolate, Handle<FixedArray> literals,
881 Handle<FixedArray> elements);
883 static void WeakCollectionInitialize(
884 Isolate* isolate, Handle<JSWeakCollection> weak_collection);
885 static void WeakCollectionSet(Handle<JSWeakCollection> weak_collection,
886 Handle<Object> key, Handle<Object> value);
887 static bool WeakCollectionDelete(Handle<JSWeakCollection> weak_collection,
892 std::ostream& operator<<(std::ostream&, Runtime::FunctionId);
894 //---------------------------------------------------------------------------
895 // Constants used by interface to runtime functions.
897 class AllocateDoubleAlignFlag : public BitField<bool, 0, 1> {};
898 class AllocateTargetSpace : public BitField<AllocationSpace, 1, 3> {};
900 class DeclareGlobalsEvalFlag : public BitField<bool, 0, 1> {};
901 class DeclareGlobalsNativeFlag : public BitField<bool, 1, 1> {};
902 STATIC_ASSERT(LANGUAGE_END == 3);
903 class DeclareGlobalsLanguageMode : public BitField<LanguageMode, 2, 2> {};
905 } // namespace internal
908 #endif // V8_RUNTIME_RUNTIME_H_