v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
runtime.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_RUNTIME_H_
29 #define V8_RUNTIME_H_
30 
31 #include "allocation.h"
32 #include "zone.h"
33 
34 namespace v8 {
35 namespace internal {
36 
37 // The interface to C++ runtime functions.
38 
39 // ----------------------------------------------------------------------------
40 // RUNTIME_FUNCTION_LIST_ALWAYS defines runtime calls available in both
41 // release and debug mode.
42 // This macro should only be used by the macro RUNTIME_FUNCTION_LIST.
43 
44 // WARNING: RUNTIME_FUNCTION_LIST_ALWAYS_* is a very large macro that caused
45 // MSVC Intellisense to crash. It was broken into two macros to work around
46 // this problem. Please avoid large recursive macros whenever possible.
47 #define RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
48  /* Property access */ \
49  F(GetProperty, 2, 1) \
50  F(KeyedGetProperty, 2, 1) \
51  F(DeleteProperty, 3, 1) \
52  F(HasLocalProperty, 2, 1) \
53  F(HasProperty, 2, 1) \
54  F(HasElement, 2, 1) \
55  F(IsPropertyEnumerable, 2, 1) \
56  F(GetPropertyNames, 1, 1) \
57  F(GetPropertyNamesFast, 1, 1) \
58  F(GetLocalPropertyNames, 2, 1) \
59  F(GetLocalElementNames, 1, 1) \
60  F(GetInterceptorInfo, 1, 1) \
61  F(GetNamedInterceptorPropertyNames, 1, 1) \
62  F(GetIndexedInterceptorElementNames, 1, 1) \
63  F(GetArgumentsProperty, 1, 1) \
64  F(ToFastProperties, 1, 1) \
65  F(FinishArrayPrototypeSetup, 1, 1) \
66  F(SpecialArrayFunctions, 1, 1) \
67  F(IsSloppyModeFunction, 1, 1) \
68  F(GetDefaultReceiver, 1, 1) \
69  \
70  F(GetPrototype, 1, 1) \
71  F(SetPrototype, 2, 1) \
72  F(IsInPrototypeChain, 2, 1) \
73  \
74  F(GetOwnProperty, 2, 1) \
75  \
76  F(IsExtensible, 1, 1) \
77  F(PreventExtensions, 1, 1)\
78  \
79  /* Utilities */ \
80  F(CheckIsBootstrapping, 0, 1) \
81  F(GetRootNaN, 0, 1) \
82  F(Call, -1 /* >= 2 */, 1) \
83  F(Apply, 5, 1) \
84  F(GetFunctionDelegate, 1, 1) \
85  F(GetConstructorDelegate, 1, 1) \
86  F(DeoptimizeFunction, 1, 1) \
87  F(ClearFunctionTypeFeedback, 1, 1) \
88  F(RunningInSimulator, 0, 1) \
89  F(IsConcurrentRecompilationSupported, 0, 1) \
90  F(OptimizeFunctionOnNextCall, -1, 1) \
91  F(NeverOptimizeFunction, 1, 1) \
92  F(GetOptimizationStatus, -1, 1) \
93  F(GetOptimizationCount, 1, 1) \
94  F(UnblockConcurrentRecompilation, 0, 1) \
95  F(CompileForOnStackReplacement, 1, 1) \
96  F(SetAllocationTimeout, -1 /* 2 || 3 */, 1) \
97  F(SetNativeFlag, 1, 1) \
98  F(SetInlineBuiltinFlag, 1, 1) \
99  F(StoreArrayLiteralElement, 5, 1) \
100  F(DebugCallbackSupportsStepping, 1, 1) \
101  F(DebugPrepareStepInIfStepping, 1, 1) \
102  F(FlattenString, 1, 1) \
103  F(TryMigrateInstance, 1, 1) \
104  F(NotifyContextDisposed, 0, 1) \
105  \
106  /* Array join support */ \
107  F(PushIfAbsent, 2, 1) \
108  F(ArrayConcat, 1, 1) \
109  \
110  /* Conversions */ \
111  F(ToBool, 1, 1) \
112  F(Typeof, 1, 1) \
113  \
114  F(StringToNumber, 1, 1) \
115  F(StringParseInt, 2, 1) \
116  F(StringParseFloat, 1, 1) \
117  F(StringToLowerCase, 1, 1) \
118  F(StringToUpperCase, 1, 1) \
119  F(StringSplit, 3, 1) \
120  F(CharFromCode, 1, 1) \
121  F(URIEscape, 1, 1) \
122  F(URIUnescape, 1, 1) \
123  \
124  F(NumberToInteger, 1, 1) \
125  F(NumberToIntegerMapMinusZero, 1, 1) \
126  F(NumberToJSUint32, 1, 1) \
127  F(NumberToJSInt32, 1, 1) \
128  \
129  /* Arithmetic operations */ \
130  F(NumberAdd, 2, 1) \
131  F(NumberSub, 2, 1) \
132  F(NumberMul, 2, 1) \
133  F(NumberDiv, 2, 1) \
134  F(NumberMod, 2, 1) \
135  F(NumberUnaryMinus, 1, 1) \
136  F(NumberAlloc, 0, 1) \
137  F(NumberImul, 2, 1) \
138  \
139  F(StringBuilderConcat, 3, 1) \
140  F(StringBuilderJoin, 3, 1) \
141  F(SparseJoinWithSeparator, 3, 1) \
142  \
143  /* Bit operations */ \
144  F(NumberOr, 2, 1) \
145  F(NumberAnd, 2, 1) \
146  F(NumberXor, 2, 1) \
147  \
148  F(NumberShl, 2, 1) \
149  F(NumberShr, 2, 1) \
150  F(NumberSar, 2, 1) \
151  \
152  /* Comparisons */ \
153  F(NumberEquals, 2, 1) \
154  F(StringEquals, 2, 1) \
155  \
156  F(NumberCompare, 3, 1) \
157  F(SmiLexicographicCompare, 2, 1) \
158  \
159  /* Math */ \
160  F(Math_acos, 1, 1) \
161  F(Math_asin, 1, 1) \
162  F(Math_atan, 1, 1) \
163  F(Math_log, 1, 1) \
164  F(Math_sqrt, 1, 1) \
165  F(Math_exp, 1, 1) \
166  F(Math_floor, 1, 1) \
167  F(Math_pow, 2, 1) \
168  F(Math_pow_cfunction, 2, 1) \
169  F(Math_atan2, 2, 1) \
170  F(RoundNumber, 1, 1) \
171  F(Math_fround, 1, 1) \
172  \
173  /* Regular expressions */ \
174  F(RegExpCompile, 3, 1) \
175  F(RegExpExecMultiple, 4, 1) \
176  F(RegExpInitializeObject, 5, 1) \
177  \
178  /* JSON */ \
179  F(ParseJson, 1, 1) \
180  F(BasicJSONStringify, 1, 1) \
181  F(QuoteJSONString, 1, 1) \
182  \
183  /* Strings */ \
184  F(StringIndexOf, 3, 1) \
185  F(StringLastIndexOf, 3, 1) \
186  F(StringLocaleCompare, 2, 1) \
187  F(StringReplaceGlobalRegExpWithString, 4, 1) \
188  F(StringReplaceOneCharWithString, 3, 1) \
189  F(StringMatch, 3, 1) \
190  F(StringTrim, 3, 1) \
191  F(StringToArray, 2, 1) \
192  F(NewStringWrapper, 1, 1) \
193  F(NewString, 2, 1) \
194  F(TruncateString, 2, 1) \
195  \
196  /* Numbers */ \
197  F(NumberToRadixString, 2, 1) \
198  F(NumberToFixed, 2, 1) \
199  F(NumberToExponential, 2, 1) \
200  F(NumberToPrecision, 2, 1) \
201  F(IsValidSmi, 1, 1)
202 
203 
204 #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
205  /* Reflection */ \
206  F(FunctionSetInstanceClassName, 2, 1) \
207  F(FunctionSetLength, 2, 1) \
208  F(FunctionSetPrototype, 2, 1) \
209  F(FunctionSetReadOnlyPrototype, 1, 1) \
210  F(FunctionGetName, 1, 1) \
211  F(FunctionSetName, 2, 1) \
212  F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
213  F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
214  F(FunctionIsGenerator, 1, 1) \
215  F(FunctionBindArguments, 4, 1) \
216  F(BoundFunctionGetBindings, 1, 1) \
217  F(FunctionRemovePrototype, 1, 1) \
218  F(FunctionGetSourceCode, 1, 1) \
219  F(FunctionGetScript, 1, 1) \
220  F(FunctionGetScriptSourcePosition, 1, 1) \
221  F(FunctionGetPositionForOffset, 2, 1) \
222  F(FunctionIsAPIFunction, 1, 1) \
223  F(FunctionIsBuiltin, 1, 1) \
224  F(GetScript, 1, 1) \
225  F(CollectStackTrace, 3, 1) \
226  F(GetAndClearOverflowedStackTrace, 1, 1) \
227  F(GetV8Version, 0, 1) \
228  \
229  F(SetCode, 2, 1) \
230  F(SetExpectedNumberOfProperties, 2, 1) \
231  \
232  F(CreateApiFunction, 1, 1) \
233  F(IsTemplate, 1, 1) \
234  F(GetTemplateField, 2, 1) \
235  F(DisableAccessChecks, 1, 1) \
236  F(EnableAccessChecks, 1, 1) \
237  F(SetAccessorProperty, 6, 1) \
238  \
239  /* Dates */ \
240  F(DateCurrentTime, 0, 1) \
241  F(DateParseString, 2, 1) \
242  F(DateLocalTimezone, 1, 1) \
243  F(DateToUTC, 1, 1) \
244  F(DateMakeDay, 2, 1) \
245  F(DateSetValue, 3, 1) \
246  F(DateCacheVersion, 0, 1) \
247  \
248  /* Globals */ \
249  F(CompileString, 2, 1) \
250  \
251  /* Eval */ \
252  F(GlobalReceiver, 1, 1) \
253  F(IsAttachedGlobal, 1, 1) \
254  \
255  F(SetProperty, -1 /* 4 or 5 */, 1) \
256  F(DefineOrRedefineDataProperty, 4, 1) \
257  F(DefineOrRedefineAccessorProperty, 5, 1) \
258  F(IgnoreAttributesAndSetProperty, -1 /* 3 or 4 */, 1) \
259  F(GetDataProperty, 2, 1) \
260  F(SetHiddenProperty, 3, 1) \
261  \
262  /* Arrays */ \
263  F(RemoveArrayHoles, 2, 1) \
264  F(GetArrayKeys, 2, 1) \
265  F(MoveArrayContents, 2, 1) \
266  F(EstimateNumberOfElements, 1, 1) \
267  \
268  /* Getters and Setters */ \
269  F(LookupAccessor, 3, 1) \
270  \
271  /* ES5 */ \
272  F(ObjectFreeze, 1, 1) \
273  \
274  /* Harmony microtasks */ \
275  F(GetMicrotaskState, 0, 1) \
276  \
277  /* Harmony modules */ \
278  F(IsJSModule, 1, 1) \
279  \
280  /* Harmony symbols */ \
281  F(CreateSymbol, 1, 1) \
282  F(CreatePrivateSymbol, 1, 1) \
283  F(CreateGlobalPrivateSymbol, 1, 1) \
284  F(NewSymbolWrapper, 1, 1) \
285  F(SymbolDescription, 1, 1) \
286  F(SymbolRegistry, 0, 1) \
287  F(SymbolIsPrivate, 1, 1) \
288  \
289  /* Harmony proxies */ \
290  F(CreateJSProxy, 2, 1) \
291  F(CreateJSFunctionProxy, 4, 1) \
292  F(IsJSProxy, 1, 1) \
293  F(IsJSFunctionProxy, 1, 1) \
294  F(GetHandler, 1, 1) \
295  F(GetCallTrap, 1, 1) \
296  F(GetConstructTrap, 1, 1) \
297  F(Fix, 1, 1) \
298  \
299  /* Harmony sets */ \
300  F(SetInitialize, 1, 1) \
301  F(SetAdd, 2, 1) \
302  F(SetHas, 2, 1) \
303  F(SetDelete, 2, 1) \
304  F(SetGetSize, 1, 1) \
305  \
306  /* Harmony maps */ \
307  F(MapInitialize, 1, 1) \
308  F(MapGet, 2, 1) \
309  F(MapHas, 2, 1) \
310  F(MapDelete, 2, 1) \
311  F(MapSet, 3, 1) \
312  F(MapGetSize, 1, 1) \
313  \
314  /* Harmony weak maps and sets */ \
315  F(WeakCollectionInitialize, 1, 1) \
316  F(WeakCollectionGet, 2, 1) \
317  F(WeakCollectionHas, 2, 1) \
318  F(WeakCollectionDelete, 2, 1) \
319  F(WeakCollectionSet, 3, 1) \
320  \
321  /* Harmony events */ \
322  F(SetMicrotaskPending, 1, 1) \
323  F(RunMicrotasks, 0, 1) \
324  \
325  /* Harmony observe */ \
326  F(IsObserved, 1, 1) \
327  F(SetIsObserved, 1, 1) \
328  F(GetObservationState, 0, 1) \
329  F(ObservationWeakMapCreate, 0, 1) \
330  F(UnwrapGlobalProxy, 1, 1) \
331  F(IsAccessAllowedForObserver, 3, 1) \
332  \
333  /* Harmony typed arrays */ \
334  F(ArrayBufferInitialize, 2, 1)\
335  F(ArrayBufferGetByteLength, 1, 1)\
336  F(ArrayBufferSliceImpl, 3, 1) \
337  F(ArrayBufferIsView, 1, 1) \
338  F(ArrayBufferNeuter, 1, 1) \
339  \
340  F(TypedArrayInitializeFromArrayLike, 4, 1) \
341  F(TypedArrayGetBuffer, 1, 1) \
342  F(TypedArrayGetByteLength, 1, 1) \
343  F(TypedArrayGetByteOffset, 1, 1) \
344  F(TypedArrayGetLength, 1, 1) \
345  F(TypedArraySetFastCases, 3, 1) \
346  \
347  F(DataViewGetBuffer, 1, 1) \
348  F(DataViewGetByteLength, 1, 1) \
349  F(DataViewGetByteOffset, 1, 1) \
350  F(DataViewGetInt8, 3, 1) \
351  F(DataViewGetUint8, 3, 1) \
352  F(DataViewGetInt16, 3, 1) \
353  F(DataViewGetUint16, 3, 1) \
354  F(DataViewGetInt32, 3, 1) \
355  F(DataViewGetUint32, 3, 1) \
356  F(DataViewGetFloat32, 3, 1) \
357  F(DataViewGetFloat64, 3, 1) \
358  \
359  F(DataViewSetInt8, 4, 1) \
360  F(DataViewSetUint8, 4, 1) \
361  F(DataViewSetInt16, 4, 1) \
362  F(DataViewSetUint16, 4, 1) \
363  F(DataViewSetInt32, 4, 1) \
364  F(DataViewSetUint32, 4, 1) \
365  F(DataViewSetFloat32, 4, 1) \
366  F(DataViewSetFloat64, 4, 1) \
367  \
368  /* Statements */ \
369  F(NewObjectFromBound, 1, 1) \
370  \
371  /* Declarations and initialization */ \
372  F(InitializeVarGlobal, -1 /* 2 or 3 */, 1) \
373  F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
374  \
375  /* Debugging */ \
376  F(DebugPrint, 1, 1) \
377  F(GlobalPrint, 1, 1) \
378  F(DebugTrace, 0, 1) \
379  F(TraceEnter, 0, 1) \
380  F(TraceExit, 1, 1) \
381  F(Abort, 1, 1) \
382  F(AbortJS, 1, 1) \
383  /* ES5 */ \
384  F(LocalKeys, 1, 1) \
385  \
386  /* Message objects */ \
387  F(MessageGetStartPosition, 1, 1) \
388  F(MessageGetScript, 1, 1) \
389  \
390  /* Pseudo functions - handled as macros by parser */ \
391  F(IS_VAR, 1, 1) \
392  \
393  /* expose boolean functions from objects-inl.h */ \
394  F(HasFastSmiElements, 1, 1) \
395  F(HasFastSmiOrObjectElements, 1, 1) \
396  F(HasFastObjectElements, 1, 1) \
397  F(HasFastDoubleElements, 1, 1) \
398  F(HasFastHoleyElements, 1, 1) \
399  F(HasDictionaryElements, 1, 1) \
400  F(HasSloppyArgumentsElements, 1, 1) \
401  F(HasExternalUint8ClampedElements, 1, 1) \
402  F(HasExternalArrayElements, 1, 1) \
403  F(HasExternalInt8Elements, 1, 1) \
404  F(HasExternalUint8Elements, 1, 1) \
405  F(HasExternalInt16Elements, 1, 1) \
406  F(HasExternalUint16Elements, 1, 1) \
407  F(HasExternalInt32Elements, 1, 1) \
408  F(HasExternalUint32Elements, 1, 1) \
409  F(HasExternalFloat32Elements, 1, 1) \
410  F(HasExternalFloat64Elements, 1, 1) \
411  F(HasFixedUint8ClampedElements, 1, 1) \
412  F(HasFixedInt8Elements, 1, 1) \
413  F(HasFixedUint8Elements, 1, 1) \
414  F(HasFixedInt16Elements, 1, 1) \
415  F(HasFixedUint16Elements, 1, 1) \
416  F(HasFixedInt32Elements, 1, 1) \
417  F(HasFixedUint32Elements, 1, 1) \
418  F(HasFixedFloat32Elements, 1, 1) \
419  F(HasFixedFloat64Elements, 1, 1) \
420  F(HasFastProperties, 1, 1) \
421  F(TransitionElementsKind, 2, 1) \
422  F(HaveSameMap, 2, 1) \
423  F(IsAccessCheckNeeded, 1, 1)
424 
425 
426 #ifdef ENABLE_DEBUGGER_SUPPORT
427 #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \
428  /* Debugger support*/ \
429  F(DebugBreak, 0, 1) \
430  F(SetDebugEventListener, 2, 1) \
431  F(Break, 0, 1) \
432  F(DebugGetPropertyDetails, 2, 1) \
433  F(DebugGetProperty, 2, 1) \
434  F(DebugPropertyTypeFromDetails, 1, 1) \
435  F(DebugPropertyAttributesFromDetails, 1, 1) \
436  F(DebugPropertyIndexFromDetails, 1, 1) \
437  F(DebugNamedInterceptorPropertyValue, 2, 1) \
438  F(DebugIndexedInterceptorElementValue, 2, 1) \
439  F(CheckExecutionState, 1, 1) \
440  F(GetFrameCount, 1, 1) \
441  F(GetFrameDetails, 2, 1) \
442  F(GetScopeCount, 2, 1) \
443  F(GetStepInPositions, 2, 1) \
444  F(GetScopeDetails, 4, 1) \
445  F(GetAllScopesDetails, 4, 1) \
446  F(GetFunctionScopeCount, 1, 1) \
447  F(GetFunctionScopeDetails, 2, 1) \
448  F(SetScopeVariableValue, 6, 1) \
449  F(DebugPrintScopes, 0, 1) \
450  F(GetThreadCount, 1, 1) \
451  F(GetThreadDetails, 2, 1) \
452  F(SetDisableBreak, 1, 1) \
453  F(GetBreakLocations, 2, 1) \
454  F(SetFunctionBreakPoint, 3, 1) \
455  F(SetScriptBreakPoint, 4, 1) \
456  F(ClearBreakPoint, 1, 1) \
457  F(ChangeBreakOnException, 2, 1) \
458  F(IsBreakOnException, 1, 1) \
459  F(PrepareStep, 4, 1) \
460  F(ClearStepping, 0, 1) \
461  F(DebugEvaluate, 6, 1) \
462  F(DebugEvaluateGlobal, 4, 1) \
463  F(DebugGetLoadedScripts, 0, 1) \
464  F(DebugReferencedBy, 3, 1) \
465  F(DebugConstructedBy, 2, 1) \
466  F(DebugGetPrototype, 1, 1) \
467  F(DebugSetScriptSource, 2, 1) \
468  F(SystemBreak, 0, 1) \
469  F(DebugDisassembleFunction, 1, 1) \
470  F(DebugDisassembleConstructor, 1, 1) \
471  F(FunctionGetInferredName, 1, 1) \
472  F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
473  F(LiveEditGatherCompileInfo, 2, 1) \
474  F(LiveEditReplaceScript, 3, 1) \
475  F(LiveEditReplaceFunctionCode, 2, 1) \
476  F(LiveEditFunctionSourceUpdated, 1, 1) \
477  F(LiveEditFunctionSetScript, 2, 1) \
478  F(LiveEditReplaceRefToNestedFunction, 3, 1) \
479  F(LiveEditPatchFunctionPositions, 2, 1) \
480  F(LiveEditCheckAndDropActivations, 2, 1) \
481  F(LiveEditCompareStrings, 2, 1) \
482  F(LiveEditRestartFrame, 2, 1) \
483  F(GetFunctionCodePositionFromSource, 2, 1) \
484  F(ExecuteInDebugContext, 2, 1) \
485  \
486  F(SetFlags, 1, 1) \
487  F(CollectGarbage, 1, 1) \
488  F(GetHeapUsage, 0, 1) \
489 
490 #else
491 #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F)
492 #endif
493 
494 
495 #ifdef V8_I18N_SUPPORT
496 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
497  /* i18n support */ \
498  /* Standalone, helper methods. */ \
499  F(CanonicalizeLanguageTag, 1, 1) \
500  F(AvailableLocalesOf, 1, 1) \
501  F(GetDefaultICULocale, 0, 1) \
502  F(GetLanguageTagVariants, 1, 1) \
503  \
504  /* Date format and parse. */ \
505  F(CreateDateTimeFormat, 3, 1) \
506  F(InternalDateFormat, 2, 1) \
507  F(InternalDateParse, 2, 1) \
508  \
509  /* Number format and parse. */ \
510  F(CreateNumberFormat, 3, 1) \
511  F(InternalNumberFormat, 2, 1) \
512  F(InternalNumberParse, 2, 1) \
513  \
514  /* Collator. */ \
515  F(CreateCollator, 3, 1) \
516  F(InternalCompare, 3, 1) \
517  \
518  /* String.prototype.normalize. */ \
519  F(StringNormalize, 2, 1) \
520  \
521  /* Break iterator. */ \
522  F(CreateBreakIterator, 3, 1) \
523  F(BreakIteratorAdoptText, 2, 1) \
524  F(BreakIteratorFirst, 1, 1) \
525  F(BreakIteratorNext, 1, 1) \
526  F(BreakIteratorCurrent, 1, 1) \
527  F(BreakIteratorBreakType, 1, 1) \
528 
529 #else
530 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
531 #endif
532 
533 
534 #ifdef DEBUG
535 #define RUNTIME_FUNCTION_LIST_DEBUG(F) \
536  /* Testing */ \
537  F(ListNatives, 0, 1)
538 #else
539 #define RUNTIME_FUNCTION_LIST_DEBUG(F)
540 #endif
541 
542 // ----------------------------------------------------------------------------
543 // RUNTIME_FUNCTION_LIST defines all runtime functions accessed
544 // either directly by id (via the code generator), or indirectly
545 // via a native call by name (from within JS code).
546 // Entries have the form F(name, number of arguments, number of return values).
547 
548 #define RUNTIME_FUNCTION_LIST(F) \
549  RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
550  RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
551  RUNTIME_FUNCTION_LIST_DEBUG(F) \
552  RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \
553  RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
554 
555 // RUNTIME_HIDDEN_FUNCTION_LIST defines all runtime functions accessed
556 // by id from code generator, but not via native call by name.
557 // Entries have the form F(name, number of arguments, number of return values).
558 #define RUNTIME_HIDDEN_FUNCTION_LIST(F) \
559  F(NumberToString, 1, 1) \
560  F(RegExpConstructResult, 3, 1) \
561  F(RegExpExec, 4, 1) \
562  F(StringAdd, 2, 1) \
563  F(SubString, 3, 1) \
564  F(StringCompare, 2, 1) \
565  F(StringCharCodeAt, 2, 1) \
566  F(Log, 3, 1) \
567  F(GetFromCache, 2, 1) \
568  \
569  /* Compilation */ \
570  F(CompileUnoptimized, 1, 1) \
571  F(CompileOptimized, 2, 1) \
572  F(TryInstallOptimizedCode, 1, 1) \
573  F(NotifyDeoptimized, 1, 1) \
574  F(NotifyStubFailure, 0, 1) \
575  \
576  /* Utilities */ \
577  F(AllocateInNewSpace, 1, 1) \
578  F(AllocateInTargetSpace, 2, 1) \
579  F(AllocateHeapNumber, 0, 1) \
580  F(NumberToSmi, 1, 1) \
581  F(NumberToStringSkipCache, 1, 1) \
582  \
583  F(NewArgumentsFast, 3, 1) \
584  F(NewStrictArgumentsFast, 3, 1) \
585  \
586  /* Harmony generators */ \
587  F(CreateJSGeneratorObject, 0, 1) \
588  F(SuspendJSGeneratorObject, 1, 1) \
589  F(ResumeJSGeneratorObject, 3, 1) \
590  F(ThrowGeneratorStateError, 1, 1) \
591  \
592  /* Arrays */ \
593  F(ArrayConstructor, -1, 1) \
594  F(InternalArrayConstructor, -1, 1) \
595  \
596  /* Literals */ \
597  F(MaterializeRegExpLiteral, 4, 1)\
598  F(CreateObjectLiteral, 4, 1) \
599  F(CreateArrayLiteral, 4, 1) \
600  F(CreateArrayLiteralStubBailout, 3, 1) \
601  \
602  /* Statements */ \
603  F(NewClosure, 3, 1) \
604  F(NewClosureFromStubFailure, 1, 1) \
605  F(NewObject, 1, 1) \
606  F(NewObjectWithAllocationSite, 2, 1) \
607  F(FinalizeInstanceSize, 1, 1) \
608  F(Throw, 1, 1) \
609  F(ReThrow, 1, 1) \
610  F(ThrowReferenceError, 1, 1) \
611  F(ThrowNotDateError, 0, 1) \
612  F(ThrowMessage, 1, 1) \
613  F(StackGuard, 0, 1) \
614  F(Interrupt, 0, 1) \
615  F(PromoteScheduledException, 0, 1) \
616  \
617  /* Contexts */ \
618  F(NewGlobalContext, 2, 1) \
619  F(NewFunctionContext, 1, 1) \
620  F(PushWithContext, 2, 1) \
621  F(PushCatchContext, 3, 1) \
622  F(PushBlockContext, 2, 1) \
623  F(PushModuleContext, 2, 1) \
624  F(DeleteContextSlot, 2, 1) \
625  F(LoadContextSlot, 2, 2) \
626  F(LoadContextSlotNoReferenceError, 2, 2) \
627  F(StoreContextSlot, 4, 1) \
628  \
629  /* Declarations and initialization */ \
630  F(DeclareGlobals, 3, 1) \
631  F(DeclareModules, 1, 1) \
632  F(DeclareContextSlot, 4, 1) \
633  F(InitializeConstGlobal, 2, 1) \
634  F(InitializeConstContextSlot, 3, 1) \
635  \
636  /* Eval */ \
637  F(ResolvePossiblyDirectEval, 5, 2)
638 
639 // ----------------------------------------------------------------------------
640 // INLINE_FUNCTION_LIST defines all inlined functions accessed
641 // with a native call of the form %_name from within JS code.
642 // Entries have the form F(name, number of arguments, number of return values).
643 #define INLINE_FUNCTION_LIST(F) \
644  F(IsSmi, 1, 1) \
645  F(IsNonNegativeSmi, 1, 1) \
646  F(IsArray, 1, 1) \
647  F(IsRegExp, 1, 1) \
648  F(IsConstructCall, 0, 1) \
649  F(CallFunction, -1 /* receiver + n args + function */, 1) \
650  F(ArgumentsLength, 0, 1) \
651  F(Arguments, 1, 1) \
652  F(ValueOf, 1, 1) \
653  F(SetValueOf, 2, 1) \
654  F(DateField, 2 /* date object, field index */, 1) \
655  F(StringCharFromCode, 1, 1) \
656  F(StringCharAt, 2, 1) \
657  F(OneByteSeqStringSetChar, 3, 1) \
658  F(TwoByteSeqStringSetChar, 3, 1) \
659  F(ObjectEquals, 2, 1) \
660  F(IsObject, 1, 1) \
661  F(IsFunction, 1, 1) \
662  F(IsUndetectableObject, 1, 1) \
663  F(IsSpecObject, 1, 1) \
664  F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
665  F(MathPow, 2, 1) \
666  F(MathSqrt, 1, 1) \
667  F(MathLog, 1, 1) \
668  F(IsMinusZero, 1, 1) \
669  F(HasCachedArrayIndex, 1, 1) \
670  F(GetCachedArrayIndex, 1, 1) \
671  F(FastAsciiArrayJoin, 2, 1) \
672  F(GeneratorNext, 2, 1) \
673  F(GeneratorThrow, 2, 1) \
674  F(DebugBreakInOptimizedCode, 0, 1) \
675  F(ClassOf, 1, 1) \
676  F(StringCharCodeAt, 2, 1) \
677  F(Log, 3, 1) \
678  F(StringAdd, 2, 1) \
679  F(SubString, 3, 1) \
680  F(StringCompare, 2, 1) \
681  F(RegExpExec, 4, 1) \
682  F(RegExpConstructResult, 3, 1) \
683  F(GetFromCache, 2, 1) \
684  F(NumberToString, 1, 1)
685 
686 
687 // ----------------------------------------------------------------------------
688 // INLINE_OPTIMIZED_FUNCTION_LIST defines all inlined functions accessed
689 // with a native call of the form %_name from within JS code that also have
690 // a corresponding runtime function, that is called from non-optimized code.
691 // Entries have the form F(name, number of arguments, number of return values).
692 #define INLINE_OPTIMIZED_FUNCTION_LIST(F) \
693  F(DoubleHi, 1, 1) \
694  F(DoubleLo, 1, 1) \
695  F(ConstructDouble, 2, 1) \
696  F(TypedArrayInitialize, 5, 1) \
697  F(DataViewInitialize, 4, 1) \
698  F(MaxSmi, 0, 1) \
699  F(TypedArrayMaxSizeInHeap, 0, 1)
700 
701 
702 //---------------------------------------------------------------------------
703 // Runtime provides access to all C++ runtime functions.
704 
706  public:
708  return &string_iterator_;
709  }
711  return &to_upper_mapping_;
712  }
714  return &to_lower_mapping_;
715  }
717  return &string_iterator_compare_x_;
718  }
720  return &string_iterator_compare_y_;
721  }
723  return &string_locale_compare_it1_;
724  }
726  return &string_locale_compare_it2_;
727  }
728 
729  private:
730  RuntimeState() {}
731  // Non-reentrant string buffer for efficient general use in the runtime.
732  StaticResource<ConsStringIteratorOp> string_iterator_;
735  ConsStringIteratorOp string_iterator_compare_x_;
736  ConsStringIteratorOp string_iterator_compare_y_;
737  ConsStringIteratorOp string_locale_compare_it1_;
738  ConsStringIteratorOp string_locale_compare_it2_;
739 
740  friend class Isolate;
741  friend class Runtime;
742 
744 };
745 
746 
747 class Runtime : public AllStatic {
748  public:
749  enum FunctionId {
750 #define F(name, nargs, ressize) k##name,
752 #undef F
753 #define F(name, nargs, ressize) kHidden##name,
755 #undef F
756 #define F(name, nargs, ressize) kInline##name,
758 #undef F
759 #define F(name, nargs, ressize) kInlineOptimized##name,
761 #undef F
763  kFirstInlineFunction = kInlineIsSmi
764  };
765 
771  };
772 
773  // Intrinsic function descriptor.
774  struct Function {
777  // The JS name of the function.
778  const char* name;
779 
780  // The C++ (native) entry point. NULL if the function is inlined.
782 
783  // The number of arguments expected. nargs is -1 if the function takes
784  // a variable number of arguments.
785  int nargs;
786  // Size of result. Most functions return a single pointer, size 1.
788  };
789 
790  static const int kNotFound = -1;
791 
792  // Add internalized strings for all the intrinsic function names to a
793  // StringDictionary.
794  // Returns failure if an allocation fails. In this case, it must be
795  // retried with a new, empty StringDictionary, not with the same one.
796  // Alternatively, heap initialization can be completely restarted.
798  Heap* heap, Object* dictionary);
799 
800  // Get the intrinsic function with the given name, which must be internalized.
802 
803  // Get the intrinsic function with the given FunctionId.
804  static const Function* FunctionForId(FunctionId id);
805 
806  // General-purpose helper functions for runtime system.
807  static int StringMatch(Isolate* isolate,
808  Handle<String> sub,
809  Handle<String> pat,
810  int index);
811 
812  static bool IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch);
813 
814  // TODO(1240886): Some of the following methods are *not* handle safe, but
815  // accept handle arguments. This seems fragile.
816 
817  // Support getting the characters in a string using [] notation as
818  // in Firefox/SpiderMonkey, Safari and Opera.
819  static Handle<Object> GetElementOrCharAt(Isolate* isolate,
820  Handle<Object> object,
821  uint32_t index);
822 
824  Isolate* isolate,
825  Handle<Object> object,
826  Handle<Object> key,
827  Handle<Object> value,
828  PropertyAttributes attr,
829  StrictMode strict_mode);
830 
832  Isolate* isolate,
833  Handle<JSObject> object,
834  Handle<Object> key,
835  Handle<Object> value,
836  PropertyAttributes attr);
837 
838  MUST_USE_RESULT static MaybeObject* DeleteObjectProperty(
839  Isolate* isolate,
840  Handle<JSReceiver> object,
841  Handle<Object> key,
843 
844  MUST_USE_RESULT static MaybeObject* HasObjectProperty(
845  Isolate* isolate,
846  Handle<JSReceiver> object,
847  Handle<Object> key);
848 
849  MUST_USE_RESULT static MaybeObject* GetObjectProperty(
850  Isolate* isolate,
851  Handle<Object> object,
852  Handle<Object> key);
853 
854  MUST_USE_RESULT static MaybeObject* GetObjectPropertyOrFail(
855  Isolate* isolate,
856  Handle<Object> object,
857  Handle<Object> key);
858 
859  static void SetupArrayBuffer(Isolate* isolate,
860  Handle<JSArrayBuffer> array_buffer,
861  bool is_external,
862  void* data,
863  size_t allocated_length);
864 
865  static bool SetupArrayBufferAllocatingData(
866  Isolate* isolate,
867  Handle<JSArrayBuffer> array_buffer,
868  size_t allocated_length,
869  bool initialize = true);
870 
871  static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
872 
873  static void FreeArrayBuffer(
874  Isolate* isolate,
875  JSArrayBuffer* phantom_array_buffer);
876 
878  // arrayIds below should be synchromized with typedarray.js natives.
888  };
889 
890  static void ArrayIdToTypeAndSize(int array_id,
891  ExternalArrayType *type,
892  ElementsKind* external_elements_kind,
893  ElementsKind* fixed_elements_kind,
894  size_t *element_size);
895 
896  // Helper functions used stubs.
897  static void PerformGC(Object* result, Isolate* isolate);
898  static void OutOfMemory();
899 
900  // Used in runtime.cc and hydrogen's VisitArrayLiteral.
902  Isolate* isolate,
904  Handle<FixedArray> elements);
905 };
906 
907 
908 //---------------------------------------------------------------------------
909 // Constants used by interface to runtime functions.
910 
911 class AllocateDoubleAlignFlag: public BitField<bool, 0, 1> {};
912 class AllocateTargetSpace: public BitField<AllocationSpace, 1, 3> {};
913 
914 class DeclareGlobalsEvalFlag: public BitField<bool, 0, 1> {};
915 class DeclareGlobalsNativeFlag: public BitField<bool, 1, 1> {};
916 class DeclareGlobalsStrictMode: public BitField<StrictMode, 2, 1> {};
917 
918 } } // namespace v8::internal
919 
920 #endif // V8_RUNTIME_H_
#define INLINE_FUNCTION_LIST(F)
Definition: runtime.h:643
ConsStringIteratorOp * string_locale_compare_it2()
Definition: runtime.h:725
static const int kNotFound
Definition: runtime.h:790
ConsStringIteratorOp * string_iterator_compare_y()
Definition: runtime.h:719
static const Function * FunctionForName(Handle< String > name)
Definition: runtime.cc:15142
StaticResource< ConsStringIteratorOp > * string_iterator()
Definition: runtime.h:707
static const Function * FunctionForId(FunctionId id)
Definition: runtime.cc:15154
ExternalArrayType
Definition: v8.h:2113
unsigned short uint16_t
Definition: unicode.cc:46
static void NeuterArrayBuffer(Handle< JSArrayBuffer > array_buffer)
Definition: runtime.cc:820
PropertyAttributes
static MUST_USE_RESULT MaybeObject * HasObjectProperty(Isolate *isolate, Handle< JSReceiver > object, Handle< Object > key)
Definition: runtime.cc:4964
#define RUNTIME_FUNCTION_LIST(F)
Definition: runtime.h:548
static MUST_USE_RESULT MaybeObject * InitializeIntrinsicFunctionNames(Heap *heap, Object *dictionary)
Definition: runtime.cc:15114
uint8_t byte
Definition: globals.h:185
static MUST_USE_RESULT MaybeObject * DeleteObjectProperty(Isolate *isolate, Handle< JSReceiver > object, Handle< Object > key, JSReceiver::DeleteMode mode)
Definition: runtime.cc:5442
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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_string(expose_natives_as
ConsStringIteratorOp * string_iterator_compare_x()
Definition: runtime.h:716
#define MUST_USE_RESULT
Definition: globals.h:381
ConsStringIteratorOp * string_locale_compare_it1()
Definition: runtime.h:722
static void PerformGC(Object *result, Isolate *isolate)
Definition: runtime.cc:15159
static Handle< Object > ForceSetObjectProperty(Isolate *isolate, Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr)
Definition: runtime.cc:5387
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: globals.h:359
IntrinsicType intrinsic_type
Definition: runtime.h:776
static Handle< Object > GetElementOrCharAt(Isolate *isolate, Handle< Object > object, uint32_t index)
Definition: runtime.cc:4924
unibrow::Mapping< unibrow::ToUppercase, 128 > * to_upper_mapping()
Definition: runtime.h:710
static int StringMatch(Isolate *isolate, Handle< String > sub, Handle< String > pat, int index)
Definition: runtime.cc:4347
static bool IsUpperCaseChar(RuntimeState *runtime_state, uint16_t ch)
Definition: runtime.cc:6913
static Handle< Object > CreateArrayLiteralBoilerplate(Isolate *isolate, Handle< FixedArray > literals, Handle< FixedArray > elements)
Definition: runtime.cc:352
static MUST_USE_RESULT MaybeObject * GetObjectPropertyOrFail(Isolate *isolate, Handle< Object > object, Handle< Object > key)
Definition: runtime.cc:4982
static void SetupArrayBuffer(Isolate *isolate, Handle< JSArrayBuffer > array_buffer, bool is_external, void *data, size_t allocated_length)
Definition: runtime.cc:768
#define RUNTIME_HIDDEN_FUNCTION_LIST(F)
Definition: runtime.h:558
static MUST_USE_RESULT MaybeObject * GetObjectProperty(Isolate *isolate, Handle< Object > object, Handle< Object > key)
Definition: runtime.cc:4990
static bool SetupArrayBufferAllocatingData(Isolate *isolate, Handle< JSArrayBuffer > array_buffer, size_t allocated_length, bool initialize=true)
Definition: runtime.cc:793
static Handle< Object > SetObjectProperty(Isolate *isolate, Handle< Object > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr, StrictMode strict_mode)
Definition: runtime.cc:5283
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric literals(0o77, 0b11)") DEFINE_bool(harmony_strings
unibrow::Mapping< unibrow::ToLowercase, 128 > * to_lower_mapping()
Definition: runtime.h:713
static void ArrayIdToTypeAndSize(int array_id, ExternalArrayType *type, ElementsKind *external_elements_kind, ElementsKind *fixed_elements_kind, size_t *element_size)
Definition: runtime.cc:928
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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 expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
Definition: flags.cc:505
static void OutOfMemory()
Definition: runtime.cc:15180
static void FreeArrayBuffer(Isolate *isolate, JSArrayBuffer *phantom_array_buffer)
Definition: runtime.cc:748
#define INLINE_OPTIMIZED_FUNCTION_LIST(F)
Definition: runtime.h:692