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(IsClassicModeFunction, 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(NewArgumentsFast, 3, 1) \
87 F(NewStrictArgumentsFast, 3, 1) \
88 F(CompileUnoptimized, 1, 1) \
89 F(CompileOptimized, 2, 1) \
90 F(TryInstallOptimizedCode, 1, 1) \
91 F(NotifyDeoptimized, 1, 1) \
92 F(NotifyStubFailure, 0, 1) \
93 F(DeoptimizeFunction, 1, 1) \
94 F(ClearFunctionTypeFeedback, 1, 1) \
95 F(RunningInSimulator, 0, 1) \
96 F(IsConcurrentRecompilationSupported, 0, 1) \
97 F(OptimizeFunctionOnNextCall, -1, 1) \
98 F(NeverOptimizeFunction, 1, 1) \
99 F(GetOptimizationStatus, -1, 1) \
100 F(GetOptimizationCount, 1, 1) \
101 F(UnblockConcurrentRecompilation, 0, 1) \
102 F(CompileForOnStackReplacement, 1, 1) \
103 F(SetAllocationTimeout, -1 /* 2 || 3 */, 1) \
104 F(AllocateInNewSpace, 1, 1) \
105 F(AllocateInTargetSpace, 2, 1) \
106 F(SetNativeFlag, 1, 1) \
107 F(SetInlineBuiltinFlag, 1, 1) \
108 F(StoreArrayLiteralElement, 5, 1) \
109 F(DebugCallbackSupportsStepping, 1, 1) \
110 F(DebugPrepareStepInIfStepping, 1, 1) \
111 F(FlattenString, 1, 1) \
112 F(TryMigrateInstance, 1, 1) \
113 F(NotifyContextDisposed, 0, 1) \
116 /* Array join support */ \
117 F(PushIfAbsent, 2, 1) \
118 F(ArrayConcat, 1, 1) \
124 F(StringToNumber, 1, 1) \
125 F(StringParseInt, 2, 1) \
126 F(StringParseFloat, 1, 1) \
127 F(StringToLowerCase, 1, 1) \
128 F(StringToUpperCase, 1, 1) \
129 F(StringSplit, 3, 1) \
130 F(CharFromCode, 1, 1) \
132 F(URIUnescape, 1, 1) \
134 F(NumberToString, 1, 1) \
135 F(NumberToStringSkipCache, 1, 1) \
136 F(NumberToInteger, 1, 1) \
137 F(NumberToPositiveInteger, 1, 1) \
138 F(NumberToIntegerMapMinusZero, 1, 1) \
139 F(NumberToJSUint32, 1, 1) \
140 F(NumberToJSInt32, 1, 1) \
141 F(NumberToSmi, 1, 1) \
142 F(AllocateHeapNumber, 0, 1) \
144 /* Arithmetic operations */ \
150 F(NumberUnaryMinus, 1, 1) \
151 F(NumberAlloc, 0, 1) \
152 F(NumberImul, 2, 1) \
155 F(StringBuilderConcat, 3, 1) \
156 F(StringBuilderJoin, 3, 1) \
157 F(SparseJoinWithSeparator, 3, 1) \
159 /* Bit operations */ \
169 F(NumberEquals, 2, 1) \
170 F(StringEquals, 2, 1) \
172 F(NumberCompare, 3, 1) \
173 F(SmiLexicographicCompare, 2, 1) \
174 F(StringCompare, 2, 1) \
180 F(Math_atan2, 2, 1) \
182 F(Math_floor, 1, 1) \
185 F(Math_pow_cfunction, 2, 1) \
186 F(RoundNumber, 1, 1) \
189 /* Float32x4 and Int32x4 */ \
190 F(AllocateFloat32x4, 0, 1) \
191 F(AllocateInt32x4, 0, 1) \
194 F(Float32x4Abs, 1, 1) \
195 F(Float32x4BitsToInt32x4, 1, 1) \
196 F(Float32x4Neg, 1, 1) \
197 F(Float32x4Reciprocal, 1, 1) \
198 F(Float32x4ReciprocalSqrt, 1, 1) \
199 F(Float32x4Sqrt, 1, 1) \
200 F(Float32x4ToInt32x4, 1, 1) \
201 F(Float32x4Add, 2, 1) \
202 F(Float32x4Div, 2, 1) \
203 F(Float32x4Max, 2, 1) \
204 F(Float32x4Min, 2, 1) \
205 F(Float32x4Mul, 2, 1) \
206 F(Float32x4Sub, 2, 1) \
207 F(Float32x4Equal, 2, 1) \
208 F(Float32x4NotEqual, 2, 1) \
209 F(Float32x4GreaterThanOrEqual, 2, 1) \
210 F(Float32x4GreaterThan, 2, 1) \
211 F(Float32x4LessThan, 2, 1) \
212 F(Float32x4LessThanOrEqual, 2, 1) \
213 F(Float32x4Shuffle, 2, 1) \
214 F(Float32x4Scale, 2, 1) \
215 F(Float32x4WithX, 2, 1) \
216 F(Float32x4WithY, 2, 1) \
217 F(Float32x4WithZ, 2, 1) \
218 F(Float32x4WithW, 2, 1) \
219 F(Float32x4Clamp, 3, 1) \
220 F(Float32x4ShuffleMix, 3, 1) \
221 F(Int32x4BitsToFloat32x4, 1, 1) \
222 F(Int32x4Neg, 1, 1) \
223 F(Int32x4Not, 1, 1) \
224 F(Int32x4ToFloat32x4, 1, 1) \
225 F(Int32x4And, 2, 1) \
227 F(Int32x4Xor, 2, 1) \
228 F(Int32x4Add, 2, 1) \
229 F(Int32x4Sub, 2, 1) \
230 F(Int32x4Mul, 2, 1) \
231 F(Int32x4Shuffle, 2, 1) \
232 F(Int32x4WithX, 2, 1) \
233 F(Int32x4WithY, 2, 1) \
234 F(Int32x4WithZ, 2, 1) \
235 F(Int32x4WithW, 2, 1) \
236 F(Int32x4WithFlagX, 2, 1) \
237 F(Int32x4WithFlagY, 2, 1) \
238 F(Int32x4WithFlagZ, 2, 1) \
239 F(Int32x4WithFlagW, 2, 1) \
240 F(Int32x4GreaterThan, 2, 1) \
241 F(Int32x4Equal, 2, 1) \
242 F(Int32x4LessThan, 2, 1) \
243 F(Int32x4Select, 3, 1) \
245 /* Regular expressions */ \
246 F(RegExpCompile, 3, 1) \
247 F(RegExpExec, 4, 1) \
248 F(RegExpExecMultiple, 4, 1) \
249 F(RegExpInitializeObject, 5, 1) \
250 F(RegExpConstructResult, 3, 1) \
254 F(BasicJSONStringify, 1, 1) \
255 F(QuoteJSONString, 1, 1) \
258 F(StringCharCodeAt, 2, 1) \
259 F(StringIndexOf, 3, 1) \
260 F(StringLastIndexOf, 3, 1) \
261 F(StringLocaleCompare, 2, 1) \
263 F(StringReplaceGlobalRegExpWithString, 4, 1) \
264 F(StringReplaceOneCharWithString, 3, 1) \
265 F(StringMatch, 3, 1) \
266 F(StringTrim, 3, 1) \
267 F(StringToArray, 2, 1) \
268 F(NewStringWrapper, 1, 1) \
270 F(TruncateString, 2, 1) \
273 F(NumberToRadixString, 2, 1) \
274 F(NumberToFixed, 2, 1) \
275 F(NumberToExponential, 2, 1) \
276 F(NumberToPrecision, 2, 1) \
280 #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
282 F(FunctionSetInstanceClassName, 2, 1) \
283 F(FunctionSetLength, 2, 1) \
284 F(FunctionSetPrototype, 2, 1) \
285 F(FunctionSetReadOnlyPrototype, 1, 1) \
286 F(FunctionGetName, 1, 1) \
287 F(FunctionSetName, 2, 1) \
288 F(FunctionNameShouldPrintAsAnonymous, 1, 1) \
289 F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \
290 F(FunctionIsGenerator, 1, 1) \
291 F(FunctionBindArguments, 4, 1) \
292 F(BoundFunctionGetBindings, 1, 1) \
293 F(FunctionRemovePrototype, 1, 1) \
294 F(FunctionGetSourceCode, 1, 1) \
295 F(FunctionGetScript, 1, 1) \
296 F(FunctionGetScriptSourcePosition, 1, 1) \
297 F(FunctionGetPositionForOffset, 2, 1) \
298 F(FunctionIsAPIFunction, 1, 1) \
299 F(FunctionIsBuiltin, 1, 1) \
301 F(CollectStackTrace, 3, 1) \
302 F(GetAndClearOverflowedStackTrace, 1, 1) \
303 F(GetV8Version, 0, 1) \
307 F(SetExpectedNumberOfProperties, 2, 1) \
309 F(CreateApiFunction, 1, 1) \
310 F(IsTemplate, 1, 1) \
311 F(GetTemplateField, 2, 1) \
312 F(DisableAccessChecks, 1, 1) \
313 F(EnableAccessChecks, 1, 1) \
314 F(SetAccessorProperty, 6, 1) \
317 F(DateCurrentTime, 0, 1) \
318 F(DateParseString, 2, 1) \
319 F(DateLocalTimezone, 1, 1) \
321 F(DateMakeDay, 2, 1) \
322 F(DateSetValue, 3, 1) \
326 /* Float32x4 and Int32x4 */ \
327 F(CreateFloat32x4, 4, 1) \
328 F(Float32x4GetX, 1, 1) \
329 F(Float32x4GetY, 1, 1) \
330 F(Float32x4GetZ, 1, 1) \
331 F(Float32x4GetW, 1, 1) \
332 F(Float32x4GetSignMask, 1, 1) \
333 F(CreateInt32x4, 4, 1) \
334 F(Int32x4GetX, 1, 1) \
335 F(Int32x4GetY, 1, 1) \
336 F(Int32x4GetZ, 1, 1) \
337 F(Int32x4GetW, 1, 1) \
338 F(Int32x4GetFlagX, 1, 1) \
339 F(Int32x4GetFlagY, 1, 1) \
340 F(Int32x4GetFlagZ, 1, 1) \
341 F(Int32x4GetFlagW, 1, 1) \
342 F(Int32x4GetSignMask, 1, 1) \
345 F(CompileString, 2, 1) \
346 F(GlobalPrint, 1, 1) \
349 F(GlobalReceiver, 1, 1) \
350 F(IsAttachedGlobal, 1, 1) \
351 F(ResolvePossiblyDirectEval, 5, 2) \
353 F(SetProperty, -1 /* 4 or 5 */, 1) \
354 F(DefineOrRedefineDataProperty, 4, 1) \
355 F(DefineOrRedefineAccessorProperty, 5, 1) \
356 F(IgnoreAttributesAndSetProperty, -1 /* 3 or 4 */, 1) \
357 F(GetDataProperty, 2, 1) \
360 F(RemoveArrayHoles, 2, 1) \
361 F(GetArrayKeys, 2, 1) \
362 F(MoveArrayContents, 2, 1) \
363 F(EstimateNumberOfElements, 1, 1) \
364 F(ArrayConstructor, -1, 1) \
365 F(InternalArrayConstructor, -1, 1) \
367 /* Getters and Setters */ \
368 F(LookupAccessor, 3, 1) \
371 F(MaterializeRegExpLiteral, 4, 1)\
372 F(CreateObjectLiteral, 4, 1) \
373 F(CreateArrayLiteral, 4, 1) \
374 F(CreateArrayLiteralStubBailout, 3, 1) \
376 /* Harmony generators */ \
377 F(CreateJSGeneratorObject, 0, 1) \
378 F(SuspendJSGeneratorObject, 1, 1) \
379 F(ResumeJSGeneratorObject, 3, 1) \
380 F(ThrowGeneratorStateError, 1, 1) \
383 F(ObjectFreeze, 1, 1) \
385 /* Harmony modules */ \
386 F(IsJSModule, 1, 1) \
388 /* Harmony symbols */ \
389 F(CreateSymbol, 1, 1) \
390 F(CreatePrivateSymbol, 1, 1) \
391 F(SymbolName, 1, 1) \
392 F(SymbolIsPrivate, 1, 1) \
394 /* Harmony proxies */ \
395 F(CreateJSProxy, 2, 1) \
396 F(CreateJSFunctionProxy, 4, 1) \
398 F(IsJSFunctionProxy, 1, 1) \
399 F(GetHandler, 1, 1) \
400 F(GetCallTrap, 1, 1) \
401 F(GetConstructTrap, 1, 1) \
405 F(SetInitialize, 1, 1) \
409 F(SetGetSize, 1, 1) \
412 F(MapInitialize, 1, 1) \
417 F(MapGetSize, 1, 1) \
419 /* Harmony weak maps and sets */ \
420 F(WeakCollectionInitialize, 1, 1) \
421 F(WeakCollectionGet, 2, 1) \
422 F(WeakCollectionHas, 2, 1) \
423 F(WeakCollectionDelete, 2, 1) \
424 F(WeakCollectionSet, 3, 1) \
426 /* Harmony events */ \
427 F(SetMicrotaskPending, 1, 1) \
429 /* Harmony observe */ \
430 F(IsObserved, 1, 1) \
431 F(SetIsObserved, 1, 1) \
432 F(GetObservationState, 0, 1) \
433 F(ObservationWeakMapCreate, 0, 1) \
434 F(UnwrapGlobalProxy, 1, 1) \
435 F(IsAccessAllowedForObserver, 3, 1) \
437 /* Harmony typed arrays */ \
438 F(ArrayBufferInitialize, 2, 1)\
439 F(ArrayBufferGetByteLength, 1, 1)\
440 F(ArrayBufferSliceImpl, 3, 1) \
441 F(ArrayBufferIsView, 1, 1) \
443 F(TypedArrayInitialize, 5, 1) \
444 F(TypedArrayInitializeFromArrayLike, 4, 1) \
445 F(TypedArrayGetBuffer, 1, 1) \
446 F(TypedArrayGetByteLength, 1, 1) \
447 F(TypedArrayGetByteOffset, 1, 1) \
448 F(TypedArrayGetLength, 1, 1) \
449 F(TypedArraySetFastCases, 3, 1) \
451 F(DataViewInitialize, 4, 1) \
452 F(DataViewGetBuffer, 1, 1) \
453 F(DataViewGetByteLength, 1, 1) \
454 F(DataViewGetByteOffset, 1, 1) \
455 F(DataViewGetInt8, 3, 1) \
456 F(DataViewGetUint8, 3, 1) \
457 F(DataViewGetInt16, 3, 1) \
458 F(DataViewGetUint16, 3, 1) \
459 F(DataViewGetInt32, 3, 1) \
460 F(DataViewGetUint32, 3, 1) \
461 F(DataViewGetFloat32, 3, 1) \
462 F(DataViewGetFloat64, 3, 1) \
464 F(DataViewSetInt8, 4, 1) \
465 F(DataViewSetUint8, 4, 1) \
466 F(DataViewSetInt16, 4, 1) \
467 F(DataViewSetUint16, 4, 1) \
468 F(DataViewSetInt32, 4, 1) \
469 F(DataViewSetUint32, 4, 1) \
470 F(DataViewSetFloat32, 4, 1) \
471 F(DataViewSetFloat64, 4, 1) \
474 F(NewClosure, 3, 1) \
475 F(NewClosureFromStubFailure, 1, 1) \
477 F(NewObjectFromBound, 1, 1) \
478 F(FinalizeInstanceSize, 1, 1) \
481 F(ThrowReferenceError, 1, 1) \
482 F(ThrowNotDateError, 0, 1) \
483 F(ThrowMessage, 1, 1) \
484 F(StackGuard, 0, 1) \
486 F(PromoteScheduledException, 0, 1) \
489 F(NewGlobalContext, 2, 1) \
490 F(NewFunctionContext, 1, 1) \
491 F(PushWithContext, 2, 1) \
492 F(PushCatchContext, 3, 1) \
493 F(PushBlockContext, 2, 1) \
494 F(PushModuleContext, 2, 1) \
495 F(DeleteContextSlot, 2, 1) \
496 F(LoadContextSlot, 2, 2) \
497 F(LoadContextSlotNoReferenceError, 2, 2) \
498 F(StoreContextSlot, 4, 1) \
500 /* Declarations and initialization */ \
501 F(DeclareGlobals, 3, 1) \
502 F(DeclareModules, 1, 1) \
503 F(DeclareContextSlot, 4, 1) \
504 F(InitializeVarGlobal, -1 /* 2 or 3 */, 1) \
505 F(InitializeConstGlobal, 2, 1) \
506 F(InitializeConstContextSlot, 3, 1) \
507 F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
510 F(DebugPrint, 1, 1) \
511 F(DebugTrace, 0, 1) \
512 F(TraceEnter, 0, 1) \
521 F(GetFromCache, 2, 1) \
523 /* Message objects */ \
524 F(MessageGetStartPosition, 1, 1) \
525 F(MessageGetScript, 1, 1) \
527 /* Pseudo functions - handled as macros by parser */ \
530 /* expose boolean functions from objects-inl.h */ \
531 F(HasFastSmiElements, 1, 1) \
532 F(HasFastSmiOrObjectElements, 1, 1) \
533 F(HasFastObjectElements, 1, 1) \
534 F(HasFastDoubleElements, 1, 1) \
535 F(HasFastHoleyElements, 1, 1) \
536 F(HasDictionaryElements, 1, 1) \
537 F(HasNonStrictArgumentsElements, 1, 1) \
538 F(HasExternalUint8ClampedElements, 1, 1) \
539 F(HasExternalArrayElements, 1, 1) \
540 F(HasExternalInt8Elements, 1, 1) \
541 F(HasExternalUint8Elements, 1, 1) \
542 F(HasExternalInt16Elements, 1, 1) \
543 F(HasExternalUint16Elements, 1, 1) \
544 F(HasExternalInt32Elements, 1, 1) \
545 F(HasExternalUint32Elements, 1, 1) \
546 F(HasExternalFloat32Elements, 1, 1) \
547 F(HasExternalFloat32x4Elements, 1, 1) \
548 F(HasExternalInt32x4Elements, 1, 1) \
549 F(HasExternalFloat64Elements, 1, 1) \
550 F(HasFastProperties, 1, 1) \
551 F(TransitionElementsKind, 2, 1) \
552 F(HaveSameMap, 2, 1) \
553 F(IsAccessCheckNeeded, 1, 1)
556 #ifdef ENABLE_DEBUGGER_SUPPORT
557 #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \
558 /* Debugger support*/ \
559 F(DebugBreak, 0, 1) \
560 F(SetDebugEventListener, 2, 1) \
562 F(DebugGetPropertyDetails, 2, 1) \
563 F(DebugGetProperty, 2, 1) \
564 F(DebugPropertyTypeFromDetails, 1, 1) \
565 F(DebugPropertyAttributesFromDetails, 1, 1) \
566 F(DebugPropertyIndexFromDetails, 1, 1) \
567 F(DebugNamedInterceptorPropertyValue, 2, 1) \
568 F(DebugIndexedInterceptorElementValue, 2, 1) \
569 F(CheckExecutionState, 1, 1) \
570 F(GetFrameCount, 1, 1) \
571 F(GetFrameDetails, 2, 1) \
572 F(GetScopeCount, 2, 1) \
573 F(GetStepInPositions, 2, 1) \
574 F(GetScopeDetails, 4, 1) \
575 F(GetFunctionScopeCount, 1, 1) \
576 F(GetFunctionScopeDetails, 2, 1) \
577 F(SetScopeVariableValue, 6, 1) \
578 F(DebugPrintScopes, 0, 1) \
579 F(GetThreadCount, 1, 1) \
580 F(GetThreadDetails, 2, 1) \
581 F(SetDisableBreak, 1, 1) \
582 F(GetBreakLocations, 2, 1) \
583 F(SetFunctionBreakPoint, 3, 1) \
584 F(SetScriptBreakPoint, 4, 1) \
585 F(ClearBreakPoint, 1, 1) \
586 F(ChangeBreakOnException, 2, 1) \
587 F(IsBreakOnException, 1, 1) \
588 F(PrepareStep, 4, 1) \
589 F(ClearStepping, 0, 1) \
590 F(DebugEvaluate, 6, 1) \
591 F(DebugEvaluateGlobal, 4, 1) \
592 F(DebugGetLoadedScripts, 0, 1) \
593 F(DebugReferencedBy, 3, 1) \
594 F(DebugConstructedBy, 2, 1) \
595 F(DebugGetPrototype, 1, 1) \
596 F(DebugSetScriptSource, 2, 1) \
597 F(SystemBreak, 0, 1) \
598 F(DebugDisassembleFunction, 1, 1) \
599 F(DebugDisassembleConstructor, 1, 1) \
600 F(FunctionGetInferredName, 1, 1) \
601 F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
602 F(LiveEditGatherCompileInfo, 2, 1) \
603 F(LiveEditReplaceScript, 3, 1) \
604 F(LiveEditReplaceFunctionCode, 2, 1) \
605 F(LiveEditFunctionSourceUpdated, 1, 1) \
606 F(LiveEditFunctionSetScript, 2, 1) \
607 F(LiveEditReplaceRefToNestedFunction, 3, 1) \
608 F(LiveEditPatchFunctionPositions, 2, 1) \
609 F(LiveEditCheckAndDropActivations, 2, 1) \
610 F(LiveEditCompareStrings, 2, 1) \
611 F(LiveEditRestartFrame, 2, 1) \
612 F(GetFunctionCodePositionFromSource, 2, 1) \
613 F(ExecuteInDebugContext, 2, 1) \
616 F(CollectGarbage, 1, 1) \
617 F(GetHeapUsage, 0, 1) \
620 #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F)
624 #ifdef V8_I18N_SUPPORT
625 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
627 /* Standalone, helper methods. */ \
628 F(CanonicalizeLanguageTag, 1, 1) \
629 F(AvailableLocalesOf, 1, 1) \
630 F(GetDefaultICULocale, 0, 1) \
631 F(GetLanguageTagVariants, 1, 1) \
633 /* Date format and parse. */ \
634 F(CreateDateTimeFormat, 3, 1) \
635 F(InternalDateFormat, 2, 1) \
636 F(InternalDateParse, 2, 1) \
638 /* Number format and parse. */ \
639 F(CreateNumberFormat, 3, 1) \
640 F(InternalNumberFormat, 2, 1) \
641 F(InternalNumberParse, 2, 1) \
644 F(CreateCollator, 3, 1) \
645 F(InternalCompare, 3, 1) \
647 /* String.prototype.normalize. */ \
648 F(StringNormalize, 2, 1) \
650 /* Break iterator. */ \
651 F(CreateBreakIterator, 3, 1) \
652 F(BreakIteratorAdoptText, 2, 1) \
653 F(BreakIteratorFirst, 1, 1) \
654 F(BreakIteratorNext, 1, 1) \
655 F(BreakIteratorCurrent, 1, 1) \
656 F(BreakIteratorBreakType, 1, 1) \
659 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
664 #define RUNTIME_FUNCTION_LIST_DEBUG(F) \
668 #define RUNTIME_FUNCTION_LIST_DEBUG(F)
671 // ----------------------------------------------------------------------------
672 // RUNTIME_FUNCTION_LIST defines all runtime functions accessed
673 // either directly by id (via the code generator), or indirectly
674 // via a native call by name (from within JS code).
676 #define RUNTIME_FUNCTION_LIST(F) \
677 RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
678 RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
679 RUNTIME_FUNCTION_LIST_DEBUG(F) \
680 RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \
681 RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
683 // ----------------------------------------------------------------------------
684 // INLINE_FUNCTION_LIST defines all inlined functions accessed
685 // with a native call of the form %_name from within JS code.
686 // Entries have the form F(name, number of arguments, number of return values).
687 #define INLINE_FUNCTION_LIST(F) \
689 F(IsNonNegativeSmi, 1, 1) \
692 F(IsConstructCall, 0, 1) \
693 F(CallFunction, -1 /* receiver + n args + function */, 1) \
694 F(ArgumentsLength, 0, 1) \
697 F(SetValueOf, 2, 1) \
698 F(DateField, 2 /* date object, field index */, 1) \
699 F(StringCharFromCode, 1, 1) \
700 F(StringCharAt, 2, 1) \
701 F(OneByteSeqStringSetChar, 3, 1) \
702 F(TwoByteSeqStringSetChar, 3, 1) \
703 F(ObjectEquals, 2, 1) \
705 F(IsFunction, 1, 1) \
706 F(IsUndetectableObject, 1, 1) \
707 F(IsSpecObject, 1, 1) \
708 F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
712 F(IsMinusZero, 1, 1) \
713 F(HasCachedArrayIndex, 1, 1) \
714 F(GetCachedArrayIndex, 1, 1) \
715 F(FastAsciiArrayJoin, 2, 1) \
716 F(GeneratorNext, 2, 1) \
717 F(GeneratorThrow, 2, 1) \
718 F(DebugBreakInOptimizedCode, 0, 1)
721 // ----------------------------------------------------------------------------
722 // INLINE_RUNTIME_FUNCTION_LIST defines all inlined functions accessed
723 // with a native call of the form %_name from within JS code that also have
724 // a corresponding runtime function, that is called for slow cases.
725 // Entries have the form F(name, number of arguments, number of return values).
726 #define INLINE_RUNTIME_FUNCTION_LIST(F) \
728 F(StringCharCodeAt, 2, 1) \
732 F(StringCompare, 2, 1) \
733 F(RegExpExec, 4, 1) \
734 F(RegExpConstructResult, 3, 1) \
735 F(GetFromCache, 2, 1) \
736 F(NumberToString, 1, 1)
739 //---------------------------------------------------------------------------
740 // Runtime provides access to all C++ runtime functions.
744 StaticResource<ConsStringIteratorOp>* string_iterator() {
745 return &string_iterator_;
747 unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
748 return &to_upper_mapping_;
750 unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
751 return &to_lower_mapping_;
753 ConsStringIteratorOp* string_iterator_compare_x() {
754 return &string_iterator_compare_x_;
756 ConsStringIteratorOp* string_iterator_compare_y() {
757 return &string_iterator_compare_y_;
759 ConsStringIteratorOp* string_locale_compare_it1() {
760 return &string_locale_compare_it1_;
762 ConsStringIteratorOp* string_locale_compare_it2() {
763 return &string_locale_compare_it2_;
768 // Non-reentrant string buffer for efficient general use in the runtime.
769 StaticResource<ConsStringIteratorOp> string_iterator_;
770 unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
771 unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
772 ConsStringIteratorOp string_iterator_compare_x_;
773 ConsStringIteratorOp string_iterator_compare_y_;
774 ConsStringIteratorOp string_locale_compare_it1_;
775 ConsStringIteratorOp string_locale_compare_it2_;
777 friend class Isolate;
778 friend class Runtime;
780 DISALLOW_COPY_AND_ASSIGN(RuntimeState);
784 class Runtime : public AllStatic {
787 #define F(name, nargs, ressize) k##name,
788 RUNTIME_FUNCTION_LIST(F)
790 #define F(name, nargs, ressize) kInline##name,
791 INLINE_FUNCTION_LIST(F)
792 INLINE_RUNTIME_FUNCTION_LIST(F)
795 kFirstInlineFunction = kInlineIsSmi
803 // Intrinsic function descriptor.
805 FunctionId function_id;
806 IntrinsicType intrinsic_type;
807 // The JS name of the function.
810 // The C++ (native) entry point. NULL if the function is inlined.
813 // The number of arguments expected. nargs is -1 if the function takes
814 // a variable number of arguments.
816 // Size of result. Most functions return a single pointer, size 1.
820 static const int kNotFound = -1;
822 // Add internalized strings for all the intrinsic function names to a
824 // Returns failure if an allocation fails. In this case, it must be
825 // retried with a new, empty StringDictionary, not with the same one.
826 // Alternatively, heap initialization can be completely restarted.
827 MUST_USE_RESULT static MaybeObject* InitializeIntrinsicFunctionNames(
828 Heap* heap, Object* dictionary);
830 // Get the intrinsic function with the given name, which must be internalized.
831 static const Function* FunctionForName(Handle<String> name);
833 // Get the intrinsic function with the given FunctionId.
834 static const Function* FunctionForId(FunctionId id);
836 // General-purpose helper functions for runtime system.
837 static int StringMatch(Isolate* isolate,
842 static bool IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch);
844 // TODO(1240886): Some of the following methods are *not* handle safe, but
845 // accept handle arguments. This seems fragile.
847 // Support getting the characters in a string using [] notation as
848 // in Firefox/SpiderMonkey, Safari and Opera.
849 MUST_USE_RESULT static MaybeObject* GetElementOrCharAt(Isolate* isolate,
850 Handle<Object> object,
853 MUST_USE_RESULT static MaybeObject* GetElementOrCharAtOrFail(
855 Handle<Object> object,
858 static Handle<Object> SetObjectProperty(
860 Handle<Object> object,
862 Handle<Object> value,
863 PropertyAttributes attr,
864 StrictModeFlag strict_mode);
866 static Handle<Object> ForceSetObjectProperty(
868 Handle<JSObject> object,
870 Handle<Object> value,
871 PropertyAttributes attr);
873 MUST_USE_RESULT static MaybeObject* DeleteObjectProperty(
875 Handle<JSReceiver> object,
877 JSReceiver::DeleteMode mode);
879 MUST_USE_RESULT static MaybeObject* HasObjectProperty(
881 Handle<JSReceiver> object,
884 MUST_USE_RESULT static MaybeObject* GetObjectProperty(
886 Handle<Object> object,
889 MUST_USE_RESULT static MaybeObject* GetObjectPropertyOrFail(
891 Handle<Object> object,
894 static void SetupArrayBuffer(Isolate* isolate,
895 Handle<JSArrayBuffer> array_buffer,
898 size_t allocated_length);
900 static bool SetupArrayBufferAllocatingData(
902 Handle<JSArrayBuffer> array_buffer,
903 size_t allocated_length,
904 bool initialize = true);
906 static void FreeArrayBuffer(
908 JSArrayBuffer* phantom_array_buffer);
911 // arrayIds below should be synchromized with typedarray.js natives.
918 ARRAY_ID_FLOAT32 = 7,
919 ARRAY_ID_FLOAT64 = 8,
920 ARRAY_ID_UINT8_CLAMPED = 9,
921 ARRAY_ID_FLOAT32x4 = 10,
922 ARRAY_ID_INT32x4 = 11
925 static void ArrayIdToTypeAndSize(int array_id,
926 ExternalArrayType *type, size_t *element_size);
928 // Helper functions used stubs.
929 static void PerformGC(Object* result, Isolate* isolate);
931 // Used in runtime.cc and hydrogen's VisitArrayLiteral.
932 static Handle<Object> CreateArrayLiteralBoilerplate(
934 Handle<FixedArray> literals,
935 Handle<FixedArray> elements);
939 //---------------------------------------------------------------------------
940 // Constants used by interface to runtime functions.
942 class AllocateDoubleAlignFlag: public BitField<bool, 0, 1> {};
943 class AllocateTargetSpace: public BitField<AllocationSpace, 1, 3> {};
945 class DeclareGlobalsEvalFlag: public BitField<bool, 0, 1> {};
946 class DeclareGlobalsNativeFlag: public BitField<bool, 1, 1> {};
947 class DeclareGlobalsLanguageMode: public BitField<LanguageMode, 2, 2> {};
949 } } // namespace v8::internal
951 #endif // V8_RUNTIME_H_