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
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.
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.
31 #include "allocation.h"
37 // The interface to C++ runtime functions.
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.
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) \
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) \
70 F(GetPrototype, 1, 1) \
71 F(SetPrototype, 2, 1) \
72 F(IsInPrototypeChain, 2, 1) \
74 F(GetOwnProperty, 2, 1) \
76 F(IsExtensible, 1, 1) \
77 F(PreventExtensions, 1, 1)\
80 F(CheckIsBootstrapping, 0, 1) \
82 F(Call, -1 /* >= 2 */, 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) \
106 /* Array join support */ \
107 F(PushIfAbsent, 2, 1) \
108 F(ArrayConcat, 1, 1) \
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) \
122 F(URIUnescape, 1, 1) \
124 F(NumberToInteger, 1, 1) \
125 F(NumberToIntegerMapMinusZero, 1, 1) \
126 F(NumberToJSUint32, 1, 1) \
127 F(NumberToJSInt32, 1, 1) \
129 /* Arithmetic operations */ \
135 F(NumberUnaryMinus, 1, 1) \
136 F(NumberAlloc, 0, 1) \
137 F(NumberImul, 2, 1) \
139 F(StringBuilderConcat, 3, 1) \
140 F(StringBuilderJoin, 3, 1) \
141 F(SparseJoinWithSeparator, 3, 1) \
143 /* Bit operations */ \
153 F(NumberEquals, 2, 1) \
154 F(StringEquals, 2, 1) \
156 F(NumberCompare, 3, 1) \
157 F(SmiLexicographicCompare, 2, 1) \
166 F(Math_floor, 1, 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) \
173 /* Float32x4 and Int32x4 */ \
174 F(AllocateFloat32x4, 0, 1) \
175 F(AllocateInt32x4, 0, 1) \
178 F(Float32x4Abs, 1, 1) \
179 F(Float32x4BitsToInt32x4, 1, 1) \
180 F(Float32x4Neg, 1, 1) \
181 F(Float32x4Reciprocal, 1, 1) \
182 F(Float32x4ReciprocalSqrt, 1, 1) \
183 F(Float32x4Sqrt, 1, 1) \
184 F(Float32x4ToInt32x4, 1, 1) \
185 F(Float32x4Add, 2, 1) \
186 F(Float32x4Div, 2, 1) \
187 F(Float32x4Max, 2, 1) \
188 F(Float32x4Min, 2, 1) \
189 F(Float32x4Mul, 2, 1) \
190 F(Float32x4Sub, 2, 1) \
191 F(Float32x4Equal, 2, 1) \
192 F(Float32x4NotEqual, 2, 1) \
193 F(Float32x4GreaterThanOrEqual, 2, 1) \
194 F(Float32x4GreaterThan, 2, 1) \
195 F(Float32x4LessThan, 2, 1) \
196 F(Float32x4LessThanOrEqual, 2, 1) \
197 F(Float32x4Shuffle, 2, 1) \
198 F(Float32x4Scale, 2, 1) \
199 F(Float32x4WithX, 2, 1) \
200 F(Float32x4WithY, 2, 1) \
201 F(Float32x4WithZ, 2, 1) \
202 F(Float32x4WithW, 2, 1) \
203 F(Float32x4Clamp, 3, 1) \
204 F(Float32x4ShuffleMix, 3, 1) \
205 F(Int32x4BitsToFloat32x4, 1, 1) \
206 F(Int32x4Neg, 1, 1) \
207 F(Int32x4Not, 1, 1) \
208 F(Int32x4ToFloat32x4, 1, 1) \
209 F(Int32x4And, 2, 1) \
211 F(Int32x4Xor, 2, 1) \
212 F(Int32x4Add, 2, 1) \
213 F(Int32x4Sub, 2, 1) \
214 F(Int32x4Mul, 2, 1) \
215 F(Int32x4Shuffle, 2, 1) \
216 F(Int32x4WithX, 2, 1) \
217 F(Int32x4WithY, 2, 1) \
218 F(Int32x4WithZ, 2, 1) \
219 F(Int32x4WithW, 2, 1) \
220 F(Int32x4WithFlagX, 2, 1) \
221 F(Int32x4WithFlagY, 2, 1) \
222 F(Int32x4WithFlagZ, 2, 1) \
223 F(Int32x4WithFlagW, 2, 1) \
224 F(Int32x4GreaterThan, 2, 1) \
225 F(Int32x4Equal, 2, 1) \
226 F(Int32x4LessThan, 2, 1) \
227 F(Int32x4Select, 3, 1) \
229 /* Regular expressions */ \
230 F(RegExpCompile, 3, 1) \
231 F(RegExpExecMultiple, 4, 1) \
232 F(RegExpInitializeObject, 5, 1) \
236 F(BasicJSONStringify, 1, 1) \
237 F(QuoteJSONString, 1, 1) \
240 F(StringIndexOf, 3, 1) \
241 F(StringLastIndexOf, 3, 1) \
242 F(StringLocaleCompare, 2, 1) \
243 F(StringReplaceGlobalRegExpWithString, 4, 1) \
244 F(StringReplaceOneCharWithString, 3, 1) \
245 F(StringMatch, 3, 1) \
246 F(StringTrim, 3, 1) \
247 F(StringToArray, 2, 1) \
248 F(NewStringWrapper, 1, 1) \
250 F(TruncateString, 2, 1) \
253 F(NumberToRadixString, 2, 1) \
254 F(NumberToFixed, 2, 1) \
255 F(NumberToExponential, 2, 1) \
256 F(NumberToPrecision, 2, 1) \
260 #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
262 F(FunctionSetInstanceClassName, 2, 1) \
263 F(FunctionSetLength, 2, 1) \
264 F(FunctionSetPrototype, 2, 1) \
265 F(FunctionSetReadOnlyPrototype, 1, 1) \
266 F(FunctionGetName, 1, 1) \
267 F(FunctionSetName, 2, 1) \
268 F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
269 F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
270 F(FunctionIsGenerator, 1, 1) \
271 F(FunctionBindArguments, 4, 1) \
272 F(BoundFunctionGetBindings, 1, 1) \
273 F(FunctionRemovePrototype, 1, 1) \
274 F(FunctionGetSourceCode, 1, 1) \
275 F(FunctionGetScript, 1, 1) \
276 F(FunctionGetScriptSourcePosition, 1, 1) \
277 F(FunctionGetPositionForOffset, 2, 1) \
278 F(FunctionIsAPIFunction, 1, 1) \
279 F(FunctionIsBuiltin, 1, 1) \
281 F(CollectStackTrace, 3, 1) \
282 F(GetAndClearOverflowedStackTrace, 1, 1) \
283 F(GetV8Version, 0, 1) \
286 F(SetExpectedNumberOfProperties, 2, 1) \
288 F(CreateApiFunction, 1, 1) \
289 F(IsTemplate, 1, 1) \
290 F(GetTemplateField, 2, 1) \
291 F(DisableAccessChecks, 1, 1) \
292 F(EnableAccessChecks, 1, 1) \
293 F(SetAccessorProperty, 6, 1) \
296 F(DateCurrentTime, 0, 1) \
297 F(DateParseString, 2, 1) \
298 F(DateLocalTimezone, 1, 1) \
300 F(DateMakeDay, 2, 1) \
301 F(DateSetValue, 3, 1) \
302 F(DateCacheVersion, 0, 1) \
304 /* Float32x4 and Int32x4 */ \
305 F(CreateFloat32x4, 4, 1) \
306 F(Float32x4GetX, 1, 1) \
307 F(Float32x4GetY, 1, 1) \
308 F(Float32x4GetZ, 1, 1) \
309 F(Float32x4GetW, 1, 1) \
310 F(Float32x4GetSignMask, 1, 1) \
311 F(CreateInt32x4, 4, 1) \
312 F(Int32x4GetX, 1, 1) \
313 F(Int32x4GetY, 1, 1) \
314 F(Int32x4GetZ, 1, 1) \
315 F(Int32x4GetW, 1, 1) \
316 F(Int32x4GetFlagX, 1, 1) \
317 F(Int32x4GetFlagY, 1, 1) \
318 F(Int32x4GetFlagZ, 1, 1) \
319 F(Int32x4GetFlagW, 1, 1) \
320 F(Int32x4GetSignMask, 1, 1) \
323 F(CompileString, 2, 1) \
326 F(GlobalReceiver, 1, 1) \
327 F(IsAttachedGlobal, 1, 1) \
329 F(SetProperty, -1 /* 4 or 5 */, 1) \
330 F(DefineOrRedefineDataProperty, 4, 1) \
331 F(DefineOrRedefineAccessorProperty, 5, 1) \
332 F(IgnoreAttributesAndSetProperty, -1 /* 3 or 4 */, 1) \
333 F(GetDataProperty, 2, 1) \
334 F(SetHiddenProperty, 3, 1) \
337 F(RemoveArrayHoles, 2, 1) \
338 F(GetArrayKeys, 2, 1) \
339 F(MoveArrayContents, 2, 1) \
340 F(EstimateNumberOfElements, 1, 1) \
342 /* Getters and Setters */ \
343 F(LookupAccessor, 3, 1) \
346 F(ObjectFreeze, 1, 1) \
348 /* Harmony microtasks */ \
349 F(GetMicrotaskState, 0, 1) \
351 /* Harmony modules */ \
352 F(IsJSModule, 1, 1) \
354 /* Harmony symbols */ \
355 F(CreateSymbol, 1, 1) \
356 F(CreatePrivateSymbol, 1, 1) \
357 F(CreateGlobalPrivateSymbol, 1, 1) \
358 F(NewSymbolWrapper, 1, 1) \
359 F(SymbolDescription, 1, 1) \
360 F(SymbolRegistry, 0, 1) \
361 F(SymbolIsPrivate, 1, 1) \
363 /* Harmony proxies */ \
364 F(CreateJSProxy, 2, 1) \
365 F(CreateJSFunctionProxy, 4, 1) \
367 F(IsJSFunctionProxy, 1, 1) \
368 F(GetHandler, 1, 1) \
369 F(GetCallTrap, 1, 1) \
370 F(GetConstructTrap, 1, 1) \
374 F(SetInitialize, 1, 1) \
378 F(SetGetSize, 1, 1) \
381 F(MapInitialize, 1, 1) \
386 F(MapGetSize, 1, 1) \
388 /* Harmony weak maps and sets */ \
389 F(WeakCollectionInitialize, 1, 1) \
390 F(WeakCollectionGet, 2, 1) \
391 F(WeakCollectionHas, 2, 1) \
392 F(WeakCollectionDelete, 2, 1) \
393 F(WeakCollectionSet, 3, 1) \
395 /* Harmony events */ \
396 F(SetMicrotaskPending, 1, 1) \
397 F(RunMicrotasks, 0, 1) \
399 /* Harmony observe */ \
400 F(IsObserved, 1, 1) \
401 F(SetIsObserved, 1, 1) \
402 F(GetObservationState, 0, 1) \
403 F(ObservationWeakMapCreate, 0, 1) \
404 F(UnwrapGlobalProxy, 1, 1) \
405 F(IsAccessAllowedForObserver, 3, 1) \
407 /* Harmony typed arrays */ \
408 F(ArrayBufferInitialize, 2, 1)\
409 F(ArrayBufferGetByteLength, 1, 1)\
410 F(ArrayBufferSliceImpl, 3, 1) \
411 F(ArrayBufferIsView, 1, 1) \
412 F(ArrayBufferNeuter, 1, 1) \
414 F(TypedArrayInitializeFromArrayLike, 4, 1) \
415 F(TypedArrayGetBuffer, 1, 1) \
416 F(TypedArrayGetByteLength, 1, 1) \
417 F(TypedArrayGetByteOffset, 1, 1) \
418 F(TypedArrayGetLength, 1, 1) \
419 F(TypedArraySetFastCases, 3, 1) \
421 F(DataViewGetBuffer, 1, 1) \
422 F(DataViewGetByteLength, 1, 1) \
423 F(DataViewGetByteOffset, 1, 1) \
424 F(DataViewGetInt8, 3, 1) \
425 F(DataViewGetUint8, 3, 1) \
426 F(DataViewGetInt16, 3, 1) \
427 F(DataViewGetUint16, 3, 1) \
428 F(DataViewGetInt32, 3, 1) \
429 F(DataViewGetUint32, 3, 1) \
430 F(DataViewGetFloat32, 3, 1) \
431 F(DataViewGetFloat64, 3, 1) \
433 F(DataViewSetInt8, 4, 1) \
434 F(DataViewSetUint8, 4, 1) \
435 F(DataViewSetInt16, 4, 1) \
436 F(DataViewSetUint16, 4, 1) \
437 F(DataViewSetInt32, 4, 1) \
438 F(DataViewSetUint32, 4, 1) \
439 F(DataViewSetFloat32, 4, 1) \
440 F(DataViewSetFloat64, 4, 1) \
443 F(NewObjectFromBound, 1, 1) \
445 /* Declarations and initialization */ \
446 F(InitializeVarGlobal, -1 /* 2 or 3 */, 1) \
447 F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
450 F(DebugPrint, 1, 1) \
451 F(GlobalPrint, 1, 1) \
452 F(DebugTrace, 0, 1) \
453 F(TraceEnter, 0, 1) \
460 /* Message objects */ \
461 F(MessageGetStartPosition, 1, 1) \
462 F(MessageGetScript, 1, 1) \
464 /* Pseudo functions - handled as macros by parser */ \
467 /* expose boolean functions from objects-inl.h */ \
468 F(HasFastSmiElements, 1, 1) \
469 F(HasFastSmiOrObjectElements, 1, 1) \
470 F(HasFastObjectElements, 1, 1) \
471 F(HasFastDoubleElements, 1, 1) \
472 F(HasFastHoleyElements, 1, 1) \
473 F(HasDictionaryElements, 1, 1) \
474 F(HasSloppyArgumentsElements, 1, 1) \
475 F(HasExternalUint8ClampedElements, 1, 1) \
476 F(HasExternalArrayElements, 1, 1) \
477 F(HasExternalInt8Elements, 1, 1) \
478 F(HasExternalUint8Elements, 1, 1) \
479 F(HasExternalInt16Elements, 1, 1) \
480 F(HasExternalUint16Elements, 1, 1) \
481 F(HasExternalInt32Elements, 1, 1) \
482 F(HasExternalUint32Elements, 1, 1) \
483 F(HasExternalFloat32Elements, 1, 1) \
484 F(HasExternalFloat32x4Elements, 1, 1) \
485 F(HasExternalInt32x4Elements, 1, 1) \
486 F(HasExternalFloat64Elements, 1, 1) \
487 F(HasFixedUint8ClampedElements, 1, 1) \
488 F(HasFixedInt8Elements, 1, 1) \
489 F(HasFixedUint8Elements, 1, 1) \
490 F(HasFixedInt16Elements, 1, 1) \
491 F(HasFixedUint16Elements, 1, 1) \
492 F(HasFixedInt32Elements, 1, 1) \
493 F(HasFixedUint32Elements, 1, 1) \
494 F(HasFixedFloat32Elements, 1, 1) \
495 F(HasFixedFloat64Elements, 1, 1) \
496 F(HasFastProperties, 1, 1) \
497 F(TransitionElementsKind, 2, 1) \
498 F(HaveSameMap, 2, 1) \
499 F(IsAccessCheckNeeded, 1, 1)
502 #ifdef ENABLE_DEBUGGER_SUPPORT
503 #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \
504 /* Debugger support*/ \
505 F(DebugBreak, 0, 1) \
506 F(SetDebugEventListener, 2, 1) \
508 F(DebugGetPropertyDetails, 2, 1) \
509 F(DebugGetProperty, 2, 1) \
510 F(DebugPropertyTypeFromDetails, 1, 1) \
511 F(DebugPropertyAttributesFromDetails, 1, 1) \
512 F(DebugPropertyIndexFromDetails, 1, 1) \
513 F(DebugNamedInterceptorPropertyValue, 2, 1) \
514 F(DebugIndexedInterceptorElementValue, 2, 1) \
515 F(CheckExecutionState, 1, 1) \
516 F(GetFrameCount, 1, 1) \
517 F(GetFrameDetails, 2, 1) \
518 F(GetScopeCount, 2, 1) \
519 F(GetStepInPositions, 2, 1) \
520 F(GetScopeDetails, 4, 1) \
521 F(GetAllScopesDetails, 4, 1) \
522 F(GetFunctionScopeCount, 1, 1) \
523 F(GetFunctionScopeDetails, 2, 1) \
524 F(SetScopeVariableValue, 6, 1) \
525 F(DebugPrintScopes, 0, 1) \
526 F(GetThreadCount, 1, 1) \
527 F(GetThreadDetails, 2, 1) \
528 F(SetDisableBreak, 1, 1) \
529 F(GetBreakLocations, 2, 1) \
530 F(SetFunctionBreakPoint, 3, 1) \
531 F(SetScriptBreakPoint, 4, 1) \
532 F(ClearBreakPoint, 1, 1) \
533 F(ChangeBreakOnException, 2, 1) \
534 F(IsBreakOnException, 1, 1) \
535 F(PrepareStep, 4, 1) \
536 F(ClearStepping, 0, 1) \
537 F(DebugEvaluate, 6, 1) \
538 F(DebugEvaluateGlobal, 4, 1) \
539 F(DebugGetLoadedScripts, 0, 1) \
540 F(DebugReferencedBy, 3, 1) \
541 F(DebugConstructedBy, 2, 1) \
542 F(DebugGetPrototype, 1, 1) \
543 F(DebugSetScriptSource, 2, 1) \
544 F(SystemBreak, 0, 1) \
545 F(DebugDisassembleFunction, 1, 1) \
546 F(DebugDisassembleConstructor, 1, 1) \
547 F(FunctionGetInferredName, 1, 1) \
548 F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
549 F(LiveEditGatherCompileInfo, 2, 1) \
550 F(LiveEditReplaceScript, 3, 1) \
551 F(LiveEditReplaceFunctionCode, 2, 1) \
552 F(LiveEditFunctionSourceUpdated, 1, 1) \
553 F(LiveEditFunctionSetScript, 2, 1) \
554 F(LiveEditReplaceRefToNestedFunction, 3, 1) \
555 F(LiveEditPatchFunctionPositions, 2, 1) \
556 F(LiveEditCheckAndDropActivations, 2, 1) \
557 F(LiveEditCompareStrings, 2, 1) \
558 F(LiveEditRestartFrame, 2, 1) \
559 F(GetFunctionCodePositionFromSource, 2, 1) \
560 F(ExecuteInDebugContext, 2, 1) \
563 F(CollectGarbage, 1, 1) \
564 F(GetHeapUsage, 0, 1) \
567 #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F)
571 #ifdef V8_I18N_SUPPORT
572 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
574 /* Standalone, helper methods. */ \
575 F(CanonicalizeLanguageTag, 1, 1) \
576 F(AvailableLocalesOf, 1, 1) \
577 F(GetDefaultICULocale, 0, 1) \
578 F(GetLanguageTagVariants, 1, 1) \
579 F(IsInitializedIntlObject, 1, 1) \
580 F(IsInitializedIntlObjectOfType, 2, 1) \
581 F(MarkAsInitializedIntlObjectOfType, 3, 1) \
582 F(GetImplFromInitializedIntlObject, 1, 1) \
584 /* Date format and parse. */ \
585 F(CreateDateTimeFormat, 3, 1) \
586 F(InternalDateFormat, 2, 1) \
587 F(InternalDateParse, 2, 1) \
589 /* Number format and parse. */ \
590 F(CreateNumberFormat, 3, 1) \
591 F(InternalNumberFormat, 2, 1) \
592 F(InternalNumberParse, 2, 1) \
595 F(CreateCollator, 3, 1) \
596 F(InternalCompare, 3, 1) \
598 /* String.prototype.normalize. */ \
599 F(StringNormalize, 2, 1) \
601 /* Break iterator. */ \
602 F(CreateBreakIterator, 3, 1) \
603 F(BreakIteratorAdoptText, 2, 1) \
604 F(BreakIteratorFirst, 1, 1) \
605 F(BreakIteratorNext, 1, 1) \
606 F(BreakIteratorCurrent, 1, 1) \
607 F(BreakIteratorBreakType, 1, 1) \
610 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
615 #define RUNTIME_FUNCTION_LIST_DEBUG(F) \
619 #define RUNTIME_FUNCTION_LIST_DEBUG(F)
622 // ----------------------------------------------------------------------------
623 // RUNTIME_FUNCTION_LIST defines all runtime functions accessed
624 // either directly by id (via the code generator), or indirectly
625 // via a native call by name (from within JS code).
626 // Entries have the form F(name, number of arguments, number of return values).
628 #define RUNTIME_FUNCTION_LIST(F) \
629 RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
630 RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
631 RUNTIME_FUNCTION_LIST_DEBUG(F) \
632 RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \
633 RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
635 // RUNTIME_HIDDEN_FUNCTION_LIST defines all runtime functions accessed
636 // by id from code generator, but not via native call by name.
637 // Entries have the form F(name, number of arguments, number of return values).
638 #define RUNTIME_HIDDEN_FUNCTION_LIST(F) \
639 F(NumberToString, 1, 1) \
640 F(RegExpConstructResult, 3, 1) \
641 F(RegExpExec, 4, 1) \
644 F(StringCompare, 2, 1) \
645 F(StringCharCodeAt, 2, 1) \
647 F(GetFromCache, 2, 1) \
650 F(CompileUnoptimized, 1, 1) \
651 F(CompileOptimized, 2, 1) \
652 F(TryInstallOptimizedCode, 1, 1) \
653 F(NotifyDeoptimized, 1, 1) \
654 F(NotifyStubFailure, 0, 1) \
657 F(AllocateInNewSpace, 1, 1) \
658 F(AllocateInTargetSpace, 2, 1) \
659 F(AllocateHeapNumber, 0, 1) \
660 F(NumberToSmi, 1, 1) \
661 F(NumberToStringSkipCache, 1, 1) \
663 F(NewArgumentsFast, 3, 1) \
664 F(NewStrictArgumentsFast, 3, 1) \
666 /* Harmony generators */ \
667 F(CreateJSGeneratorObject, 0, 1) \
668 F(SuspendJSGeneratorObject, 1, 1) \
669 F(ResumeJSGeneratorObject, 3, 1) \
670 F(ThrowGeneratorStateError, 1, 1) \
673 F(ArrayConstructor, -1, 1) \
674 F(InternalArrayConstructor, -1, 1) \
677 F(MaterializeRegExpLiteral, 4, 1)\
678 F(CreateObjectLiteral, 4, 1) \
679 F(CreateArrayLiteral, 4, 1) \
680 F(CreateArrayLiteralStubBailout, 3, 1) \
683 F(NewClosure, 3, 1) \
684 F(NewClosureFromStubFailure, 1, 1) \
686 F(NewObjectWithAllocationSite, 2, 1) \
687 F(FinalizeInstanceSize, 1, 1) \
690 F(ThrowReferenceError, 1, 1) \
691 F(ThrowNotDateError, 0, 1) \
692 F(ThrowMessage, 1, 1) \
693 F(StackGuard, 0, 1) \
695 F(PromoteScheduledException, 0, 1) \
698 F(NewGlobalContext, 2, 1) \
699 F(NewFunctionContext, 1, 1) \
700 F(PushWithContext, 2, 1) \
701 F(PushCatchContext, 3, 1) \
702 F(PushBlockContext, 2, 1) \
703 F(PushModuleContext, 2, 1) \
704 F(DeleteContextSlot, 2, 1) \
705 F(LoadContextSlot, 2, 2) \
706 F(LoadContextSlotNoReferenceError, 2, 2) \
707 F(StoreContextSlot, 4, 1) \
709 /* Declarations and initialization */ \
710 F(DeclareGlobals, 3, 1) \
711 F(DeclareModules, 1, 1) \
712 F(DeclareContextSlot, 4, 1) \
713 F(InitializeConstGlobal, 2, 1) \
714 F(InitializeConstContextSlot, 3, 1) \
717 F(ResolvePossiblyDirectEval, 5, 2)
719 // ----------------------------------------------------------------------------
720 // INLINE_FUNCTION_LIST defines all inlined functions accessed
721 // with a native call of the form %_name from within JS code.
722 // Entries have the form F(name, number of arguments, number of return values).
723 #define INLINE_FUNCTION_LIST(F) \
725 F(IsNonNegativeSmi, 1, 1) \
728 F(IsConstructCall, 0, 1) \
729 F(CallFunction, -1 /* receiver + n args + function */, 1) \
730 F(ArgumentsLength, 0, 1) \
733 F(SetValueOf, 2, 1) \
734 F(DateField, 2 /* date object, field index */, 1) \
735 F(StringCharFromCode, 1, 1) \
736 F(StringCharAt, 2, 1) \
737 F(OneByteSeqStringSetChar, 3, 1) \
738 F(TwoByteSeqStringSetChar, 3, 1) \
739 F(ObjectEquals, 2, 1) \
741 F(IsFunction, 1, 1) \
742 F(IsUndetectableObject, 1, 1) \
743 F(IsSpecObject, 1, 1) \
744 F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
748 F(IsMinusZero, 1, 1) \
749 F(HasCachedArrayIndex, 1, 1) \
750 F(GetCachedArrayIndex, 1, 1) \
751 F(FastAsciiArrayJoin, 2, 1) \
752 F(GeneratorNext, 2, 1) \
753 F(GeneratorThrow, 2, 1) \
754 F(DebugBreakInOptimizedCode, 0, 1) \
756 F(StringCharCodeAt, 2, 1) \
760 F(StringCompare, 2, 1) \
761 F(RegExpExec, 4, 1) \
762 F(RegExpConstructResult, 3, 1) \
763 F(GetFromCache, 2, 1) \
764 F(NumberToString, 1, 1)
767 // ----------------------------------------------------------------------------
768 // INLINE_OPTIMIZED_FUNCTION_LIST defines all inlined functions accessed
769 // with a native call of the form %_name from within JS code that also have
770 // a corresponding runtime function, that is called from non-optimized code.
771 // Entries have the form F(name, number of arguments, number of return values).
772 #define INLINE_OPTIMIZED_FUNCTION_LIST(F) \
775 F(ConstructDouble, 2, 1) \
776 F(TypedArrayInitialize, 5, 1) \
777 F(DataViewInitialize, 4, 1) \
779 F(TypedArrayMaxSizeInHeap, 0, 1)
782 //---------------------------------------------------------------------------
783 // Runtime provides access to all C++ runtime functions.
787 StaticResource<ConsStringIteratorOp>* string_iterator() {
788 return &string_iterator_;
790 unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
791 return &to_upper_mapping_;
793 unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
794 return &to_lower_mapping_;
796 ConsStringIteratorOp* string_iterator_compare_x() {
797 return &string_iterator_compare_x_;
799 ConsStringIteratorOp* string_iterator_compare_y() {
800 return &string_iterator_compare_y_;
802 ConsStringIteratorOp* string_locale_compare_it1() {
803 return &string_locale_compare_it1_;
805 ConsStringIteratorOp* string_locale_compare_it2() {
806 return &string_locale_compare_it2_;
811 // Non-reentrant string buffer for efficient general use in the runtime.
812 StaticResource<ConsStringIteratorOp> string_iterator_;
813 unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
814 unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
815 ConsStringIteratorOp string_iterator_compare_x_;
816 ConsStringIteratorOp string_iterator_compare_y_;
817 ConsStringIteratorOp string_locale_compare_it1_;
818 ConsStringIteratorOp string_locale_compare_it2_;
820 friend class Isolate;
821 friend class Runtime;
823 DISALLOW_COPY_AND_ASSIGN(RuntimeState);
827 class Runtime : public AllStatic {
830 #define F(name, nargs, ressize) k##name,
831 RUNTIME_FUNCTION_LIST(F)
833 #define F(name, nargs, ressize) kHidden##name,
834 RUNTIME_HIDDEN_FUNCTION_LIST(F)
836 #define F(name, nargs, ressize) kInline##name,
837 INLINE_FUNCTION_LIST(F)
839 #define F(name, nargs, ressize) kInlineOptimized##name,
840 INLINE_OPTIMIZED_FUNCTION_LIST(F)
843 kFirstInlineFunction = kInlineIsSmi
853 // Intrinsic function descriptor.
855 FunctionId function_id;
856 IntrinsicType intrinsic_type;
857 // The JS name of the function.
860 // The C++ (native) entry point. NULL if the function is inlined.
863 // The number of arguments expected. nargs is -1 if the function takes
864 // a variable number of arguments.
866 // Size of result. Most functions return a single pointer, size 1.
870 static const int kNotFound = -1;
872 // Add internalized strings for all the intrinsic function names to a
874 // Returns failure if an allocation fails. In this case, it must be
875 // retried with a new, empty StringDictionary, not with the same one.
876 // Alternatively, heap initialization can be completely restarted.
877 MUST_USE_RESULT static MaybeObject* InitializeIntrinsicFunctionNames(
878 Heap* heap, Object* dictionary);
880 // Get the intrinsic function with the given name, which must be internalized.
881 static const Function* FunctionForName(Handle<String> name);
883 // Get the intrinsic function with the given FunctionId.
884 static const Function* FunctionForId(FunctionId id);
886 // General-purpose helper functions for runtime system.
887 static int StringMatch(Isolate* isolate,
892 static bool IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch);
894 // TODO(1240886): Some of the following methods are *not* handle safe, but
895 // accept handle arguments. This seems fragile.
897 // Support getting the characters in a string using [] notation as
898 // in Firefox/SpiderMonkey, Safari and Opera.
899 static Handle<Object> GetElementOrCharAt(Isolate* isolate,
900 Handle<Object> object,
903 static Handle<Object> SetObjectProperty(
905 Handle<Object> object,
907 Handle<Object> value,
908 PropertyAttributes attr,
909 StrictMode strict_mode);
911 static Handle<Object> ForceSetObjectProperty(
913 Handle<JSObject> object,
915 Handle<Object> value,
916 PropertyAttributes attr);
918 MUST_USE_RESULT static MaybeObject* DeleteObjectProperty(
920 Handle<JSReceiver> object,
922 JSReceiver::DeleteMode mode);
924 MUST_USE_RESULT static MaybeObject* HasObjectProperty(
926 Handle<JSReceiver> object,
929 MUST_USE_RESULT static MaybeObject* GetObjectProperty(
931 Handle<Object> object,
934 MUST_USE_RESULT static MaybeObject* GetObjectPropertyOrFail(
936 Handle<Object> object,
939 static void SetupArrayBuffer(Isolate* isolate,
940 Handle<JSArrayBuffer> array_buffer,
943 size_t allocated_length);
945 static bool SetupArrayBufferAllocatingData(
947 Handle<JSArrayBuffer> array_buffer,
948 size_t allocated_length,
949 bool initialize = true);
951 static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
953 static void FreeArrayBuffer(
955 JSArrayBuffer* phantom_array_buffer);
958 // arrayIds below should be synchromized with typedarray.js natives.
965 ARRAY_ID_FLOAT32 = 7,
966 ARRAY_ID_FLOAT64 = 8,
967 ARRAY_ID_UINT8_CLAMPED = 9,
968 ARRAY_ID_FLOAT32x4 = 10,
969 ARRAY_ID_INT32x4 = 11
972 static void ArrayIdToTypeAndSize(int array_id,
973 ExternalArrayType *type,
974 ElementsKind* external_elements_kind,
975 ElementsKind* fixed_elements_kind,
976 size_t *element_size);
978 // Helper functions used stubs.
979 static void PerformGC(Object* result, Isolate* isolate);
981 // Used in runtime.cc and hydrogen's VisitArrayLiteral.
982 static Handle<Object> CreateArrayLiteralBoilerplate(
984 Handle<FixedArray> literals,
985 Handle<FixedArray> elements);
989 //---------------------------------------------------------------------------
990 // Constants used by interface to runtime functions.
992 class AllocateDoubleAlignFlag: public BitField<bool, 0, 1> {};
993 class AllocateTargetSpace: public BitField<AllocationSpace, 1, 3> {};
995 class DeclareGlobalsEvalFlag: public BitField<bool, 0, 1> {};
996 class DeclareGlobalsNativeFlag: public BitField<bool, 1, 1> {};
997 class DeclareGlobalsStrictMode: public BitField<StrictMode, 2, 1> {};
999 } } // namespace v8::internal
1001 #endif // V8_RUNTIME_H_