Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / v8 / src / runtime.h
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_RUNTIME_H_
6 #define V8_RUNTIME_H_
7
8 #include "src/allocation.h"
9 #include "src/zone.h"
10
11 namespace v8 {
12 namespace internal {
13
14 // The interface to C++ runtime functions.
15
16 // ----------------------------------------------------------------------------
17 // RUNTIME_FUNCTION_LIST_ALWAYS defines runtime calls available in both
18 // release and debug mode.
19 // This macro should only be used by the macro RUNTIME_FUNCTION_LIST.
20
21 // WARNING: RUNTIME_FUNCTION_LIST_ALWAYS_* is a very large macro that caused
22 // MSVC Intellisense to crash.  It was broken into two macros to work around
23 // this problem. Please avoid large recursive macros whenever possible.
24 #define RUNTIME_FUNCTION_LIST_ALWAYS_1(F)                  \
25   /* Property access */                                    \
26   F(GetProperty, 2, 1)                                     \
27   F(KeyedGetProperty, 2, 1)                                \
28   F(DeleteProperty, 3, 1)                                  \
29   F(HasOwnProperty, 2, 1)                                  \
30   F(HasProperty, 2, 1)                                     \
31   F(HasElement, 2, 1)                                      \
32   F(IsPropertyEnumerable, 2, 1)                            \
33   F(GetPropertyNames, 1, 1)                                \
34   F(GetPropertyNamesFast, 1, 1)                            \
35   F(GetOwnPropertyNames, 2, 1)                             \
36   F(GetOwnElementNames, 1, 1)                              \
37   F(GetInterceptorInfo, 1, 1)                              \
38   F(GetNamedInterceptorPropertyNames, 1, 1)                \
39   F(GetIndexedInterceptorElementNames, 1, 1)               \
40   F(GetArgumentsProperty, 1, 1)                            \
41   F(ToFastProperties, 1, 1)                                \
42   F(FinishArrayPrototypeSetup, 1, 1)                       \
43   F(SpecialArrayFunctions, 0, 1)                           \
44   F(IsSloppyModeFunction, 1, 1)                            \
45   F(GetDefaultReceiver, 1, 1)                              \
46                                                            \
47   F(GetPrototype, 1, 1)                                    \
48   F(SetPrototype, 2, 1)                                    \
49   F(InternalSetPrototype, 2, 1)                            \
50   F(IsInPrototypeChain, 2, 1)                              \
51                                                            \
52   F(GetOwnProperty, 2, 1)                                  \
53                                                            \
54   F(IsExtensible, 1, 1)                                    \
55   F(PreventExtensions, 1, 1)                               \
56                                                            \
57   /* Utilities */                                          \
58   F(CheckIsBootstrapping, 0, 1)                            \
59   F(GetRootNaN, 0, 1)                                      \
60   F(Call, -1 /* >= 2 */, 1)                                \
61   F(Apply, 5, 1)                                           \
62   F(GetFunctionDelegate, 1, 1)                             \
63   F(GetConstructorDelegate, 1, 1)                          \
64   F(DeoptimizeFunction, 1, 1)                              \
65   F(ClearFunctionTypeFeedback, 1, 1)                       \
66   F(RunningInSimulator, 0, 1)                              \
67   F(IsConcurrentRecompilationSupported, 0, 1)              \
68   F(OptimizeFunctionOnNextCall, -1, 1)                     \
69   F(NeverOptimizeFunction, 1, 1)                           \
70   F(GetOptimizationStatus, -1, 1)                          \
71   F(GetOptimizationCount, 1, 1)                            \
72   F(UnblockConcurrentRecompilation, 0, 1)                  \
73   F(CompileForOnStackReplacement, 1, 1)                    \
74   F(SetAllocationTimeout, -1 /* 2 || 3 */, 1)              \
75   F(SetNativeFlag, 1, 1)                                   \
76   F(SetInlineBuiltinFlag, 1, 1)                            \
77   F(StoreArrayLiteralElement, 5, 1)                        \
78   F(DebugPrepareStepInIfStepping, 1, 1)                    \
79   F(DebugPushPromise, 1, 1)                                \
80   F(DebugPopPromise, 0, 1)                                 \
81   F(DebugPromiseEvent, 1, 1)                               \
82   F(DebugPromiseRejectEvent, 2, 1)                         \
83   F(DebugAsyncTaskEvent, 1, 1)                             \
84   F(FlattenString, 1, 1)                                   \
85   F(LoadMutableDouble, 2, 1)                               \
86   F(TryMigrateInstance, 1, 1)                              \
87   F(NotifyContextDisposed, 0, 1)                           \
88                                                            \
89   /* Array join support */                                 \
90   F(PushIfAbsent, 2, 1)                                    \
91   F(ArrayConcat, 1, 1)                                     \
92                                                            \
93   /* Conversions */                                        \
94   F(ToBool, 1, 1)                                          \
95   F(Typeof, 1, 1)                                          \
96                                                            \
97   F(Booleanize, 2, 1) /* TODO(turbofan): Only temporary */ \
98                                                            \
99   F(StringToNumber, 1, 1)                                  \
100   F(StringParseInt, 2, 1)                                  \
101   F(StringParseFloat, 1, 1)                                \
102   F(StringToLowerCase, 1, 1)                               \
103   F(StringToUpperCase, 1, 1)                               \
104   F(StringSplit, 3, 1)                                     \
105   F(CharFromCode, 1, 1)                                    \
106   F(URIEscape, 1, 1)                                       \
107   F(URIUnescape, 1, 1)                                     \
108                                                            \
109   F(NumberToInteger, 1, 1)                                 \
110   F(NumberToIntegerMapMinusZero, 1, 1)                     \
111   F(NumberToJSUint32, 1, 1)                                \
112   F(NumberToJSInt32, 1, 1)                                 \
113                                                            \
114   /* Arithmetic operations */                              \
115   F(NumberAdd, 2, 1)                                       \
116   F(NumberSub, 2, 1)                                       \
117   F(NumberMul, 2, 1)                                       \
118   F(NumberDiv, 2, 1)                                       \
119   F(NumberMod, 2, 1)                                       \
120   F(NumberUnaryMinus, 1, 1)                                \
121   F(NumberImul, 2, 1)                                      \
122                                                            \
123   F(StringBuilderConcat, 3, 1)                             \
124   F(StringBuilderJoin, 3, 1)                               \
125   F(SparseJoinWithSeparator, 3, 1)                         \
126                                                            \
127   /* Bit operations */                                     \
128   F(NumberOr, 2, 1)                                        \
129   F(NumberAnd, 2, 1)                                       \
130   F(NumberXor, 2, 1)                                       \
131                                                            \
132   F(NumberShl, 2, 1)                                       \
133   F(NumberShr, 2, 1)                                       \
134   F(NumberSar, 2, 1)                                       \
135                                                            \
136   /* Comparisons */                                        \
137   F(NumberEquals, 2, 1)                                    \
138   F(StringEquals, 2, 1)                                    \
139                                                            \
140   F(NumberCompare, 3, 1)                                   \
141   F(SmiLexicographicCompare, 2, 1)                         \
142                                                            \
143   /* Math */                                               \
144   F(MathAcos, 1, 1)                                        \
145   F(MathAsin, 1, 1)                                        \
146   F(MathAtan, 1, 1)                                        \
147   F(MathFloorRT, 1, 1)                                     \
148   F(MathAtan2, 2, 1)                                       \
149   F(MathExpRT, 1, 1)                                       \
150   F(RoundNumber, 1, 1)                                     \
151   F(MathFround, 1, 1)                                      \
152   F(RemPiO2, 1, 1)                                         \
153                                                            \
154   /* Float32x4 and Int32x4 */                              \
155   F(AllocateFloat32x4, 0, 1)                               \
156   F(AllocateFloat64x2, 0, 1)                               \
157   F(AllocateInt32x4, 0, 1)                                 \
158                                                            \
159   /* SIMD */                                               \
160   F(Float32x4LoadX, 2, 1)                                  \
161   F(Float32x4LoadXY, 2, 1)                                 \
162   F(Float32x4LoadXYZ, 2, 1)                                \
163   F(Float32x4LoadXYZW, 2, 1)                               \
164   F(Float32x4StoreX, 3, 1)                                 \
165   F(Float32x4StoreXY, 3, 1)                                \
166   F(Float32x4StoreXYZ, 3, 1)                               \
167   F(Float32x4StoreXYZW, 3, 1)                              \
168   F(Float32x4Abs, 1, 1)                                    \
169   F(Float32x4BitsToInt32x4, 1, 1)                          \
170   F(Float32x4Neg, 1, 1)                                    \
171   F(Float32x4Reciprocal, 1, 1)                             \
172   F(Float32x4ReciprocalSqrt, 1, 1)                         \
173   F(Float32x4Sqrt, 1, 1)                                   \
174   F(Float32x4ToInt32x4, 1, 1)                              \
175   F(Float32x4Add, 2, 1)                                    \
176   F(Float32x4Div, 2, 1)                                    \
177   F(Float32x4Max, 2, 1)                                    \
178   F(Float32x4Min, 2, 1)                                    \
179   F(Float32x4Mul, 2, 1)                                    \
180   F(Float32x4Sub, 2, 1)                                    \
181   F(Float32x4Equal, 2, 1)                                  \
182   F(Float32x4NotEqual, 2, 1)                               \
183   F(Float32x4GreaterThanOrEqual, 2, 1)                     \
184   F(Float32x4GreaterThan, 2, 1)                            \
185   F(Float32x4LessThan, 2, 1)                               \
186   F(Float32x4LessThanOrEqual, 2, 1)                        \
187   F(Float32x4Shuffle, 2, 1)                                \
188   F(Float32x4Scale, 2, 1)                                  \
189   F(Float32x4WithX, 2, 1)                                  \
190   F(Float32x4WithY, 2, 1)                                  \
191   F(Float32x4WithZ, 2, 1)                                  \
192   F(Float32x4WithW, 2, 1)                                  \
193   F(Float32x4Clamp, 3, 1)                                  \
194   F(Float32x4ShuffleMix, 3, 1)                             \
195   F(Float32x4Select, 3, 1)                                 \
196   F(Float64x2LoadX, 2, 1)                                  \
197   F(Float64x2LoadXY, 2, 1)                                 \
198   F(Float64x2StoreX, 3, 1)                                 \
199   F(Float64x2StoreXY, 3, 1)                                \
200   F(Float64x2Abs, 1, 1)                                    \
201   F(Float64x2Neg, 1, 1)                                    \
202   F(Float64x2Sqrt, 1, 1)                                   \
203   F(Float64x2Add, 2, 1)                                    \
204   F(Float64x2Div, 2, 1)                                    \
205   F(Float64x2Max, 2, 1)                                    \
206   F(Float64x2Min, 2, 1)                                    \
207   F(Float64x2Mul, 2, 1)                                    \
208   F(Float64x2Sub, 2, 1)                                    \
209   F(Float64x2Scale, 2, 1)                                  \
210   F(Float64x2WithX, 2, 1)                                  \
211   F(Float64x2WithY, 2, 1)                                  \
212   F(Float64x2Clamp, 3, 1)                                  \
213   F(Int32x4LoadX, 2, 1)                                    \
214   F(Int32x4LoadXY, 2, 1)                                   \
215   F(Int32x4LoadXYZ, 2, 1)                                  \
216   F(Int32x4LoadXYZW, 2, 1)                                 \
217   F(Int32x4StoreX, 3, 1)                                   \
218   F(Int32x4StoreXY, 3, 1)                                  \
219   F(Int32x4StoreXYZ, 3, 1)                                 \
220   F(Int32x4StoreXYZW, 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)                                      \
226   F(Int32x4Or, 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)                                   \
244                                                            \
245   /* Regular expressions */                                \
246   F(RegExpCompile, 3, 1)                                   \
247   F(RegExpExecMultiple, 4, 1)                              \
248   F(RegExpInitializeObject, 6, 1)                          \
249                                                            \
250   /* JSON */                                               \
251   F(ParseJson, 1, 1)                                       \
252   F(BasicJSONStringify, 1, 1)                              \
253   F(QuoteJSONString, 1, 1)                                 \
254                                                            \
255   /* Strings */                                            \
256   F(StringIndexOf, 3, 1)                                   \
257   F(StringLastIndexOf, 3, 1)                               \
258   F(StringLocaleCompare, 2, 1)                             \
259   F(StringReplaceGlobalRegExpWithString, 4, 1)             \
260   F(StringReplaceOneCharWithString, 3, 1)                  \
261   F(StringMatch, 3, 1)                                     \
262   F(StringTrim, 3, 1)                                      \
263   F(StringToArray, 2, 1)                                   \
264   F(NewStringWrapper, 1, 1)                                \
265   F(NewString, 2, 1)                                       \
266   F(TruncateString, 2, 1)                                  \
267                                                            \
268   /* Numbers */                                            \
269   F(NumberToRadixString, 2, 1)                             \
270   F(NumberToFixed, 2, 1)                                   \
271   F(NumberToExponential, 2, 1)                             \
272   F(NumberToPrecision, 2, 1)                               \
273   F(IsValidSmi, 1, 1)                                      \
274                                                            \
275   /* Classes support */                                    \
276   F(ToMethod, 2, 1)                                        \
277   F(HomeObjectSymbol, 0, 1)                                \
278   F(ThrowNonMethodError, 0, 1)                             \
279   F(ThrowUnsupportedSuperError, 0, 1)                      \
280   F(LoadFromSuper, 3, 1)
281
282
283 #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F)                             \
284   /* Reflection */                                                    \
285   F(FunctionSetInstanceClassName, 2, 1)                               \
286   F(FunctionSetLength, 2, 1)                                          \
287   F(FunctionSetPrototype, 2, 1)                                       \
288   F(FunctionGetName, 1, 1)                                            \
289   F(FunctionSetName, 2, 1)                                            \
290   F(FunctionNameShouldPrintAsAnonymous, 1, 1)                         \
291   F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1)                     \
292   F(FunctionIsGenerator, 1, 1)                                        \
293   F(FunctionIsArrow, 1, 1)                                            \
294   F(FunctionIsConciseMethod, 1, 1)                                    \
295   F(FunctionBindArguments, 4, 1)                                      \
296   F(BoundFunctionGetBindings, 1, 1)                                   \
297   F(FunctionRemovePrototype, 1, 1)                                    \
298   F(FunctionGetSourceCode, 1, 1)                                      \
299   F(FunctionGetScript, 1, 1)                                          \
300   F(FunctionGetScriptSourcePosition, 1, 1)                            \
301   F(FunctionGetPositionForOffset, 2, 1)                               \
302   F(FunctionIsAPIFunction, 1, 1)                                      \
303   F(FunctionIsBuiltin, 1, 1)                                          \
304   F(GetScript, 1, 1)                                                  \
305   F(CollectStackTrace, 2, 1)                                          \
306   F(GetV8Version, 0, 1)                                               \
307   F(GeneratorGetFunction, 1, 1)                                       \
308   F(GeneratorGetContext, 1, 1)                                        \
309   F(GeneratorGetReceiver, 1, 1)                                       \
310   F(GeneratorGetContinuation, 1, 1)                                   \
311   F(GeneratorGetSourcePosition, 1, 1)                                 \
312                                                                       \
313   F(SetCode, 2, 1)                                                    \
314                                                                       \
315   F(CreateApiFunction, 2, 1)                                          \
316   F(IsTemplate, 1, 1)                                                 \
317   F(GetTemplateField, 2, 1)                                           \
318   F(DisableAccessChecks, 1, 1)                                        \
319   F(EnableAccessChecks, 1, 1)                                         \
320                                                                       \
321   /* Dates */                                                         \
322   F(DateCurrentTime, 0, 1)                                            \
323   F(DateParseString, 2, 1)                                            \
324   F(DateLocalTimezone, 1, 1)                                          \
325   F(DateToUTC, 1, 1)                                                  \
326   F(DateMakeDay, 2, 1)                                                \
327   F(DateSetValue, 3, 1)                                               \
328   F(DateCacheVersion, 0, 1)                                           \
329                                                                       \
330   /* Float32x4, Float64x2 and Int32x4 */                              \
331   F(CreateFloat32x4, 4, 1)                                            \
332   F(Float32x4GetX, 1, 1)                                              \
333   F(Float32x4GetY, 1, 1)                                              \
334   F(Float32x4GetZ, 1, 1)                                              \
335   F(Float32x4GetW, 1, 1)                                              \
336   F(Float32x4GetSignMask, 1, 1)                                       \
337   F(CreateFloat64x2, 2, 1)                                            \
338   F(Float64x2GetX, 1, 1)                                              \
339   F(Float64x2GetY, 1, 1)                                              \
340   F(Float64x2GetSignMask, 1, 1)                                       \
341   F(CreateInt32x4, 4, 1)                                              \
342   F(Int32x4GetX, 1, 1)                                                \
343   F(Int32x4GetY, 1, 1)                                                \
344   F(Int32x4GetZ, 1, 1)                                                \
345   F(Int32x4GetW, 1, 1)                                                \
346   F(Int32x4GetFlagX, 1, 1)                                            \
347   F(Int32x4GetFlagY, 1, 1)                                            \
348   F(Int32x4GetFlagZ, 1, 1)                                            \
349   F(Int32x4GetFlagW, 1, 1)                                            \
350   F(Int32x4GetSignMask, 1, 1)                                         \
351                                                                       \
352   /* Globals */                                                       \
353   F(CompileString, 2, 1)                                              \
354                                                                       \
355   /* Eval */                                                          \
356   F(GlobalProxy, 1, 1)                                                \
357   F(IsAttachedGlobal, 1, 1)                                           \
358                                                                       \
359   F(AddNamedProperty, 4, 1)                                           \
360   F(AddPropertyForTemplate, 4, 1)                                     \
361   F(SetProperty, 4, 1)                                                \
362   F(AddElement, 4, 1)                                                 \
363   F(DefineApiAccessorProperty, 5, 1)                                  \
364   F(DefineDataPropertyUnchecked, 4, 1)                                \
365   F(DefineAccessorPropertyUnchecked, 5, 1)                            \
366   F(GetDataProperty, 2, 1)                                            \
367   F(SetHiddenProperty, 3, 1)                                          \
368                                                                       \
369   /* Arrays */                                                        \
370   F(RemoveArrayHoles, 2, 1)                                           \
371   F(GetArrayKeys, 2, 1)                                               \
372   F(MoveArrayContents, 2, 1)                                          \
373   F(EstimateNumberOfElements, 1, 1)                                   \
374   F(NormalizeElements, 1, 1)                                          \
375                                                                       \
376   /* Getters and Setters */                                           \
377   F(LookupAccessor, 3, 1)                                             \
378                                                                       \
379   /* ES5 */                                                           \
380   F(ObjectFreeze, 1, 1)                                               \
381                                                                       \
382   /* Harmony modules */                                               \
383   F(IsJSModule, 1, 1)                                                 \
384                                                                       \
385   /* Harmony symbols */                                               \
386   F(CreateSymbol, 1, 1)                                               \
387   F(CreatePrivateSymbol, 1, 1)                                        \
388   F(CreateGlobalPrivateOwnSymbol, 1, 1)                               \
389   F(CreatePrivateOwnSymbol, 1, 1)                                     \
390   F(NewSymbolWrapper, 1, 1)                                           \
391   F(SymbolDescription, 1, 1)                                          \
392   F(SymbolRegistry, 0, 1)                                             \
393   F(SymbolIsPrivate, 1, 1)                                            \
394                                                                       \
395   /* Harmony proxies */                                               \
396   F(CreateJSProxy, 2, 1)                                              \
397   F(CreateJSFunctionProxy, 4, 1)                                      \
398   F(IsJSProxy, 1, 1)                                                  \
399   F(IsJSFunctionProxy, 1, 1)                                          \
400   F(GetHandler, 1, 1)                                                 \
401   F(GetCallTrap, 1, 1)                                                \
402   F(GetConstructTrap, 1, 1)                                           \
403   F(Fix, 1, 1)                                                        \
404                                                                       \
405   /* Harmony sets */                                                  \
406   F(SetInitialize, 1, 1)                                              \
407   F(SetAdd, 2, 1)                                                     \
408   F(SetHas, 2, 1)                                                     \
409   F(SetDelete, 2, 1)                                                  \
410   F(SetClear, 1, 1)                                                   \
411   F(SetGetSize, 1, 1)                                                 \
412                                                                       \
413   F(SetIteratorInitialize, 3, 1)                                      \
414   F(SetIteratorNext, 2, 1)                                            \
415                                                                       \
416   /* Harmony maps */                                                  \
417   F(MapInitialize, 1, 1)                                              \
418   F(MapGet, 2, 1)                                                     \
419   F(MapHas, 2, 1)                                                     \
420   F(MapDelete, 2, 1)                                                  \
421   F(MapClear, 1, 1)                                                   \
422   F(MapSet, 3, 1)                                                     \
423   F(MapGetSize, 1, 1)                                                 \
424                                                                       \
425   F(MapIteratorInitialize, 3, 1)                                      \
426   F(MapIteratorNext, 2, 1)                                            \
427                                                                       \
428   /* Harmony weak maps and sets */                                    \
429   F(WeakCollectionInitialize, 1, 1)                                   \
430   F(WeakCollectionGet, 2, 1)                                          \
431   F(WeakCollectionHas, 2, 1)                                          \
432   F(WeakCollectionDelete, 2, 1)                                       \
433   F(WeakCollectionSet, 3, 1)                                          \
434                                                                       \
435   F(GetWeakMapEntries, 1, 1)                                          \
436   F(GetWeakSetValues, 1, 1)                                           \
437                                                                       \
438   /* Harmony events */                                                \
439   F(EnqueueMicrotask, 1, 1)                                           \
440   F(RunMicrotasks, 0, 1)                                              \
441                                                                       \
442   /* Harmony observe */                                               \
443   F(IsObserved, 1, 1)                                                 \
444   F(SetIsObserved, 1, 1)                                              \
445   F(GetObservationState, 0, 1)                                        \
446   F(ObservationWeakMapCreate, 0, 1)                                   \
447   F(ObserverObjectAndRecordHaveSameOrigin, 3, 1)                      \
448   F(ObjectWasCreatedInCurrentOrigin, 1, 1)                            \
449   F(GetObjectContextObjectObserve, 1, 1)                              \
450   F(GetObjectContextObjectGetNotifier, 1, 1)                          \
451   F(GetObjectContextNotifierPerformChange, 1, 1)                      \
452                                                                       \
453   /* Harmony typed arrays */                                          \
454   F(ArrayBufferInitialize, 2, 1)                                      \
455   F(ArrayBufferSliceImpl, 3, 1)                                       \
456   F(ArrayBufferIsView, 1, 1)                                          \
457   F(ArrayBufferNeuter, 1, 1)                                          \
458                                                                       \
459   F(TypedArrayInitializeFromArrayLike, 4, 1)                          \
460   F(TypedArrayGetBuffer, 1, 1)                                        \
461   F(TypedArraySetFastCases, 3, 1)                                     \
462                                                                       \
463   F(DataViewGetBuffer, 1, 1)                                          \
464   F(DataViewGetInt8, 3, 1)                                            \
465   F(DataViewGetUint8, 3, 1)                                           \
466   F(DataViewGetInt16, 3, 1)                                           \
467   F(DataViewGetUint16, 3, 1)                                          \
468   F(DataViewGetInt32, 3, 1)                                           \
469   F(DataViewGetUint32, 3, 1)                                          \
470   F(DataViewGetFloat32, 3, 1)                                         \
471   F(DataViewGetFloat64, 3, 1)                                         \
472                                                                       \
473   F(DataViewSetInt8, 4, 1)                                            \
474   F(DataViewSetUint8, 4, 1)                                           \
475   F(DataViewSetInt16, 4, 1)                                           \
476   F(DataViewSetUint16, 4, 1)                                          \
477   F(DataViewSetInt32, 4, 1)                                           \
478   F(DataViewSetUint32, 4, 1)                                          \
479   F(DataViewSetFloat32, 4, 1)                                         \
480   F(DataViewSetFloat64, 4, 1)                                         \
481                                                                       \
482   /* Statements */                                                    \
483   F(NewObjectFromBound, 1, 1)                                         \
484                                                                       \
485   /* Declarations and initialization */                               \
486   F(InitializeVarGlobal, 3, 1)                                        \
487   F(OptimizeObjectForAddingMultipleProperties, 2, 1)                  \
488                                                                       \
489   /* Debugging */                                                     \
490   F(DebugPrint, 1, 1)                                                 \
491   F(GlobalPrint, 1, 1)                                                \
492   F(DebugTrace, 0, 1)                                                 \
493   F(TraceEnter, 0, 1)                                                 \
494   F(TraceExit, 1, 1)                                                  \
495   F(Abort, 1, 1)                                                      \
496   F(AbortJS, 1, 1)                                                    \
497   /* ES5 */                                                           \
498   F(OwnKeys, 1, 1)                                                    \
499                                                                       \
500   /* Message objects */                                               \
501   F(MessageGetStartPosition, 1, 1)                                    \
502   F(MessageGetScript, 1, 1)                                           \
503                                                                       \
504   /* Pseudo functions - handled as macros by parser */                \
505   F(IS_VAR, 1, 1)                                                     \
506                                                                       \
507   /* expose boolean functions from objects-inl.h */                   \
508   F(HasFastSmiElements, 1, 1)                                         \
509   F(HasFastSmiOrObjectElements, 1, 1)                                 \
510   F(HasFastObjectElements, 1, 1)                                      \
511   F(HasFastDoubleElements, 1, 1)                                      \
512   F(HasFastHoleyElements, 1, 1)                                       \
513   F(HasDictionaryElements, 1, 1)                                      \
514   F(HasSloppyArgumentsElements, 1, 1)                                 \
515   F(HasExternalUint8ClampedElements, 1, 1)                            \
516   F(HasExternalArrayElements, 1, 1)                                   \
517   F(HasExternalInt8Elements, 1, 1)                                    \
518   F(HasExternalUint8Elements, 1, 1)                                   \
519   F(HasExternalInt16Elements, 1, 1)                                   \
520   F(HasExternalUint16Elements, 1, 1)                                  \
521   F(HasExternalInt32Elements, 1, 1)                                   \
522   F(HasExternalUint32Elements, 1, 1)                                  \
523   F(HasExternalFloat32Elements, 1, 1)                                 \
524   F(HasExternalFloat32x4Elements, 1, 1)                               \
525   F(HasExternalInt32x4Elements, 1, 1)                                 \
526   F(HasExternalFloat64Elements, 1, 1)                                 \
527   F(HasExternalFloat64x2Elements, 1, 1)                               \
528   F(HasFixedUint8ClampedElements, 1, 1)                               \
529   F(HasFixedInt8Elements, 1, 1)                                       \
530   F(HasFixedUint8Elements, 1, 1)                                      \
531   F(HasFixedInt16Elements, 1, 1)                                      \
532   F(HasFixedUint16Elements, 1, 1)                                     \
533   F(HasFixedInt32Elements, 1, 1)                                      \
534   F(HasFixedUint32Elements, 1, 1)                                     \
535   F(HasFixedFloat32Elements, 1, 1)                                    \
536   F(HasFixedFloat64Elements, 1, 1)                                    \
537   F(HasFastProperties, 1, 1)                                          \
538   F(TransitionElementsKind, 2, 1)                                     \
539   F(HaveSameMap, 2, 1)                                                \
540   F(IsJSGlobalProxy, 1, 1)                                            \
541   F(ForInInit, 2, 2)             /* TODO(turbofan): Only temporary */ \
542   F(ForInNext, 4, 2)             /* TODO(turbofan): Only temporary */ \
543   F(ForInCacheArrayLength, 2, 1) /* TODO(turbofan): Only temporary */
544
545
546 #define RUNTIME_FUNCTION_LIST_ALWAYS_3(F)                    \
547   /* String and Regexp */                                    \
548   F(NumberToStringRT, 1, 1)                                  \
549   F(RegExpConstructResult, 3, 1)                             \
550   F(RegExpExecRT, 4, 1)                                      \
551   F(StringAdd, 2, 1)                                         \
552   F(SubString, 3, 1)                                         \
553   F(InternalizeString, 1, 1)                                 \
554   F(StringCompare, 2, 1)                                     \
555   F(StringCharCodeAtRT, 2, 1)                                \
556   F(GetFromCache, 2, 1)                                      \
557                                                              \
558   /* Compilation */                                          \
559   F(CompileLazy, 1, 1)                                       \
560   F(CompileOptimized, 2, 1)                                  \
561   F(TryInstallOptimizedCode, 1, 1)                           \
562   F(NotifyDeoptimized, 1, 1)                                 \
563   F(NotifyStubFailure, 0, 1)                                 \
564                                                              \
565   /* Utilities */                                            \
566   F(AllocateInNewSpace, 1, 1)                                \
567   F(AllocateInTargetSpace, 2, 1)                             \
568   F(AllocateHeapNumber, 0, 1)                                \
569   F(NumberToSmi, 1, 1)                                       \
570   F(NumberToStringSkipCache, 1, 1)                           \
571                                                              \
572   F(NewArguments, 1, 1) /* TODO(turbofan): Only temporary */ \
573   F(NewSloppyArguments, 3, 1)                                \
574   F(NewStrictArguments, 3, 1)                                \
575                                                              \
576   /* Harmony generators */                                   \
577   F(CreateJSGeneratorObject, 0, 1)                           \
578   F(SuspendJSGeneratorObject, 1, 1)                          \
579   F(ResumeJSGeneratorObject, 3, 1)                           \
580   F(ThrowGeneratorStateError, 1, 1)                          \
581                                                              \
582   /* Arrays */                                               \
583   F(ArrayConstructor, -1, 1)                                 \
584   F(InternalArrayConstructor, -1, 1)                         \
585                                                              \
586   /* Literals */                                             \
587   F(MaterializeRegExpLiteral, 4, 1)                          \
588   F(CreateObjectLiteral, 4, 1)                               \
589   F(CreateArrayLiteral, 4, 1)                                \
590   F(CreateArrayLiteralStubBailout, 3, 1)                     \
591                                                              \
592   /* Statements */                                           \
593   F(NewClosure, 3, 1)                                        \
594   F(NewClosureFromStubFailure, 1, 1)                         \
595   F(NewObject, 1, 1)                                         \
596   F(NewObjectWithAllocationSite, 2, 1)                       \
597   F(FinalizeInstanceSize, 1, 1)                              \
598   F(Throw, 1, 1)                                             \
599   F(ReThrow, 1, 1)                                           \
600   F(ThrowReferenceError, 1, 1)                               \
601   F(ThrowNotDateError, 0, 1)                                 \
602   F(StackGuard, 0, 1)                                        \
603   F(Interrupt, 0, 1)                                         \
604   F(PromoteScheduledException, 0, 1)                         \
605                                                              \
606   /* Contexts */                                             \
607   F(NewGlobalContext, 2, 1)                                  \
608   F(NewFunctionContext, 1, 1)                                \
609   F(PushWithContext, 2, 1)                                   \
610   F(PushCatchContext, 3, 1)                                  \
611   F(PushBlockContext, 2, 1)                                  \
612   F(PushModuleContext, 2, 1)                                 \
613   F(DeleteLookupSlot, 2, 1)                                  \
614   F(LoadLookupSlot, 2, 2)                                    \
615   F(LoadLookupSlotNoReferenceError, 2, 2)                    \
616   F(StoreLookupSlot, 4, 1)                                   \
617                                                              \
618   /* Declarations and initialization */                      \
619   F(DeclareGlobals, 3, 1)                                    \
620   F(DeclareModules, 1, 1)                                    \
621   F(DeclareLookupSlot, 4, 1)                                 \
622   F(InitializeConstGlobal, 2, 1)                             \
623   F(InitializeLegacyConstLookupSlot, 3, 1)                   \
624                                                              \
625   /* Eval */                                                 \
626   F(ResolvePossiblyDirectEval, 6, 2)                         \
627                                                              \
628   /* Maths */                                                \
629   F(MathPowSlow, 2, 1)                                       \
630   F(MathPowRT, 2, 1)
631
632
633 #define RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
634   /* Debugger support*/ \
635   F(DebugBreak, 0, 1) \
636   F(SetDebugEventListener, 2, 1) \
637   F(Break, 0, 1) \
638   F(DebugGetPropertyDetails, 2, 1) \
639   F(DebugGetProperty, 2, 1) \
640   F(DebugPropertyTypeFromDetails, 1, 1) \
641   F(DebugPropertyAttributesFromDetails, 1, 1) \
642   F(DebugPropertyIndexFromDetails, 1, 1) \
643   F(DebugNamedInterceptorPropertyValue, 2, 1) \
644   F(DebugIndexedInterceptorElementValue, 2, 1) \
645   F(CheckExecutionState, 1, 1) \
646   F(GetFrameCount, 1, 1) \
647   F(GetFrameDetails, 2, 1) \
648   F(GetScopeCount, 2, 1) \
649   F(GetStepInPositions, 2, 1) \
650   F(GetScopeDetails, 4, 1) \
651   F(GetAllScopesDetails, 4, 1) \
652   F(GetFunctionScopeCount, 1, 1) \
653   F(GetFunctionScopeDetails, 2, 1) \
654   F(SetScopeVariableValue, 6, 1) \
655   F(DebugPrintScopes, 0, 1) \
656   F(GetThreadCount, 1, 1) \
657   F(GetThreadDetails, 2, 1) \
658   F(SetDisableBreak, 1, 1) \
659   F(GetBreakLocations, 2, 1) \
660   F(SetFunctionBreakPoint, 3, 1) \
661   F(SetScriptBreakPoint, 4, 1) \
662   F(ClearBreakPoint, 1, 1) \
663   F(ChangeBreakOnException, 2, 1) \
664   F(IsBreakOnException, 1, 1) \
665   F(PrepareStep, 4, 1) \
666   F(ClearStepping, 0, 1) \
667   F(DebugEvaluate, 6, 1) \
668   F(DebugEvaluateGlobal, 4, 1) \
669   F(DebugGetLoadedScripts, 0, 1) \
670   F(DebugReferencedBy, 3, 1) \
671   F(DebugConstructedBy, 2, 1) \
672   F(DebugGetPrototype, 1, 1) \
673   F(DebugSetScriptSource, 2, 1) \
674   F(DebugCallbackSupportsStepping, 1, 1) \
675   F(SystemBreak, 0, 1) \
676   F(DebugDisassembleFunction, 1, 1) \
677   F(DebugDisassembleConstructor, 1, 1) \
678   F(FunctionGetInferredName, 1, 1) \
679   F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \
680   F(LiveEditGatherCompileInfo, 2, 1) \
681   F(LiveEditReplaceScript, 3, 1) \
682   F(LiveEditReplaceFunctionCode, 2, 1) \
683   F(LiveEditFunctionSourceUpdated, 1, 1) \
684   F(LiveEditFunctionSetScript, 2, 1) \
685   F(LiveEditReplaceRefToNestedFunction, 3, 1) \
686   F(LiveEditPatchFunctionPositions, 2, 1) \
687   F(LiveEditCheckAndDropActivations, 2, 1) \
688   F(LiveEditCompareStrings, 2, 1) \
689   F(LiveEditRestartFrame, 2, 1) \
690   F(GetFunctionCodePositionFromSource, 2, 1) \
691   F(ExecuteInDebugContext, 2, 1) \
692   \
693   F(SetFlags, 1, 1) \
694   F(CollectGarbage, 1, 1) \
695   F(GetHeapUsage, 0, 1) \
696
697
698 #ifdef V8_I18N_SUPPORT
699 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
700   /* i18n support */ \
701   /* Standalone, helper methods. */ \
702   F(CanonicalizeLanguageTag, 1, 1) \
703   F(AvailableLocalesOf, 1, 1) \
704   F(GetDefaultICULocale, 0, 1) \
705   F(GetLanguageTagVariants, 1, 1) \
706   F(IsInitializedIntlObject, 1, 1) \
707   F(IsInitializedIntlObjectOfType, 2, 1) \
708   F(MarkAsInitializedIntlObjectOfType, 3, 1) \
709   F(GetImplFromInitializedIntlObject, 1, 1) \
710   \
711   /* Date format and parse. */ \
712   F(CreateDateTimeFormat, 3, 1) \
713   F(InternalDateFormat, 2, 1) \
714   F(InternalDateParse, 2, 1) \
715   \
716   /* Number format and parse. */ \
717   F(CreateNumberFormat, 3, 1) \
718   F(InternalNumberFormat, 2, 1) \
719   F(InternalNumberParse, 2, 1) \
720   \
721   /* Collator. */ \
722   F(CreateCollator, 3, 1) \
723   F(InternalCompare, 3, 1) \
724   \
725   /* String.prototype.normalize. */ \
726   F(StringNormalize, 2, 1) \
727   \
728   /* Break iterator. */ \
729   F(CreateBreakIterator, 3, 1) \
730   F(BreakIteratorAdoptText, 2, 1) \
731   F(BreakIteratorFirst, 1, 1) \
732   F(BreakIteratorNext, 1, 1) \
733   F(BreakIteratorCurrent, 1, 1) \
734   F(BreakIteratorBreakType, 1, 1) \
735
736 #else
737 #define RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
738 #endif
739
740
741 #ifdef DEBUG
742 #define RUNTIME_FUNCTION_LIST_DEBUG(F) \
743   /* Testing */ \
744   F(ListNatives, 0, 1)
745 #else
746 #define RUNTIME_FUNCTION_LIST_DEBUG(F)
747 #endif
748
749 // ----------------------------------------------------------------------------
750 // RUNTIME_FUNCTION_LIST defines all runtime functions accessed
751 // either directly by id (via the code generator), or indirectly
752 // via a native call by name (from within JS code).
753 // Entries have the form F(name, number of arguments, number of return values).
754
755 #define RUNTIME_FUNCTION_LIST(F) \
756   RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
757   RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
758   RUNTIME_FUNCTION_LIST_ALWAYS_3(F) \
759   RUNTIME_FUNCTION_LIST_DEBUG(F) \
760   RUNTIME_FUNCTION_LIST_DEBUGGER(F) \
761   RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
762
763 // ----------------------------------------------------------------------------
764 // INLINE_FUNCTION_LIST defines all inlined functions accessed
765 // with a native call of the form %_name from within JS code.
766 // Entries have the form F(name, number of arguments, number of return values).
767 #define INLINE_FUNCTION_LIST(F)                             \
768   F(IsSmi, 1, 1)                                            \
769   F(IsNonNegativeSmi, 1, 1)                                 \
770   F(IsArray, 1, 1)                                          \
771   F(IsRegExp, 1, 1)                                         \
772   F(IsConstructCall, 0, 1)                                  \
773   F(CallFunction, -1 /* receiver + n args + function */, 1) \
774   F(ArgumentsLength, 0, 1)                                  \
775   F(Arguments, 1, 1)                                        \
776   F(ValueOf, 1, 1)                                          \
777   F(SetValueOf, 2, 1)                                       \
778   F(DateField, 2 /* date object, field index */, 1)         \
779   F(StringCharFromCode, 1, 1)                               \
780   F(StringCharAt, 2, 1)                                     \
781   F(OneByteSeqStringSetChar, 3, 1)                          \
782   F(TwoByteSeqStringSetChar, 3, 1)                          \
783   F(ObjectEquals, 2, 1)                                     \
784   F(IsObject, 1, 1)                                         \
785   F(IsFunction, 1, 1)                                       \
786   F(IsUndetectableObject, 1, 1)                             \
787   F(IsSpecObject, 1, 1)                                     \
788   F(IsStringWrapperSafeForDefaultValueOf, 1, 1)             \
789   F(MathPow, 2, 1)                                          \
790   F(IsMinusZero, 1, 1)                                      \
791   F(HasCachedArrayIndex, 1, 1)                              \
792   F(GetCachedArrayIndex, 1, 1)                              \
793   F(FastOneByteArrayJoin, 2, 1)                             \
794   F(GeneratorNext, 2, 1)                                    \
795   F(GeneratorThrow, 2, 1)                                   \
796   F(DebugBreakInOptimizedCode, 0, 1)                        \
797   F(ClassOf, 1, 1)                                          \
798   F(StringCharCodeAt, 2, 1)                                 \
799   F(StringAdd, 2, 1)                                        \
800   F(SubString, 3, 1)                                        \
801   F(StringCompare, 2, 1)                                    \
802   F(RegExpExec, 4, 1)                                       \
803   F(RegExpConstructResult, 3, 1)                            \
804   F(GetFromCache, 2, 1)                                     \
805   F(NumberToString, 1, 1)                                   \
806   F(DebugIsActive, 0, 1)
807
808
809 // ----------------------------------------------------------------------------
810 // INLINE_OPTIMIZED_FUNCTION_LIST defines all inlined functions accessed
811 // with a native call of the form %_name from within JS code that also have
812 // a corresponding runtime function, that is called from non-optimized code.
813 // For the benefit of (fuzz) tests, the runtime version can also be called
814 // directly as %name (i.e. without the leading underscore).
815 // Entries have the form F(name, number of arguments, number of return values).
816 #define INLINE_OPTIMIZED_FUNCTION_LIST(F) \
817   /* Typed Arrays */                                                         \
818   F(TypedArrayInitialize, 5, 1)                                              \
819   F(DataViewInitialize, 4, 1)                                                \
820   F(MaxSmi, 0, 1)                                                            \
821   F(TypedArrayMaxSizeInHeap, 0, 1)                                           \
822   F(ArrayBufferViewGetByteLength, 1, 1)                                      \
823   F(ArrayBufferViewGetByteOffset, 1, 1)                                      \
824   F(TypedArrayGetLength, 1, 1)                                               \
825   /* ArrayBuffer */                                                          \
826   F(ArrayBufferGetByteLength, 1, 1)                                          \
827   /* Maths */                                                                \
828   F(ConstructDouble, 2, 1)                                                   \
829   F(DoubleHi, 1, 1)                                                          \
830   F(DoubleLo, 1, 1)                                                          \
831   F(MathSqrtRT, 1, 1)                                                        \
832   F(MathLogRT, 1, 1)
833
834
835 //---------------------------------------------------------------------------
836 // Runtime provides access to all C++ runtime functions.
837
838 class RuntimeState {
839  public:
840   StaticResource<ConsStringIteratorOp>* string_iterator() {
841     return &string_iterator_;
842   }
843   unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
844     return &to_upper_mapping_;
845   }
846   unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
847     return &to_lower_mapping_;
848   }
849   ConsStringIteratorOp* string_iterator_compare_x() {
850     return &string_iterator_compare_x_;
851   }
852   ConsStringIteratorOp* string_iterator_compare_y() {
853     return &string_iterator_compare_y_;
854   }
855   ConsStringIteratorOp* string_locale_compare_it1() {
856     return &string_locale_compare_it1_;
857   }
858   ConsStringIteratorOp* string_locale_compare_it2() {
859     return &string_locale_compare_it2_;
860   }
861
862  private:
863   RuntimeState() {}
864   // Non-reentrant string buffer for efficient general use in the runtime.
865   StaticResource<ConsStringIteratorOp> string_iterator_;
866   unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
867   unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
868   ConsStringIteratorOp string_iterator_compare_x_;
869   ConsStringIteratorOp string_iterator_compare_y_;
870   ConsStringIteratorOp string_locale_compare_it1_;
871   ConsStringIteratorOp string_locale_compare_it2_;
872
873   friend class Isolate;
874   friend class Runtime;
875
876   DISALLOW_COPY_AND_ASSIGN(RuntimeState);
877 };
878
879
880 class Runtime : public AllStatic {
881  public:
882   enum FunctionId {
883 #define F(name, nargs, ressize) k##name,
884     RUNTIME_FUNCTION_LIST(F)
885     INLINE_OPTIMIZED_FUNCTION_LIST(F)
886 #undef F
887 #define F(name, nargs, ressize) kInline##name,
888     INLINE_FUNCTION_LIST(F)
889 #undef F
890 #define F(name, nargs, ressize) kInlineOptimized##name,
891     INLINE_OPTIMIZED_FUNCTION_LIST(F)
892 #undef F
893     kNumFunctions,
894     kFirstInlineFunction = kInlineIsSmi
895   };
896
897   enum IntrinsicType {
898     RUNTIME,
899     INLINE,
900     INLINE_OPTIMIZED
901   };
902
903   // Intrinsic function descriptor.
904   struct Function {
905     FunctionId function_id;
906     IntrinsicType intrinsic_type;
907     // The JS name of the function.
908     const char* name;
909
910     // The C++ (native) entry point.  NULL if the function is inlined.
911     byte* entry;
912
913     // The number of arguments expected. nargs is -1 if the function takes
914     // a variable number of arguments.
915     int nargs;
916     // Size of result.  Most functions return a single pointer, size 1.
917     int result_size;
918   };
919
920   static const int kNotFound = -1;
921
922   // Add internalized strings for all the intrinsic function names to a
923   // StringDictionary.
924   static void InitializeIntrinsicFunctionNames(Isolate* isolate,
925                                                Handle<NameDictionary> dict);
926
927   // Get the intrinsic function with the given name, which must be internalized.
928   static const Function* FunctionForName(Handle<String> name);
929
930   // Get the intrinsic function with the given FunctionId.
931   static const Function* FunctionForId(FunctionId id);
932
933   // Get the intrinsic function with the given function entry address.
934   static const Function* FunctionForEntry(Address ref);
935
936   // General-purpose helper functions for runtime system.
937   static int StringMatch(Isolate* isolate,
938                          Handle<String> sub,
939                          Handle<String> pat,
940                          int index);
941
942   static bool IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch);
943
944   // TODO(1240886): Some of the following methods are *not* handle safe, but
945   // accept handle arguments. This seems fragile.
946
947   // Support getting the characters in a string using [] notation as
948   // in Firefox/SpiderMonkey, Safari and Opera.
949   MUST_USE_RESULT static MaybeHandle<Object> GetElementOrCharAt(
950       Isolate* isolate,
951       Handle<Object> object,
952       uint32_t index);
953
954   MUST_USE_RESULT static MaybeHandle<Object> SetObjectProperty(
955       Isolate* isolate, Handle<Object> object, Handle<Object> key,
956       Handle<Object> value, StrictMode strict_mode);
957
958   MUST_USE_RESULT static MaybeHandle<Object> DefineObjectProperty(
959       Handle<JSObject> object, Handle<Object> key, Handle<Object> value,
960       PropertyAttributes attr);
961
962   MUST_USE_RESULT static MaybeHandle<Object> DeleteObjectProperty(
963       Isolate* isolate,
964       Handle<JSReceiver> object,
965       Handle<Object> key,
966       JSReceiver::DeleteMode mode);
967
968   MUST_USE_RESULT static MaybeHandle<Object> HasObjectProperty(
969       Isolate* isolate,
970       Handle<JSReceiver> object,
971       Handle<Object> key);
972
973   MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
974       Isolate* isolate,
975       Handle<Object> object,
976       Handle<Object> key);
977
978   static void SetupArrayBuffer(Isolate* isolate,
979                                Handle<JSArrayBuffer> array_buffer,
980                                bool is_external,
981                                void* data,
982                                size_t allocated_length);
983
984   static bool SetupArrayBufferAllocatingData(
985       Isolate* isolate,
986       Handle<JSArrayBuffer> array_buffer,
987       size_t allocated_length,
988       bool initialize = true);
989
990   static void NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer);
991
992   static void FreeArrayBuffer(
993       Isolate* isolate,
994       JSArrayBuffer* phantom_array_buffer);
995
996   enum TypedArrayId {
997     // arrayIds below should be synchromized with typedarray.js natives.
998     ARRAY_ID_UINT8 = 1,
999     ARRAY_ID_INT8 = 2,
1000     ARRAY_ID_UINT16 = 3,
1001     ARRAY_ID_INT16 = 4,
1002     ARRAY_ID_UINT32 = 5,
1003     ARRAY_ID_INT32 = 6,
1004     ARRAY_ID_FLOAT32 = 7,
1005     ARRAY_ID_FLOAT64 = 8,
1006     ARRAY_ID_UINT8_CLAMPED = 9,
1007     ARRAY_ID_FLOAT32x4 = 10,
1008     ARRAY_ID_FLOAT64x2 = 11,
1009     ARRAY_ID_INT32x4 = 12,
1010     ARRAY_ID_FIRST = ARRAY_ID_UINT8,
1011     ARRAY_ID_LAST = ARRAY_ID_INT32x4
1012   };
1013
1014   static void ArrayIdToTypeAndSize(int array_id,
1015       ExternalArrayType *type,
1016       ElementsKind* external_elements_kind,
1017       ElementsKind* fixed_elements_kind,
1018       size_t *element_size);
1019
1020   // Used in runtime.cc and hydrogen's VisitArrayLiteral.
1021   MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
1022       Isolate* isolate,
1023       Handle<FixedArray> literals,
1024       Handle<FixedArray> elements);
1025 };
1026
1027
1028 //---------------------------------------------------------------------------
1029 // Constants used by interface to runtime functions.
1030
1031 class AllocateDoubleAlignFlag:  public BitField<bool,            0, 1> {};
1032 class AllocateTargetSpace:      public BitField<AllocationSpace, 1, 3> {};
1033
1034 class DeclareGlobalsEvalFlag:   public BitField<bool,       0, 1> {};
1035 class DeclareGlobalsNativeFlag: public BitField<bool,       1, 1> {};
1036 class DeclareGlobalsStrictMode: public BitField<StrictMode, 2, 1> {};
1037
1038 } }  // namespace v8::internal
1039
1040 #endif  // V8_RUNTIME_H_