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(GetOptimizationCount, 1, 1) \
72 F(UnblockConcurrentRecompilation, 0, 1) \
73 F(CompileForOnStackReplacement, 1, 1) \
74 F(SetAllocationTimeout, -1 /* 2 || 3 */, 1) \
75 F(SetNativeFlag, 1, 1) \
76 F(SetInlineBuiltinFlag, 1, 1) \
77 F(StoreArrayLiteralElement, 5, 1) \
78 F(DebugPrepareStepInIfStepping, 1, 1) \
79 F(DebugPushPromise, 1, 1) \
80 F(DebugPopPromise, 0, 1) \
81 F(DebugPromiseEvent, 1, 1) \
82 F(DebugPromiseRejectEvent, 2, 1) \
83 F(DebugAsyncTaskEvent, 1, 1) \
84 F(FlattenString, 1, 1) \
85 F(LoadMutableDouble, 2, 1) \
86 F(TryMigrateInstance, 1, 1) \
87 F(NotifyContextDisposed, 0, 1) \
89 /* Array join support */ \
90 F(PushIfAbsent, 2, 1) \
91 F(ArrayConcat, 1, 1) \
97 F(Booleanize, 2, 1) /* TODO(turbofan): Only temporary */ \
99 F(StringToNumber, 1, 1) \
100 F(StringParseInt, 2, 1) \
101 F(StringParseFloat, 1, 1) \
102 F(StringToLowerCase, 1, 1) \
103 F(StringToUpperCase, 1, 1) \
104 F(StringSplit, 3, 1) \
105 F(CharFromCode, 1, 1) \
107 F(URIUnescape, 1, 1) \
109 F(NumberToInteger, 1, 1) \
110 F(NumberToIntegerMapMinusZero, 1, 1) \
111 F(NumberToJSUint32, 1, 1) \
112 F(NumberToJSInt32, 1, 1) \
114 /* Arithmetic operations */ \
120 F(NumberUnaryMinus, 1, 1) \
121 F(NumberImul, 2, 1) \
123 F(StringBuilderConcat, 3, 1) \
124 F(StringBuilderJoin, 3, 1) \
125 F(SparseJoinWithSeparator, 3, 1) \
127 /* Bit operations */ \
137 F(NumberEquals, 2, 1) \
138 F(StringEquals, 2, 1) \
140 F(NumberCompare, 3, 1) \
141 F(SmiLexicographicCompare, 2, 1) \
147 F(MathFloorRT, 1, 1) \
150 F(RoundNumber, 1, 1) \
151 F(MathFround, 1, 1) \
154 /* Float32x4 and Int32x4 */ \
155 F(AllocateFloat32x4, 0, 1) \
156 F(AllocateFloat64x2, 0, 1) \
157 F(AllocateInt32x4, 0, 1) \
160 F(Float32x4Abs, 1, 1) \
161 F(Float32x4BitsToInt32x4, 1, 1) \
162 F(Float32x4Neg, 1, 1) \
163 F(Float32x4Reciprocal, 1, 1) \
164 F(Float32x4ReciprocalSqrt, 1, 1) \
165 F(Float32x4Sqrt, 1, 1) \
166 F(Float32x4ToInt32x4, 1, 1) \
167 F(Float32x4Add, 2, 1) \
168 F(Float32x4Div, 2, 1) \
169 F(Float32x4Max, 2, 1) \
170 F(Float32x4Min, 2, 1) \
171 F(Float32x4Mul, 2, 1) \
172 F(Float32x4Sub, 2, 1) \
173 F(Float32x4Equal, 2, 1) \
174 F(Float32x4NotEqual, 2, 1) \
175 F(Float32x4GreaterThanOrEqual, 2, 1) \
176 F(Float32x4GreaterThan, 2, 1) \
177 F(Float32x4LessThan, 2, 1) \
178 F(Float32x4LessThanOrEqual, 2, 1) \
179 F(Float32x4Shuffle, 2, 1) \
180 F(Float32x4Scale, 2, 1) \
181 F(Float32x4WithX, 2, 1) \
182 F(Float32x4WithY, 2, 1) \
183 F(Float32x4WithZ, 2, 1) \
184 F(Float32x4WithW, 2, 1) \
185 F(Float32x4Clamp, 3, 1) \
186 F(Float32x4ShuffleMix, 3, 1) \
187 F(Float32x4Select, 3, 1) \
188 F(Float64x2Abs, 1, 1) \
189 F(Float64x2Neg, 1, 1) \
190 F(Float64x2Sqrt, 1, 1) \
191 F(Float64x2Add, 2, 1) \
192 F(Float64x2Div, 2, 1) \
193 F(Float64x2Max, 2, 1) \
194 F(Float64x2Min, 2, 1) \
195 F(Float64x2Mul, 2, 1) \
196 F(Float64x2Sub, 2, 1) \
197 F(Float64x2Scale, 2, 1) \
198 F(Float64x2WithX, 2, 1) \
199 F(Float64x2WithY, 2, 1) \
200 F(Float64x2Clamp, 3, 1) \
201 F(Int32x4BitsToFloat32x4, 1, 1) \
202 F(Int32x4Neg, 1, 1) \
203 F(Int32x4Not, 1, 1) \
204 F(Int32x4ToFloat32x4, 1, 1) \
205 F(Int32x4And, 2, 1) \
207 F(Int32x4Xor, 2, 1) \
208 F(Int32x4Add, 2, 1) \
209 F(Int32x4Sub, 2, 1) \
210 F(Int32x4Mul, 2, 1) \
211 F(Int32x4Shuffle, 2, 1) \
212 F(Int32x4WithX, 2, 1) \
213 F(Int32x4WithY, 2, 1) \
214 F(Int32x4WithZ, 2, 1) \
215 F(Int32x4WithW, 2, 1) \
216 F(Int32x4WithFlagX, 2, 1) \
217 F(Int32x4WithFlagY, 2, 1) \
218 F(Int32x4WithFlagZ, 2, 1) \
219 F(Int32x4WithFlagW, 2, 1) \
220 F(Int32x4GreaterThan, 2, 1) \
221 F(Int32x4Equal, 2, 1) \
222 F(Int32x4LessThan, 2, 1) \
223 F(Int32x4Select, 3, 1) \
225 /* Regular expressions */ \
226 F(RegExpCompile, 3, 1) \
227 F(RegExpExecMultiple, 4, 1) \
228 F(RegExpInitializeObject, 6, 1) \
232 F(BasicJSONStringify, 1, 1) \
233 F(QuoteJSONString, 1, 1) \
236 F(StringIndexOf, 3, 1) \
237 F(StringLastIndexOf, 3, 1) \
238 F(StringLocaleCompare, 2, 1) \
239 F(StringReplaceGlobalRegExpWithString, 4, 1) \
240 F(StringReplaceOneCharWithString, 3, 1) \
241 F(StringMatch, 3, 1) \
242 F(StringTrim, 3, 1) \
243 F(StringToArray, 2, 1) \
244 F(NewStringWrapper, 1, 1) \
246 F(TruncateString, 2, 1) \
249 F(NumberToRadixString, 2, 1) \
250 F(NumberToFixed, 2, 1) \
251 F(NumberToExponential, 2, 1) \
252 F(NumberToPrecision, 2, 1) \
253 F(IsValidSmi, 1, 1) \
255 /* Classes support */ \
257 F(HomeObjectSymbol, 0, 1) \
258 F(ThrowNonMethodError, 0, 1) \
259 F(ThrowUnsupportedSuperError, 0, 1) \
260 F(LoadFromSuper, 3, 1)
263 #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
265 F(FunctionSetInstanceClassName, 2, 1) \
266 F(FunctionSetLength, 2, 1) \
267 F(FunctionSetPrototype, 2, 1) \
268 F(FunctionGetName, 1, 1) \
269 F(FunctionSetName, 2, 1) \
270 F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
271 F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
272 F(FunctionIsGenerator, 1, 1) \
273 F(FunctionIsArrow, 1, 1) \
274 F(FunctionIsConciseMethod, 1, 1) \
275 F(FunctionBindArguments, 4, 1) \
276 F(BoundFunctionGetBindings, 1, 1) \
277 F(FunctionRemovePrototype, 1, 1) \
278 F(FunctionGetSourceCode, 1, 1) \
279 F(FunctionGetScript, 1, 1) \
280 F(FunctionGetScriptSourcePosition, 1, 1) \
281 F(FunctionGetPositionForOffset, 2, 1) \
282 F(FunctionIsAPIFunction, 1, 1) \
283 F(FunctionIsBuiltin, 1, 1) \
285 F(CollectStackTrace, 2, 1) \
286 F(GetV8Version, 0, 1) \
287 F(GeneratorGetFunction, 1, 1) \
288 F(GeneratorGetContext, 1, 1) \
289 F(GeneratorGetReceiver, 1, 1) \
290 F(GeneratorGetContinuation, 1, 1) \
291 F(GeneratorGetSourcePosition, 1, 1) \
295 F(CreateApiFunction, 2, 1) \
296 F(IsTemplate, 1, 1) \
297 F(GetTemplateField, 2, 1) \
298 F(DisableAccessChecks, 1, 1) \
299 F(EnableAccessChecks, 1, 1) \
302 F(DateCurrentTime, 0, 1) \
303 F(DateParseString, 2, 1) \
304 F(DateLocalTimezone, 1, 1) \
306 F(DateMakeDay, 2, 1) \
307 F(DateSetValue, 3, 1) \
308 F(DateCacheVersion, 0, 1) \
310 /* Float32x4, Float64x2 and Int32x4 */ \
311 F(CreateFloat32x4, 4, 1) \
312 F(Float32x4GetX, 1, 1) \
313 F(Float32x4GetY, 1, 1) \
314 F(Float32x4GetZ, 1, 1) \
315 F(Float32x4GetW, 1, 1) \
316 F(Float32x4GetSignMask, 1, 1) \
317 F(CreateFloat64x2, 2, 1) \
318 F(Float64x2GetX, 1, 1) \
319 F(Float64x2GetY, 1, 1) \
320 F(Float64x2GetSignMask, 1, 1) \
321 F(CreateInt32x4, 4, 1) \
322 F(Int32x4GetX, 1, 1) \
323 F(Int32x4GetY, 1, 1) \
324 F(Int32x4GetZ, 1, 1) \
325 F(Int32x4GetW, 1, 1) \
326 F(Int32x4GetFlagX, 1, 1) \
327 F(Int32x4GetFlagY, 1, 1) \
328 F(Int32x4GetFlagZ, 1, 1) \
329 F(Int32x4GetFlagW, 1, 1) \
330 F(Int32x4GetSignMask, 1, 1) \
333 F(CompileString, 2, 1) \
336 F(GlobalProxy, 1, 1) \
337 F(IsAttachedGlobal, 1, 1) \
339 F(AddNamedProperty, 4, 1) \
340 F(AddPropertyForTemplate, 4, 1) \
341 F(SetProperty, 4, 1) \
342 F(AddElement, 4, 1) \
343 F(DefineApiAccessorProperty, 5, 1) \
344 F(DefineDataPropertyUnchecked, 4, 1) \
345 F(DefineAccessorPropertyUnchecked, 5, 1) \
346 F(GetDataProperty, 2, 1) \
347 F(SetHiddenProperty, 3, 1) \
350 F(RemoveArrayHoles, 2, 1) \
351 F(GetArrayKeys, 2, 1) \
352 F(MoveArrayContents, 2, 1) \
353 F(EstimateNumberOfElements, 1, 1) \
354 F(NormalizeElements, 1, 1) \
356 /* Getters and Setters */ \
357 F(LookupAccessor, 3, 1) \
360 F(ObjectFreeze, 1, 1) \
362 /* Harmony modules */ \
363 F(IsJSModule, 1, 1) \
365 /* Harmony symbols */ \
366 F(CreateSymbol, 1, 1) \
367 F(CreatePrivateSymbol, 1, 1) \
368 F(CreateGlobalPrivateOwnSymbol, 1, 1) \
369 F(CreatePrivateOwnSymbol, 1, 1) \
370 F(NewSymbolWrapper, 1, 1) \
371 F(SymbolDescription, 1, 1) \
372 F(SymbolRegistry, 0, 1) \
373 F(SymbolIsPrivate, 1, 1) \
375 /* Harmony proxies */ \
376 F(CreateJSProxy, 2, 1) \
377 F(CreateJSFunctionProxy, 4, 1) \
379 F(IsJSFunctionProxy, 1, 1) \
380 F(GetHandler, 1, 1) \
381 F(GetCallTrap, 1, 1) \
382 F(GetConstructTrap, 1, 1) \
386 F(SetInitialize, 1, 1) \
391 F(SetGetSize, 1, 1) \
393 F(SetIteratorInitialize, 3, 1) \
394 F(SetIteratorNext, 2, 1) \
397 F(MapInitialize, 1, 1) \
403 F(MapGetSize, 1, 1) \
405 F(MapIteratorInitialize, 3, 1) \
406 F(MapIteratorNext, 2, 1) \
408 /* Harmony weak maps and sets */ \
409 F(WeakCollectionInitialize, 1, 1) \
410 F(WeakCollectionGet, 2, 1) \
411 F(WeakCollectionHas, 2, 1) \
412 F(WeakCollectionDelete, 2, 1) \
413 F(WeakCollectionSet, 3, 1) \
415 F(GetWeakMapEntries, 1, 1) \
416 F(GetWeakSetValues, 1, 1) \
418 /* Harmony events */ \
419 F(EnqueueMicrotask, 1, 1) \
420 F(RunMicrotasks, 0, 1) \
422 /* Harmony observe */ \
423 F(IsObserved, 1, 1) \
424 F(SetIsObserved, 1, 1) \
425 F(GetObservationState, 0, 1) \
426 F(ObservationWeakMapCreate, 0, 1) \
427 F(ObserverObjectAndRecordHaveSameOrigin, 3, 1) \
428 F(ObjectWasCreatedInCurrentOrigin, 1, 1) \
429 F(GetObjectContextObjectObserve, 1, 1) \
430 F(GetObjectContextObjectGetNotifier, 1, 1) \
431 F(GetObjectContextNotifierPerformChange, 1, 1) \
433 /* Harmony typed arrays */ \
434 F(ArrayBufferInitialize, 2, 1) \
435 F(ArrayBufferSliceImpl, 3, 1) \
436 F(ArrayBufferIsView, 1, 1) \
437 F(ArrayBufferNeuter, 1, 1) \
439 F(TypedArrayInitializeFromArrayLike, 4, 1) \
440 F(TypedArrayGetBuffer, 1, 1) \
441 F(TypedArraySetFastCases, 3, 1) \
443 F(DataViewGetBuffer, 1, 1) \
444 F(DataViewGetInt8, 3, 1) \
445 F(DataViewGetUint8, 3, 1) \
446 F(DataViewGetInt16, 3, 1) \
447 F(DataViewGetUint16, 3, 1) \
448 F(DataViewGetInt32, 3, 1) \
449 F(DataViewGetUint32, 3, 1) \
450 F(DataViewGetFloat32, 3, 1) \
451 F(DataViewGetFloat64, 3, 1) \
453 F(DataViewSetInt8, 4, 1) \
454 F(DataViewSetUint8, 4, 1) \
455 F(DataViewSetInt16, 4, 1) \
456 F(DataViewSetUint16, 4, 1) \
457 F(DataViewSetInt32, 4, 1) \
458 F(DataViewSetUint32, 4, 1) \
459 F(DataViewSetFloat32, 4, 1) \
460 F(DataViewSetFloat64, 4, 1) \
463 F(NewObjectFromBound, 1, 1) \
465 /* Declarations and initialization */ \
466 F(InitializeVarGlobal, 3, 1) \
467 F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
470 F(DebugPrint, 1, 1) \
471 F(GlobalPrint, 1, 1) \
472 F(DebugTrace, 0, 1) \
473 F(TraceEnter, 0, 1) \
480 /* Message objects */ \
481 F(MessageGetStartPosition, 1, 1) \
482 F(MessageGetScript, 1, 1) \
484 /* Pseudo functions - handled as macros by parser */ \
487 /* expose boolean functions from objects-inl.h */ \
488 F(HasFastSmiElements, 1, 1) \
489 F(HasFastSmiOrObjectElements, 1, 1) \
490 F(HasFastObjectElements, 1, 1) \
491 F(HasFastDoubleElements, 1, 1) \
492 F(HasFastHoleyElements, 1, 1) \
493 F(HasDictionaryElements, 1, 1) \
494 F(HasSloppyArgumentsElements, 1, 1) \
495 F(HasExternalUint8ClampedElements, 1, 1) \
496 F(HasExternalArrayElements, 1, 1) \
497 F(HasExternalInt8Elements, 1, 1) \
498 F(HasExternalUint8Elements, 1, 1) \
499 F(HasExternalInt16Elements, 1, 1) \
500 F(HasExternalUint16Elements, 1, 1) \
501 F(HasExternalInt32Elements, 1, 1) \
502 F(HasExternalUint32Elements, 1, 1) \
503 F(HasExternalFloat32Elements, 1, 1) \
504 F(HasExternalFloat32x4Elements, 1, 1) \
505 F(HasExternalInt32x4Elements, 1, 1) \
506 F(HasExternalFloat64Elements, 1, 1) \
507 F(HasExternalFloat64x2Elements, 1, 1) \
508 F(HasFixedUint8ClampedElements, 1, 1) \
509 F(HasFixedInt8Elements, 1, 1) \
510 F(HasFixedUint8Elements, 1, 1) \
511 F(HasFixedInt16Elements, 1, 1) \
512 F(HasFixedUint16Elements, 1, 1) \
513 F(HasFixedInt32Elements, 1, 1) \
514 F(HasFixedUint32Elements, 1, 1) \
515 F(HasFixedFloat32Elements, 1, 1) \
516 F(HasFixedFloat64Elements, 1, 1) \
517 F(HasFastProperties, 1, 1) \
518 F(TransitionElementsKind, 2, 1) \
519 F(HaveSameMap, 2, 1) \
520 F(IsJSGlobalProxy, 1, 1) \
521 F(ForInInit, 2, 2) /* TODO(turbofan): Only temporary */ \
522 F(ForInNext, 4, 2) /* TODO(turbofan): Only temporary */ \
523 F(ForInCacheArrayLength, 2, 1) /* TODO(turbofan): Only temporary */
526 #define RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
527 /* String and Regexp */ \
528 F(NumberToStringRT, 1, 1) \
529 F(RegExpConstructResult, 3, 1) \
530 F(RegExpExecRT, 4, 1) \
533 F(InternalizeString, 1, 1) \
534 F(StringCompare, 2, 1) \
535 F(StringCharCodeAtRT, 2, 1) \
536 F(GetFromCache, 2, 1) \
539 F(CompileLazy, 1, 1) \
540 F(CompileOptimized, 2, 1) \
541 F(TryInstallOptimizedCode, 1, 1) \
542 F(NotifyDeoptimized, 1, 1) \
543 F(NotifyStubFailure, 0, 1) \
546 F(AllocateInNewSpace, 1, 1) \
547 F(AllocateInTargetSpace, 2, 1) \
548 F(AllocateHeapNumber, 0, 1) \
549 F(NumberToSmi, 1, 1) \
550 F(NumberToStringSkipCache, 1, 1) \
552 F(NewArguments, 1, 1) /* TODO(turbofan): Only temporary */ \
553 F(NewSloppyArguments, 3, 1) \
554 F(NewStrictArguments, 3, 1) \
556 /* Harmony generators */ \
557 F(CreateJSGeneratorObject, 0, 1) \
558 F(SuspendJSGeneratorObject, 1, 1) \
559 F(ResumeJSGeneratorObject, 3, 1) \
560 F(ThrowGeneratorStateError, 1, 1) \
563 F(ArrayConstructor, -1, 1) \
564 F(InternalArrayConstructor, -1, 1) \
567 F(MaterializeRegExpLiteral, 4, 1) \
568 F(CreateObjectLiteral, 4, 1) \
569 F(CreateArrayLiteral, 4, 1) \
570 F(CreateArrayLiteralStubBailout, 3, 1) \
573 F(NewClosure, 3, 1) \
574 F(NewClosureFromStubFailure, 1, 1) \
576 F(NewObjectWithAllocationSite, 2, 1) \
577 F(FinalizeInstanceSize, 1, 1) \
580 F(ThrowReferenceError, 1, 1) \
581 F(ThrowNotDateError, 0, 1) \
582 F(StackGuard, 0, 1) \
584 F(PromoteScheduledException, 0, 1) \
587 F(NewGlobalContext, 2, 1) \
588 F(NewFunctionContext, 1, 1) \
589 F(PushWithContext, 2, 1) \
590 F(PushCatchContext, 3, 1) \
591 F(PushBlockContext, 2, 1) \
592 F(PushModuleContext, 2, 1) \
593 F(DeleteLookupSlot, 2, 1) \
594 F(LoadLookupSlot, 2, 2) \
595 F(LoadLookupSlotNoReferenceError, 2, 2) \
596 F(StoreLookupSlot, 4, 1) \
598 /* Declarations and initialization */ \
599 F(DeclareGlobals, 3, 1) \
600 F(DeclareModules, 1, 1) \
601 F(DeclareLookupSlot, 4, 1) \
602 F(InitializeConstGlobal, 2, 1) \
603 F(InitializeLegacyConstLookupSlot, 3, 1) \
606 F(ResolvePossiblyDirectEval, 6, 2) \
609 F(MathPowSlow, 2, 1) \
613 #define RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
614 /* Debugger support*/ \
615 F(DebugBreak, 0, 1) \
616 F(SetDebugEventListener, 2, 1) \
618 F(DebugGetPropertyDetails, 2, 1) \
619 F(DebugGetProperty, 2, 1) \
620 F(DebugPropertyTypeFromDetails, 1, 1) \
621 F(DebugPropertyAttributesFromDetails, 1, 1) \
622 F(DebugPropertyIndexFromDetails, 1, 1) \
623 F(DebugNamedInterceptorPropertyValue, 2, 1) \
624 F(DebugIndexedInterceptorElementValue, 2, 1) \
625 F(CheckExecutionState, 1, 1) \
626 F(GetFrameCount, 1, 1) \
627 F(GetFrameDetails, 2, 1) \
628 F(GetScopeCount, 2, 1) \
629 F(GetStepInPositions, 2, 1) \
630 F(GetScopeDetails, 4, 1) \
631 F(GetAllScopesDetails, 4, 1) \
632 F(GetFunctionScopeCount, 1, 1) \
633 F(GetFunctionScopeDetails, 2, 1) \
634 F(SetScopeVariableValue, 6, 1) \
635 F(DebugPrintScopes, 0, 1) \
636 F(GetThreadCount, 1, 1) \
637 F(GetThreadDetails, 2, 1) \
638 F(SetDisableBreak, 1, 1) \
639 F(GetBreakLocations, 2, 1) \
640 F(SetFunctionBreakPoint, 3, 1) \
641 F(SetScriptBreakPoint, 4, 1) \
642 F(ClearBreakPoint, 1, 1) \
643 F(ChangeBreakOnException, 2, 1) \
644 F(IsBreakOnException, 1, 1) \
645 F(PrepareStep, 4, 1) \
646 F(ClearStepping, 0, 1) \
647 F(DebugEvaluate, 6, 1) \
648 F(DebugEvaluateGlobal, 4, 1) \
649 F(DebugGetLoadedScripts, 0, 1) \
650 F(DebugReferencedBy, 3, 1) \
651 F(DebugConstructedBy, 2, 1) \
652 F(DebugGetPrototype, 1, 1) \
653 F(DebugSetScriptSource, 2, 1) \
654 F(DebugCallbackSupportsStepping, 1, 1) \
655 F(SystemBreak, 0, 1) \
656 F(DebugDisassembleFunction, 1, 1) \
657 F(DebugDisassembleConstructor, 1, 1) \
658 F(FunctionGetInferredName, 1, 1) \
659 F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
660 F(LiveEditGatherCompileInfo, 2, 1) \
661 F(LiveEditReplaceScript, 3, 1) \
662 F(LiveEditReplaceFunctionCode, 2, 1) \
663 F(LiveEditFunctionSourceUpdated, 1, 1) \
664 F(LiveEditFunctionSetScript, 2, 1) \
665 F(LiveEditReplaceRefToNestedFunction, 3, 1) \
666 F(LiveEditPatchFunctionPositions, 2, 1) \
667 F(LiveEditCheckAndDropActivations, 2, 1) \
668 F(LiveEditCompareStrings, 2, 1) \
669 F(LiveEditRestartFrame, 2, 1) \
670 F(GetFunctionCodePositionFromSource, 2, 1) \
671 F(ExecuteInDebugContext, 2, 1) \
674 F(CollectGarbage, 1, 1) \
675 F(GetHeapUsage, 0, 1) \
678 #ifdef V8_I18N_SUPPORT
679 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
681 /* Standalone, helper methods. */ \
682 F(CanonicalizeLanguageTag, 1, 1) \
683 F(AvailableLocalesOf, 1, 1) \
684 F(GetDefaultICULocale, 0, 1) \
685 F(GetLanguageTagVariants, 1, 1) \
686 F(IsInitializedIntlObject, 1, 1) \
687 F(IsInitializedIntlObjectOfType, 2, 1) \
688 F(MarkAsInitializedIntlObjectOfType, 3, 1) \
689 F(GetImplFromInitializedIntlObject, 1, 1) \
691 /* Date format and parse. */ \
692 F(CreateDateTimeFormat, 3, 1) \
693 F(InternalDateFormat, 2, 1) \
694 F(InternalDateParse, 2, 1) \
696 /* Number format and parse. */ \
697 F(CreateNumberFormat, 3, 1) \
698 F(InternalNumberFormat, 2, 1) \
699 F(InternalNumberParse, 2, 1) \
702 F(CreateCollator, 3, 1) \
703 F(InternalCompare, 3, 1) \
705 /* String.prototype.normalize. */ \
706 F(StringNormalize, 2, 1) \
708 /* Break iterator. */ \
709 F(CreateBreakIterator, 3, 1) \
710 F(BreakIteratorAdoptText, 2, 1) \
711 F(BreakIteratorFirst, 1, 1) \
712 F(BreakIteratorNext, 1, 1) \
713 F(BreakIteratorCurrent, 1, 1) \
714 F(BreakIteratorBreakType, 1, 1) \
717 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
722 #define RUNTIME_FUNCTION_LIST_DEBUG(F) \
726 #define RUNTIME_FUNCTION_LIST_DEBUG(F)
729 // ----------------------------------------------------------------------------
730 // RUNTIME_FUNCTION_LIST defines all runtime functions accessed
731 // either directly by id (via the code generator), or indirectly
732 // via a native call by name (from within JS code).
733 // Entries have the form F(name, number of arguments, number of return values).
735 #define RUNTIME_FUNCTION_LIST(F) \
736 RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
737 RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
738 RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
739 RUNTIME_FUNCTION_LIST_DEBUG(F) \
740 RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
741 RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
743 // ----------------------------------------------------------------------------
744 // INLINE_FUNCTION_LIST defines all inlined functions accessed
745 // with a native call of the form %_name from within JS code.
746 // Entries have the form F(name, number of arguments, number of return values).
747 #define INLINE_FUNCTION_LIST(F) \
749 F(IsNonNegativeSmi, 1, 1) \
752 F(IsConstructCall, 0, 1) \
753 F(CallFunction, -1 /* receiver + n args + function */, 1) \
754 F(ArgumentsLength, 0, 1) \
757 F(SetValueOf, 2, 1) \
758 F(DateField, 2 /* date object, field index */, 1) \
759 F(StringCharFromCode, 1, 1) \
760 F(StringCharAt, 2, 1) \
761 F(OneByteSeqStringSetChar, 3, 1) \
762 F(TwoByteSeqStringSetChar, 3, 1) \
763 F(ObjectEquals, 2, 1) \
765 F(IsFunction, 1, 1) \
766 F(IsUndetectableObject, 1, 1) \
767 F(IsSpecObject, 1, 1) \
768 F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
770 F(IsMinusZero, 1, 1) \
771 F(HasCachedArrayIndex, 1, 1) \
772 F(GetCachedArrayIndex, 1, 1) \
773 F(FastOneByteArrayJoin, 2, 1) \
774 F(GeneratorNext, 2, 1) \
775 F(GeneratorThrow, 2, 1) \
776 F(DebugBreakInOptimizedCode, 0, 1) \
778 F(StringCharCodeAt, 2, 1) \
781 F(StringCompare, 2, 1) \
782 F(RegExpExec, 4, 1) \
783 F(RegExpConstructResult, 3, 1) \
784 F(GetFromCache, 2, 1) \
785 F(NumberToString, 1, 1) \
786 F(DebugIsActive, 0, 1)
789 // ----------------------------------------------------------------------------
790 // INLINE_OPTIMIZED_FUNCTION_LIST defines all inlined functions accessed
791 // with a native call of the form %_name from within JS code that also have
792 // a corresponding runtime function, that is called from non-optimized code.
793 // For the benefit of (fuzz) tests, the runtime version can also be called
794 // directly as %name (i.e. without the leading underscore).
795 // Entries have the form F(name, number of arguments, number of return values).
796 #define INLINE_OPTIMIZED_FUNCTION_LIST(F) \
798 F(TypedArrayInitialize, 5, 1) \
799 F(DataViewInitialize, 4, 1) \
801 F(TypedArrayMaxSizeInHeap, 0, 1) \
802 F(ArrayBufferViewGetByteLength, 1, 1) \
803 F(ArrayBufferViewGetByteOffset, 1, 1) \
804 F(TypedArrayGetLength, 1, 1) \
806 F(ArrayBufferGetByteLength, 1, 1) \
808 F(ConstructDouble, 2, 1) \
811 F(MathSqrtRT, 1, 1) \
815 //---------------------------------------------------------------------------
816 // Runtime provides access to all C++ runtime functions.
820 StaticResource<ConsStringIteratorOp>* string_iterator() {
821 return &string_iterator_;
823 unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
824 return &to_upper_mapping_;
826 unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
827 return &to_lower_mapping_;
829 ConsStringIteratorOp* string_iterator_compare_x() {
830 return &string_iterator_compare_x_;
832 ConsStringIteratorOp* string_iterator_compare_y() {
833 return &string_iterator_compare_y_;
835 ConsStringIteratorOp* string_locale_compare_it1() {
836 return &string_locale_compare_it1_;
838 ConsStringIteratorOp* string_locale_compare_it2() {
839 return &string_locale_compare_it2_;
844 // Non-reentrant string buffer for efficient general use in the runtime.
845 StaticResource<ConsStringIteratorOp> string_iterator_;
846 unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
847 unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
848 ConsStringIteratorOp string_iterator_compare_x_;
849 ConsStringIteratorOp string_iterator_compare_y_;
850 ConsStringIteratorOp string_locale_compare_it1_;
851 ConsStringIteratorOp string_locale_compare_it2_;
853 friend class Isolate;
854 friend class Runtime;
856 DISALLOW_COPY_AND_ASSIGN(RuntimeState);
860 class Runtime : public AllStatic {
863 #define F(name, nargs, ressize) k##name,
864 RUNTIME_FUNCTION_LIST(F)
865 INLINE_OPTIMIZED_FUNCTION_LIST(F)
867 #define F(name, nargs, ressize) kInline##name,
868 INLINE_FUNCTION_LIST(F)
870 #define F(name, nargs, ressize) kInlineOptimized##name,
871 INLINE_OPTIMIZED_FUNCTION_LIST(F)
874 kFirstInlineFunction = kInlineIsSmi
883 // Intrinsic function descriptor.
885 FunctionId function_id;
886 IntrinsicType intrinsic_type;
887 // The JS name of the function.
890 // The C++ (native) entry point. NULL if the function is inlined.
893 // The number of arguments expected. nargs is -1 if the function takes
894 // a variable number of arguments.
896 // Size of result. Most functions return a single pointer, size 1.
900 static const int kNotFound = -1;
902 // Add internalized strings for all the intrinsic function names to a
904 static void InitializeIntrinsicFunctionNames(Isolate* isolate,
905 Handle<NameDictionary> dict);
907 // Get the intrinsic function with the given name, which must be internalized.
908 static const Function* FunctionForName(Handle<String> name);
910 // Get the intrinsic function with the given FunctionId.
911 static const Function* FunctionForId(FunctionId id);
913 // Get the intrinsic function with the given function entry address.
914 static const Function* FunctionForEntry(Address ref);
916 // General-purpose helper functions for runtime system.
917 static int StringMatch(Isolate* isolate,
922 static bool IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch);
924 // TODO(1240886): Some of the following methods are *not* handle safe, but
925 // accept handle arguments. This seems fragile.
927 // Support getting the characters in a string using [] notation as
928 // in Firefox/SpiderMonkey, Safari and Opera.
929 MUST_USE_RESULT static MaybeHandle<Object> GetElementOrCharAt(
931 Handle<Object> object,
934 MUST_USE_RESULT static MaybeHandle<Object> SetObjectProperty(
935 Isolate* isolate, Handle<Object> object, Handle<Object> key,
936 Handle<Object> value, StrictMode strict_mode);
938 MUST_USE_RESULT static MaybeHandle<Object> DefineObjectProperty(
939 Handle<JSObject> object, Handle<Object> key, Handle<Object> value,
940 PropertyAttributes attr);
942 MUST_USE_RESULT static MaybeHandle<Object> DeleteObjectProperty(
944 Handle<JSReceiver> object,
946 JSReceiver::DeleteMode mode);
948 MUST_USE_RESULT static MaybeHandle<Object> HasObjectProperty(
950 Handle<JSReceiver> object,
953 MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
955 Handle<Object> object,
958 static void SetupArrayBuffer(Isolate* isolate,
959 Handle<JSArrayBuffer> array_buffer,
962 size_t allocated_length);
964 static bool SetupArrayBufferAllocatingData(
966 Handle<JSArrayBuffer> array_buffer,
967 size_t allocated_length,
968 bool initialize = true);
970 static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
972 static void FreeArrayBuffer(
974 JSArrayBuffer* phantom_array_buffer);
977 // arrayIds below should be synchromized with typedarray.js natives.
984 ARRAY_ID_FLOAT32 = 7,
985 ARRAY_ID_FLOAT64 = 8,
986 ARRAY_ID_UINT8_CLAMPED = 9,
987 ARRAY_ID_FLOAT32x4 = 10,
988 ARRAY_ID_FLOAT64x2 = 11,
989 ARRAY_ID_INT32x4 = 12,
990 ARRAY_ID_FIRST = ARRAY_ID_UINT8,
991 ARRAY_ID_LAST = ARRAY_ID_INT32x4
994 static void ArrayIdToTypeAndSize(int array_id,
995 ExternalArrayType *type,
996 ElementsKind* external_elements_kind,
997 ElementsKind* fixed_elements_kind,
998 size_t *element_size);
1000 // Used in runtime.cc and hydrogen's VisitArrayLiteral.
1001 MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
1003 Handle<FixedArray> literals,
1004 Handle<FixedArray> elements);
1008 //---------------------------------------------------------------------------
1009 // Constants used by interface to runtime functions.
1011 class AllocateDoubleAlignFlag: public BitField<bool, 0, 1> {};
1012 class AllocateTargetSpace: public BitField<AllocationSpace, 1, 3> {};
1014 class DeclareGlobalsEvalFlag: public BitField<bool, 0, 1> {};
1015 class DeclareGlobalsNativeFlag: public BitField<bool, 1, 1> {};
1016 class DeclareGlobalsStrictMode: public BitField<StrictMode, 2, 1> {};
1018 } } // namespace v8::internal
1020 #endif // V8_RUNTIME_H_