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 // WARNING: RUNTIME_FUNCTION_LIST_ALWAYS_* is a very large macro that caused
19 // MSVC Intellisense to crash. It was broken into two macros to work around
20 // this problem. Please avoid large recursive macros whenever possible.
21 #define RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
22 /* Property access */ \
23 F(GetProperty, 2, 1) \
24 F(KeyedGetProperty, 2, 1) \
25 F(DeleteProperty, 3, 1) \
26 F(HasOwnProperty, 2, 1) \
27 F(HasProperty, 2, 1) \
29 F(IsPropertyEnumerable, 2, 1) \
30 F(GetPropertyNames, 1, 1) \
31 F(GetPropertyNamesFast, 1, 1) \
32 F(GetOwnPropertyNames, 2, 1) \
33 F(GetOwnElementNames, 1, 1) \
34 F(GetInterceptorInfo, 1, 1) \
35 F(GetNamedInterceptorPropertyNames, 1, 1) \
36 F(GetIndexedInterceptorElementNames, 1, 1) \
37 F(GetArgumentsProperty, 1, 1) \
38 F(ToFastProperties, 1, 1) \
39 F(FinishArrayPrototypeSetup, 1, 1) \
40 F(SpecialArrayFunctions, 0, 1) \
41 F(IsSloppyModeFunction, 1, 1) \
42 F(GetDefaultReceiver, 1, 1) \
44 F(SetPrototype, 2, 1) \
45 F(InternalSetPrototype, 2, 1) \
46 F(IsInPrototypeChain, 2, 1) \
48 F(GetOwnProperty, 2, 1) \
50 F(IsExtensible, 1, 1) \
51 F(PreventExtensions, 1, 1) \
54 F(CheckIsBootstrapping, 0, 1) \
56 F(Call, -1 /* >= 2 */, 1) \
58 F(GetFunctionDelegate, 1, 1) \
59 F(GetConstructorDelegate, 1, 1) \
60 F(DeoptimizeFunction, 1, 1) \
61 F(DeoptimizeNow, 0, 1) \
62 F(ClearFunctionTypeFeedback, 1, 1) \
63 F(RunningInSimulator, 0, 1) \
64 F(IsConcurrentRecompilationSupported, 0, 1) \
65 F(OptimizeFunctionOnNextCall, -1, 1) \
66 F(OptimizeOsr, -1, 1) \
67 F(NeverOptimizeFunction, 1, 1) \
68 F(GetOptimizationStatus, -1, 1) \
69 F(GetOptimizationCount, 1, 1) \
70 F(UnblockConcurrentRecompilation, 0, 1) \
71 F(CompileForOnStackReplacement, 1, 1) \
72 F(SetAllocationTimeout, -1 /* 2 || 3 */, 1) \
73 F(SetNativeFlag, 1, 1) \
74 F(IsConstructor, 1, 1) \
75 F(SetInlineBuiltinFlag, 1, 1) \
76 F(StoreArrayLiteralElement, 5, 1) \
77 F(DebugPrepareStepInIfStepping, 1, 1) \
78 F(DebugPushPromise, 2, 1) \
79 F(DebugPopPromise, 0, 1) \
80 F(DebugPromiseEvent, 1, 1) \
81 F(DebugAsyncTaskEvent, 1, 1) \
82 F(PromiseRejectEvent, 3, 1) \
83 F(PromiseRevokeReject, 1, 1) \
84 F(PromiseHasHandlerSymbol, 0, 1) \
85 F(FlattenString, 1, 1) \
86 F(LoadMutableDouble, 2, 1) \
87 F(TryMigrateInstance, 1, 1) \
88 F(NotifyContextDisposed, 0, 1) \
89 F(ThrowIteratorResultNotAnObject, 1, 1) \
90 F(IncrementStatsCounter, 1, 1) \
92 /* Array join support */ \
93 F(PushIfAbsent, 2, 1) \
94 F(ArrayConcat, 1, 1) \
100 F(StringToNumber, 1, 1) \
101 F(StringParseInt, 2, 1) \
102 F(StringParseFloat, 1, 1) \
103 F(StringToLowerCase, 1, 1) \
104 F(StringToUpperCase, 1, 1) \
105 F(StringSplit, 3, 1) \
106 F(CharFromCode, 1, 1) \
108 F(URIUnescape, 1, 1) \
110 F(NumberToInteger, 1, 1) \
111 F(NumberToIntegerMapMinusZero, 1, 1) \
112 F(NumberToJSUint32, 1, 1) \
113 F(NumberToJSInt32, 1, 1) \
115 /* Arithmetic operations */ \
121 F(NumberUnaryMinus, 1, 1) \
122 F(NumberImul, 2, 1) \
124 F(StringBuilderConcat, 3, 1) \
125 F(StringBuilderJoin, 3, 1) \
126 F(SparseJoinWithSeparator, 3, 1) \
128 /* Bit operations */ \
138 F(NumberEquals, 2, 1) \
139 F(StringEquals, 2, 1) \
141 F(NumberCompare, 3, 1) \
142 F(SmiLexicographicCompare, 2, 1) \
150 F(RoundNumber, 1, 1) \
151 F(MathFround, 1, 1) \
154 /* Regular expressions */ \
155 F(RegExpInitializeAndCompile, 3, 1) \
156 F(RegExpExecMultiple, 4, 1) \
157 F(RegExpExecReThrow, 4, 1) \
161 F(BasicJSONStringify, 1, 1) \
162 F(QuoteJSONString, 1, 1) \
165 F(StringIndexOf, 3, 1) \
166 F(StringLastIndexOf, 3, 1) \
167 F(StringLocaleCompare, 2, 1) \
168 F(StringReplaceGlobalRegExpWithString, 4, 1) \
169 F(StringReplaceOneCharWithString, 3, 1) \
170 F(StringMatch, 3, 1) \
171 F(StringTrim, 3, 1) \
172 F(StringToArray, 2, 1) \
173 F(NewStringWrapper, 1, 1) \
175 F(NewConsString, 4, 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 */ \
186 F(ClassGetSourceCode, 1, 1) \
187 F(DefineClass, 6, 1) \
188 F(DefineClassMethod, 3, 1) \
189 F(HandleStepInForDerivedConstructors, 1, 1) \
190 F(HomeObjectSymbol, 0, 1) \
191 F(LoadFromSuper, 3, 1) \
192 F(LoadKeyedFromSuper, 3, 1) \
193 F(StoreKeyedToSuper_Sloppy, 4, 1) \
194 F(StoreKeyedToSuper_Strict, 4, 1) \
195 F(StoreToSuper_Sloppy, 4, 1) \
196 F(StoreToSuper_Strict, 4, 1) \
197 F(ThrowArrayNotSubclassableError, 0, 1) \
198 F(ThrowConstructorNonCallableError, 0, 1) \
199 F(ThrowIfStaticPrototype, 1, 1) \
200 F(ThrowNonMethodError, 0, 1) \
201 F(ThrowStaticPrototypeError, 0, 1) \
202 F(ThrowUnsupportedSuperError, 0, 1) \
206 #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
208 F(FunctionSetInstanceClassName, 2, 1) \
209 F(FunctionSetLength, 2, 1) \
210 F(FunctionSetPrototype, 2, 1) \
211 F(FunctionGetName, 1, 1) \
212 F(FunctionSetName, 2, 1) \
213 F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
214 F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
215 F(FunctionIsGenerator, 1, 1) \
216 F(FunctionIsArrow, 1, 1) \
217 F(FunctionIsConciseMethod, 1, 1) \
218 F(FunctionBindArguments, 4, 1) \
219 F(BoundFunctionGetBindings, 1, 1) \
220 F(FunctionRemovePrototype, 1, 1) \
221 F(FunctionGetSourceCode, 1, 1) \
222 F(FunctionGetScript, 1, 1) \
223 F(FunctionGetScriptSourcePosition, 1, 1) \
224 F(FunctionGetPositionForOffset, 2, 1) \
225 F(FunctionIsAPIFunction, 1, 1) \
226 F(FunctionIsBuiltin, 1, 1) \
228 F(CollectStackTrace, 2, 1) \
229 F(GetV8Version, 0, 1) \
230 F(GeneratorGetFunction, 1, 1) \
231 F(GeneratorGetContext, 1, 1) \
232 F(GeneratorGetReceiver, 1, 1) \
233 F(GeneratorGetContinuation, 1, 1) \
234 F(GeneratorGetSourcePosition, 1, 1) \
238 F(DisableAccessChecks, 1, 1) \
239 F(EnableAccessChecks, 1, 1) \
242 F(DateCurrentTime, 0, 1) \
243 F(DateParseString, 2, 1) \
244 F(DateLocalTimezone, 1, 1) \
246 F(DateMakeDay, 2, 1) \
247 F(DateSetValue, 3, 1) \
248 F(DateCacheVersion, 0, 1) \
251 F(CompileString, 3, 1) \
254 F(GlobalProxy, 1, 1) \
256 F(AddNamedProperty, 4, 1) \
257 F(SetProperty, 4, 1) \
258 F(AddElement, 4, 1) \
259 F(DefineDataPropertyUnchecked, 4, 1) \
260 F(DefineAccessorPropertyUnchecked, 5, 1) \
261 F(GetDataProperty, 2, 1) \
262 F(DefineGetterPropertyUnchecked, 4, 1) \
263 F(DefineSetterPropertyUnchecked, 4, 1) \
266 F(RemoveArrayHoles, 2, 1) \
267 F(GetArrayKeys, 2, 1) \
268 F(MoveArrayContents, 2, 1) \
269 F(EstimateNumberOfElements, 1, 1) \
270 F(NormalizeElements, 1, 1) \
271 F(HasComplexElements, 1, 1) \
273 /* Getters and Setters */ \
274 F(LookupAccessor, 3, 1) \
277 F(ObjectSeal, 1, 1) \
278 F(ObjectFreeze, 1, 1) \
280 /* Harmony modules */ \
281 F(IsJSModule, 1, 1) \
283 /* Harmony symbols */ \
284 F(CreateSymbol, 1, 1) \
285 F(CreatePrivateSymbol, 1, 1) \
286 F(CreateGlobalPrivateOwnSymbol, 1, 1) \
287 F(CreatePrivateOwnSymbol, 1, 1) \
288 F(NewSymbolWrapper, 1, 1) \
289 F(SymbolDescription, 1, 1) \
290 F(SymbolRegistry, 0, 1) \
291 F(SymbolIsPrivate, 1, 1) \
293 /* Harmony proxies */ \
294 F(CreateJSProxy, 2, 1) \
295 F(CreateJSFunctionProxy, 4, 1) \
296 F(IsJSFunctionProxy, 1, 1) \
297 F(GetHandler, 1, 1) \
298 F(GetCallTrap, 1, 1) \
299 F(GetConstructTrap, 1, 1) \
302 /* ES6 collection iterators */ \
303 F(SetIteratorInitialize, 3, 1) \
304 F(SetIteratorClone, 1, 1) \
305 F(SetIteratorNext, 2, 1) \
306 F(SetIteratorDetails, 1, 1) \
307 F(MapIteratorInitialize, 3, 1) \
308 F(MapIteratorClone, 1, 1) \
309 F(MapIteratorNext, 2, 1) \
310 F(MapIteratorDetails, 1, 1) \
312 /* Harmony weak maps and sets */ \
313 F(WeakCollectionInitialize, 1, 1) \
314 F(WeakCollectionGet, 2, 1) \
315 F(WeakCollectionHas, 2, 1) \
316 F(WeakCollectionDelete, 2, 1) \
317 F(WeakCollectionSet, 3, 1) \
319 F(GetWeakMapEntries, 2, 1) \
320 F(GetWeakSetValues, 2, 1) \
322 /* Harmony events */ \
323 F(EnqueueMicrotask, 1, 1) \
324 F(RunMicrotasks, 0, 1) \
326 /* Harmony observe */ \
327 F(IsObserved, 1, 1) \
328 F(SetIsObserved, 1, 1) \
329 F(GetObservationState, 0, 1) \
330 F(ObservationWeakMapCreate, 0, 1) \
331 F(ObserverObjectAndRecordHaveSameOrigin, 3, 1) \
332 F(ObjectWasCreatedInCurrentOrigin, 1, 1) \
333 F(GetObjectContextObjectObserve, 1, 1) \
334 F(GetObjectContextObjectGetNotifier, 1, 1) \
335 F(GetObjectContextNotifierPerformChange, 1, 1) \
336 F(DeliverObservationChangeRecords, 2, 1) \
338 /* Harmony typed arrays */ \
339 F(ArrayBufferInitialize, 2, 1) \
340 F(ArrayBufferSliceImpl, 3, 1) \
341 F(ArrayBufferIsView, 1, 1) \
342 F(ArrayBufferNeuter, 1, 1) \
344 F(IsTypedArray, 1, 1) \
345 F(TypedArrayInitializeFromArrayLike, 4, 1) \
346 F(TypedArrayGetBuffer, 1, 1) \
347 F(TypedArraySetFastCases, 3, 1) \
349 F(DataViewGetBuffer, 1, 1) \
350 F(DataViewGetInt8, 3, 1) \
351 F(DataViewGetUint8, 3, 1) \
352 F(DataViewGetInt16, 3, 1) \
353 F(DataViewGetUint16, 3, 1) \
354 F(DataViewGetInt32, 3, 1) \
355 F(DataViewGetUint32, 3, 1) \
356 F(DataViewGetFloat32, 3, 1) \
357 F(DataViewGetFloat64, 3, 1) \
359 F(DataViewSetInt8, 4, 1) \
360 F(DataViewSetUint8, 4, 1) \
361 F(DataViewSetInt16, 4, 1) \
362 F(DataViewSetUint16, 4, 1) \
363 F(DataViewSetInt32, 4, 1) \
364 F(DataViewSetUint32, 4, 1) \
365 F(DataViewSetFloat32, 4, 1) \
366 F(DataViewSetFloat64, 4, 1) \
369 F(NewObjectFromBound, 1, 1) \
371 /* Declarations and initialization */ \
372 F(InitializeVarGlobal, 3, 1) \
373 F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
376 F(DebugPrint, 1, 1) \
377 F(GlobalPrint, 1, 1) \
378 F(DebugTrace, 0, 1) \
379 F(TraceEnter, 0, 1) \
383 F(NativeScriptsCount, 0, 1) \
384 F(RenderCallSite, 0, 1) \
388 /* Message objects */ \
389 F(MessageGetStartPosition, 1, 1) \
390 F(MessageGetScript, 1, 1) \
392 /* Pseudo functions - handled as macros by parser */ \
395 /* expose boolean functions from objects-inl.h */ \
396 F(HasFastSmiElements, 1, 1) \
397 F(HasFastSmiOrObjectElements, 1, 1) \
398 F(HasFastObjectElements, 1, 1) \
399 F(HasFastDoubleElements, 1, 1) \
400 F(HasFastHoleyElements, 1, 1) \
401 F(HasDictionaryElements, 1, 1) \
402 F(HasSloppyArgumentsElements, 1, 1) \
403 F(HasExternalUint8ClampedElements, 1, 1) \
404 F(HasExternalArrayElements, 1, 1) \
405 F(HasExternalInt8Elements, 1, 1) \
406 F(HasExternalUint8Elements, 1, 1) \
407 F(HasExternalInt16Elements, 1, 1) \
408 F(HasExternalUint16Elements, 1, 1) \
409 F(HasExternalInt32Elements, 1, 1) \
410 F(HasExternalUint32Elements, 1, 1) \
411 F(HasExternalFloat32Elements, 1, 1) \
412 F(HasExternalFloat64Elements, 1, 1) \
413 F(HasFixedUint8ClampedElements, 1, 1) \
414 F(HasFixedInt8Elements, 1, 1) \
415 F(HasFixedUint8Elements, 1, 1) \
416 F(HasFixedInt16Elements, 1, 1) \
417 F(HasFixedUint16Elements, 1, 1) \
418 F(HasFixedInt32Elements, 1, 1) \
419 F(HasFixedUint32Elements, 1, 1) \
420 F(HasFixedFloat32Elements, 1, 1) \
421 F(HasFixedFloat64Elements, 1, 1) \
422 F(HasFastProperties, 1, 1) \
423 F(TransitionElementsKind, 2, 1) \
424 F(HaveSameMap, 2, 1) \
425 F(DisassembleFunction, 1, 1) \
426 F(IsJSGlobalProxy, 1, 1) \
427 F(ForInCacheArrayLength, 2, 1) /* TODO(turbofan): Only temporary */
430 #define RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
431 /* String and Regexp */ \
432 F(NumberToStringRT, 1, 1) \
433 F(RegExpConstructResultRT, 3, 1) \
434 F(StringAddRT, 2, 1) \
435 F(SubStringRT, 3, 1) \
436 F(InternalizeString, 1, 1) \
437 F(StringCompareRT, 2, 1) \
438 F(StringCharCodeAtRT, 2, 1) \
439 F(GetFromCacheRT, 2, 1) \
442 F(CompileLazy, 1, 1) \
443 F(CompileOptimized, 2, 1) \
444 F(TryInstallOptimizedCode, 1, 1) \
445 F(NotifyDeoptimized, 1, 1) \
446 F(NotifyStubFailure, 0, 1) \
449 F(AllocateInNewSpace, 1, 1) \
450 F(AllocateInTargetSpace, 2, 1) \
451 F(AllocateHeapNumber, 0, 1) \
452 F(NumberToSmi, 1, 1) \
453 F(NumberToStringSkipCache, 1, 1) \
455 F(NewArguments, 1, 1) /* TODO(turbofan): Only temporary */ \
456 F(NewSloppyArguments, 3, 1) \
457 F(NewStrictArguments, 3, 1) \
458 F(NewRestParam, 3, 1) \
459 F(NewRestParamSlow, 1, 1) \
461 /* Harmony generators */ \
462 F(CreateJSGeneratorObject, 0, 1) \
463 F(SuspendJSGeneratorObject, -1, 1) \
464 F(ResumeJSGeneratorObject, 3, 1) \
465 F(GeneratorClose, 1, 1) \
468 F(ArrayConstructor, -1, 1) \
469 F(ArrayConstructorWithSubclassing, -1, 1) \
470 F(InternalArrayConstructor, -1, 1) \
473 F(MaterializeRegExpLiteral, 4, 1) \
474 F(CreateObjectLiteral, 4, 1) \
475 F(CreateArrayLiteral, 4, 1) \
476 F(CreateArrayLiteralStubBailout, 3, 1) \
479 F(NewClosure, 3, 1) \
480 F(NewClosureFromStubFailure, 1, 1) \
482 F(NewObjectWithAllocationSite, 3, 1) \
483 F(FinalizeInstanceSize, 1, 1) \
486 F(ThrowReferenceError, 1, 1) \
487 F(ThrowNotDateError, 0, 1) \
488 F(ThrowConstAssignError, 0, 1) \
489 F(StackGuard, 0, 1) \
491 F(FindExceptionHandler, 0, 1) \
492 F(PromoteScheduledException, 0, 1) \
495 F(NewScriptContext, 2, 1) \
496 F(NewFunctionContext, 1, 1) \
497 F(PushWithContext, 2, 1) \
498 F(PushCatchContext, 3, 1) \
499 F(PushBlockContext, 2, 1) \
500 F(PushModuleContext, 2, 1) \
501 F(DeleteLookupSlot, 2, 1) \
502 F(StoreLookupSlot, 4, 1) \
504 /* Declarations and initialization */ \
505 F(DeclareGlobals, 3, 1) \
506 F(DeclareModules, 1, 1) \
507 F(DeclareLookupSlot, 4, 1) \
508 F(InitializeConstGlobal, 2, 1) \
509 F(InitializeLegacyConstLookupSlot, 3, 1) \
512 F(MathPowSlow, 2, 1) \
516 #define FOR_EACH_INTRINSIC_RETURN_PAIR(F) \
517 F(LoadLookupSlot, 2, 2) \
518 F(LoadLookupSlotNoReferenceError, 2, 2) \
519 F(ResolvePossiblyDirectEval, 6, 2) \
520 F(ForInInit, 2, 2) /* TODO(turbofan): Only temporary */ \
521 F(ForInNext, 4, 2) /* TODO(turbofan): Only temporary */
524 #define RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
525 /* Debugger support*/ \
526 F(DebugBreak, 0, 1) \
527 F(SetDebugEventListener, 2, 1) \
528 F(ScheduleBreak, 0, 1) \
529 F(DebugGetPropertyDetails, 2, 1) \
530 F(DebugGetProperty, 2, 1) \
531 F(DebugPropertyTypeFromDetails, 1, 1) \
532 F(DebugPropertyAttributesFromDetails, 1, 1) \
533 F(DebugPropertyIndexFromDetails, 1, 1) \
534 F(DebugNamedInterceptorPropertyValue, 2, 1) \
535 F(DebugIndexedInterceptorElementValue, 2, 1) \
536 F(CheckExecutionState, 1, 1) \
537 F(GetFrameCount, 1, 1) \
538 F(GetFrameDetails, 2, 1) \
539 F(GetScopeCount, 2, 1) \
540 F(GetStepInPositions, 2, 1) \
541 F(GetScopeDetails, 4, 1) \
542 F(GetAllScopesDetails, 4, 1) \
543 F(GetFunctionScopeCount, 1, 1) \
544 F(GetFunctionScopeDetails, 2, 1) \
545 F(SetScopeVariableValue, 6, 1) \
546 F(DebugPrintScopes, 0, 1) \
547 F(GetThreadCount, 1, 1) \
548 F(GetThreadDetails, 2, 1) \
549 F(SetDisableBreak, 1, 1) \
550 F(GetBreakLocations, 2, 1) \
551 F(SetFunctionBreakPoint, 3, 1) \
552 F(SetScriptBreakPoint, 4, 1) \
553 F(ClearBreakPoint, 1, 1) \
554 F(ChangeBreakOnException, 2, 1) \
555 F(IsBreakOnException, 1, 1) \
556 F(PrepareStep, 4, 1) \
557 F(ClearStepping, 0, 1) \
558 F(DebugEvaluate, 6, 1) \
559 F(DebugEvaluateGlobal, 4, 1) \
560 F(DebugGetLoadedScripts, 0, 1) \
561 F(DebugReferencedBy, 3, 1) \
562 F(DebugConstructedBy, 2, 1) \
563 F(DebugGetPrototype, 1, 1) \
564 F(DebugSetScriptSource, 2, 1) \
565 F(DebugCallbackSupportsStepping, 1, 1) \
566 F(SystemBreak, 0, 1) \
567 F(FunctionGetInferredName, 1, 1) \
568 F(FunctionGetDebugName, 1, 1) \
569 F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
570 F(LiveEditGatherCompileInfo, 2, 1) \
571 F(LiveEditReplaceScript, 3, 1) \
572 F(LiveEditReplaceFunctionCode, 2, 1) \
573 F(LiveEditFunctionSourceUpdated, 1, 1) \
574 F(LiveEditFunctionSetScript, 2, 1) \
575 F(LiveEditReplaceRefToNestedFunction, 3, 1) \
576 F(LiveEditPatchFunctionPositions, 2, 1) \
577 F(LiveEditCheckAndDropActivations, 2, 1) \
578 F(LiveEditCompareStrings, 2, 1) \
579 F(LiveEditRestartFrame, 2, 1) \
580 F(GetFunctionCodePositionFromSource, 2, 1) \
581 F(ExecuteInDebugContext, 1, 1) \
582 F(GetDebugContext, 0, 1) \
584 F(CollectGarbage, 1, 1) \
585 F(GetHeapUsage, 0, 1)
588 #ifdef V8_I18N_SUPPORT
589 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
591 /* Standalone, helper methods. */ \
592 F(CanonicalizeLanguageTag, 1, 1) \
593 F(AvailableLocalesOf, 1, 1) \
594 F(GetDefaultICULocale, 0, 1) \
595 F(GetLanguageTagVariants, 1, 1) \
596 F(IsInitializedIntlObject, 1, 1) \
597 F(IsInitializedIntlObjectOfType, 2, 1) \
598 F(MarkAsInitializedIntlObjectOfType, 3, 1) \
599 F(GetImplFromInitializedIntlObject, 1, 1) \
601 /* Date format and parse. */ \
602 F(CreateDateTimeFormat, 3, 1) \
603 F(InternalDateFormat, 2, 1) \
604 F(InternalDateParse, 2, 1) \
606 /* Number format and parse. */ \
607 F(CreateNumberFormat, 3, 1) \
608 F(InternalNumberFormat, 2, 1) \
609 F(InternalNumberParse, 2, 1) \
612 F(CreateCollator, 3, 1) \
613 F(InternalCompare, 3, 1) \
615 /* String.prototype.normalize. */ \
616 F(StringNormalize, 2, 1) \
618 /* Break iterator. */ \
619 F(CreateBreakIterator, 3, 1) \
620 F(BreakIteratorAdoptText, 2, 1) \
621 F(BreakIteratorFirst, 1, 1) \
622 F(BreakIteratorNext, 1, 1) \
623 F(BreakIteratorCurrent, 1, 1) \
624 F(BreakIteratorBreakType, 1, 1)
627 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
631 // ----------------------------------------------------------------------------
632 // INLINE_FUNCTION_LIST defines the intrinsics typically handled specially by
633 // the various compilers.
634 // Entries have the form F(name, number of arguments, number of return values).
635 #define INLINE_FUNCTION_LIST(F) \
637 F(IsNonNegativeSmi, 1, 1) \
641 F(IsConstructCall, 0, 1) \
642 F(CallFunction, -1 /* receiver + n args + function */, 1) \
643 F(DefaultConstructorCallSuper, 0, 1) \
644 F(ArgumentsLength, 0, 1) \
647 F(SetValueOf, 2, 1) \
648 F(DateField, 2 /* date object, field index */, 1) \
649 F(StringCharFromCode, 1, 1) \
650 F(StringCharAt, 2, 1) \
651 F(OneByteSeqStringGetChar, 2, 1) \
652 F(OneByteSeqStringSetChar, 3, 1) \
653 F(TwoByteSeqStringGetChar, 2, 1) \
654 F(TwoByteSeqStringSetChar, 3, 1) \
655 F(ObjectEquals, 2, 1) \
657 F(IsFunction, 1, 1) \
658 F(IsUndetectableObject, 1, 1) \
659 F(IsSpecObject, 1, 1) \
660 F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
662 F(IsMinusZero, 1, 1) \
663 F(HasCachedArrayIndex, 1, 1) \
664 F(GetCachedArrayIndex, 1, 1) \
665 F(FastOneByteArrayJoin, 2, 1) \
666 F(GeneratorNext, 2, 1) \
667 F(GeneratorThrow, 2, 1) \
668 F(DebugBreakInOptimizedCode, 0, 1) \
670 F(StringCharCodeAt, 2, 1) \
673 F(StringCompare, 2, 1) \
674 F(RegExpExec, 4, 1) \
675 F(RegExpConstructResult, 3, 1) \
676 F(GetFromCache, 2, 1) \
677 F(NumberToString, 1, 1) \
678 F(DebugIsActive, 0, 1)
681 // ----------------------------------------------------------------------------
682 // INLINE_OPTIMIZED_FUNCTION_LIST defines the intrinsics typically handled
683 // specially by Crankshaft.
684 // Entries have the form F(name, number of arguments, number of return values).
685 #define INLINE_OPTIMIZED_FUNCTION_LIST(F) \
687 F(TypedArrayInitialize, 5, 1) \
688 F(DataViewInitialize, 4, 1) \
690 F(TypedArrayMaxSizeInHeap, 0, 1) \
691 F(ArrayBufferViewGetByteLength, 1, 1) \
692 F(ArrayBufferViewGetByteOffset, 1, 1) \
693 F(TypedArrayGetLength, 1, 1) \
695 F(ArrayBufferGetByteLength, 1, 1) \
697 F(ConstructDouble, 2, 1) \
704 /* ES6 Collections */ \
708 F(MapGetSize, 1, 1) \
710 F(MapInitialize, 1, 1) \
715 F(SetGetSize, 1, 1) \
717 F(SetInitialize, 1, 1) \
719 F(HasFastPackedElements, 1, 1) \
720 F(GetPrototype, 1, 1) \
722 F(StringGetLength, 1, 1) \
724 F(JSValueGetValue, 1, 1) \
726 F(HeapObjectGetMap, 1, 1) \
728 F(MapGetInstanceType, 1, 1)
731 #define FOR_EACH_INTRINSIC_RETURN_OBJECT(F) \
732 RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
733 RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
734 RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
735 RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
736 RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
737 INLINE_FUNCTION_LIST(F) \
738 INLINE_OPTIMIZED_FUNCTION_LIST(F)
741 // FOR_EACH_INTRINSIC defines the list of all intrinsics, coming in 2 flavors,
742 // either returning an object or a pair.
743 // Entries have the form F(name, number of arguments, number of values).
744 #define FOR_EACH_INTRINSIC(F) \
745 FOR_EACH_INTRINSIC_RETURN_PAIR(F) \
746 FOR_EACH_INTRINSIC_RETURN_OBJECT(F)
749 //---------------------------------------------------------------------------
750 // Runtime provides access to all C++ runtime functions.
754 unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
755 return &to_upper_mapping_;
757 unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
758 return &to_lower_mapping_;
763 unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
764 unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
766 friend class Isolate;
767 friend class Runtime;
769 DISALLOW_COPY_AND_ASSIGN(RuntimeState);
773 class JavaScriptFrameIterator; // Forward declaration.
776 class Runtime : public AllStatic {
779 #define F(name, nargs, ressize) k##name,
780 #define I(name, nargs, ressize) kInline##name,
781 FOR_EACH_INTRINSIC(F) FOR_EACH_INTRINSIC(I)
787 enum IntrinsicType { RUNTIME, INLINE };
789 // Intrinsic function descriptor.
791 FunctionId function_id;
792 IntrinsicType intrinsic_type;
793 // The JS name of the function.
796 // The C++ (native) entry point. NULL if the function is inlined.
799 // The number of arguments expected. nargs is -1 if the function takes
800 // a variable number of arguments.
802 // Size of result. Most functions return a single pointer, size 1.
806 static const int kNotFound = -1;
808 // Add internalized strings for all the intrinsic function names to a
810 static void InitializeIntrinsicFunctionNames(Isolate* isolate,
811 Handle<NameDictionary> dict);
813 // Get the intrinsic function with the given name, which must be internalized.
814 static const Function* FunctionForName(Handle<String> name);
816 // Get the intrinsic function with the given FunctionId.
817 static const Function* FunctionForId(FunctionId id);
819 // Get the intrinsic function with the given function entry address.
820 static const Function* FunctionForEntry(Address ref);
822 // TODO(1240886): Some of the following methods are *not* handle safe, but
823 // accept handle arguments. This seems fragile.
825 // Support getting the characters in a string using [] notation as
826 // in Firefox/SpiderMonkey, Safari and Opera.
827 MUST_USE_RESULT static MaybeHandle<Object> GetElementOrCharAt(
828 Isolate* isolate, Handle<Object> object, uint32_t index);
830 MUST_USE_RESULT static MaybeHandle<Object> SetObjectProperty(
831 Isolate* isolate, Handle<Object> object, Handle<Object> key,
832 Handle<Object> value, LanguageMode language_mode);
834 MUST_USE_RESULT static MaybeHandle<Object> DefineObjectProperty(
835 Handle<JSObject> object, Handle<Object> key, Handle<Object> value,
836 PropertyAttributes attr);
838 MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
839 Isolate* isolate, Handle<Object> object, Handle<Object> key);
841 MUST_USE_RESULT static MaybeHandle<Object> GetPrototype(
842 Isolate* isolate, Handle<Object> object);
844 MUST_USE_RESULT static MaybeHandle<Name> ToName(Isolate* isolate,
847 static void SetupArrayBuffer(Isolate* isolate,
848 Handle<JSArrayBuffer> array_buffer,
849 bool is_external, void* data,
850 size_t allocated_length);
852 static bool SetupArrayBufferAllocatingData(Isolate* isolate,
853 Handle<JSArrayBuffer> array_buffer,
854 size_t allocated_length,
855 bool initialize = true);
857 static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
859 static void FreeArrayBuffer(Isolate* isolate,
860 JSArrayBuffer* phantom_array_buffer);
862 static int FindIndexedNonNativeFrame(JavaScriptFrameIterator* it, int index);
865 // arrayIds below should be synchromized with typedarray.js natives.
872 ARRAY_ID_FLOAT32 = 7,
873 ARRAY_ID_FLOAT64 = 8,
874 ARRAY_ID_UINT8_CLAMPED = 9,
875 ARRAY_ID_FIRST = ARRAY_ID_UINT8,
876 ARRAY_ID_LAST = ARRAY_ID_UINT8_CLAMPED
879 static void ArrayIdToTypeAndSize(int array_id, ExternalArrayType* type,
880 ElementsKind* external_elements_kind,
881 ElementsKind* fixed_elements_kind,
882 size_t* element_size);
884 // Used in runtime.cc and hydrogen's VisitArrayLiteral.
885 MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
886 Isolate* isolate, Handle<FixedArray> literals,
887 Handle<FixedArray> elements);
889 static void WeakCollectionInitialize(
890 Isolate* isolate, Handle<JSWeakCollection> weak_collection);
891 static void WeakCollectionSet(Handle<JSWeakCollection> weak_collection,
892 Handle<Object> key, Handle<Object> value);
893 static bool WeakCollectionDelete(Handle<JSWeakCollection> weak_collection,
898 std::ostream& operator<<(std::ostream&, Runtime::FunctionId);
900 //---------------------------------------------------------------------------
901 // Constants used by interface to runtime functions.
903 class AllocateDoubleAlignFlag : public BitField<bool, 0, 1> {};
904 class AllocateTargetSpace : public BitField<AllocationSpace, 1, 3> {};
906 class DeclareGlobalsEvalFlag : public BitField<bool, 0, 1> {};
907 class DeclareGlobalsNativeFlag : public BitField<bool, 1, 1> {};
908 STATIC_ASSERT(LANGUAGE_END == 3);
909 class DeclareGlobalsLanguageMode : public BitField<LanguageMode, 2, 2> {};
911 } // namespace internal
914 #endif // V8_RUNTIME_RUNTIME_H_