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.
8 #include "src/allocation.h"
14 // The interface to C++ runtime functions.
16 // ----------------------------------------------------------------------------
17 // RUNTIME_FUNCTION_LIST_ALWAYS defines runtime calls available in both
18 // release and debug mode.
19 // This macro should only be used by the macro RUNTIME_FUNCTION_LIST.
21 // WARNING: RUNTIME_FUNCTION_LIST_ALWAYS_* is a very large macro that caused
22 // MSVC Intellisense to crash. It was broken into two macros to work around
23 // this problem. Please avoid large recursive macros whenever possible.
24 #define RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
25 /* Property access */ \
26 F(GetProperty, 2, 1) \
27 F(KeyedGetProperty, 2, 1) \
28 F(DeleteProperty, 3, 1) \
29 F(HasOwnProperty, 2, 1) \
30 F(HasProperty, 2, 1) \
32 F(IsPropertyEnumerable, 2, 1) \
33 F(GetPropertyNames, 1, 1) \
34 F(GetPropertyNamesFast, 1, 1) \
35 F(GetOwnPropertyNames, 2, 1) \
36 F(GetOwnElementNames, 1, 1) \
37 F(GetInterceptorInfo, 1, 1) \
38 F(GetNamedInterceptorPropertyNames, 1, 1) \
39 F(GetIndexedInterceptorElementNames, 1, 1) \
40 F(GetArgumentsProperty, 1, 1) \
41 F(ToFastProperties, 1, 1) \
42 F(FinishArrayPrototypeSetup, 1, 1) \
43 F(SpecialArrayFunctions, 0, 1) \
44 F(IsSloppyModeFunction, 1, 1) \
45 F(GetDefaultReceiver, 1, 1) \
47 F(GetPrototype, 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(NeverOptimizeFunction, 1, 1) \
70 F(GetOptimizationStatus, -1, 1) \
71 F(IsOptimized, 0, 1) /* TODO(turbofan): Only temporary */ \
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(DebugPromiseRejectEvent, 2, 1) \
84 F(DebugAsyncTaskEvent, 1, 1) \
85 F(FlattenString, 1, 1) \
86 F(LoadMutableDouble, 2, 1) \
87 F(TryMigrateInstance, 1, 1) \
88 F(NotifyContextDisposed, 0, 1) \
90 /* Array join support */ \
91 F(PushIfAbsent, 2, 1) \
92 F(ArrayConcat, 1, 1) \
98 F(Booleanize, 2, 1) /* TODO(turbofan): Only temporary */ \
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) \
148 F(MathFloorRT, 1, 1) \
151 F(RoundNumber, 1, 1) \
152 F(MathFround, 1, 1) \
155 /* Regular expressions */ \
156 F(RegExpCompile, 3, 1) \
157 F(RegExpExecMultiple, 4, 1) \
158 F(RegExpInitializeObject, 5, 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) \
186 #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
188 F(FunctionSetInstanceClassName, 2, 1) \
189 F(FunctionSetLength, 2, 1) \
190 F(FunctionSetPrototype, 2, 1) \
191 F(FunctionGetName, 1, 1) \
192 F(FunctionSetName, 2, 1) \
193 F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
194 F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
195 F(FunctionIsGenerator, 1, 1) \
196 F(FunctionIsArrow, 1, 1) \
197 F(FunctionBindArguments, 4, 1) \
198 F(BoundFunctionGetBindings, 1, 1) \
199 F(FunctionRemovePrototype, 1, 1) \
200 F(FunctionGetSourceCode, 1, 1) \
201 F(FunctionGetScript, 1, 1) \
202 F(FunctionGetScriptSourcePosition, 1, 1) \
203 F(FunctionGetPositionForOffset, 2, 1) \
204 F(FunctionIsAPIFunction, 1, 1) \
205 F(FunctionIsBuiltin, 1, 1) \
207 F(CollectStackTrace, 2, 1) \
208 F(GetV8Version, 0, 1) \
212 F(CreateApiFunction, 2, 1) \
213 F(IsTemplate, 1, 1) \
214 F(GetTemplateField, 2, 1) \
215 F(DisableAccessChecks, 1, 1) \
216 F(EnableAccessChecks, 1, 1) \
219 F(DateCurrentTime, 0, 1) \
220 F(DateParseString, 2, 1) \
221 F(DateLocalTimezone, 1, 1) \
223 F(DateMakeDay, 2, 1) \
224 F(DateSetValue, 3, 1) \
225 F(DateCacheVersion, 0, 1) \
228 F(CompileString, 2, 1) \
231 F(GlobalProxy, 1, 1) \
232 F(IsAttachedGlobal, 1, 1) \
234 F(AddNamedProperty, 4, 1) \
235 F(AddPropertyForTemplate, 4, 1) \
236 F(SetProperty, 4, 1) \
237 F(DefineApiAccessorProperty, 5, 1) \
238 F(DefineDataPropertyUnchecked, 4, 1) \
239 F(DefineAccessorPropertyUnchecked, 5, 1) \
240 F(GetDataProperty, 2, 1) \
241 F(SetHiddenProperty, 3, 1) \
244 F(RemoveArrayHoles, 2, 1) \
245 F(GetArrayKeys, 2, 1) \
246 F(MoveArrayContents, 2, 1) \
247 F(EstimateNumberOfElements, 1, 1) \
248 F(NormalizeElements, 1, 1) \
250 /* Getters and Setters */ \
251 F(LookupAccessor, 3, 1) \
254 F(ObjectFreeze, 1, 1) \
256 /* Harmony modules */ \
257 F(IsJSModule, 1, 1) \
259 /* Harmony symbols */ \
260 F(CreateSymbol, 1, 1) \
261 F(CreatePrivateSymbol, 1, 1) \
262 F(CreateGlobalPrivateSymbol, 1, 1) \
263 F(NewSymbolWrapper, 1, 1) \
264 F(SymbolDescription, 1, 1) \
265 F(SymbolRegistry, 0, 1) \
266 F(SymbolIsPrivate, 1, 1) \
268 /* Harmony proxies */ \
269 F(CreateJSProxy, 2, 1) \
270 F(CreateJSFunctionProxy, 4, 1) \
272 F(IsJSFunctionProxy, 1, 1) \
273 F(GetHandler, 1, 1) \
274 F(GetCallTrap, 1, 1) \
275 F(GetConstructTrap, 1, 1) \
279 F(SetInitialize, 1, 1) \
284 F(SetGetSize, 1, 1) \
286 F(SetIteratorInitialize, 3, 1) \
287 F(SetIteratorNext, 2, 1) \
290 F(MapInitialize, 1, 1) \
296 F(MapGetSize, 1, 1) \
298 F(MapIteratorInitialize, 3, 1) \
299 F(MapIteratorNext, 2, 1) \
301 /* Harmony weak maps and sets */ \
302 F(WeakCollectionInitialize, 1, 1) \
303 F(WeakCollectionGet, 2, 1) \
304 F(WeakCollectionHas, 2, 1) \
305 F(WeakCollectionDelete, 2, 1) \
306 F(WeakCollectionSet, 3, 1) \
308 F(GetWeakMapEntries, 1, 1) \
309 F(GetWeakSetValues, 1, 1) \
311 /* Harmony events */ \
312 F(EnqueueMicrotask, 1, 1) \
313 F(RunMicrotasks, 0, 1) \
315 /* Harmony observe */ \
316 F(IsObserved, 1, 1) \
317 F(SetIsObserved, 1, 1) \
318 F(GetObservationState, 0, 1) \
319 F(ObservationWeakMapCreate, 0, 1) \
320 F(ObserverObjectAndRecordHaveSameOrigin, 3, 1) \
321 F(ObjectWasCreatedInCurrentOrigin, 1, 1) \
322 F(GetObjectContextObjectObserve, 1, 1) \
323 F(GetObjectContextObjectGetNotifier, 1, 1) \
324 F(GetObjectContextNotifierPerformChange, 1, 1) \
326 /* Harmony typed arrays */ \
327 F(ArrayBufferInitialize, 2, 1) \
328 F(ArrayBufferSliceImpl, 3, 1) \
329 F(ArrayBufferIsView, 1, 1) \
330 F(ArrayBufferNeuter, 1, 1) \
332 F(TypedArrayInitializeFromArrayLike, 4, 1) \
333 F(TypedArrayGetBuffer, 1, 1) \
334 F(TypedArraySetFastCases, 3, 1) \
336 F(DataViewGetBuffer, 1, 1) \
337 F(DataViewGetInt8, 3, 1) \
338 F(DataViewGetUint8, 3, 1) \
339 F(DataViewGetInt16, 3, 1) \
340 F(DataViewGetUint16, 3, 1) \
341 F(DataViewGetInt32, 3, 1) \
342 F(DataViewGetUint32, 3, 1) \
343 F(DataViewGetFloat32, 3, 1) \
344 F(DataViewGetFloat64, 3, 1) \
346 F(DataViewSetInt8, 4, 1) \
347 F(DataViewSetUint8, 4, 1) \
348 F(DataViewSetInt16, 4, 1) \
349 F(DataViewSetUint16, 4, 1) \
350 F(DataViewSetInt32, 4, 1) \
351 F(DataViewSetUint32, 4, 1) \
352 F(DataViewSetFloat32, 4, 1) \
353 F(DataViewSetFloat64, 4, 1) \
356 F(NewObjectFromBound, 1, 1) \
358 /* Declarations and initialization */ \
359 F(InitializeVarGlobal, 3, 1) \
360 F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
363 F(DebugPrint, 1, 1) \
364 F(GlobalPrint, 1, 1) \
365 F(DebugTrace, 0, 1) \
366 F(TraceEnter, 0, 1) \
373 /* Message objects */ \
374 F(MessageGetStartPosition, 1, 1) \
375 F(MessageGetScript, 1, 1) \
377 /* Pseudo functions - handled as macros by parser */ \
380 /* expose boolean functions from objects-inl.h */ \
381 F(HasFastSmiElements, 1, 1) \
382 F(HasFastSmiOrObjectElements, 1, 1) \
383 F(HasFastObjectElements, 1, 1) \
384 F(HasFastDoubleElements, 1, 1) \
385 F(HasFastHoleyElements, 1, 1) \
386 F(HasDictionaryElements, 1, 1) \
387 F(HasSloppyArgumentsElements, 1, 1) \
388 F(HasExternalUint8ClampedElements, 1, 1) \
389 F(HasExternalArrayElements, 1, 1) \
390 F(HasExternalInt8Elements, 1, 1) \
391 F(HasExternalUint8Elements, 1, 1) \
392 F(HasExternalInt16Elements, 1, 1) \
393 F(HasExternalUint16Elements, 1, 1) \
394 F(HasExternalInt32Elements, 1, 1) \
395 F(HasExternalUint32Elements, 1, 1) \
396 F(HasExternalFloat32Elements, 1, 1) \
397 F(HasExternalFloat64Elements, 1, 1) \
398 F(HasFixedUint8ClampedElements, 1, 1) \
399 F(HasFixedInt8Elements, 1, 1) \
400 F(HasFixedUint8Elements, 1, 1) \
401 F(HasFixedInt16Elements, 1, 1) \
402 F(HasFixedUint16Elements, 1, 1) \
403 F(HasFixedInt32Elements, 1, 1) \
404 F(HasFixedUint32Elements, 1, 1) \
405 F(HasFixedFloat32Elements, 1, 1) \
406 F(HasFixedFloat64Elements, 1, 1) \
407 F(HasFastProperties, 1, 1) \
408 F(TransitionElementsKind, 2, 1) \
409 F(HaveSameMap, 2, 1) \
410 F(IsJSGlobalProxy, 1, 1) \
411 F(ForInInit, 2, 2) /* TODO(turbofan): Only temporary */ \
412 F(ForInNext, 4, 2) /* TODO(turbofan): Only temporary */ \
413 F(ForInCacheArrayLength, 2, 1) /* TODO(turbofan): Only temporary */
416 #define RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
417 /* String and Regexp */ \
418 F(NumberToStringRT, 1, 1) \
419 F(RegExpConstructResult, 3, 1) \
420 F(RegExpExecRT, 4, 1) \
423 F(InternalizeString, 1, 1) \
424 F(StringCompare, 2, 1) \
425 F(StringCharCodeAtRT, 2, 1) \
426 F(GetFromCache, 2, 1) \
429 F(CompileUnoptimized, 1, 1) \
430 F(CompileOptimized, 2, 1) \
431 F(TryInstallOptimizedCode, 1, 1) \
432 F(NotifyDeoptimized, 1, 1) \
433 F(NotifyStubFailure, 0, 1) \
436 F(AllocateInNewSpace, 1, 1) \
437 F(AllocateInTargetSpace, 2, 1) \
438 F(AllocateHeapNumber, 0, 1) \
439 F(NumberToSmi, 1, 1) \
440 F(NumberToStringSkipCache, 1, 1) \
442 F(NewArguments, 1, 1) /* TODO(turbofan): Only temporary */ \
443 F(NewSloppyArguments, 3, 1) \
444 F(NewStrictArguments, 3, 1) \
446 /* Harmony generators */ \
447 F(CreateJSGeneratorObject, 0, 1) \
448 F(SuspendJSGeneratorObject, 1, 1) \
449 F(ResumeJSGeneratorObject, 3, 1) \
450 F(ThrowGeneratorStateError, 1, 1) \
453 F(ArrayConstructor, -1, 1) \
454 F(InternalArrayConstructor, -1, 1) \
457 F(MaterializeRegExpLiteral, 4, 1) \
458 F(CreateObjectLiteral, 4, 1) \
459 F(CreateArrayLiteral, 4, 1) \
460 F(CreateArrayLiteralStubBailout, 3, 1) \
463 F(NewClosure, 3, 1) \
464 F(NewClosureFromStubFailure, 1, 1) \
466 F(NewObjectWithAllocationSite, 2, 1) \
467 F(FinalizeInstanceSize, 1, 1) \
470 F(ThrowReferenceError, 1, 1) \
471 F(ThrowNotDateError, 0, 1) \
472 F(StackGuard, 0, 1) \
474 F(PromoteScheduledException, 0, 1) \
477 F(NewGlobalContext, 2, 1) \
478 F(NewFunctionContext, 1, 1) \
479 F(PushWithContext, 2, 1) \
480 F(PushCatchContext, 3, 1) \
481 F(PushBlockContext, 2, 1) \
482 F(PushModuleContext, 2, 1) \
483 F(DeleteLookupSlot, 2, 1) \
484 F(LoadLookupSlot, 2, 2) \
485 F(LoadLookupSlotNoReferenceError, 2, 2) \
486 F(StoreLookupSlot, 4, 1) \
488 /* Declarations and initialization */ \
489 F(DeclareGlobals, 3, 1) \
490 F(DeclareModules, 1, 1) \
491 F(DeclareLookupSlot, 4, 1) \
492 F(InitializeConstGlobal, 2, 1) \
493 F(InitializeLegacyConstLookupSlot, 3, 1) \
496 F(ResolvePossiblyDirectEval, 5, 2) \
499 F(MathPowSlow, 2, 1) \
503 #define RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
504 /* Debugger support*/ \
505 F(DebugBreak, 0, 1) \
506 F(SetDebugEventListener, 2, 1) \
508 F(DebugGetPropertyDetails, 2, 1) \
509 F(DebugGetProperty, 2, 1) \
510 F(DebugPropertyTypeFromDetails, 1, 1) \
511 F(DebugPropertyAttributesFromDetails, 1, 1) \
512 F(DebugPropertyIndexFromDetails, 1, 1) \
513 F(DebugNamedInterceptorPropertyValue, 2, 1) \
514 F(DebugIndexedInterceptorElementValue, 2, 1) \
515 F(CheckExecutionState, 1, 1) \
516 F(GetFrameCount, 1, 1) \
517 F(GetFrameDetails, 2, 1) \
518 F(GetScopeCount, 2, 1) \
519 F(GetStepInPositions, 2, 1) \
520 F(GetScopeDetails, 4, 1) \
521 F(GetAllScopesDetails, 4, 1) \
522 F(GetFunctionScopeCount, 1, 1) \
523 F(GetFunctionScopeDetails, 2, 1) \
524 F(SetScopeVariableValue, 6, 1) \
525 F(DebugPrintScopes, 0, 1) \
526 F(GetThreadCount, 1, 1) \
527 F(GetThreadDetails, 2, 1) \
528 F(SetDisableBreak, 1, 1) \
529 F(GetBreakLocations, 2, 1) \
530 F(SetFunctionBreakPoint, 3, 1) \
531 F(SetScriptBreakPoint, 4, 1) \
532 F(ClearBreakPoint, 1, 1) \
533 F(ChangeBreakOnException, 2, 1) \
534 F(IsBreakOnException, 1, 1) \
535 F(PrepareStep, 4, 1) \
536 F(ClearStepping, 0, 1) \
537 F(DebugEvaluate, 6, 1) \
538 F(DebugEvaluateGlobal, 4, 1) \
539 F(DebugGetLoadedScripts, 0, 1) \
540 F(DebugReferencedBy, 3, 1) \
541 F(DebugConstructedBy, 2, 1) \
542 F(DebugGetPrototype, 1, 1) \
543 F(DebugSetScriptSource, 2, 1) \
544 F(DebugCallbackSupportsStepping, 1, 1) \
545 F(SystemBreak, 0, 1) \
546 F(DebugDisassembleFunction, 1, 1) \
547 F(DebugDisassembleConstructor, 1, 1) \
548 F(FunctionGetInferredName, 1, 1) \
549 F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
550 F(LiveEditGatherCompileInfo, 2, 1) \
551 F(LiveEditReplaceScript, 3, 1) \
552 F(LiveEditReplaceFunctionCode, 2, 1) \
553 F(LiveEditFunctionSourceUpdated, 1, 1) \
554 F(LiveEditFunctionSetScript, 2, 1) \
555 F(LiveEditReplaceRefToNestedFunction, 3, 1) \
556 F(LiveEditPatchFunctionPositions, 2, 1) \
557 F(LiveEditCheckAndDropActivations, 2, 1) \
558 F(LiveEditCompareStrings, 2, 1) \
559 F(LiveEditRestartFrame, 2, 1) \
560 F(GetFunctionCodePositionFromSource, 2, 1) \
561 F(ExecuteInDebugContext, 2, 1) \
564 F(CollectGarbage, 1, 1) \
565 F(GetHeapUsage, 0, 1) \
568 #ifdef V8_I18N_SUPPORT
569 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
571 /* Standalone, helper methods. */ \
572 F(CanonicalizeLanguageTag, 1, 1) \
573 F(AvailableLocalesOf, 1, 1) \
574 F(GetDefaultICULocale, 0, 1) \
575 F(GetLanguageTagVariants, 1, 1) \
576 F(IsInitializedIntlObject, 1, 1) \
577 F(IsInitializedIntlObjectOfType, 2, 1) \
578 F(MarkAsInitializedIntlObjectOfType, 3, 1) \
579 F(GetImplFromInitializedIntlObject, 1, 1) \
581 /* Date format and parse. */ \
582 F(CreateDateTimeFormat, 3, 1) \
583 F(InternalDateFormat, 2, 1) \
584 F(InternalDateParse, 2, 1) \
586 /* Number format and parse. */ \
587 F(CreateNumberFormat, 3, 1) \
588 F(InternalNumberFormat, 2, 1) \
589 F(InternalNumberParse, 2, 1) \
592 F(CreateCollator, 3, 1) \
593 F(InternalCompare, 3, 1) \
595 /* String.prototype.normalize. */ \
596 F(StringNormalize, 2, 1) \
598 /* Break iterator. */ \
599 F(CreateBreakIterator, 3, 1) \
600 F(BreakIteratorAdoptText, 2, 1) \
601 F(BreakIteratorFirst, 1, 1) \
602 F(BreakIteratorNext, 1, 1) \
603 F(BreakIteratorCurrent, 1, 1) \
604 F(BreakIteratorBreakType, 1, 1) \
607 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
612 #define RUNTIME_FUNCTION_LIST_DEBUG(F) \
616 #define RUNTIME_FUNCTION_LIST_DEBUG(F)
619 // ----------------------------------------------------------------------------
620 // RUNTIME_FUNCTION_LIST defines all runtime functions accessed
621 // either directly by id (via the code generator), or indirectly
622 // via a native call by name (from within JS code).
623 // Entries have the form F(name, number of arguments, number of return values).
625 #define RUNTIME_FUNCTION_LIST(F) \
626 RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
627 RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
628 RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
629 RUNTIME_FUNCTION_LIST_DEBUG(F) \
630 RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
631 RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
633 // ----------------------------------------------------------------------------
634 // INLINE_FUNCTION_LIST defines all inlined functions accessed
635 // with a native call of the form %_name from within JS code.
636 // Entries have the form F(name, number of arguments, number of return values).
637 #define INLINE_FUNCTION_LIST(F) \
639 F(IsNonNegativeSmi, 1, 1) \
642 F(IsConstructCall, 0, 1) \
643 F(CallFunction, -1 /* receiver + n args + function */, 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(OneByteSeqStringSetChar, 3, 1) \
652 F(TwoByteSeqStringSetChar, 3, 1) \
653 F(ObjectEquals, 2, 1) \
655 F(IsFunction, 1, 1) \
656 F(IsUndetectableObject, 1, 1) \
657 F(IsSpecObject, 1, 1) \
658 F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
660 F(IsMinusZero, 1, 1) \
661 F(HasCachedArrayIndex, 1, 1) \
662 F(GetCachedArrayIndex, 1, 1) \
663 F(FastAsciiArrayJoin, 2, 1) \
664 F(GeneratorNext, 2, 1) \
665 F(GeneratorThrow, 2, 1) \
666 F(DebugBreakInOptimizedCode, 0, 1) \
668 F(StringCharCodeAt, 2, 1) \
671 F(StringCompare, 2, 1) \
672 F(RegExpExec, 4, 1) \
673 F(RegExpConstructResult, 3, 1) \
674 F(GetFromCache, 2, 1) \
675 F(NumberToString, 1, 1) \
676 F(DebugIsActive, 0, 1)
679 // ----------------------------------------------------------------------------
680 // INLINE_OPTIMIZED_FUNCTION_LIST defines all inlined functions accessed
681 // with a native call of the form %_name from within JS code that also have
682 // a corresponding runtime function, that is called from non-optimized code.
683 // For the benefit of (fuzz) tests, the runtime version can also be called
684 // directly as %name (i.e. without the leading underscore).
685 // Entries have the form F(name, number of arguments, number of return values).
686 #define INLINE_OPTIMIZED_FUNCTION_LIST(F) \
688 F(TypedArrayInitialize, 5, 1) \
689 F(DataViewInitialize, 4, 1) \
691 F(TypedArrayMaxSizeInHeap, 0, 1) \
692 F(ArrayBufferViewGetByteLength, 1, 1) \
693 F(ArrayBufferViewGetByteOffset, 1, 1) \
694 F(TypedArrayGetLength, 1, 1) \
696 F(ArrayBufferGetByteLength, 1, 1) \
698 F(ConstructDouble, 2, 1) \
701 F(MathSqrtRT, 1, 1) \
705 //---------------------------------------------------------------------------
706 // Runtime provides access to all C++ runtime functions.
710 StaticResource<ConsStringIteratorOp>* string_iterator() {
711 return &string_iterator_;
713 unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
714 return &to_upper_mapping_;
716 unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
717 return &to_lower_mapping_;
719 ConsStringIteratorOp* string_iterator_compare_x() {
720 return &string_iterator_compare_x_;
722 ConsStringIteratorOp* string_iterator_compare_y() {
723 return &string_iterator_compare_y_;
725 ConsStringIteratorOp* string_locale_compare_it1() {
726 return &string_locale_compare_it1_;
728 ConsStringIteratorOp* string_locale_compare_it2() {
729 return &string_locale_compare_it2_;
734 // Non-reentrant string buffer for efficient general use in the runtime.
735 StaticResource<ConsStringIteratorOp> string_iterator_;
736 unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
737 unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
738 ConsStringIteratorOp string_iterator_compare_x_;
739 ConsStringIteratorOp string_iterator_compare_y_;
740 ConsStringIteratorOp string_locale_compare_it1_;
741 ConsStringIteratorOp string_locale_compare_it2_;
743 friend class Isolate;
744 friend class Runtime;
746 DISALLOW_COPY_AND_ASSIGN(RuntimeState);
750 class Runtime : public AllStatic {
753 #define F(name, nargs, ressize) k##name,
754 RUNTIME_FUNCTION_LIST(F)
755 INLINE_OPTIMIZED_FUNCTION_LIST(F)
757 #define F(name, nargs, ressize) kInline##name,
758 INLINE_FUNCTION_LIST(F)
760 #define F(name, nargs, ressize) kInlineOptimized##name,
761 INLINE_OPTIMIZED_FUNCTION_LIST(F)
764 kFirstInlineFunction = kInlineIsSmi
773 // Intrinsic function descriptor.
775 FunctionId function_id;
776 IntrinsicType intrinsic_type;
777 // The JS name of the function.
780 // The C++ (native) entry point. NULL if the function is inlined.
783 // The number of arguments expected. nargs is -1 if the function takes
784 // a variable number of arguments.
786 // Size of result. Most functions return a single pointer, size 1.
790 static const int kNotFound = -1;
792 // Add internalized strings for all the intrinsic function names to a
794 static void InitializeIntrinsicFunctionNames(Isolate* isolate,
795 Handle<NameDictionary> dict);
797 // Get the intrinsic function with the given name, which must be internalized.
798 static const Function* FunctionForName(Handle<String> name);
800 // Get the intrinsic function with the given FunctionId.
801 static const Function* FunctionForId(FunctionId id);
803 // Get the intrinsic function with the given function entry address.
804 static const Function* FunctionForEntry(Address ref);
806 // General-purpose helper functions for runtime system.
807 static int StringMatch(Isolate* isolate,
812 static bool IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch);
814 // TODO(1240886): Some of the following methods are *not* handle safe, but
815 // accept handle arguments. This seems fragile.
817 // Support getting the characters in a string using [] notation as
818 // in Firefox/SpiderMonkey, Safari and Opera.
819 MUST_USE_RESULT static MaybeHandle<Object> GetElementOrCharAt(
821 Handle<Object> object,
824 MUST_USE_RESULT static MaybeHandle<Object> SetObjectProperty(
825 Isolate* isolate, Handle<Object> object, Handle<Object> key,
826 Handle<Object> value, StrictMode strict_mode);
828 MUST_USE_RESULT static MaybeHandle<Object> DefineObjectProperty(
829 Handle<JSObject> object,
831 Handle<Object> value,
832 PropertyAttributes attr,
833 JSReceiver::StoreFromKeyed store_from_keyed =
834 JSReceiver::MAY_BE_STORE_FROM_KEYED);
836 MUST_USE_RESULT static MaybeHandle<Object> DeleteObjectProperty(
838 Handle<JSReceiver> object,
840 JSReceiver::DeleteMode mode);
842 MUST_USE_RESULT static MaybeHandle<Object> HasObjectProperty(
844 Handle<JSReceiver> object,
847 MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
849 Handle<Object> object,
852 static void SetupArrayBuffer(Isolate* isolate,
853 Handle<JSArrayBuffer> array_buffer,
856 size_t allocated_length);
858 static bool SetupArrayBufferAllocatingData(
860 Handle<JSArrayBuffer> array_buffer,
861 size_t allocated_length,
862 bool initialize = true);
864 static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
866 static void FreeArrayBuffer(
868 JSArrayBuffer* phantom_array_buffer);
871 // arrayIds below should be synchromized with typedarray.js natives.
878 ARRAY_ID_FLOAT32 = 7,
879 ARRAY_ID_FLOAT64 = 8,
880 ARRAY_ID_UINT8_CLAMPED = 9,
882 ARRAY_ID_FIRST = ARRAY_ID_UINT8,
883 ARRAY_ID_LAST = ARRAY_ID_UINT8_CLAMPED
886 static void ArrayIdToTypeAndSize(int array_id,
887 ExternalArrayType *type,
888 ElementsKind* external_elements_kind,
889 ElementsKind* fixed_elements_kind,
890 size_t *element_size);
892 // Used in runtime.cc and hydrogen's VisitArrayLiteral.
893 MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
895 Handle<FixedArray> literals,
896 Handle<FixedArray> elements);
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 class DeclareGlobalsStrictMode: public BitField<StrictMode, 2, 1> {};
910 } } // namespace v8::internal
912 #endif // V8_RUNTIME_H_