1 // Copyright 2011 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_BUILTINS_H_
6 #define V8_BUILTINS_H_
7 
8 #include "src/base/flags.h"
9 #include "src/handles.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 // Specifies extra arguments required by a C++ builtin.
15 enum class BuiltinExtraArguments : uint8_t {
16   kNone = 0u,
17   kTarget = 1u << 0,
18   kNewTarget = 1u << 1,
19   kTargetAndNewTarget = kTarget | kNewTarget
20 };
21 
22 inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) {
23   return static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs);
24 }
25 
26 
27 #define CODE_AGE_LIST_WITH_ARG(V, A)     \
28   V(Quadragenarian, A)                   \
29   V(Quinquagenarian, A)                  \
30   V(Sexagenarian, A)                     \
31   V(Septuagenarian, A)                   \
32   V(Octogenarian, A)
33 
34 #define CODE_AGE_LIST_IGNORE_ARG(X, V) V(X)
35 
36 #define CODE_AGE_LIST(V) \
37   CODE_AGE_LIST_WITH_ARG(CODE_AGE_LIST_IGNORE_ARG, V)
38 
39 #define CODE_AGE_LIST_COMPLETE(V)                  \
40   V(ToBeExecutedOnce)                              \
41   V(NotExecuted)                                   \
42   V(ExecutedOnce)                                  \
43   V(NoAge)                                         \
44   CODE_AGE_LIST_WITH_ARG(CODE_AGE_LIST_IGNORE_ARG, V)
45 
46 #define DECLARE_CODE_AGE_BUILTIN(C, V)             \
47   V(Make##C##CodeYoungAgainOddMarking, BUILTIN,    \
48     UNINITIALIZED, kNoExtraICState)                \
49   V(Make##C##CodeYoungAgainEvenMarking, BUILTIN,   \
50     UNINITIALIZED, kNoExtraICState)
51 
52 
53 // Define list of builtins implemented in C++.
54 #define BUILTIN_LIST_C(V)                                      \
55   V(Illegal, kNone)                                            \
56                                                                \
57   V(EmptyFunction, kNone)                                      \
58                                                                \
59   V(ArrayConcat, kNone)                                        \
60   V(ArrayIsArray, kNone)                                       \
61   V(ArrayPop, kNone)                                           \
62   V(ArrayPush, kNone)                                          \
63   V(ArrayShift, kNone)                                         \
64   V(ArraySlice, kNone)                                         \
65   V(ArraySplice, kNone)                                        \
66   V(ArrayUnshift, kNone)                                       \
67                                                                \
68   V(ArrayBufferConstructor, kTarget)                           \
69   V(ArrayBufferConstructor_ConstructStub, kTargetAndNewTarget) \
70   V(ArrayBufferIsView, kNone)                                  \
71                                                                \
72   V(DateConstructor, kNone)                                    \
73   V(DateConstructor_ConstructStub, kTargetAndNewTarget)        \
74   V(DateNow, kNone)                                            \
75   V(DateParse, kNone)                                          \
76   V(DateUTC, kNone)                                            \
77   V(DatePrototypeSetDate, kNone)                               \
78   V(DatePrototypeSetFullYear, kNone)                           \
79   V(DatePrototypeSetHours, kNone)                              \
80   V(DatePrototypeSetMilliseconds, kNone)                       \
81   V(DatePrototypeSetMinutes, kNone)                            \
82   V(DatePrototypeSetMonth, kNone)                              \
83   V(DatePrototypeSetSeconds, kNone)                            \
84   V(DatePrototypeSetTime, kNone)                               \
85   V(DatePrototypeSetUTCDate, kNone)                            \
86   V(DatePrototypeSetUTCFullYear, kNone)                        \
87   V(DatePrototypeSetUTCHours, kNone)                           \
88   V(DatePrototypeSetUTCMilliseconds, kNone)                    \
89   V(DatePrototypeSetUTCMinutes, kNone)                         \
90   V(DatePrototypeSetUTCMonth, kNone)                           \
91   V(DatePrototypeSetUTCSeconds, kNone)                         \
92   V(DatePrototypeToDateString, kNone)                          \
93   V(DatePrototypeToISOString, kNone)                           \
94   V(DatePrototypeToPrimitive, kNone)                           \
95   V(DatePrototypeToUTCString, kNone)                           \
96   V(DatePrototypeToString, kNone)                              \
97   V(DatePrototypeToTimeString, kNone)                          \
98   V(DatePrototypeValueOf, kNone)                               \
99   V(DatePrototypeGetYear, kNone)                               \
100   V(DatePrototypeSetYear, kNone)                               \
101                                                                \
102   V(FunctionConstructor, kTargetAndNewTarget)                  \
103   V(FunctionPrototypeBind, kNone)                              \
104   V(FunctionPrototypeToString, kNone)                          \
105                                                                \
106   V(GeneratorFunctionConstructor, kTargetAndNewTarget)         \
107                                                                \
108   V(GlobalEval, kTarget)                                       \
109                                                                \
110   V(ObjectAssign, kNone)                                       \
111   V(ObjectCreate, kNone)                                       \
112   V(ObjectFreeze, kNone)                                       \
113   V(ObjectIsExtensible, kNone)                                 \
114   V(ObjectIsFrozen, kNone)                                     \
115   V(ObjectIsSealed, kNone)                                     \
116   V(ObjectKeys, kNone)                                         \
117   V(ObjectPreventExtensions, kNone)                            \
118   V(ObjectSeal, kNone)                                         \
119   V(ObjectProtoToString, kNone)                                \
120                                                                \
121   V(ProxyConstructor, kNone)                                   \
122   V(ProxyConstructor_ConstructStub, kTarget)                   \
123                                                                \
124   V(ReflectDefineProperty, kNone)                              \
125   V(ReflectDeleteProperty, kNone)                              \
126   V(ReflectGet, kNone)                                         \
127   V(ReflectGetOwnPropertyDescriptor, kNone)                    \
128   V(ReflectGetPrototypeOf, kNone)                              \
129   V(ReflectHas, kNone)                                         \
130   V(ReflectIsExtensible, kNone)                                \
131   V(ReflectOwnKeys, kNone)                                     \
132   V(ReflectPreventExtensions, kNone)                           \
133   V(ReflectSet, kNone)                                         \
134   V(ReflectSetPrototypeOf, kNone)                              \
135                                                                \
136   V(SymbolConstructor, kNone)                                  \
137   V(SymbolConstructor_ConstructStub, kTarget)                  \
138                                                                \
139   V(HandleApiCall, kTarget)                                    \
140   V(HandleApiCallConstruct, kTarget)                           \
141   V(HandleApiCallAsFunction, kNone)                            \
142   V(HandleApiCallAsConstructor, kNone)                         \
143                                                                \
144   V(RestrictedFunctionPropertiesThrower, kNone)                \
145   V(RestrictedStrictArgumentsPropertiesThrower, kNone)
146 
147 // Define list of builtins implemented in assembly.
148 #define BUILTIN_LIST_A(V)                                                      \
149   V(ArgumentsAdaptorTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState)       \
150                                                                                \
151   V(ConstructedNonConstructable, BUILTIN, UNINITIALIZED, kNoExtraICState)      \
152                                                                                \
153   V(CallFunction_ReceiverIsNullOrUndefined, BUILTIN, UNINITIALIZED,            \
154     kNoExtraICState)                                                           \
155   V(CallFunction_ReceiverIsNotNullOrUndefined, BUILTIN, UNINITIALIZED,         \
156     kNoExtraICState)                                                           \
157   V(CallFunction_ReceiverIsAny, BUILTIN, UNINITIALIZED, kNoExtraICState)       \
158   V(CallBoundFunction, BUILTIN, UNINITIALIZED, kNoExtraICState)                \
159   V(Call_ReceiverIsNullOrUndefined, BUILTIN, UNINITIALIZED, kNoExtraICState)   \
160   V(Call_ReceiverIsNotNullOrUndefined, BUILTIN, UNINITIALIZED,                 \
161     kNoExtraICState)                                                           \
162   V(Call_ReceiverIsAny, BUILTIN, UNINITIALIZED, kNoExtraICState)               \
163                                                                                \
164   V(ConstructFunction, BUILTIN, UNINITIALIZED, kNoExtraICState)                \
165   V(ConstructBoundFunction, BUILTIN, UNINITIALIZED, kNoExtraICState)           \
166   V(ConstructProxy, BUILTIN, UNINITIALIZED, kNoExtraICState)                   \
167   V(Construct, BUILTIN, UNINITIALIZED, kNoExtraICState)                        \
168                                                                                \
169   V(Apply, BUILTIN, UNINITIALIZED, kNoExtraICState)                            \
170                                                                                \
171   V(HandleFastApiCall, BUILTIN, UNINITIALIZED, kNoExtraICState)                \
172                                                                                \
173   V(InOptimizationQueue, BUILTIN, UNINITIALIZED, kNoExtraICState)              \
174   V(JSConstructStubGeneric, BUILTIN, UNINITIALIZED, kNoExtraICState)           \
175   V(JSBuiltinsConstructStub, BUILTIN, UNINITIALIZED, kNoExtraICState)          \
176   V(JSConstructStubApi, BUILTIN, UNINITIALIZED, kNoExtraICState)               \
177   V(JSEntryTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState)                \
178   V(JSConstructEntryTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState)       \
179   V(CompileLazy, BUILTIN, UNINITIALIZED, kNoExtraICState)                      \
180   V(CompileOptimized, BUILTIN, UNINITIALIZED, kNoExtraICState)                 \
181   V(CompileOptimizedConcurrent, BUILTIN, UNINITIALIZED, kNoExtraICState)       \
182   V(NotifyDeoptimized, BUILTIN, UNINITIALIZED, kNoExtraICState)                \
183   V(NotifySoftDeoptimized, BUILTIN, UNINITIALIZED, kNoExtraICState)            \
184   V(NotifyLazyDeoptimized, BUILTIN, UNINITIALIZED, kNoExtraICState)            \
185   V(NotifyStubFailure, BUILTIN, UNINITIALIZED, kNoExtraICState)                \
186   V(NotifyStubFailureSaveDoubles, BUILTIN, UNINITIALIZED, kNoExtraICState)     \
187                                                                                \
188   V(InterpreterEntryTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState)       \
189   V(InterpreterExitTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState)        \
190   V(InterpreterPushArgsAndCall, BUILTIN, UNINITIALIZED, kNoExtraICState)       \
191   V(InterpreterPushArgsAndConstruct, BUILTIN, UNINITIALIZED, kNoExtraICState)  \
192   V(InterpreterNotifyDeoptimized, BUILTIN, UNINITIALIZED, kNoExtraICState)     \
193   V(InterpreterNotifySoftDeoptimized, BUILTIN, UNINITIALIZED, kNoExtraICState) \
194   V(InterpreterNotifyLazyDeoptimized, BUILTIN, UNINITIALIZED, kNoExtraICState) \
195                                                                                \
196   V(LoadIC_Miss, BUILTIN, UNINITIALIZED, kNoExtraICState)                      \
197   V(KeyedLoadIC_Miss, BUILTIN, UNINITIALIZED, kNoExtraICState)                 \
198   V(StoreIC_Miss, BUILTIN, UNINITIALIZED, kNoExtraICState)                     \
199   V(KeyedStoreIC_Miss, BUILTIN, UNINITIALIZED, kNoExtraICState)                \
200   V(LoadIC_Getter_ForDeopt, LOAD_IC, MONOMORPHIC, kNoExtraICState)             \
201   V(KeyedLoadIC_Megamorphic, KEYED_LOAD_IC, MEGAMORPHIC, kNoExtraICState)      \
202                                                                                \
203   V(KeyedLoadIC_Megamorphic_Strong, KEYED_LOAD_IC, MEGAMORPHIC,                \
204     LoadICState::kStrongModeState)                                             \
205                                                                                \
206   V(StoreIC_Setter_ForDeopt, STORE_IC, MONOMORPHIC,                            \
207     StoreICState::kStrictModeState)                                            \
208                                                                                \
209   V(KeyedStoreIC_Initialize, KEYED_STORE_IC, UNINITIALIZED, kNoExtraICState)   \
210   V(KeyedStoreIC_PreMonomorphic, KEYED_STORE_IC, PREMONOMORPHIC,               \
211     kNoExtraICState)                                                           \
212   V(KeyedStoreIC_Megamorphic, KEYED_STORE_IC, MEGAMORPHIC, kNoExtraICState)    \
213                                                                                \
214   V(KeyedStoreIC_Initialize_Strict, KEYED_STORE_IC, UNINITIALIZED,             \
215     StoreICState::kStrictModeState)                                            \
216   V(KeyedStoreIC_PreMonomorphic_Strict, KEYED_STORE_IC, PREMONOMORPHIC,        \
217     StoreICState::kStrictModeState)                                            \
218   V(KeyedStoreIC_Megamorphic_Strict, KEYED_STORE_IC, MEGAMORPHIC,              \
219     StoreICState::kStrictModeState)                                            \
220                                                                                \
221   V(DatePrototypeGetDate, BUILTIN, UNINITIALIZED, kNoExtraICState)             \
222   V(DatePrototypeGetDay, BUILTIN, UNINITIALIZED, kNoExtraICState)              \
223   V(DatePrototypeGetFullYear, BUILTIN, UNINITIALIZED, kNoExtraICState)         \
224   V(DatePrototypeGetHours, BUILTIN, UNINITIALIZED, kNoExtraICState)            \
225   V(DatePrototypeGetMilliseconds, BUILTIN, UNINITIALIZED, kNoExtraICState)     \
226   V(DatePrototypeGetMinutes, BUILTIN, UNINITIALIZED, kNoExtraICState)          \
227   V(DatePrototypeGetMonth, BUILTIN, UNINITIALIZED, kNoExtraICState)            \
228   V(DatePrototypeGetSeconds, BUILTIN, UNINITIALIZED, kNoExtraICState)          \
229   V(DatePrototypeGetTime, BUILTIN, UNINITIALIZED, kNoExtraICState)             \
230   V(DatePrototypeGetTimezoneOffset, BUILTIN, UNINITIALIZED, kNoExtraICState)   \
231   V(DatePrototypeGetUTCDate, BUILTIN, UNINITIALIZED, kNoExtraICState)          \
232   V(DatePrototypeGetUTCDay, BUILTIN, UNINITIALIZED, kNoExtraICState)           \
233   V(DatePrototypeGetUTCFullYear, BUILTIN, UNINITIALIZED, kNoExtraICState)      \
234   V(DatePrototypeGetUTCHours, BUILTIN, UNINITIALIZED, kNoExtraICState)         \
235   V(DatePrototypeGetUTCMilliseconds, BUILTIN, UNINITIALIZED, kNoExtraICState)  \
236   V(DatePrototypeGetUTCMinutes, BUILTIN, UNINITIALIZED, kNoExtraICState)       \
237   V(DatePrototypeGetUTCMonth, BUILTIN, UNINITIALIZED, kNoExtraICState)         \
238   V(DatePrototypeGetUTCSeconds, BUILTIN, UNINITIALIZED, kNoExtraICState)       \
239                                                                                \
240   V(FunctionPrototypeApply, BUILTIN, UNINITIALIZED, kNoExtraICState)           \
241   V(FunctionPrototypeCall, BUILTIN, UNINITIALIZED, kNoExtraICState)            \
242                                                                                \
243   V(ReflectApply, BUILTIN, UNINITIALIZED, kNoExtraICState)                     \
244   V(ReflectConstruct, BUILTIN, UNINITIALIZED, kNoExtraICState)                 \
245                                                                                \
246   V(InternalArrayCode, BUILTIN, UNINITIALIZED, kNoExtraICState)                \
247   V(ArrayCode, BUILTIN, UNINITIALIZED, kNoExtraICState)                        \
248                                                                                \
249   V(NumberConstructor, BUILTIN, UNINITIALIZED, kNoExtraICState)                \
250   V(NumberConstructor_ConstructStub, BUILTIN, UNINITIALIZED, kNoExtraICState)  \
251                                                                                \
252   V(StringConstructor, BUILTIN, UNINITIALIZED, kNoExtraICState)                \
253   V(StringConstructor_ConstructStub, BUILTIN, UNINITIALIZED, kNoExtraICState)  \
254                                                                                \
255   V(OnStackReplacement, BUILTIN, UNINITIALIZED, kNoExtraICState)               \
256   V(InterruptCheck, BUILTIN, UNINITIALIZED, kNoExtraICState)                   \
257   V(OsrAfterStackCheck, BUILTIN, UNINITIALIZED, kNoExtraICState)               \
258   V(StackCheck, BUILTIN, UNINITIALIZED, kNoExtraICState)                       \
259                                                                                \
260   V(MarkCodeAsToBeExecutedOnce, BUILTIN, UNINITIALIZED, kNoExtraICState)       \
261   V(MarkCodeAsExecutedOnce, BUILTIN, UNINITIALIZED, kNoExtraICState)           \
262   V(MarkCodeAsExecutedTwice, BUILTIN, UNINITIALIZED, kNoExtraICState)          \
263   CODE_AGE_LIST_WITH_ARG(DECLARE_CODE_AGE_BUILTIN, V)
264 
265 // Define list of builtin handlers implemented in assembly.
266 #define BUILTIN_LIST_H(V)                    \
267   V(LoadIC_Slow,             LOAD_IC)        \
268   V(LoadIC_Slow_Strong,      LOAD_IC)        \
269   V(KeyedLoadIC_Slow,        KEYED_LOAD_IC)  \
270   V(KeyedLoadIC_Slow_Strong, KEYED_LOAD_IC)  \
271   V(StoreIC_Slow,            STORE_IC)       \
272   V(KeyedStoreIC_Slow,       KEYED_STORE_IC) \
273   V(LoadIC_Normal,           LOAD_IC)        \
274   V(LoadIC_Normal_Strong,    LOAD_IC)        \
275   V(StoreIC_Normal,          STORE_IC)
276 
277 // Define list of builtins used by the debugger implemented in assembly.
278 #define BUILTIN_LIST_DEBUG_A(V)                                 \
279   V(Return_DebugBreak, BUILTIN, DEBUG_STUB, kNoExtraICState)    \
280   V(Slot_DebugBreak, BUILTIN, DEBUG_STUB, kNoExtraICState)      \
281   V(FrameDropper_LiveEdit, BUILTIN, DEBUG_STUB, kNoExtraICState)
282 
283 
284 class BuiltinFunctionTable;
285 class ObjectVisitor;
286 
287 
288 class Builtins {
289  public:
290   ~Builtins();
291 
292   // Generate all builtin code objects. Should be called once during
293   // isolate initialization.
294   void SetUp(Isolate* isolate, bool create_heap_objects);
295   void TearDown();
296 
297   // Garbage collection support.
298   void IterateBuiltins(ObjectVisitor* v);
299 
300   // Disassembler support.
301   const char* Lookup(byte* pc);
302 
303   enum Name {
304 #define DEF_ENUM_C(name, ignore) k##name,
305 #define DEF_ENUM_A(name, kind, state, extra) k##name,
306 #define DEF_ENUM_H(name, kind) k##name,
307     BUILTIN_LIST_C(DEF_ENUM_C)
308     BUILTIN_LIST_A(DEF_ENUM_A)
309     BUILTIN_LIST_H(DEF_ENUM_H)
310     BUILTIN_LIST_DEBUG_A(DEF_ENUM_A)
311 #undef DEF_ENUM_C
312 #undef DEF_ENUM_A
313     builtin_count
314   };
315 
316   enum CFunctionId {
317 #define DEF_ENUM_C(name, ignore) c_##name,
318     BUILTIN_LIST_C(DEF_ENUM_C)
319 #undef DEF_ENUM_C
320     cfunction_count
321   };
322 
323 #define DECLARE_BUILTIN_ACCESSOR_C(name, ignore) Handle<Code> name();
324 #define DECLARE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \
325   Handle<Code> name();
326 #define DECLARE_BUILTIN_ACCESSOR_H(name, kind) Handle<Code> name();
327   BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C)
328   BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A)
329   BUILTIN_LIST_H(DECLARE_BUILTIN_ACCESSOR_H)
330   BUILTIN_LIST_DEBUG_A(DECLARE_BUILTIN_ACCESSOR_A)
331 #undef DECLARE_BUILTIN_ACCESSOR_C
332 #undef DECLARE_BUILTIN_ACCESSOR_A
333 
334   // Convenience wrappers.
335   Handle<Code> CallFunction(ConvertReceiverMode = ConvertReceiverMode::kAny);
336   Handle<Code> Call(ConvertReceiverMode = ConvertReceiverMode::kAny);
337 
builtin(Name name)338   Code* builtin(Name name) {
339     // Code::cast cannot be used here since we access builtins
340     // during the marking phase of mark sweep. See IC::Clear.
341     return reinterpret_cast<Code*>(builtins_[name]);
342   }
343 
builtin_address(Name name)344   Address builtin_address(Name name) {
345     return reinterpret_cast<Address>(&builtins_[name]);
346   }
347 
c_function_address(CFunctionId id)348   static Address c_function_address(CFunctionId id) {
349     return c_functions_[id];
350   }
351 
name(int index)352   const char* name(int index) {
353     DCHECK(index >= 0);
354     DCHECK(index < builtin_count);
355     return names_[index];
356   }
357 
is_initialized()358   bool is_initialized() const { return initialized_; }
359 
360   MUST_USE_RESULT static MaybeHandle<Object> InvokeApiFunction(
361       Handle<JSFunction> function, Handle<Object> receiver, int argc,
362       Handle<Object> args[]);
363 
364  private:
365   Builtins();
366 
367   // The external C++ functions called from the code.
368   static Address const c_functions_[cfunction_count];
369 
370   // Note: These are always Code objects, but to conform with
371   // IterateBuiltins() above which assumes Object**'s for the callback
372   // function f, we use an Object* array here.
373   Object* builtins_[builtin_count];
374   const char* names_[builtin_count];
375 
376   static void Generate_Adaptor(MacroAssembler* masm,
377                                CFunctionId id,
378                                BuiltinExtraArguments extra_args);
379   static void Generate_ConstructedNonConstructable(MacroAssembler* masm);
380   static void Generate_CompileLazy(MacroAssembler* masm);
381   static void Generate_InOptimizationQueue(MacroAssembler* masm);
382   static void Generate_CompileOptimized(MacroAssembler* masm);
383   static void Generate_CompileOptimizedConcurrent(MacroAssembler* masm);
384   static void Generate_JSConstructStubGeneric(MacroAssembler* masm);
385   static void Generate_JSBuiltinsConstructStub(MacroAssembler* masm);
386   static void Generate_JSConstructStubApi(MacroAssembler* masm);
387   static void Generate_JSEntryTrampoline(MacroAssembler* masm);
388   static void Generate_JSConstructEntryTrampoline(MacroAssembler* masm);
389   static void Generate_NotifyDeoptimized(MacroAssembler* masm);
390   static void Generate_NotifySoftDeoptimized(MacroAssembler* masm);
391   static void Generate_NotifyLazyDeoptimized(MacroAssembler* masm);
392   static void Generate_NotifyStubFailure(MacroAssembler* masm);
393   static void Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm);
394   static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm);
395 
396   static void Generate_Apply(MacroAssembler* masm);
397 
398   // ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList)
399   static void Generate_CallFunction(MacroAssembler* masm,
400                                     ConvertReceiverMode mode);
Generate_CallFunction_ReceiverIsNullOrUndefined(MacroAssembler * masm)401   static void Generate_CallFunction_ReceiverIsNullOrUndefined(
402       MacroAssembler* masm) {
403     Generate_CallFunction(masm, ConvertReceiverMode::kNullOrUndefined);
404   }
Generate_CallFunction_ReceiverIsNotNullOrUndefined(MacroAssembler * masm)405   static void Generate_CallFunction_ReceiverIsNotNullOrUndefined(
406       MacroAssembler* masm) {
407     Generate_CallFunction(masm, ConvertReceiverMode::kNotNullOrUndefined);
408   }
Generate_CallFunction_ReceiverIsAny(MacroAssembler * masm)409   static void Generate_CallFunction_ReceiverIsAny(MacroAssembler* masm) {
410     Generate_CallFunction(masm, ConvertReceiverMode::kAny);
411   }
412   // ES6 section 9.4.1.1 [[Call]] ( thisArgument, argumentsList)
413   static void Generate_CallBoundFunction(MacroAssembler* masm);
414   // ES6 section 7.3.12 Call(F, V, [argumentsList])
415   static void Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode);
Generate_Call_ReceiverIsNullOrUndefined(MacroAssembler * masm)416   static void Generate_Call_ReceiverIsNullOrUndefined(MacroAssembler* masm) {
417     Generate_Call(masm, ConvertReceiverMode::kNullOrUndefined);
418   }
Generate_Call_ReceiverIsNotNullOrUndefined(MacroAssembler * masm)419   static void Generate_Call_ReceiverIsNotNullOrUndefined(MacroAssembler* masm) {
420     Generate_Call(masm, ConvertReceiverMode::kNotNullOrUndefined);
421   }
Generate_Call_ReceiverIsAny(MacroAssembler * masm)422   static void Generate_Call_ReceiverIsAny(MacroAssembler* masm) {
423     Generate_Call(masm, ConvertReceiverMode::kAny);
424   }
425 
426   // ES6 section 9.2.2 [[Construct]] ( argumentsList, newTarget)
427   static void Generate_ConstructFunction(MacroAssembler* masm);
428   // ES6 section 9.4.1.2 [[Construct]] (argumentsList, newTarget)
429   static void Generate_ConstructBoundFunction(MacroAssembler* masm);
430   // ES6 section 9.5.14 [[Construct]] ( argumentsList, newTarget)
431   static void Generate_ConstructProxy(MacroAssembler* masm);
432   // ES6 section 7.3.13 Construct (F, [argumentsList], [newTarget])
433   static void Generate_Construct(MacroAssembler* masm);
434 
435   static void Generate_HandleFastApiCall(MacroAssembler* masm);
436 
437   static void Generate_DatePrototype_GetField(MacroAssembler* masm,
438                                               int field_index);
439   // ES6 section 20.3.4.2 Date.prototype.getDate ( )
440   static void Generate_DatePrototypeGetDate(MacroAssembler* masm);
441   // ES6 section 20.3.4.3 Date.prototype.getDay ( )
442   static void Generate_DatePrototypeGetDay(MacroAssembler* masm);
443   // ES6 section 20.3.4.4 Date.prototype.getFullYear ( )
444   static void Generate_DatePrototypeGetFullYear(MacroAssembler* masm);
445   // ES6 section 20.3.4.5 Date.prototype.getHours ( )
446   static void Generate_DatePrototypeGetHours(MacroAssembler* masm);
447   // ES6 section 20.3.4.6 Date.prototype.getMilliseconds ( )
448   static void Generate_DatePrototypeGetMilliseconds(MacroAssembler* masm);
449   // ES6 section 20.3.4.7 Date.prototype.getMinutes ( )
450   static void Generate_DatePrototypeGetMinutes(MacroAssembler* masm);
451   // ES6 section 20.3.4.8 Date.prototype.getMonth ( )
452   static void Generate_DatePrototypeGetMonth(MacroAssembler* masm);
453   // ES6 section 20.3.4.9 Date.prototype.getSeconds ( )
454   static void Generate_DatePrototypeGetSeconds(MacroAssembler* masm);
455   // ES6 section 20.3.4.10 Date.prototype.getTime ( )
456   static void Generate_DatePrototypeGetTime(MacroAssembler* masm);
457   // ES6 section 20.3.4.11 Date.prototype.getTimezoneOffset ( )
458   static void Generate_DatePrototypeGetTimezoneOffset(MacroAssembler* masm);
459   // ES6 section 20.3.4.12 Date.prototype.getUTCDate ( )
460   static void Generate_DatePrototypeGetUTCDate(MacroAssembler* masm);
461   // ES6 section 20.3.4.13 Date.prototype.getUTCDay ( )
462   static void Generate_DatePrototypeGetUTCDay(MacroAssembler* masm);
463   // ES6 section 20.3.4.14 Date.prototype.getUTCFullYear ( )
464   static void Generate_DatePrototypeGetUTCFullYear(MacroAssembler* masm);
465   // ES6 section 20.3.4.15 Date.prototype.getUTCHours ( )
466   static void Generate_DatePrototypeGetUTCHours(MacroAssembler* masm);
467   // ES6 section 20.3.4.16 Date.prototype.getUTCMilliseconds ( )
468   static void Generate_DatePrototypeGetUTCMilliseconds(MacroAssembler* masm);
469   // ES6 section 20.3.4.17 Date.prototype.getUTCMinutes ( )
470   static void Generate_DatePrototypeGetUTCMinutes(MacroAssembler* masm);
471   // ES6 section 20.3.4.18 Date.prototype.getUTCMonth ( )
472   static void Generate_DatePrototypeGetUTCMonth(MacroAssembler* masm);
473   // ES6 section 20.3.4.19 Date.prototype.getUTCSeconds ( )
474   static void Generate_DatePrototypeGetUTCSeconds(MacroAssembler* masm);
475 
476   static void Generate_FunctionPrototypeApply(MacroAssembler* masm);
477   static void Generate_FunctionPrototypeCall(MacroAssembler* masm);
478 
479   static void Generate_ReflectApply(MacroAssembler* masm);
480   static void Generate_ReflectConstruct(MacroAssembler* masm);
481 
482   static void Generate_InternalArrayCode(MacroAssembler* masm);
483   static void Generate_ArrayCode(MacroAssembler* masm);
484 
485   // ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Call]] case.
486   static void Generate_NumberConstructor(MacroAssembler* masm);
487   // ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Construct]] case.
488   static void Generate_NumberConstructor_ConstructStub(MacroAssembler* masm);
489 
490   static void Generate_StringConstructor(MacroAssembler* masm);
491   static void Generate_StringConstructor_ConstructStub(MacroAssembler* masm);
492   static void Generate_OnStackReplacement(MacroAssembler* masm);
493   static void Generate_OsrAfterStackCheck(MacroAssembler* masm);
494   static void Generate_InterruptCheck(MacroAssembler* masm);
495   static void Generate_StackCheck(MacroAssembler* masm);
496 
497   static void Generate_InterpreterEntryTrampoline(MacroAssembler* masm);
498   static void Generate_InterpreterExitTrampoline(MacroAssembler* masm);
499   static void Generate_InterpreterPushArgsAndCall(MacroAssembler* masm);
500   static void Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm);
501   static void Generate_InterpreterNotifyDeoptimized(MacroAssembler* masm);
502   static void Generate_InterpreterNotifySoftDeoptimized(MacroAssembler* masm);
503   static void Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm);
504 
505 #define DECLARE_CODE_AGE_BUILTIN_GENERATOR(C)                \
506   static void Generate_Make##C##CodeYoungAgainEvenMarking(   \
507       MacroAssembler* masm);                                 \
508   static void Generate_Make##C##CodeYoungAgainOddMarking(    \
509       MacroAssembler* masm);
510   CODE_AGE_LIST(DECLARE_CODE_AGE_BUILTIN_GENERATOR)
511 #undef DECLARE_CODE_AGE_BUILTIN_GENERATOR
512 
513   static void Generate_MarkCodeAsToBeExecutedOnce(MacroAssembler* masm);
514   static void Generate_MarkCodeAsExecutedOnce(MacroAssembler* masm);
515   static void Generate_MarkCodeAsExecutedTwice(MacroAssembler* masm);
516 
517   static void InitBuiltinFunctionTable();
518 
519   bool initialized_;
520 
521   friend class BuiltinFunctionTable;
522   friend class Isolate;
523 
524   DISALLOW_COPY_AND_ASSIGN(Builtins);
525 };
526 
527 }  // namespace internal
528 }  // namespace v8
529 
530 #endif  // V8_BUILTINS_H_
531