V8 Project
runtime.h
Go to the documentation of this file.
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.
4 
5 #ifndef V8_RUNTIME_H_
6 #define V8_RUNTIME_H_
7 
8 #include "src/allocation.h"
9 #include "src/zone.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 // The interface to C++ runtime functions.
15 
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.
20 
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) \
31  F(HasElement, 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) \
46  \
47  F(GetPrototype, 1, 1) \
48  F(SetPrototype, 2, 1) \
49  F(InternalSetPrototype, 2, 1) \
50  F(IsInPrototypeChain, 2, 1) \
51  \
52  F(GetOwnProperty, 2, 1) \
53  \
54  F(IsExtensible, 1, 1) \
55  F(PreventExtensions, 1, 1) \
56  \
57  /* Utilities */ \
58  F(CheckIsBootstrapping, 0, 1) \
59  F(GetRootNaN, 0, 1) \
60  F(Call, -1 /* >= 2 */, 1) \
61  F(Apply, 5, 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) \
88  \
89  /* Array join support */ \
90  F(PushIfAbsent, 2, 1) \
91  F(ArrayConcat, 1, 1) \
92  \
93  /* Conversions */ \
94  F(ToBool, 1, 1) \
95  F(Typeof, 1, 1) \
96  \
97  F(Booleanize, 2, 1) /* TODO(turbofan): Only temporary */ \
98  \
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) \
106  F(URIEscape, 1, 1) \
107  F(URIUnescape, 1, 1) \
108  \
109  F(NumberToInteger, 1, 1) \
110  F(NumberToIntegerMapMinusZero, 1, 1) \
111  F(NumberToJSUint32, 1, 1) \
112  F(NumberToJSInt32, 1, 1) \
113  \
114  /* Arithmetic operations */ \
115  F(NumberAdd, 2, 1) \
116  F(NumberSub, 2, 1) \
117  F(NumberMul, 2, 1) \
118  F(NumberDiv, 2, 1) \
119  F(NumberMod, 2, 1) \
120  F(NumberUnaryMinus, 1, 1) \
121  F(NumberImul, 2, 1) \
122  \
123  F(StringBuilderConcat, 3, 1) \
124  F(StringBuilderJoin, 3, 1) \
125  F(SparseJoinWithSeparator, 3, 1) \
126  \
127  /* Bit operations */ \
128  F(NumberOr, 2, 1) \
129  F(NumberAnd, 2, 1) \
130  F(NumberXor, 2, 1) \
131  \
132  F(NumberShl, 2, 1) \
133  F(NumberShr, 2, 1) \
134  F(NumberSar, 2, 1) \
135  \
136  /* Comparisons */ \
137  F(NumberEquals, 2, 1) \
138  F(StringEquals, 2, 1) \
139  \
140  F(NumberCompare, 3, 1) \
141  F(SmiLexicographicCompare, 2, 1) \
142  \
143  /* Math */ \
144  F(MathAcos, 1, 1) \
145  F(MathAsin, 1, 1) \
146  F(MathAtan, 1, 1) \
147  F(MathFloorRT, 1, 1) \
148  F(MathAtan2, 2, 1) \
149  F(MathExpRT, 1, 1) \
150  F(RoundNumber, 1, 1) \
151  F(MathFround, 1, 1) \
152  F(RemPiO2, 1, 1) \
153  \
154  /* Regular expressions */ \
155  F(RegExpCompile, 3, 1) \
156  F(RegExpExecMultiple, 4, 1) \
157  F(RegExpInitializeObject, 6, 1) \
158  \
159  /* JSON */ \
160  F(ParseJson, 1, 1) \
161  F(BasicJSONStringify, 1, 1) \
162  F(QuoteJSONString, 1, 1) \
163  \
164  /* Strings */ \
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) \
174  F(NewString, 2, 1) \
175  F(TruncateString, 2, 1) \
176  \
177  /* Numbers */ \
178  F(NumberToRadixString, 2, 1) \
179  F(NumberToFixed, 2, 1) \
180  F(NumberToExponential, 2, 1) \
181  F(NumberToPrecision, 2, 1) \
182  F(IsValidSmi, 1, 1) \
183  \
184  /* Classes support */ \
185  F(ToMethod, 2, 1) \
186  F(HomeObjectSymbol, 0, 1) \
187  F(ThrowNonMethodError, 0, 1) \
188  F(ThrowUnsupportedSuperError, 0, 1) \
189  F(LoadFromSuper, 3, 1) \
190  F(StoreToSuper_Strict, 4, 1) \
191  F(StoreToSuper_Sloppy, 4, 1)
192 
193 
194 #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
195  /* Reflection */ \
196  F(FunctionSetInstanceClassName, 2, 1) \
197  F(FunctionSetLength, 2, 1) \
198  F(FunctionSetPrototype, 2, 1) \
199  F(FunctionGetName, 1, 1) \
200  F(FunctionSetName, 2, 1) \
201  F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
202  F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
203  F(FunctionIsGenerator, 1, 1) \
204  F(FunctionIsArrow, 1, 1) \
205  F(FunctionIsConciseMethod, 1, 1) \
206  F(FunctionBindArguments, 4, 1) \
207  F(BoundFunctionGetBindings, 1, 1) \
208  F(FunctionRemovePrototype, 1, 1) \
209  F(FunctionGetSourceCode, 1, 1) \
210  F(FunctionGetScript, 1, 1) \
211  F(FunctionGetScriptSourcePosition, 1, 1) \
212  F(FunctionGetPositionForOffset, 2, 1) \
213  F(FunctionIsAPIFunction, 1, 1) \
214  F(FunctionIsBuiltin, 1, 1) \
215  F(GetScript, 1, 1) \
216  F(CollectStackTrace, 2, 1) \
217  F(GetV8Version, 0, 1) \
218  F(GeneratorGetFunction, 1, 1) \
219  F(GeneratorGetContext, 1, 1) \
220  F(GeneratorGetReceiver, 1, 1) \
221  F(GeneratorGetContinuation, 1, 1) \
222  F(GeneratorGetSourcePosition, 1, 1) \
223  \
224  F(SetCode, 2, 1) \
225  \
226  F(CreateApiFunction, 2, 1) \
227  F(IsTemplate, 1, 1) \
228  F(GetTemplateField, 2, 1) \
229  F(DisableAccessChecks, 1, 1) \
230  F(EnableAccessChecks, 1, 1) \
231  \
232  /* Dates */ \
233  F(DateCurrentTime, 0, 1) \
234  F(DateParseString, 2, 1) \
235  F(DateLocalTimezone, 1, 1) \
236  F(DateToUTC, 1, 1) \
237  F(DateMakeDay, 2, 1) \
238  F(DateSetValue, 3, 1) \
239  F(DateCacheVersion, 0, 1) \
240  \
241  /* Globals */ \
242  F(CompileString, 2, 1) \
243  \
244  /* Eval */ \
245  F(GlobalProxy, 1, 1) \
246  F(IsAttachedGlobal, 1, 1) \
247  \
248  F(AddNamedProperty, 4, 1) \
249  F(AddPropertyForTemplate, 4, 1) \
250  F(SetProperty, 4, 1) \
251  F(AddElement, 4, 1) \
252  F(DefineApiAccessorProperty, 5, 1) \
253  F(DefineDataPropertyUnchecked, 4, 1) \
254  F(DefineAccessorPropertyUnchecked, 5, 1) \
255  F(GetDataProperty, 2, 1) \
256  F(SetHiddenProperty, 3, 1) \
257  \
258  /* Arrays */ \
259  F(RemoveArrayHoles, 2, 1) \
260  F(GetArrayKeys, 2, 1) \
261  F(MoveArrayContents, 2, 1) \
262  F(EstimateNumberOfElements, 1, 1) \
263  F(NormalizeElements, 1, 1) \
264  \
265  /* Getters and Setters */ \
266  F(LookupAccessor, 3, 1) \
267  \
268  /* ES5 */ \
269  F(ObjectFreeze, 1, 1) \
270  \
271  /* Harmony modules */ \
272  F(IsJSModule, 1, 1) \
273  \
274  /* Harmony symbols */ \
275  F(CreateSymbol, 1, 1) \
276  F(CreatePrivateSymbol, 1, 1) \
277  F(CreateGlobalPrivateOwnSymbol, 1, 1) \
278  F(CreatePrivateOwnSymbol, 1, 1) \
279  F(NewSymbolWrapper, 1, 1) \
280  F(SymbolDescription, 1, 1) \
281  F(SymbolRegistry, 0, 1) \
282  F(SymbolIsPrivate, 1, 1) \
283  \
284  /* Harmony proxies */ \
285  F(CreateJSProxy, 2, 1) \
286  F(CreateJSFunctionProxy, 4, 1) \
287  F(IsJSProxy, 1, 1) \
288  F(IsJSFunctionProxy, 1, 1) \
289  F(GetHandler, 1, 1) \
290  F(GetCallTrap, 1, 1) \
291  F(GetConstructTrap, 1, 1) \
292  F(Fix, 1, 1) \
293  \
294  /* Harmony sets */ \
295  F(SetInitialize, 1, 1) \
296  F(SetAdd, 2, 1) \
297  F(SetHas, 2, 1) \
298  F(SetDelete, 2, 1) \
299  F(SetClear, 1, 1) \
300  F(SetGetSize, 1, 1) \
301  \
302  F(SetIteratorInitialize, 3, 1) \
303  F(SetIteratorNext, 2, 1) \
304  \
305  /* Harmony maps */ \
306  F(MapInitialize, 1, 1) \
307  F(MapGet, 2, 1) \
308  F(MapHas, 2, 1) \
309  F(MapDelete, 2, 1) \
310  F(MapClear, 1, 1) \
311  F(MapSet, 3, 1) \
312  F(MapGetSize, 1, 1) \
313  \
314  F(MapIteratorInitialize, 3, 1) \
315  F(MapIteratorNext, 2, 1) \
316  \
317  /* Harmony weak maps and sets */ \
318  F(WeakCollectionInitialize, 1, 1) \
319  F(WeakCollectionGet, 2, 1) \
320  F(WeakCollectionHas, 2, 1) \
321  F(WeakCollectionDelete, 2, 1) \
322  F(WeakCollectionSet, 3, 1) \
323  \
324  F(GetWeakMapEntries, 1, 1) \
325  F(GetWeakSetValues, 1, 1) \
326  \
327  /* Harmony events */ \
328  F(EnqueueMicrotask, 1, 1) \
329  F(RunMicrotasks, 0, 1) \
330  \
331  /* Harmony observe */ \
332  F(IsObserved, 1, 1) \
333  F(SetIsObserved, 1, 1) \
334  F(GetObservationState, 0, 1) \
335  F(ObservationWeakMapCreate, 0, 1) \
336  F(ObserverObjectAndRecordHaveSameOrigin, 3, 1) \
337  F(ObjectWasCreatedInCurrentOrigin, 1, 1) \
338  F(GetObjectContextObjectObserve, 1, 1) \
339  F(GetObjectContextObjectGetNotifier, 1, 1) \
340  F(GetObjectContextNotifierPerformChange, 1, 1) \
341  \
342  /* Harmony typed arrays */ \
343  F(ArrayBufferInitialize, 2, 1) \
344  F(ArrayBufferSliceImpl, 3, 1) \
345  F(ArrayBufferIsView, 1, 1) \
346  F(ArrayBufferNeuter, 1, 1) \
347  \
348  F(TypedArrayInitializeFromArrayLike, 4, 1) \
349  F(TypedArrayGetBuffer, 1, 1) \
350  F(TypedArraySetFastCases, 3, 1) \
351  \
352  F(DataViewGetBuffer, 1, 1) \
353  F(DataViewGetInt8, 3, 1) \
354  F(DataViewGetUint8, 3, 1) \
355  F(DataViewGetInt16, 3, 1) \
356  F(DataViewGetUint16, 3, 1) \
357  F(DataViewGetInt32, 3, 1) \
358  F(DataViewGetUint32, 3, 1) \
359  F(DataViewGetFloat32, 3, 1) \
360  F(DataViewGetFloat64, 3, 1) \
361  \
362  F(DataViewSetInt8, 4, 1) \
363  F(DataViewSetUint8, 4, 1) \
364  F(DataViewSetInt16, 4, 1) \
365  F(DataViewSetUint16, 4, 1) \
366  F(DataViewSetInt32, 4, 1) \
367  F(DataViewSetUint32, 4, 1) \
368  F(DataViewSetFloat32, 4, 1) \
369  F(DataViewSetFloat64, 4, 1) \
370  \
371  /* Statements */ \
372  F(NewObjectFromBound, 1, 1) \
373  \
374  /* Declarations and initialization */ \
375  F(InitializeVarGlobal, 3, 1) \
376  F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
377  \
378  /* Debugging */ \
379  F(DebugPrint, 1, 1) \
380  F(GlobalPrint, 1, 1) \
381  F(DebugTrace, 0, 1) \
382  F(TraceEnter, 0, 1) \
383  F(TraceExit, 1, 1) \
384  F(Abort, 1, 1) \
385  F(AbortJS, 1, 1) \
386  /* ES5 */ \
387  F(OwnKeys, 1, 1) \
388  \
389  /* Message objects */ \
390  F(MessageGetStartPosition, 1, 1) \
391  F(MessageGetScript, 1, 1) \
392  \
393  /* Pseudo functions - handled as macros by parser */ \
394  F(IS_VAR, 1, 1) \
395  \
396  /* expose boolean functions from objects-inl.h */ \
397  F(HasFastSmiElements, 1, 1) \
398  F(HasFastSmiOrObjectElements, 1, 1) \
399  F(HasFastObjectElements, 1, 1) \
400  F(HasFastDoubleElements, 1, 1) \
401  F(HasFastHoleyElements, 1, 1) \
402  F(HasDictionaryElements, 1, 1) \
403  F(HasSloppyArgumentsElements, 1, 1) \
404  F(HasExternalUint8ClampedElements, 1, 1) \
405  F(HasExternalArrayElements, 1, 1) \
406  F(HasExternalInt8Elements, 1, 1) \
407  F(HasExternalUint8Elements, 1, 1) \
408  F(HasExternalInt16Elements, 1, 1) \
409  F(HasExternalUint16Elements, 1, 1) \
410  F(HasExternalInt32Elements, 1, 1) \
411  F(HasExternalUint32Elements, 1, 1) \
412  F(HasExternalFloat32Elements, 1, 1) \
413  F(HasExternalFloat64Elements, 1, 1) \
414  F(HasFixedUint8ClampedElements, 1, 1) \
415  F(HasFixedInt8Elements, 1, 1) \
416  F(HasFixedUint8Elements, 1, 1) \
417  F(HasFixedInt16Elements, 1, 1) \
418  F(HasFixedUint16Elements, 1, 1) \
419  F(HasFixedInt32Elements, 1, 1) \
420  F(HasFixedUint32Elements, 1, 1) \
421  F(HasFixedFloat32Elements, 1, 1) \
422  F(HasFixedFloat64Elements, 1, 1) \
423  F(HasFastProperties, 1, 1) \
424  F(TransitionElementsKind, 2, 1) \
425  F(HaveSameMap, 2, 1) \
426  F(IsJSGlobalProxy, 1, 1) \
427  F(ForInCacheArrayLength, 2, 1) /* TODO(turbofan): Only temporary */
428 
429 
430 #define RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
431  /* String and Regexp */ \
432  F(NumberToStringRT, 1, 1) \
433  F(RegExpConstructResult, 3, 1) \
434  F(RegExpExecRT, 4, 1) \
435  F(StringAdd, 2, 1) \
436  F(SubString, 3, 1) \
437  F(InternalizeString, 1, 1) \
438  F(StringCompare, 2, 1) \
439  F(StringCharCodeAtRT, 2, 1) \
440  F(GetFromCache, 2, 1) \
441  \
442  /* Compilation */ \
443  F(CompileLazy, 1, 1) \
444  F(CompileOptimized, 2, 1) \
445  F(TryInstallOptimizedCode, 1, 1) \
446  F(NotifyDeoptimized, 1, 1) \
447  F(NotifyStubFailure, 0, 1) \
448  \
449  /* Utilities */ \
450  F(AllocateInNewSpace, 1, 1) \
451  F(AllocateInTargetSpace, 2, 1) \
452  F(AllocateHeapNumber, 0, 1) \
453  F(NumberToSmi, 1, 1) \
454  F(NumberToStringSkipCache, 1, 1) \
455  \
456  F(NewArguments, 1, 1) /* TODO(turbofan): Only temporary */ \
457  F(NewSloppyArguments, 3, 1) \
458  F(NewStrictArguments, 3, 1) \
459  \
460  /* Harmony generators */ \
461  F(CreateJSGeneratorObject, 0, 1) \
462  F(SuspendJSGeneratorObject, 1, 1) \
463  F(ResumeJSGeneratorObject, 3, 1) \
464  F(ThrowGeneratorStateError, 1, 1) \
465  \
466  /* Arrays */ \
467  F(ArrayConstructor, -1, 1) \
468  F(InternalArrayConstructor, -1, 1) \
469  \
470  /* Literals */ \
471  F(MaterializeRegExpLiteral, 4, 1) \
472  F(CreateObjectLiteral, 4, 1) \
473  F(CreateArrayLiteral, 4, 1) \
474  F(CreateArrayLiteralStubBailout, 3, 1) \
475  \
476  /* Statements */ \
477  F(NewClosure, 3, 1) \
478  F(NewClosureFromStubFailure, 1, 1) \
479  F(NewObject, 1, 1) \
480  F(NewObjectWithAllocationSite, 2, 1) \
481  F(FinalizeInstanceSize, 1, 1) \
482  F(Throw, 1, 1) \
483  F(ReThrow, 1, 1) \
484  F(ThrowReferenceError, 1, 1) \
485  F(ThrowNotDateError, 0, 1) \
486  F(StackGuard, 0, 1) \
487  F(Interrupt, 0, 1) \
488  F(PromoteScheduledException, 0, 1) \
489  \
490  /* Contexts */ \
491  F(NewGlobalContext, 2, 1) \
492  F(NewFunctionContext, 1, 1) \
493  F(PushWithContext, 2, 1) \
494  F(PushCatchContext, 3, 1) \
495  F(PushBlockContext, 2, 1) \
496  F(PushModuleContext, 2, 1) \
497  F(DeleteLookupSlot, 2, 1) \
498  F(StoreLookupSlot, 4, 1) \
499  \
500  /* Declarations and initialization */ \
501  F(DeclareGlobals, 3, 1) \
502  F(DeclareModules, 1, 1) \
503  F(DeclareLookupSlot, 4, 1) \
504  F(InitializeConstGlobal, 2, 1) \
505  F(InitializeLegacyConstLookupSlot, 3, 1) \
506  \
507  /* Maths */ \
508  F(MathPowSlow, 2, 1) \
509  F(MathPowRT, 2, 1)
510 
511 
512 #define RUNTIME_FUNCTION_LIST_RETURN_PAIR(F) \
513  F(LoadLookupSlot, 2, 2) \
514  F(LoadLookupSlotNoReferenceError, 2, 2) \
515  F(ResolvePossiblyDirectEval, 5, 2) \
516  F(ForInInit, 2, 2) /* TODO(turbofan): Only temporary */ \
517  F(ForInNext, 4, 2) /* TODO(turbofan): Only temporary */
518 
519 
520 #define RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
521  /* Debugger support*/ \
522  F(DebugBreak, 0, 1) \
523  F(SetDebugEventListener, 2, 1) \
524  F(Break, 0, 1) \
525  F(DebugGetPropertyDetails, 2, 1) \
526  F(DebugGetProperty, 2, 1) \
527  F(DebugPropertyTypeFromDetails, 1, 1) \
528  F(DebugPropertyAttributesFromDetails, 1, 1) \
529  F(DebugPropertyIndexFromDetails, 1, 1) \
530  F(DebugNamedInterceptorPropertyValue, 2, 1) \
531  F(DebugIndexedInterceptorElementValue, 2, 1) \
532  F(CheckExecutionState, 1, 1) \
533  F(GetFrameCount, 1, 1) \
534  F(GetFrameDetails, 2, 1) \
535  F(GetScopeCount, 2, 1) \
536  F(GetStepInPositions, 2, 1) \
537  F(GetScopeDetails, 4, 1) \
538  F(GetAllScopesDetails, 4, 1) \
539  F(GetFunctionScopeCount, 1, 1) \
540  F(GetFunctionScopeDetails, 2, 1) \
541  F(SetScopeVariableValue, 6, 1) \
542  F(DebugPrintScopes, 0, 1) \
543  F(GetThreadCount, 1, 1) \
544  F(GetThreadDetails, 2, 1) \
545  F(SetDisableBreak, 1, 1) \
546  F(GetBreakLocations, 2, 1) \
547  F(SetFunctionBreakPoint, 3, 1) \
548  F(SetScriptBreakPoint, 4, 1) \
549  F(ClearBreakPoint, 1, 1) \
550  F(ChangeBreakOnException, 2, 1) \
551  F(IsBreakOnException, 1, 1) \
552  F(PrepareStep, 4, 1) \
553  F(ClearStepping, 0, 1) \
554  F(DebugEvaluate, 6, 1) \
555  F(DebugEvaluateGlobal, 4, 1) \
556  F(DebugGetLoadedScripts, 0, 1) \
557  F(DebugReferencedBy, 3, 1) \
558  F(DebugConstructedBy, 2, 1) \
559  F(DebugGetPrototype, 1, 1) \
560  F(DebugSetScriptSource, 2, 1) \
561  F(DebugCallbackSupportsStepping, 1, 1) \
562  F(SystemBreak, 0, 1) \
563  F(DebugDisassembleFunction, 1, 1) \
564  F(DebugDisassembleConstructor, 1, 1) \
565  F(FunctionGetInferredName, 1, 1) \
566  F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
567  F(LiveEditGatherCompileInfo, 2, 1) \
568  F(LiveEditReplaceScript, 3, 1) \
569  F(LiveEditReplaceFunctionCode, 2, 1) \
570  F(LiveEditFunctionSourceUpdated, 1, 1) \
571  F(LiveEditFunctionSetScript, 2, 1) \
572  F(LiveEditReplaceRefToNestedFunction, 3, 1) \
573  F(LiveEditPatchFunctionPositions, 2, 1) \
574  F(LiveEditCheckAndDropActivations, 2, 1) \
575  F(LiveEditCompareStrings, 2, 1) \
576  F(LiveEditRestartFrame, 2, 1) \
577  F(GetFunctionCodePositionFromSource, 2, 1) \
578  F(ExecuteInDebugContext, 2, 1) \
579  \
580  F(SetFlags, 1, 1) \
581  F(CollectGarbage, 1, 1) \
582  F(GetHeapUsage, 0, 1)
583 
584 
585 #ifdef V8_I18N_SUPPORT
586 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
587  /* i18n support */ \
588  /* Standalone, helper methods. */ \
589  F(CanonicalizeLanguageTag, 1, 1) \
590  F(AvailableLocalesOf, 1, 1) \
591  F(GetDefaultICULocale, 0, 1) \
592  F(GetLanguageTagVariants, 1, 1) \
593  F(IsInitializedIntlObject, 1, 1) \
594  F(IsInitializedIntlObjectOfType, 2, 1) \
595  F(MarkAsInitializedIntlObjectOfType, 3, 1) \
596  F(GetImplFromInitializedIntlObject, 1, 1) \
597  \
598  /* Date format and parse. */ \
599  F(CreateDateTimeFormat, 3, 1) \
600  F(InternalDateFormat, 2, 1) \
601  F(InternalDateParse, 2, 1) \
602  \
603  /* Number format and parse. */ \
604  F(CreateNumberFormat, 3, 1) \
605  F(InternalNumberFormat, 2, 1) \
606  F(InternalNumberParse, 2, 1) \
607  \
608  /* Collator. */ \
609  F(CreateCollator, 3, 1) \
610  F(InternalCompare, 3, 1) \
611  \
612  /* String.prototype.normalize. */ \
613  F(StringNormalize, 2, 1) \
614  \
615  /* Break iterator. */ \
616  F(CreateBreakIterator, 3, 1) \
617  F(BreakIteratorAdoptText, 2, 1) \
618  F(BreakIteratorFirst, 1, 1) \
619  F(BreakIteratorNext, 1, 1) \
620  F(BreakIteratorCurrent, 1, 1) \
621  F(BreakIteratorBreakType, 1, 1)
622 
623 #else
624 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
625 #endif
626 
627 
628 #ifdef DEBUG
629 #define RUNTIME_FUNCTION_LIST_DEBUG(F) \
630  /* Testing */ \
631  F(ListNatives, 0, 1)
632 #else
633 #define RUNTIME_FUNCTION_LIST_DEBUG(F)
634 #endif
635 
636 // ----------------------------------------------------------------------------
637 // RUNTIME_FUNCTION_LIST defines all runtime functions accessed
638 // either directly by id (via the code generator), or indirectly
639 // via a native call by name (from within JS code).
640 // Entries have the form F(name, number of arguments, number of return values).
641 
642 #define RUNTIME_FUNCTION_LIST_RETURN_OBJECT(F) \
643  RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
644  RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
645  RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
646  RUNTIME_FUNCTION_LIST_DEBUG(F) \
647  RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
648  RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
649 
650 
651 #define RUNTIME_FUNCTION_LIST(F) \
652  RUNTIME_FUNCTION_LIST_RETURN_OBJECT(F) \
653  RUNTIME_FUNCTION_LIST_RETURN_PAIR(F)
654 
655 // ----------------------------------------------------------------------------
656 // INLINE_FUNCTION_LIST defines all inlined functions accessed
657 // with a native call of the form %_name from within JS code.
658 // Entries have the form F(name, number of arguments, number of return values).
659 #define INLINE_FUNCTION_LIST(F) \
660  F(IsSmi, 1, 1) \
661  F(IsNonNegativeSmi, 1, 1) \
662  F(IsArray, 1, 1) \
663  F(IsRegExp, 1, 1) \
664  F(IsConstructCall, 0, 1) \
665  F(CallFunction, -1 /* receiver + n args + function */, 1) \
666  F(ArgumentsLength, 0, 1) \
667  F(Arguments, 1, 1) \
668  F(ValueOf, 1, 1) \
669  F(SetValueOf, 2, 1) \
670  F(DateField, 2 /* date object, field index */, 1) \
671  F(StringCharFromCode, 1, 1) \
672  F(StringCharAt, 2, 1) \
673  F(OneByteSeqStringSetChar, 3, 1) \
674  F(TwoByteSeqStringSetChar, 3, 1) \
675  F(ObjectEquals, 2, 1) \
676  F(IsObject, 1, 1) \
677  F(IsFunction, 1, 1) \
678  F(IsUndetectableObject, 1, 1) \
679  F(IsSpecObject, 1, 1) \
680  F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
681  F(MathPow, 2, 1) \
682  F(IsMinusZero, 1, 1) \
683  F(HasCachedArrayIndex, 1, 1) \
684  F(GetCachedArrayIndex, 1, 1) \
685  F(FastOneByteArrayJoin, 2, 1) \
686  F(GeneratorNext, 2, 1) \
687  F(GeneratorThrow, 2, 1) \
688  F(DebugBreakInOptimizedCode, 0, 1) \
689  F(ClassOf, 1, 1) \
690  F(StringCharCodeAt, 2, 1) \
691  F(StringAdd, 2, 1) \
692  F(SubString, 3, 1) \
693  F(StringCompare, 2, 1) \
694  F(RegExpExec, 4, 1) \
695  F(RegExpConstructResult, 3, 1) \
696  F(GetFromCache, 2, 1) \
697  F(NumberToString, 1, 1) \
698  F(DebugIsActive, 0, 1)
699 
700 
701 // ----------------------------------------------------------------------------
702 // INLINE_OPTIMIZED_FUNCTION_LIST defines all inlined functions accessed
703 // with a native call of the form %_name from within JS code that also have
704 // a corresponding runtime function, that is called from non-optimized code.
705 // For the benefit of (fuzz) tests, the runtime version can also be called
706 // directly as %name (i.e. without the leading underscore).
707 // Entries have the form F(name, number of arguments, number of return values).
708 #define INLINE_OPTIMIZED_FUNCTION_LIST(F) \
709  /* Typed Arrays */ \
710  F(TypedArrayInitialize, 5, 1) \
711  F(DataViewInitialize, 4, 1) \
712  F(MaxSmi, 0, 1) \
713  F(TypedArrayMaxSizeInHeap, 0, 1) \
714  F(ArrayBufferViewGetByteLength, 1, 1) \
715  F(ArrayBufferViewGetByteOffset, 1, 1) \
716  F(TypedArrayGetLength, 1, 1) \
717  /* ArrayBuffer */ \
718  F(ArrayBufferGetByteLength, 1, 1) \
719  /* Maths */ \
720  F(ConstructDouble, 2, 1) \
721  F(DoubleHi, 1, 1) \
722  F(DoubleLo, 1, 1) \
723  F(MathSqrtRT, 1, 1) \
724  F(MathLogRT, 1, 1)
725 
726 
727 //---------------------------------------------------------------------------
728 // Runtime provides access to all C++ runtime functions.
729 
731  public:
733  return &string_iterator_;
734  }
736  return &to_upper_mapping_;
737  }
739  return &to_lower_mapping_;
740  }
743  }
746  }
749  }
752  }
753 
754  private:
756  // Non-reentrant string buffer for efficient general use in the runtime.
764 
765  friend class Isolate;
766  friend class Runtime;
767 
769 };
770 
771 
772 class Runtime : public AllStatic {
773  public:
774  enum FunctionId {
775 #define F(name, nargs, ressize) k##name,
777 #undef F
778 #define F(name, nargs, ressize) kInline##name,
780 #undef F
781 #define F(name, nargs, ressize) kInlineOptimized##name,
783 #undef F
784  kNumFunctions,
785  kFirstInlineFunction = kInlineIsSmi
786  };
787 
789 
790  // Intrinsic function descriptor.
791  struct Function {
794  // The JS name of the function.
795  const char* name;
796 
797  // The C++ (native) entry point. NULL if the function is inlined.
798  byte* entry;
799 
800  // The number of arguments expected. nargs is -1 if the function takes
801  // a variable number of arguments.
802  int nargs;
803  // Size of result. Most functions return a single pointer, size 1.
805  };
806 
807  static const int kNotFound = -1;
808 
809  // Add internalized strings for all the intrinsic function names to a
810  // StringDictionary.
811  static void InitializeIntrinsicFunctionNames(Isolate* isolate,
813 
814  // Get the intrinsic function with the given name, which must be internalized.
816 
817  // Get the intrinsic function with the given FunctionId.
818  static const Function* FunctionForId(FunctionId id);
819 
820  // Get the intrinsic function with the given function entry address.
821  static const Function* FunctionForEntry(Address ref);
822 
823  // General-purpose helper functions for runtime system.
824  static int StringMatch(Isolate* isolate, Handle<String> sub,
825  Handle<String> pat, int index);
826 
827  // TODO(1240886): Some of the following methods are *not* handle safe, but
828  // accept handle arguments. This seems fragile.
829 
830  // Support getting the characters in a string using [] notation as
831  // in Firefox/SpiderMonkey, Safari and Opera.
833  Isolate* isolate, Handle<Object> object, uint32_t index);
834 
836  Isolate* isolate, Handle<Object> object, Handle<Object> key,
837  Handle<Object> value, StrictMode strict_mode);
838 
841  PropertyAttributes attr);
842 
844  Isolate* isolate, Handle<JSReceiver> object, Handle<Object> key,
846 
848  Isolate* isolate, Handle<JSReceiver> object, Handle<Object> key);
849 
851  Isolate* isolate, Handle<Object> object, Handle<Object> key);
852 
853  static void SetupArrayBuffer(Isolate* isolate,
854  Handle<JSArrayBuffer> array_buffer,
855  bool is_external, void* data,
856  size_t allocated_length);
857 
858  static bool SetupArrayBufferAllocatingData(Isolate* isolate,
859  Handle<JSArrayBuffer> array_buffer,
860  size_t allocated_length,
861  bool initialize = true);
862 
863  static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
864 
865  static void FreeArrayBuffer(Isolate* isolate,
866  JSArrayBuffer* phantom_array_buffer);
867 
869  // arrayIds below should be synchromized with typedarray.js natives.
881  };
882 
883  static void ArrayIdToTypeAndSize(int array_id, ExternalArrayType* type,
884  ElementsKind* external_elements_kind,
885  ElementsKind* fixed_elements_kind,
886  size_t* element_size);
887 
888  // Used in runtime.cc and hydrogen's VisitArrayLiteral.
891  Handle<FixedArray> elements);
892 };
893 
894 
895 //---------------------------------------------------------------------------
896 // Constants used by interface to runtime functions.
897 
898 class AllocateDoubleAlignFlag : public BitField<bool, 0, 1> {};
899 class AllocateTargetSpace : public BitField<AllocationSpace, 1, 3> {};
900 
901 class DeclareGlobalsEvalFlag : public BitField<bool, 0, 1> {};
902 class DeclareGlobalsNativeFlag : public BitField<bool, 1, 1> {};
903 class DeclareGlobalsStrictMode : public BitField<StrictMode, 2, 1> {};
904 }
905 } // namespace v8::internal
906 
907 #endif // V8_RUNTIME_H_
unibrow::Mapping< unibrow::ToLowercase, 128 > to_lower_mapping_
Definition: runtime.h:759
ConsStringIteratorOp string_iterator_compare_y_
Definition: runtime.h:761
ConsStringIteratorOp * string_locale_compare_it2()
Definition: runtime.h:750
unibrow::Mapping< unibrow::ToUppercase, 128 > to_upper_mapping_
Definition: runtime.h:758
ConsStringIteratorOp * string_iterator_compare_y()
Definition: runtime.h:744
unibrow::Mapping< unibrow::ToUppercase, 128 > * to_upper_mapping()
Definition: runtime.h:735
ConsStringIteratorOp string_locale_compare_it2_
Definition: runtime.h:763
StaticResource< ConsStringIteratorOp > string_iterator_
Definition: runtime.h:757
ConsStringIteratorOp string_iterator_compare_x_
Definition: runtime.h:760
unibrow::Mapping< unibrow::ToLowercase, 128 > * to_lower_mapping()
Definition: runtime.h:738
ConsStringIteratorOp string_locale_compare_it1_
Definition: runtime.h:762
StaticResource< ConsStringIteratorOp > * string_iterator()
Definition: runtime.h:732
ConsStringIteratorOp * string_iterator_compare_x()
Definition: runtime.h:741
ConsStringIteratorOp * string_locale_compare_it1()
Definition: runtime.h:747
DISALLOW_COPY_AND_ASSIGN(RuntimeState)
static int StringMatch(Isolate *isolate, Handle< String > sub, Handle< String > pat, int index)
static const int kNotFound
Definition: runtime.h:807
static const Function * FunctionForId(FunctionId id)
Definition: runtime.cc:9312
static void InitializeIntrinsicFunctionNames(Isolate *isolate, Handle< NameDictionary > dict)
Definition: runtime.cc:9273
static MUST_USE_RESULT MaybeHandle< Object > HasObjectProperty(Isolate *isolate, Handle< JSReceiver > object, Handle< Object > key)
Definition: runtime.cc:1891
static MUST_USE_RESULT MaybeHandle< Object > SetObjectProperty(Isolate *isolate, Handle< Object > object, Handle< Object > key, Handle< Object > value, StrictMode strict_mode)
Definition: runtime.cc:2181
static void NeuterArrayBuffer(Handle< JSArrayBuffer > array_buffer)
static const Function * FunctionForEntry(Address ref)
Definition: runtime.cc:9302
static void SetupArrayBuffer(Isolate *isolate, Handle< JSArrayBuffer > array_buffer, bool is_external, void *data, size_t allocated_length)
static MUST_USE_RESULT MaybeHandle< Object > GetObjectProperty(Isolate *isolate, Handle< Object > object, Handle< Object > key)
Definition: runtime.cc:1912
static MUST_USE_RESULT MaybeHandle< Object > GetElementOrCharAt(Isolate *isolate, Handle< Object > object, uint32_t index)
Definition: runtime.cc:1850
static void ArrayIdToTypeAndSize(int array_id, ExternalArrayType *type, ElementsKind *external_elements_kind, ElementsKind *fixed_elements_kind, size_t *element_size)
static MUST_USE_RESULT MaybeHandle< Object > CreateArrayLiteralBoilerplate(Isolate *isolate, Handle< FixedArray > literals, Handle< FixedArray > elements)
Definition: runtime.cc:248
static const Function * FunctionForName(Handle< String > name)
Definition: runtime.cc:9290
static MUST_USE_RESULT MaybeHandle< Object > DefineObjectProperty(Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr)
Definition: runtime.cc:2277
static MUST_USE_RESULT MaybeHandle< Object > DeleteObjectProperty(Isolate *isolate, Handle< JSReceiver > object, Handle< Object > key, JSReceiver::DeleteMode mode)
Definition: runtime.cc:2328
static void FreeArrayBuffer(Isolate *isolate, JSArrayBuffer *phantom_array_buffer)
static bool SetupArrayBufferAllocatingData(Isolate *isolate, Handle< JSArrayBuffer > array_buffer, size_t allocated_length, bool initialize=true)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
enable harmony numeric literals(0o77, 0b11)") DEFINE_BOOL(harmony_object_literals
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
#define MUST_USE_RESULT
Definition: macros.h:266
byte * Address
Definition: globals.h:101
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20
ExternalArrayType
Definition: v8.h:2217
PropertyAttributes
#define INLINE_OPTIMIZED_FUNCTION_LIST(F)
Definition: runtime.h:708
#define INLINE_FUNCTION_LIST(F)
Definition: runtime.h:659
IntrinsicType intrinsic_type
Definition: runtime.h:793