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 // * Each intrinsic is consistently exposed in JavaScript via 2 names:
16 // * %#name, which is always a runtime call.
17 // * %_#name, which can be inlined or just a runtime call, the compiler in
20 // * IntrinsicTypes are Runtime::RUNTIME and Runtime::INLINE, respectively.
22 // * IDs are Runtime::k##name and Runtime::kInline##name, respectively.
24 // * All intrinsics have a C++ implementation Runtime_##name.
26 // * Each compiler has an explicit list of intrisics it supports, falling back
27 // to a simple runtime call if necessary.
30 // Entries have the form F(name, number of arguments, number of values):
32 #define FOR_EACH_INTRINSIC_ARRAY(F) \
33 F(FinishArrayPrototypeSetup, 1, 1) \
34 F(SpecialArrayFunctions, 0, 1) \
35 F(TransitionElementsKind, 2, 1) \
36 F(PushIfAbsent, 2, 1) \
37 F(ArrayConcat, 1, 1) \
38 F(RemoveArrayHoles, 2, 1) \
39 F(MoveArrayContents, 2, 1) \
40 F(EstimateNumberOfElements, 1, 1) \
41 F(GetArrayKeys, 2, 1) \
42 F(ArrayConstructor, -1, 1) \
43 F(ArrayConstructorWithSubclassing, -1, 1) \
44 F(InternalArrayConstructor, -1, 1) \
45 F(NormalizeElements, 1, 1) \
46 F(GrowArrayElements, 2, 1) \
47 F(HasComplexElements, 1, 1) \
49 F(HasCachedArrayIndex, 1, 1) \
50 F(GetCachedArrayIndex, 1, 1) \
51 F(FixedArrayGet, 2, 1) \
52 F(FixedArraySet, 3, 1) \
53 F(FastOneByteArrayJoin, 2, 1)
56 #define FOR_EACH_INTRINSIC_ATOMICS(F) \
57 F(AtomicsCompareExchange, 4, 1) \
58 F(AtomicsLoad, 2, 1) \
59 F(AtomicsStore, 3, 1) \
65 F(AtomicsExchange, 3, 1) \
66 F(AtomicsIsLockFree, 1, 1)
69 #define FOR_EACH_INTRINSIC_FUTEX(F) \
70 F(AtomicsFutexWait, 4, 1) \
71 F(AtomicsFutexWake, 3, 1) \
72 F(AtomicsFutexWakeOrRequeue, 5, 1) \
73 F(AtomicsFutexNumWaitersForTesting, 2, 1)
76 #define FOR_EACH_INTRINSIC_CLASSES(F) \
77 F(ThrowNonMethodError, 0, 1) \
78 F(ThrowUnsupportedSuperError, 0, 1) \
79 F(ThrowConstructorNonCallableError, 0, 1) \
80 F(ThrowArrayNotSubclassableError, 0, 1) \
81 F(ThrowStaticPrototypeError, 0, 1) \
82 F(ThrowIfStaticPrototype, 1, 1) \
84 F(HomeObjectSymbol, 0, 1) \
85 F(DefineClass, 6, 1) \
86 F(DefineClassStrong, 6, 1) \
87 F(DefineClassMethod, 3, 1) \
88 F(ClassGetSourceCode, 1, 1) \
89 F(LoadFromSuper, 4, 1) \
90 F(LoadKeyedFromSuper, 4, 1) \
91 F(StoreToSuper_Strict, 4, 1) \
92 F(StoreToSuper_Sloppy, 4, 1) \
93 F(StoreKeyedToSuper_Strict, 4, 1) \
94 F(StoreKeyedToSuper_Sloppy, 4, 1) \
95 F(HandleStepInForDerivedConstructors, 1, 1) \
96 F(DefaultConstructorCallSuper, 2, 1)
99 #define FOR_EACH_INTRINSIC_COLLECTIONS(F) \
100 F(StringGetRawHashField, 1, 1) \
102 F(JSCollectionGetTable, 1, 1) \
103 F(GenericHash, 1, 1) \
104 F(SetInitialize, 1, 1) \
108 F(SetIteratorInitialize, 3, 1) \
109 F(SetIteratorClone, 1, 1) \
110 F(SetIteratorNext, 2, 1) \
111 F(SetIteratorDetails, 1, 1) \
112 F(MapInitialize, 1, 1) \
116 F(MapIteratorInitialize, 3, 1) \
117 F(MapIteratorClone, 1, 1) \
118 F(MapIteratorDetails, 1, 1) \
119 F(GetWeakMapEntries, 2, 1) \
120 F(MapIteratorNext, 2, 1) \
121 F(WeakCollectionInitialize, 1, 1) \
122 F(WeakCollectionGet, 3, 1) \
123 F(WeakCollectionHas, 3, 1) \
124 F(WeakCollectionDelete, 3, 1) \
125 F(WeakCollectionSet, 4, 1) \
126 F(GetWeakSetValues, 2, 1) \
127 F(ObservationWeakMapCreate, 0, 1)
130 #define FOR_EACH_INTRINSIC_COMPILER(F) \
131 F(CompileLazy, 1, 1) \
132 F(CompileOptimized, 2, 1) \
133 F(NotifyStubFailure, 0, 1) \
134 F(NotifyDeoptimized, 1, 1) \
135 F(CompileForOnStackReplacement, 1, 1) \
136 F(TryInstallOptimizedCode, 1, 1) \
137 F(CompileString, 2, 1) \
138 F(ResolvePossiblyDirectEval, 5, 1)
141 #define FOR_EACH_INTRINSIC_DATE(F) \
142 F(DateMakeDay, 2, 1) \
143 F(DateSetValue, 3, 1) \
145 F(ThrowNotDateError, 0, 1) \
146 F(DateCurrentTime, 0, 1) \
147 F(DateParseString, 2, 1) \
148 F(DateLocalTimezone, 1, 1) \
150 F(DateCacheVersion, 0, 1) \
151 F(DateField, 2 /* date object, field index */, 1)
154 #define FOR_EACH_INTRINSIC_DEBUG(F) \
155 F(HandleDebuggerStatement, 0, 1) \
156 F(DebugBreak, 0, 1) \
157 F(SetDebugEventListener, 2, 1) \
158 F(ScheduleBreak, 0, 1) \
159 F(DebugGetInternalProperties, 1, 1) \
160 F(DebugGetPropertyDetails, 2, 1) \
161 F(DebugGetProperty, 2, 1) \
162 F(DebugPropertyTypeFromDetails, 1, 1) \
163 F(DebugPropertyAttributesFromDetails, 1, 1) \
164 F(DebugPropertyIndexFromDetails, 1, 1) \
165 F(DebugNamedInterceptorPropertyValue, 2, 1) \
166 F(DebugIndexedInterceptorElementValue, 2, 1) \
167 F(CheckExecutionState, 1, 1) \
168 F(GetFrameCount, 1, 1) \
169 F(GetFrameDetails, 2, 1) \
170 F(GetScopeCount, 2, 1) \
171 F(GetStepInPositions, 2, 1) \
172 F(GetScopeDetails, 4, 1) \
173 F(GetAllScopesDetails, 4, 1) \
174 F(GetFunctionScopeCount, 1, 1) \
175 F(GetFunctionScopeDetails, 2, 1) \
176 F(SetScopeVariableValue, 6, 1) \
177 F(DebugPrintScopes, 0, 1) \
178 F(GetThreadCount, 1, 1) \
179 F(GetThreadDetails, 2, 1) \
180 F(SetDisableBreak, 1, 1) \
181 F(GetBreakLocations, 2, 1) \
182 F(SetFunctionBreakPoint, 3, 1) \
183 F(SetScriptBreakPoint, 4, 1) \
184 F(ClearBreakPoint, 1, 1) \
185 F(ChangeBreakOnException, 2, 1) \
186 F(IsBreakOnException, 1, 1) \
187 F(PrepareStep, 4, 1) \
188 F(ClearStepping, 0, 1) \
189 F(DebugEvaluate, 6, 1) \
190 F(DebugEvaluateGlobal, 4, 1) \
191 F(DebugGetLoadedScripts, 0, 1) \
192 F(DebugReferencedBy, 3, 1) \
193 F(DebugConstructedBy, 2, 1) \
194 F(DebugGetPrototype, 1, 1) \
195 F(DebugSetScriptSource, 2, 1) \
196 F(FunctionGetInferredName, 1, 1) \
197 F(GetFunctionCodePositionFromSource, 2, 1) \
198 F(ExecuteInDebugContext, 1, 1) \
199 F(GetDebugContext, 0, 1) \
200 F(CollectGarbage, 1, 1) \
201 F(GetHeapUsage, 0, 1) \
203 F(DebugCallbackSupportsStepping, 1, 1) \
204 F(DebugPrepareStepInIfStepping, 1, 1) \
205 F(DebugPushPromise, 2, 1) \
206 F(DebugPopPromise, 0, 1) \
207 F(DebugPromiseEvent, 1, 1) \
208 F(DebugAsyncTaskEvent, 1, 1) \
209 F(DebugIsActive, 0, 1) \
210 F(DebugBreakInOptimizedCode, 0, 1)
213 #define FOR_EACH_INTRINSIC_FORIN(F) \
215 F(ForInFilter, 2, 1) \
220 #define FOR_EACH_INTRINSIC_FUNCTION(F) \
221 F(IsSloppyModeFunction, 1, 1) \
222 F(FunctionGetName, 1, 1) \
223 F(FunctionSetName, 2, 1) \
224 F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
225 F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
226 F(FunctionIsArrow, 1, 1) \
227 F(FunctionIsConciseMethod, 1, 1) \
228 F(FunctionRemovePrototype, 1, 1) \
229 F(FunctionGetScript, 1, 1) \
230 F(FunctionGetSourceCode, 1, 1) \
231 F(FunctionGetScriptSourcePosition, 1, 1) \
232 F(FunctionGetPositionForOffset, 2, 1) \
233 F(FunctionSetInstanceClassName, 2, 1) \
234 F(FunctionSetLength, 2, 1) \
235 F(FunctionSetPrototype, 2, 1) \
236 F(FunctionIsAPIFunction, 1, 1) \
237 F(FunctionIsBuiltin, 1, 1) \
239 F(SetNativeFlag, 1, 1) \
240 F(ThrowStrongModeTooFewArguments, 0, 1) \
241 F(IsConstructor, 1, 1) \
242 F(SetForceInlineFlag, 1, 1) \
243 F(FunctionBindArguments, 4, 1) \
244 F(BoundFunctionGetBindings, 1, 1) \
245 F(NewObjectFromBound, 1, 1) \
246 F(Call, -1 /* >= 2 */, 1) \
248 F(GetFunctionDelegate, 1, 1) \
249 F(GetConstructorDelegate, 1, 1) \
250 F(GetOriginalConstructor, 0, 1) \
251 F(CallFunction, -1 /* receiver + n args + function */, 1) \
252 F(IsConstructCall, 0, 1) \
256 #define FOR_EACH_INTRINSIC_GENERATOR(F) \
257 F(CreateJSGeneratorObject, 0, 1) \
258 F(SuspendJSGeneratorObject, -1, 1) \
259 F(ResumeJSGeneratorObject, 3, 1) \
260 F(GeneratorClose, 1, 1) \
261 F(GeneratorGetFunction, 1, 1) \
262 F(GeneratorGetContext, 1, 1) \
263 F(GeneratorGetReceiver, 1, 1) \
264 F(GeneratorGetContinuation, 1, 1) \
265 F(GeneratorGetSourcePosition, 1, 1) \
266 F(FunctionIsGenerator, 1, 1) \
267 F(GeneratorNext, 2, 1) \
268 F(GeneratorThrow, 2, 1)
271 #ifdef V8_I18N_SUPPORT
272 #define FOR_EACH_INTRINSIC_I18N(F) \
273 F(CanonicalizeLanguageTag, 1, 1) \
274 F(AvailableLocalesOf, 1, 1) \
275 F(GetDefaultICULocale, 0, 1) \
276 F(GetLanguageTagVariants, 1, 1) \
277 F(IsInitializedIntlObject, 1, 1) \
278 F(IsInitializedIntlObjectOfType, 2, 1) \
279 F(MarkAsInitializedIntlObjectOfType, 3, 1) \
280 F(GetImplFromInitializedIntlObject, 1, 1) \
281 F(CreateDateTimeFormat, 3, 1) \
282 F(InternalDateFormat, 2, 1) \
283 F(InternalDateParse, 2, 1) \
284 F(CreateNumberFormat, 3, 1) \
285 F(InternalNumberFormat, 2, 1) \
286 F(InternalNumberParse, 2, 1) \
287 F(CreateCollator, 3, 1) \
288 F(InternalCompare, 3, 1) \
289 F(StringNormalize, 2, 1) \
290 F(CreateBreakIterator, 3, 1) \
291 F(BreakIteratorAdoptText, 2, 1) \
292 F(BreakIteratorFirst, 1, 1) \
293 F(BreakIteratorNext, 1, 1) \
294 F(BreakIteratorCurrent, 1, 1) \
295 F(BreakIteratorBreakType, 1, 1)
297 #define FOR_EACH_INTRINSIC_I18N(F)
301 #define FOR_EACH_INTRINSIC_INTERNAL(F) \
302 F(CheckIsBootstrapping, 0, 1) \
305 F(UnwindAndFindExceptionHandler, 0, 1) \
306 F(PromoteScheduledException, 0, 1) \
307 F(ThrowReferenceError, 1, 1) \
308 F(NewTypeError, 2, 1) \
309 F(NewSyntaxError, 2, 1) \
310 F(NewReferenceError, 2, 1) \
311 F(ThrowIteratorResultNotAnObject, 1, 1) \
312 F(ThrowStrongModeImplicitConversion, 0, 1) \
313 F(PromiseRejectEvent, 3, 1) \
314 F(PromiseRevokeReject, 1, 1) \
315 F(PromiseHasHandlerSymbol, 0, 1) \
316 F(StackGuard, 0, 1) \
318 F(AllocateInNewSpace, 1, 1) \
319 F(AllocateInTargetSpace, 2, 1) \
320 F(CollectStackTrace, 2, 1) \
321 F(RenderCallSite, 0, 1) \
322 F(GetFromCacheRT, 2, 1) \
323 F(MessageGetStartPosition, 1, 1) \
324 F(MessageGetScript, 1, 1) \
325 F(FormatMessageString, 4, 1) \
326 F(CallSiteGetFileNameRT, 3, 1) \
327 F(CallSiteGetFunctionNameRT, 3, 1) \
328 F(CallSiteGetScriptNameOrSourceUrlRT, 3, 1) \
329 F(CallSiteGetMethodNameRT, 3, 1) \
330 F(CallSiteGetLineNumberRT, 3, 1) \
331 F(CallSiteGetColumnNumberRT, 3, 1) \
332 F(CallSiteIsNativeRT, 3, 1) \
333 F(CallSiteIsToplevelRT, 3, 1) \
334 F(CallSiteIsEvalRT, 3, 1) \
335 F(CallSiteIsConstructorRT, 3, 1) \
337 F(GetFromCache, 2, 1) \
338 F(IncrementStatsCounter, 1, 1) \
341 F(HarmonyToString, 0, 1) \
342 F(GetTypeFeedbackVector, 1, 1) \
343 F(GetCallerJSFunction, 0, 1) \
344 F(GetCodeStubExportsObject, 0, 1)
347 #define FOR_EACH_INTRINSIC_JSON(F) \
348 F(QuoteJSONString, 1, 1) \
349 F(BasicJSONStringify, 1, 1) \
353 #define FOR_EACH_INTRINSIC_LITERALS(F) \
354 F(CreateObjectLiteral, 4, 1) \
355 F(CreateArrayLiteral, 4, 1) \
356 F(CreateArrayLiteralStubBailout, 3, 1) \
357 F(StoreArrayLiteralElement, 5, 1)
360 #define FOR_EACH_INTRINSIC_LIVEEDIT(F) \
361 F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
362 F(LiveEditGatherCompileInfo, 2, 1) \
363 F(LiveEditReplaceScript, 3, 1) \
364 F(LiveEditFunctionSourceUpdated, 1, 1) \
365 F(LiveEditReplaceFunctionCode, 2, 1) \
366 F(LiveEditFunctionSetScript, 2, 1) \
367 F(LiveEditReplaceRefToNestedFunction, 3, 1) \
368 F(LiveEditPatchFunctionPositions, 2, 1) \
369 F(LiveEditCheckAndDropActivations, 2, 1) \
370 F(LiveEditCompareStrings, 2, 1) \
371 F(LiveEditRestartFrame, 2, 1)
374 #define FOR_EACH_INTRINSIC_MATHS(F) \
381 F(ConstructDouble, 2, 1) \
387 F(MathPowSlow, 2, 1) \
389 F(RoundNumber, 1, 1) \
391 F(MathFround, 1, 1) \
396 #define FOR_EACH_INTRINSIC_NUMBERS(F) \
397 F(NumberToRadixString, 2, 1) \
398 F(NumberToFixed, 2, 1) \
399 F(NumberToExponential, 2, 1) \
400 F(NumberToPrecision, 2, 1) \
401 F(IsValidSmi, 1, 1) \
402 F(StringToNumber, 1, 1) \
403 F(StringParseInt, 2, 1) \
404 F(StringParseFloat, 1, 1) \
405 F(NumberToStringRT, 1, 1) \
406 F(NumberToStringSkipCache, 1, 1) \
407 F(NumberToInteger, 1, 1) \
408 F(NumberToIntegerMapMinusZero, 1, 1) \
409 F(NumberToJSUint32, 1, 1) \
410 F(NumberToJSInt32, 1, 1) \
411 F(NumberToSmi, 1, 1) \
415 F(NumberUnaryMinus, 1, 1) \
418 F(NumberImul, 2, 1) \
425 F(NumberEquals, 2, 1) \
426 F(NumberCompare, 3, 1) \
427 F(SmiLexicographicCompare, 2, 1) \
429 F(NumberToString, 1, 1) \
431 F(IsNonNegativeSmi, 1, 1) \
435 #define FOR_EACH_INTRINSIC_OBJECT(F) \
436 F(GetPrototype, 1, 1) \
437 F(InternalSetPrototype, 2, 1) \
438 F(SetPrototype, 2, 1) \
439 F(IsInPrototypeChain, 2, 1) \
440 F(GetOwnProperty, 2, 1) \
441 F(PreventExtensions, 1, 1) \
442 F(IsExtensible, 1, 1) \
443 F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
444 F(ObjectFreeze, 1, 1) \
445 F(ObjectSeal, 1, 1) \
446 F(GetProperty, 2, 1) \
447 F(GetPropertyStrong, 2, 1) \
448 F(KeyedGetProperty, 2, 1) \
449 F(KeyedGetPropertyStrong, 2, 1) \
450 F(LoadGlobalViaContext, 3, 1) \
451 F(StoreGlobalViaContext, 5, 1) \
452 F(AddNamedProperty, 4, 1) \
453 F(SetProperty, 4, 1) \
454 F(AddElement, 3, 1) \
455 F(AppendElement, 2, 1) \
456 F(DeleteProperty, 3, 1) \
457 F(HasOwnProperty, 2, 1) \
458 F(HasProperty, 2, 1) \
459 F(HasElement, 2, 1) \
460 F(IsPropertyEnumerable, 2, 1) \
461 F(GetPropertyNames, 1, 1) \
462 F(GetPropertyNamesFast, 1, 1) \
463 F(GetOwnPropertyNames, 2, 1) \
464 F(GetOwnElementNames, 1, 1) \
465 F(GetInterceptorInfo, 1, 1) \
466 F(GetNamedInterceptorPropertyNames, 1, 1) \
467 F(GetIndexedInterceptorElementNames, 1, 1) \
469 F(ToFastProperties, 1, 1) \
471 F(NewStringWrapper, 1, 1) \
472 F(AllocateHeapNumber, 0, 1) \
474 F(NewObjectWithAllocationSite, 3, 1) \
475 F(FinalizeInstanceSize, 1, 1) \
476 F(GlobalProxy, 1, 1) \
477 F(LookupAccessor, 3, 1) \
478 F(LoadMutableDouble, 2, 1) \
479 F(TryMigrateInstance, 1, 1) \
480 F(IsJSGlobalProxy, 1, 1) \
481 F(DefineAccessorPropertyUnchecked, 5, 1) \
482 F(DefineDataPropertyUnchecked, 4, 1) \
483 F(GetDataProperty, 2, 1) \
484 F(HasFastPackedElements, 1, 1) \
486 F(SetValueOf, 2, 1) \
487 F(JSValueGetValue, 1, 1) \
488 F(HeapObjectGetMap, 1, 1) \
489 F(MapGetInstanceType, 1, 1) \
490 F(ObjectEquals, 2, 1) \
492 F(IsUndetectableObject, 1, 1) \
493 F(IsSpecObject, 1, 1) \
496 F(DefineGetterPropertyUnchecked, 4, 1) \
497 F(DefineSetterPropertyUnchecked, 4, 1)
500 #define FOR_EACH_INTRINSIC_OBSERVE(F) \
501 F(IsObserved, 1, 1) \
502 F(SetIsObserved, 1, 1) \
503 F(EnqueueMicrotask, 1, 1) \
504 F(RunMicrotasks, 0, 1) \
505 F(DeliverObservationChangeRecords, 2, 1) \
506 F(GetObservationState, 0, 1) \
507 F(ObserverObjectAndRecordHaveSameOrigin, 3, 1) \
508 F(ObjectWasCreatedInCurrentOrigin, 1, 1) \
509 F(GetObjectContextObjectObserve, 1, 1) \
510 F(GetObjectContextObjectGetNotifier, 1, 1) \
511 F(GetObjectContextNotifierPerformChange, 1, 1)
514 #define FOR_EACH_INTRINSIC_PROXY(F) \
515 F(CreateJSProxy, 2, 1) \
516 F(CreateJSFunctionProxy, 4, 1) \
518 F(IsJSFunctionProxy, 1, 1) \
519 F(GetHandler, 1, 1) \
520 F(GetCallTrap, 1, 1) \
521 F(GetConstructTrap, 1, 1) \
525 #define FOR_EACH_INTRINSIC_REGEXP(F) \
526 F(StringReplaceGlobalRegExpWithString, 4, 1) \
527 F(StringSplit, 3, 1) \
528 F(RegExpExec, 4, 1) \
529 F(RegExpConstructResultRT, 3, 1) \
530 F(RegExpConstructResult, 3, 1) \
531 F(RegExpInitializeAndCompile, 3, 1) \
532 F(MaterializeRegExpLiteral, 4, 1) \
533 F(RegExpExecMultiple, 4, 1) \
534 F(RegExpExecReThrow, 4, 1) \
538 #define FOR_EACH_INTRINSIC_SCOPES(F) \
539 F(ThrowConstAssignError, 0, 1) \
540 F(DeclareGlobals, 3, 1) \
541 F(InitializeVarGlobal, 3, 1) \
542 F(InitializeConstGlobal, 2, 1) \
543 F(DeclareLookupSlot, 4, 1) \
544 F(InitializeLegacyConstLookupSlot, 3, 1) \
545 F(NewArguments, 1, 1) /* TODO(turbofan): Only temporary */ \
546 F(NewSloppyArguments, 3, 1) \
547 F(NewStrictArguments, 3, 1) \
548 F(NewRestParam, 4, 1) \
549 F(NewRestParamSlow, 2, 1) \
550 F(NewClosureFromStubFailure, 1, 1) \
551 F(NewClosure, 3, 1) \
552 F(NewScriptContext, 2, 1) \
553 F(NewFunctionContext, 1, 1) \
554 F(PushWithContext, 2, 1) \
555 F(PushCatchContext, 3, 1) \
556 F(PushBlockContext, 2, 1) \
557 F(IsJSModule, 1, 1) \
558 F(PushModuleContext, 2, 1) \
559 F(DeclareModules, 1, 1) \
560 F(DeleteLookupSlot, 2, 1) \
561 F(StoreLookupSlot, 4, 1) \
562 F(GetArgumentsProperty, 1, 1) \
563 F(ArgumentsLength, 0, 1) \
567 #define FOR_EACH_INTRINSIC_SIMD(F) \
568 F(CreateFloat32x4, 4, 1) \
569 F(NewFloat32x4Wrapper, 1, 1) \
570 F(Float32x4Check, 1, 1) \
571 F(Float32x4ExtractLane, 2, 1) \
572 F(Float32x4Equals, 2, 1) \
573 F(Float32x4SameValue, 2, 1) \
574 F(Float32x4SameValueZero, 2, 1)
577 #define FOR_EACH_INTRINSIC_STRINGS(F) \
578 F(StringReplaceOneCharWithString, 3, 1) \
579 F(StringIndexOf, 3, 1) \
580 F(StringLastIndexOf, 3, 1) \
581 F(StringLocaleCompare, 2, 1) \
582 F(SubStringRT, 3, 1) \
584 F(StringAddRT, 2, 1) \
586 F(InternalizeString, 1, 1) \
587 F(StringMatch, 3, 1) \
588 F(StringCharCodeAtRT, 2, 1) \
589 F(CharFromCode, 1, 1) \
590 F(StringCompareRT, 2, 1) \
591 F(StringCompare, 2, 1) \
592 F(StringBuilderConcat, 3, 1) \
593 F(StringBuilderJoin, 3, 1) \
594 F(SparseJoinWithSeparator, 3, 1) \
595 F(StringToArray, 2, 1) \
596 F(StringToLowerCase, 1, 1) \
597 F(StringToUpperCase, 1, 1) \
598 F(StringTrim, 3, 1) \
599 F(TruncateString, 2, 1) \
601 F(NewConsString, 4, 1) \
602 F(StringEquals, 2, 1) \
603 F(FlattenString, 1, 1) \
604 F(StringCharFromCode, 1, 1) \
605 F(StringCharAt, 2, 1) \
606 F(OneByteSeqStringGetChar, 2, 1) \
607 F(OneByteSeqStringSetChar, 3, 1) \
608 F(TwoByteSeqStringGetChar, 2, 1) \
609 F(TwoByteSeqStringSetChar, 3, 1) \
610 F(StringCharCodeAt, 2, 1) \
611 F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
612 F(StringGetLength, 1, 1)
615 #define FOR_EACH_INTRINSIC_SYMBOL(F) \
616 F(CreateSymbol, 1, 1) \
617 F(CreatePrivateSymbol, 1, 1) \
618 F(CreateGlobalPrivateSymbol, 1, 1) \
619 F(NewSymbolWrapper, 1, 1) \
620 F(SymbolDescription, 1, 1) \
621 F(SymbolRegistry, 0, 1) \
622 F(SymbolIsPrivate, 1, 1)
625 #define FOR_EACH_INTRINSIC_TEST(F) \
626 F(DeoptimizeFunction, 1, 1) \
627 F(DeoptimizeNow, 0, 1) \
628 F(RunningInSimulator, 0, 1) \
629 F(IsConcurrentRecompilationSupported, 0, 1) \
630 F(OptimizeFunctionOnNextCall, -1, 1) \
631 F(OptimizeOsr, -1, 1) \
632 F(NeverOptimizeFunction, 1, 1) \
633 F(GetOptimizationStatus, -1, 1) \
634 F(UnblockConcurrentRecompilation, 0, 1) \
635 F(GetOptimizationCount, 1, 1) \
636 F(GetUndetectable, 0, 1) \
637 F(ClearFunctionTypeFeedback, 1, 1) \
638 F(NotifyContextDisposed, 0, 1) \
639 F(SetAllocationTimeout, -1 /* 2 || 3 */, 1) \
640 F(DebugPrint, 1, 1) \
641 F(DebugTrace, 0, 1) \
642 F(GlobalPrint, 1, 1) \
643 F(SystemBreak, 0, 1) \
647 F(NativeScriptsCount, 0, 1) \
648 F(GetV8Version, 0, 1) \
649 F(DisassembleFunction, 1, 1) \
650 F(TraceEnter, 0, 1) \
652 F(HaveSameMap, 2, 1) \
653 F(HasFastSmiElements, 1, 1) \
654 F(HasFastObjectElements, 1, 1) \
655 F(HasFastSmiOrObjectElements, 1, 1) \
656 F(HasFastDoubleElements, 1, 1) \
657 F(HasFastHoleyElements, 1, 1) \
658 F(HasDictionaryElements, 1, 1) \
659 F(HasSloppyArgumentsElements, 1, 1) \
660 F(HasExternalArrayElements, 1, 1) \
661 F(HasFastProperties, 1, 1) \
662 F(HasExternalUint8Elements, 1, 1) \
663 F(HasExternalInt8Elements, 1, 1) \
664 F(HasExternalUint16Elements, 1, 1) \
665 F(HasExternalInt16Elements, 1, 1) \
666 F(HasExternalUint32Elements, 1, 1) \
667 F(HasExternalInt32Elements, 1, 1) \
668 F(HasExternalFloat32Elements, 1, 1) \
669 F(HasExternalFloat64Elements, 1, 1) \
670 F(HasExternalUint8ClampedElements, 1, 1) \
671 F(HasFixedUint8Elements, 1, 1) \
672 F(HasFixedInt8Elements, 1, 1) \
673 F(HasFixedUint16Elements, 1, 1) \
674 F(HasFixedInt16Elements, 1, 1) \
675 F(HasFixedUint32Elements, 1, 1) \
676 F(HasFixedInt32Elements, 1, 1) \
677 F(HasFixedFloat32Elements, 1, 1) \
678 F(HasFixedFloat64Elements, 1, 1) \
679 F(HasFixedUint8ClampedElements, 1, 1)
682 #define FOR_EACH_INTRINSIC_TYPEDARRAY(F) \
683 F(ArrayBufferInitialize, 3, 1) \
684 F(ArrayBufferGetByteLength, 1, 1) \
685 F(ArrayBufferSliceImpl, 3, 1) \
686 F(ArrayBufferIsView, 1, 1) \
687 F(ArrayBufferNeuter, 1, 1) \
688 F(TypedArrayInitialize, 6, 1) \
689 F(TypedArrayInitializeFromArrayLike, 4, 1) \
690 F(ArrayBufferViewGetByteLength, 1, 1) \
691 F(ArrayBufferViewGetByteOffset, 1, 1) \
692 F(TypedArrayGetLength, 1, 1) \
693 F(DataViewGetBuffer, 1, 1) \
694 F(TypedArrayGetBuffer, 1, 1) \
695 F(TypedArraySetFastCases, 3, 1) \
696 F(TypedArrayMaxSizeInHeap, 0, 1) \
697 F(IsTypedArray, 1, 1) \
698 F(IsSharedTypedArray, 1, 1) \
699 F(IsSharedIntegerTypedArray, 1, 1) \
700 F(DataViewInitialize, 4, 1) \
701 F(DataViewGetUint8, 3, 1) \
702 F(DataViewGetInt8, 3, 1) \
703 F(DataViewGetUint16, 3, 1) \
704 F(DataViewGetInt16, 3, 1) \
705 F(DataViewGetUint32, 3, 1) \
706 F(DataViewGetInt32, 3, 1) \
707 F(DataViewGetFloat32, 3, 1) \
708 F(DataViewGetFloat64, 3, 1) \
709 F(DataViewSetUint8, 4, 1) \
710 F(DataViewSetInt8, 4, 1) \
711 F(DataViewSetUint16, 4, 1) \
712 F(DataViewSetInt16, 4, 1) \
713 F(DataViewSetUint32, 4, 1) \
714 F(DataViewSetInt32, 4, 1) \
715 F(DataViewSetFloat32, 4, 1) \
716 F(DataViewSetFloat64, 4, 1)
719 #define FOR_EACH_INTRINSIC_URI(F) \
724 #define FOR_EACH_INTRINSIC_RETURN_PAIR(F) \
725 F(LoadLookupSlot, 2, 2) \
726 F(LoadLookupSlotNoReferenceError, 2, 2)
729 // Most intrinsics are implemented in the runtime/ directory, but ICs are
730 // implemented in ic.cc for now.
731 #define FOR_EACH_INTRINSIC_IC(F) \
732 F(LoadIC_Miss, 3, 1) \
733 F(KeyedLoadIC_Miss, 3, 1) \
734 F(CallIC_Miss, 3, 1) \
735 F(CallIC_Customization_Miss, 3, 1) \
736 F(StoreIC_Miss, 3, 1) \
737 F(StoreIC_Slow, 3, 1) \
738 F(KeyedStoreIC_Miss, 3, 1) \
739 F(KeyedStoreIC_Slow, 3, 1) \
740 F(StoreCallbackProperty, 5, 1) \
741 F(LoadPropertyWithInterceptorOnly, 3, 1) \
742 F(LoadPropertyWithInterceptor, 3, 1) \
743 F(LoadElementWithInterceptor, 2, 1) \
744 F(StorePropertyWithInterceptor, 3, 1) \
745 F(CompareIC_Miss, 3, 1) \
746 F(BinaryOpIC_Miss, 2, 1) \
747 F(CompareNilIC_Miss, 1, 1) \
748 F(Unreachable, 0, 1) \
749 F(ToBooleanIC_Miss, 1, 1) \
750 F(KeyedLoadIC_MissFromStubFailure, 4, 1) \
751 F(KeyedStoreIC_MissFromStubFailure, 3, 1) \
752 F(StoreIC_MissFromStubFailure, 3, 1) \
753 F(ElementsTransitionAndStoreIC_Miss, 4, 1) \
754 F(BinaryOpIC_MissWithAllocationSite, 3, 1) \
755 F(LoadIC_MissFromStubFailure, 0, 1)
758 #define FOR_EACH_INTRINSIC_RETURN_OBJECT(F) \
759 FOR_EACH_INTRINSIC_IC(F) \
760 FOR_EACH_INTRINSIC_ARRAY(F) \
761 FOR_EACH_INTRINSIC_ATOMICS(F) \
762 FOR_EACH_INTRINSIC_CLASSES(F) \
763 FOR_EACH_INTRINSIC_COLLECTIONS(F) \
764 FOR_EACH_INTRINSIC_COMPILER(F) \
765 FOR_EACH_INTRINSIC_DATE(F) \
766 FOR_EACH_INTRINSIC_DEBUG(F) \
767 FOR_EACH_INTRINSIC_FORIN(F) \
768 FOR_EACH_INTRINSIC_FUNCTION(F) \
769 FOR_EACH_INTRINSIC_FUTEX(F) \
770 FOR_EACH_INTRINSIC_GENERATOR(F) \
771 FOR_EACH_INTRINSIC_I18N(F) \
772 FOR_EACH_INTRINSIC_INTERNAL(F) \
773 FOR_EACH_INTRINSIC_JSON(F) \
774 FOR_EACH_INTRINSIC_LITERALS(F) \
775 FOR_EACH_INTRINSIC_LIVEEDIT(F) \
776 FOR_EACH_INTRINSIC_MATHS(F) \
777 FOR_EACH_INTRINSIC_NUMBERS(F) \
778 FOR_EACH_INTRINSIC_OBJECT(F) \
779 FOR_EACH_INTRINSIC_OBSERVE(F) \
780 FOR_EACH_INTRINSIC_PROXY(F) \
781 FOR_EACH_INTRINSIC_REGEXP(F) \
782 FOR_EACH_INTRINSIC_SCOPES(F) \
783 FOR_EACH_INTRINSIC_SIMD(F) \
784 FOR_EACH_INTRINSIC_STRINGS(F) \
785 FOR_EACH_INTRINSIC_SYMBOL(F) \
786 FOR_EACH_INTRINSIC_TEST(F) \
787 FOR_EACH_INTRINSIC_TYPEDARRAY(F) \
788 FOR_EACH_INTRINSIC_URI(F)
790 // FOR_EACH_INTRINSIC defines the list of all intrinsics, coming in 2 flavors,
791 // either returning an object or a pair.
792 #define FOR_EACH_INTRINSIC(F) \
793 FOR_EACH_INTRINSIC_RETURN_PAIR(F) \
794 FOR_EACH_INTRINSIC_RETURN_OBJECT(F)
797 #define F(name, nargs, ressize) \
798 Object* Runtime_##name(int args_length, Object** args_object, \
800 FOR_EACH_INTRINSIC_RETURN_OBJECT(F)
803 //---------------------------------------------------------------------------
804 // Runtime provides access to all C++ runtime functions.
808 unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
809 return &to_upper_mapping_;
811 unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
812 return &to_lower_mapping_;
817 unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
818 unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
820 friend class Isolate;
821 friend class Runtime;
823 DISALLOW_COPY_AND_ASSIGN(RuntimeState);
827 class JavaScriptFrameIterator; // Forward declaration.
830 class Runtime : public AllStatic {
833 #define F(name, nargs, ressize) k##name,
834 #define I(name, nargs, ressize) kInline##name,
835 FOR_EACH_INTRINSIC(F) FOR_EACH_INTRINSIC(I)
841 enum IntrinsicType { RUNTIME, INLINE };
843 // Intrinsic function descriptor.
845 FunctionId function_id;
846 IntrinsicType intrinsic_type;
847 // The JS name of the function.
850 // The C++ (native) entry point. NULL if the function is inlined.
853 // The number of arguments expected. nargs is -1 if the function takes
854 // a variable number of arguments.
856 // Size of result. Most functions return a single pointer, size 1.
860 static const int kNotFound = -1;
862 // Add internalized strings for all the intrinsic function names to a
864 static void InitializeIntrinsicFunctionNames(Isolate* isolate,
865 Handle<NameDictionary> dict);
867 // Get the intrinsic function with the given name, which must be internalized.
868 static const Function* FunctionForName(Handle<String> name);
870 // Get the intrinsic function with the given FunctionId.
871 static const Function* FunctionForId(FunctionId id);
873 // Get the intrinsic function with the given function entry address.
874 static const Function* FunctionForEntry(Address ref);
876 MUST_USE_RESULT static MaybeHandle<Object> DeleteObjectProperty(
877 Isolate* isolate, Handle<JSReceiver> receiver, Handle<Object> key,
878 LanguageMode language_mode);
880 MUST_USE_RESULT static MaybeHandle<Object> SetObjectProperty(
881 Isolate* isolate, Handle<Object> object, Handle<Object> key,
882 Handle<Object> value, LanguageMode language_mode);
884 MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
885 Isolate* isolate, Handle<Object> object, Handle<Object> key,
886 LanguageMode language_mode = SLOPPY);
888 MUST_USE_RESULT static MaybeHandle<Object> KeyedGetObjectProperty(
889 Isolate* isolate, Handle<Object> receiver_obj, Handle<Object> key_obj,
890 LanguageMode language_mode);
892 MUST_USE_RESULT static MaybeHandle<Object> GetPrototype(
893 Isolate* isolate, Handle<Object> object);
895 MUST_USE_RESULT static MaybeHandle<Name> ToName(Isolate* isolate,
898 static void SetupArrayBuffer(Isolate* isolate,
899 Handle<JSArrayBuffer> array_buffer,
900 bool is_external, void* data,
901 size_t allocated_length,
902 SharedFlag shared = SharedFlag::kNotShared);
904 static bool SetupArrayBufferAllocatingData(
905 Isolate* isolate, Handle<JSArrayBuffer> array_buffer,
906 size_t allocated_length, bool initialize = true,
907 SharedFlag shared = SharedFlag::kNotShared);
909 static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
911 static int FindIndexedNonNativeFrame(JavaScriptFrameIterator* it, int index);
914 // arrayIds below should be synchromized with typedarray.js natives.
921 ARRAY_ID_FLOAT32 = 7,
922 ARRAY_ID_FLOAT64 = 8,
923 ARRAY_ID_UINT8_CLAMPED = 9,
924 ARRAY_ID_FIRST = ARRAY_ID_UINT8,
925 ARRAY_ID_LAST = ARRAY_ID_UINT8_CLAMPED
928 static void ArrayIdToTypeAndSize(int array_id, ExternalArrayType* type,
929 ElementsKind* external_elements_kind,
930 ElementsKind* fixed_elements_kind,
931 size_t* element_size);
933 // Used in runtime.cc and hydrogen's VisitArrayLiteral.
934 MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
935 Isolate* isolate, Handle<FixedArray> literals,
936 Handle<FixedArray> elements, bool is_strong);
939 static void JSMapInitialize(Isolate* isolate, Handle<JSMap> map);
940 static void JSMapClear(Isolate* isolate, Handle<JSMap> map);
941 static void JSSetInitialize(Isolate* isolate, Handle<JSSet> set);
942 static void JSSetClear(Isolate* isolate, Handle<JSSet> set);
944 static void WeakCollectionInitialize(
945 Isolate* isolate, Handle<JSWeakCollection> weak_collection);
946 static void WeakCollectionSet(Handle<JSWeakCollection> weak_collection,
947 Handle<Object> key, Handle<Object> value,
949 static bool WeakCollectionDelete(Handle<JSWeakCollection> weak_collection,
951 static bool WeakCollectionDelete(Handle<JSWeakCollection> weak_collection,
952 Handle<Object> key, int32_t hash);
954 static MaybeHandle<JSArray> GetInternalProperties(Isolate* isolate,
957 static bool AtomicIsLockFree(uint32_t size);
961 std::ostream& operator<<(std::ostream&, Runtime::FunctionId);
963 //---------------------------------------------------------------------------
964 // Constants used by interface to runtime functions.
966 class AllocateDoubleAlignFlag : public BitField<bool, 0, 1> {};
967 class AllocateTargetSpace : public BitField<AllocationSpace, 1, 3> {};
969 class DeclareGlobalsEvalFlag : public BitField<bool, 0, 1> {};
970 class DeclareGlobalsNativeFlag : public BitField<bool, 1, 1> {};
971 STATIC_ASSERT(LANGUAGE_END == 3);
972 class DeclareGlobalsLanguageMode : public BitField<LanguageMode, 2, 2> {};
974 //---------------------------------------------------------------------------
977 // Assume that 32-bit architectures don't have 64-bit atomic ops.
978 // TODO(binji): can we do better here?
979 #if V8_TARGET_ARCH_64_BIT && V8_HOST_ARCH_64_BIT
981 #define ATOMICS_REQUIRE_LOCK_64_BIT 0
983 inline bool Runtime::AtomicIsLockFree(uint32_t size) {
984 return size == 1 || size == 2 || size == 4 || size == 8;
989 #define ATOMICS_REQUIRE_LOCK_64_BIT 1
991 inline bool Runtime::AtomicIsLockFree(uint32_t size) {
992 return size == 1 || size == 2 || size == 4;
997 } // namespace internal
1000 #endif // V8_RUNTIME_RUNTIME_H_