Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 4 | |
| 5 | #ifndef V8_BUILTINS_H_ |
| 6 | #define V8_BUILTINS_H_ |
| 7 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 8 | #include "src/base/flags.h" |
| 9 | #include "src/handles.h" |
| 10 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 11 | namespace v8 { |
| 12 | namespace internal { |
| 13 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 14 | // Forward declarations. |
| 15 | class CodeStubAssembler; |
| 16 | |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 17 | // Specifies extra arguments required by a C++ builtin. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 18 | enum class BuiltinExtraArguments : uint8_t { |
| 19 | kNone = 0u, |
| 20 | kTarget = 1u << 0, |
| 21 | kNewTarget = 1u << 1, |
| 22 | kTargetAndNewTarget = kTarget | kNewTarget |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 23 | }; |
| 24 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 25 | inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) { |
| 26 | return static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs); |
| 27 | } |
| 28 | |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 29 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 30 | #define CODE_AGE_LIST_WITH_ARG(V, A) \ |
| 31 | V(Quadragenarian, A) \ |
| 32 | V(Quinquagenarian, A) \ |
| 33 | V(Sexagenarian, A) \ |
| 34 | V(Septuagenarian, A) \ |
| 35 | V(Octogenarian, A) |
| 36 | |
| 37 | #define CODE_AGE_LIST_IGNORE_ARG(X, V) V(X) |
| 38 | |
| 39 | #define CODE_AGE_LIST(V) \ |
| 40 | CODE_AGE_LIST_WITH_ARG(CODE_AGE_LIST_IGNORE_ARG, V) |
| 41 | |
| 42 | #define CODE_AGE_LIST_COMPLETE(V) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 43 | V(ToBeExecutedOnce) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 44 | V(NotExecuted) \ |
| 45 | V(ExecutedOnce) \ |
| 46 | V(NoAge) \ |
| 47 | CODE_AGE_LIST_WITH_ARG(CODE_AGE_LIST_IGNORE_ARG, V) |
| 48 | |
| 49 | #define DECLARE_CODE_AGE_BUILTIN(C, V) \ |
| 50 | V(Make##C##CodeYoungAgainOddMarking, BUILTIN, \ |
| 51 | UNINITIALIZED, kNoExtraICState) \ |
| 52 | V(Make##C##CodeYoungAgainEvenMarking, BUILTIN, \ |
| 53 | UNINITIALIZED, kNoExtraICState) |
| 54 | |
| 55 | |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 56 | // Define list of builtins implemented in C++. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 57 | #define BUILTIN_LIST_C(V) \ |
| 58 | V(Illegal, kNone) \ |
| 59 | \ |
| 60 | V(EmptyFunction, kNone) \ |
| 61 | \ |
| 62 | V(ArrayConcat, kNone) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 63 | V(ArrayPop, kNone) \ |
| 64 | V(ArrayPush, kNone) \ |
| 65 | V(ArrayShift, kNone) \ |
| 66 | V(ArraySlice, kNone) \ |
| 67 | V(ArraySplice, kNone) \ |
| 68 | V(ArrayUnshift, kNone) \ |
| 69 | \ |
| 70 | V(ArrayBufferConstructor, kTarget) \ |
| 71 | V(ArrayBufferConstructor_ConstructStub, kTargetAndNewTarget) \ |
| 72 | V(ArrayBufferIsView, kNone) \ |
| 73 | \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 74 | V(BooleanConstructor, kNone) \ |
| 75 | V(BooleanConstructor_ConstructStub, kTargetAndNewTarget) \ |
| 76 | V(BooleanPrototypeToString, kNone) \ |
| 77 | V(BooleanPrototypeValueOf, kNone) \ |
| 78 | \ |
| 79 | V(DataViewConstructor, kNone) \ |
| 80 | V(DataViewConstructor_ConstructStub, kTargetAndNewTarget) \ |
| 81 | \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 82 | V(DateConstructor, kNone) \ |
| 83 | V(DateConstructor_ConstructStub, kTargetAndNewTarget) \ |
| 84 | V(DateNow, kNone) \ |
| 85 | V(DateParse, kNone) \ |
| 86 | V(DateUTC, kNone) \ |
| 87 | V(DatePrototypeSetDate, kNone) \ |
| 88 | V(DatePrototypeSetFullYear, kNone) \ |
| 89 | V(DatePrototypeSetHours, kNone) \ |
| 90 | V(DatePrototypeSetMilliseconds, kNone) \ |
| 91 | V(DatePrototypeSetMinutes, kNone) \ |
| 92 | V(DatePrototypeSetMonth, kNone) \ |
| 93 | V(DatePrototypeSetSeconds, kNone) \ |
| 94 | V(DatePrototypeSetTime, kNone) \ |
| 95 | V(DatePrototypeSetUTCDate, kNone) \ |
| 96 | V(DatePrototypeSetUTCFullYear, kNone) \ |
| 97 | V(DatePrototypeSetUTCHours, kNone) \ |
| 98 | V(DatePrototypeSetUTCMilliseconds, kNone) \ |
| 99 | V(DatePrototypeSetUTCMinutes, kNone) \ |
| 100 | V(DatePrototypeSetUTCMonth, kNone) \ |
| 101 | V(DatePrototypeSetUTCSeconds, kNone) \ |
| 102 | V(DatePrototypeToDateString, kNone) \ |
| 103 | V(DatePrototypeToISOString, kNone) \ |
| 104 | V(DatePrototypeToPrimitive, kNone) \ |
| 105 | V(DatePrototypeToUTCString, kNone) \ |
| 106 | V(DatePrototypeToString, kNone) \ |
| 107 | V(DatePrototypeToTimeString, kNone) \ |
| 108 | V(DatePrototypeValueOf, kNone) \ |
| 109 | V(DatePrototypeGetYear, kNone) \ |
| 110 | V(DatePrototypeSetYear, kNone) \ |
| 111 | \ |
| 112 | V(FunctionConstructor, kTargetAndNewTarget) \ |
| 113 | V(FunctionPrototypeBind, kNone) \ |
| 114 | V(FunctionPrototypeToString, kNone) \ |
| 115 | \ |
| 116 | V(GeneratorFunctionConstructor, kTargetAndNewTarget) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 117 | V(AsyncFunctionConstructor, kTargetAndNewTarget) \ |
| 118 | \ |
| 119 | V(GlobalEncodeURI, kNone) \ |
| 120 | V(GlobalEncodeURIComponent, kNone) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 121 | \ |
| 122 | V(GlobalEval, kTarget) \ |
| 123 | \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 124 | V(MathAcos, kNone) \ |
| 125 | V(MathAsin, kNone) \ |
| 126 | V(MathAtan, kNone) \ |
| 127 | V(MathFround, kNone) \ |
| 128 | V(MathImul, kNone) \ |
| 129 | \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 130 | V(ObjectAssign, kNone) \ |
| 131 | V(ObjectCreate, kNone) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 132 | V(ObjectDefineGetter, kNone) \ |
| 133 | V(ObjectDefineProperties, kNone) \ |
| 134 | V(ObjectDefineProperty, kNone) \ |
| 135 | V(ObjectDefineSetter, kNone) \ |
| 136 | V(ObjectEntries, kNone) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 137 | V(ObjectFreeze, kNone) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 138 | V(ObjectGetOwnPropertyDescriptor, kNone) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 139 | V(ObjectGetOwnPropertyDescriptors, kNone) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 140 | V(ObjectGetOwnPropertyNames, kNone) \ |
| 141 | V(ObjectGetOwnPropertySymbols, kNone) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 142 | V(ObjectGetPrototypeOf, kNone) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 143 | V(ObjectIs, kNone) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 144 | V(ObjectIsExtensible, kNone) \ |
| 145 | V(ObjectIsFrozen, kNone) \ |
| 146 | V(ObjectIsSealed, kNone) \ |
| 147 | V(ObjectKeys, kNone) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 148 | V(ObjectLookupGetter, kNone) \ |
| 149 | V(ObjectLookupSetter, kNone) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 150 | V(ObjectPreventExtensions, kNone) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 151 | V(ObjectProtoToString, kNone) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 152 | V(ObjectSeal, kNone) \ |
| 153 | V(ObjectValues, kNone) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 154 | \ |
| 155 | V(ProxyConstructor, kNone) \ |
| 156 | V(ProxyConstructor_ConstructStub, kTarget) \ |
| 157 | \ |
| 158 | V(ReflectDefineProperty, kNone) \ |
| 159 | V(ReflectDeleteProperty, kNone) \ |
| 160 | V(ReflectGet, kNone) \ |
| 161 | V(ReflectGetOwnPropertyDescriptor, kNone) \ |
| 162 | V(ReflectGetPrototypeOf, kNone) \ |
| 163 | V(ReflectHas, kNone) \ |
| 164 | V(ReflectIsExtensible, kNone) \ |
| 165 | V(ReflectOwnKeys, kNone) \ |
| 166 | V(ReflectPreventExtensions, kNone) \ |
| 167 | V(ReflectSet, kNone) \ |
| 168 | V(ReflectSetPrototypeOf, kNone) \ |
| 169 | \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 170 | V(StringFromCharCode, kNone) \ |
| 171 | \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 172 | V(SymbolConstructor, kNone) \ |
| 173 | V(SymbolConstructor_ConstructStub, kTarget) \ |
| 174 | \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 175 | V(HandleApiCall, kTargetAndNewTarget) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 176 | V(HandleApiCallAsFunction, kNone) \ |
| 177 | V(HandleApiCallAsConstructor, kNone) \ |
| 178 | \ |
| 179 | V(RestrictedFunctionPropertiesThrower, kNone) \ |
| 180 | V(RestrictedStrictArgumentsPropertiesThrower, kNone) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 181 | |
| 182 | // Define list of builtins implemented in assembly. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 183 | #define BUILTIN_LIST_A(V) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 184 | V(AllocateInNewSpace, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 185 | V(AllocateInOldSpace, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 186 | \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 187 | V(ArgumentsAdaptorTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 188 | \ |
| 189 | V(ConstructedNonConstructable, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 190 | \ |
| 191 | V(CallFunction_ReceiverIsNullOrUndefined, BUILTIN, UNINITIALIZED, \ |
| 192 | kNoExtraICState) \ |
| 193 | V(CallFunction_ReceiverIsNotNullOrUndefined, BUILTIN, UNINITIALIZED, \ |
| 194 | kNoExtraICState) \ |
| 195 | V(CallFunction_ReceiverIsAny, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 196 | V(TailCallFunction_ReceiverIsNullOrUndefined, BUILTIN, UNINITIALIZED, \ |
| 197 | kNoExtraICState) \ |
| 198 | V(TailCallFunction_ReceiverIsNotNullOrUndefined, BUILTIN, UNINITIALIZED, \ |
| 199 | kNoExtraICState) \ |
| 200 | V(TailCallFunction_ReceiverIsAny, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 201 | V(CallBoundFunction, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 202 | V(TailCallBoundFunction, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 203 | V(Call_ReceiverIsNullOrUndefined, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 204 | V(Call_ReceiverIsNotNullOrUndefined, BUILTIN, UNINITIALIZED, \ |
| 205 | kNoExtraICState) \ |
| 206 | V(Call_ReceiverIsAny, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 207 | V(TailCall_ReceiverIsNullOrUndefined, BUILTIN, UNINITIALIZED, \ |
| 208 | kNoExtraICState) \ |
| 209 | V(TailCall_ReceiverIsNotNullOrUndefined, BUILTIN, UNINITIALIZED, \ |
| 210 | kNoExtraICState) \ |
| 211 | V(TailCall_ReceiverIsAny, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 212 | \ |
| 213 | V(ConstructFunction, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 214 | V(ConstructBoundFunction, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 215 | V(ConstructProxy, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 216 | V(Construct, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 217 | \ |
| 218 | V(Apply, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 219 | \ |
| 220 | V(HandleFastApiCall, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 221 | \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 222 | V(InOptimizationQueue, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 223 | V(JSConstructStubGeneric, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 224 | V(JSBuiltinsConstructStub, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 225 | V(JSBuiltinsConstructStubForDerived, BUILTIN, UNINITIALIZED, \ |
| 226 | kNoExtraICState) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 227 | V(JSConstructStubApi, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 228 | V(JSEntryTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 229 | V(JSConstructEntryTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 230 | V(ResumeGeneratorTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 231 | V(CompileLazy, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 232 | V(CompileBaseline, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 233 | V(CompileOptimized, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 234 | V(CompileOptimizedConcurrent, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 235 | V(NotifyDeoptimized, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 236 | V(NotifySoftDeoptimized, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 237 | V(NotifyLazyDeoptimized, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 238 | V(NotifyStubFailure, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 239 | V(NotifyStubFailureSaveDoubles, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 240 | \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 241 | V(InterpreterEntryTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 242 | V(InterpreterPushArgsAndCall, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 243 | V(InterpreterPushArgsAndTailCall, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 244 | V(InterpreterPushArgsAndConstruct, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 245 | V(InterpreterEnterBytecodeDispatch, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 246 | \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 247 | V(LoadIC_Miss, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 248 | V(KeyedLoadIC_Miss, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 249 | V(StoreIC_Miss, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 250 | V(KeyedStoreIC_Miss, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 251 | V(LoadIC_Getter_ForDeopt, LOAD_IC, MONOMORPHIC, kNoExtraICState) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 252 | V(KeyedLoadIC_Megamorphic, KEYED_LOAD_IC, MEGAMORPHIC, kNoExtraICState) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 253 | \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 254 | V(StoreIC_Setter_ForDeopt, STORE_IC, MONOMORPHIC, \ |
| 255 | StoreICState::kStrictModeState) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 256 | \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 257 | V(StoreIC_Megamorphic, STORE_IC, MEGAMORPHIC, kNoExtraICState) \ |
| 258 | V(StoreIC_Megamorphic_Strict, STORE_IC, MEGAMORPHIC, \ |
| 259 | StoreICState::kStrictModeState) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 260 | \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 261 | V(KeyedStoreIC_Megamorphic, KEYED_STORE_IC, MEGAMORPHIC, kNoExtraICState) \ |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 262 | V(KeyedStoreIC_Megamorphic_Strict, KEYED_STORE_IC, MEGAMORPHIC, \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 263 | StoreICState::kStrictModeState) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 264 | \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 265 | V(DatePrototypeGetDate, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 266 | V(DatePrototypeGetDay, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 267 | V(DatePrototypeGetFullYear, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 268 | V(DatePrototypeGetHours, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 269 | V(DatePrototypeGetMilliseconds, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 270 | V(DatePrototypeGetMinutes, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 271 | V(DatePrototypeGetMonth, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 272 | V(DatePrototypeGetSeconds, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 273 | V(DatePrototypeGetTime, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 274 | V(DatePrototypeGetTimezoneOffset, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 275 | V(DatePrototypeGetUTCDate, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 276 | V(DatePrototypeGetUTCDay, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 277 | V(DatePrototypeGetUTCFullYear, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 278 | V(DatePrototypeGetUTCHours, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 279 | V(DatePrototypeGetUTCMilliseconds, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 280 | V(DatePrototypeGetUTCMinutes, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 281 | V(DatePrototypeGetUTCMonth, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 282 | V(DatePrototypeGetUTCSeconds, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 283 | \ |
| 284 | V(FunctionPrototypeApply, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 285 | V(FunctionPrototypeCall, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 286 | \ |
| 287 | V(ReflectApply, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 288 | V(ReflectConstruct, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 289 | \ |
| 290 | V(InternalArrayCode, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 291 | V(ArrayCode, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 292 | \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 293 | V(MathMax, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 294 | V(MathMin, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 295 | \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 296 | V(NumberConstructor, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 297 | V(NumberConstructor_ConstructStub, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 298 | \ |
| 299 | V(StringConstructor, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 300 | V(StringConstructor_ConstructStub, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 301 | \ |
| 302 | V(OnStackReplacement, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 303 | V(InterruptCheck, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 304 | V(StackCheck, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 305 | \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 306 | V(MarkCodeAsToBeExecutedOnce, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 307 | V(MarkCodeAsExecutedOnce, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 308 | V(MarkCodeAsExecutedTwice, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
| 309 | CODE_AGE_LIST_WITH_ARG(DECLARE_CODE_AGE_BUILTIN, V) |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 310 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 311 | // Define list of builtins implemented in TurboFan (with JS linkage). |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 312 | #define BUILTIN_LIST_T(V) \ |
| 313 | V(FunctionPrototypeHasInstance, 2) \ |
| 314 | V(GeneratorPrototypeNext, 2) \ |
| 315 | V(GeneratorPrototypeReturn, 2) \ |
| 316 | V(GeneratorPrototypeThrow, 2) \ |
| 317 | V(MathCeil, 2) \ |
| 318 | V(MathClz32, 2) \ |
| 319 | V(MathFloor, 2) \ |
| 320 | V(MathRound, 2) \ |
| 321 | V(MathSqrt, 2) \ |
| 322 | V(MathTrunc, 2) \ |
| 323 | V(ObjectHasOwnProperty, 2) \ |
| 324 | V(ArrayIsArray, 2) \ |
| 325 | V(StringPrototypeCharAt, 2) \ |
| 326 | V(StringPrototypeCharCodeAt, 2) \ |
| 327 | V(AtomicsLoad, 3) \ |
| 328 | V(AtomicsStore, 4) |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 329 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 330 | // Define list of builtin handlers implemented in assembly. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 331 | #define BUILTIN_LIST_H(V) \ |
| 332 | V(LoadIC_Slow, LOAD_IC) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 333 | V(KeyedLoadIC_Slow, KEYED_LOAD_IC) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 334 | V(StoreIC_Slow, STORE_IC) \ |
| 335 | V(KeyedStoreIC_Slow, KEYED_STORE_IC) \ |
| 336 | V(LoadIC_Normal, LOAD_IC) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 337 | V(StoreIC_Normal, STORE_IC) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 338 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 339 | // Define list of builtins used by the debugger implemented in assembly. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 340 | #define BUILTIN_LIST_DEBUG_A(V) \ |
| 341 | V(Return_DebugBreak, BUILTIN, DEBUG_STUB, kNoExtraICState) \ |
| 342 | V(Slot_DebugBreak, BUILTIN, DEBUG_STUB, kNoExtraICState) \ |
| 343 | V(FrameDropper_LiveEdit, BUILTIN, DEBUG_STUB, kNoExtraICState) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 344 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 345 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 346 | class BuiltinFunctionTable; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 347 | class ObjectVisitor; |
| 348 | |
| 349 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 350 | class Builtins { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 351 | public: |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 352 | ~Builtins(); |
| 353 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 354 | // Generate all builtin code objects. Should be called once during |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 355 | // isolate initialization. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 356 | void SetUp(Isolate* isolate, bool create_heap_objects); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 357 | void TearDown(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 358 | |
| 359 | // Garbage collection support. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 360 | void IterateBuiltins(ObjectVisitor* v); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 361 | |
| 362 | // Disassembler support. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 363 | const char* Lookup(byte* pc); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 364 | |
| 365 | enum Name { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 366 | #define DEF_ENUM_C(name, ignore) k##name, |
| 367 | #define DEF_ENUM_A(name, kind, state, extra) k##name, |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 368 | #define DEF_ENUM_T(name, argc) k##name, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 369 | #define DEF_ENUM_H(name, kind) k##name, |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 370 | BUILTIN_LIST_C(DEF_ENUM_C) BUILTIN_LIST_A(DEF_ENUM_A) |
| 371 | BUILTIN_LIST_T(DEF_ENUM_T) BUILTIN_LIST_H(DEF_ENUM_H) |
| 372 | BUILTIN_LIST_DEBUG_A(DEF_ENUM_A) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 373 | #undef DEF_ENUM_C |
| 374 | #undef DEF_ENUM_A |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 375 | #undef DEF_ENUM_T |
| 376 | #undef DEF_ENUM_H |
| 377 | builtin_count |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 378 | }; |
| 379 | |
| 380 | enum CFunctionId { |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 381 | #define DEF_ENUM_C(name, ignore) c_##name, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 382 | BUILTIN_LIST_C(DEF_ENUM_C) |
| 383 | #undef DEF_ENUM_C |
| 384 | cfunction_count |
| 385 | }; |
| 386 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 387 | #define DECLARE_BUILTIN_ACCESSOR_C(name, ignore) Handle<Code> name(); |
| 388 | #define DECLARE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ |
| 389 | Handle<Code> name(); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 390 | #define DECLARE_BUILTIN_ACCESSOR_T(name, argc) Handle<Code> name(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 391 | #define DECLARE_BUILTIN_ACCESSOR_H(name, kind) Handle<Code> name(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 392 | BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C) |
| 393 | BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A) |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 394 | BUILTIN_LIST_T(DECLARE_BUILTIN_ACCESSOR_T) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 395 | BUILTIN_LIST_H(DECLARE_BUILTIN_ACCESSOR_H) |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 396 | BUILTIN_LIST_DEBUG_A(DECLARE_BUILTIN_ACCESSOR_A) |
| 397 | #undef DECLARE_BUILTIN_ACCESSOR_C |
| 398 | #undef DECLARE_BUILTIN_ACCESSOR_A |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 399 | #undef DECLARE_BUILTIN_ACCESSOR_T |
| 400 | #undef DECLARE_BUILTIN_ACCESSOR_H |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 401 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 402 | // Convenience wrappers. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 403 | Handle<Code> CallFunction( |
| 404 | ConvertReceiverMode = ConvertReceiverMode::kAny, |
| 405 | TailCallMode tail_call_mode = TailCallMode::kDisallow); |
| 406 | Handle<Code> Call(ConvertReceiverMode = ConvertReceiverMode::kAny, |
| 407 | TailCallMode tail_call_mode = TailCallMode::kDisallow); |
| 408 | Handle<Code> CallBoundFunction(TailCallMode tail_call_mode); |
| 409 | Handle<Code> InterpreterPushArgsAndCall(TailCallMode tail_call_mode); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 410 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 411 | Code* builtin(Name name) { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 412 | // Code::cast cannot be used here since we access builtins |
| 413 | // during the marking phase of mark sweep. See IC::Clear. |
| 414 | return reinterpret_cast<Code*>(builtins_[name]); |
| 415 | } |
| 416 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 417 | Address builtin_address(Name name) { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 418 | return reinterpret_cast<Address>(&builtins_[name]); |
| 419 | } |
| 420 | |
| 421 | static Address c_function_address(CFunctionId id) { |
| 422 | return c_functions_[id]; |
| 423 | } |
| 424 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 425 | const char* name(int index) { |
| 426 | DCHECK(index >= 0); |
| 427 | DCHECK(index < builtin_count); |
| 428 | return names_[index]; |
| 429 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 430 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 431 | bool is_initialized() const { return initialized_; } |
| 432 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 433 | MUST_USE_RESULT static MaybeHandle<Object> InvokeApiFunction( |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 434 | Handle<HeapObject> function, Handle<Object> receiver, int argc, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 435 | Handle<Object> args[]); |
| 436 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 437 | private: |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 438 | Builtins(); |
| 439 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 440 | // The external C++ functions called from the code. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 441 | static Address const c_functions_[cfunction_count]; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 442 | |
| 443 | // Note: These are always Code objects, but to conform with |
| 444 | // IterateBuiltins() above which assumes Object**'s for the callback |
| 445 | // function f, we use an Object* array here. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 446 | Object* builtins_[builtin_count]; |
| 447 | const char* names_[builtin_count]; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 448 | |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 449 | static void Generate_Adaptor(MacroAssembler* masm, |
| 450 | CFunctionId id, |
| 451 | BuiltinExtraArguments extra_args); |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 452 | static void Generate_AllocateInNewSpace(MacroAssembler* masm); |
| 453 | static void Generate_AllocateInOldSpace(MacroAssembler* masm); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 454 | static void Generate_ConstructedNonConstructable(MacroAssembler* masm); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 455 | static void Generate_CompileLazy(MacroAssembler* masm); |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 456 | static void Generate_CompileBaseline(MacroAssembler* masm); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 457 | static void Generate_InOptimizationQueue(MacroAssembler* masm); |
| 458 | static void Generate_CompileOptimized(MacroAssembler* masm); |
| 459 | static void Generate_CompileOptimizedConcurrent(MacroAssembler* masm); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 460 | static void Generate_JSConstructStubGeneric(MacroAssembler* masm); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 461 | static void Generate_JSBuiltinsConstructStub(MacroAssembler* masm); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 462 | static void Generate_JSBuiltinsConstructStubForDerived(MacroAssembler* masm); |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 463 | static void Generate_JSConstructStubApi(MacroAssembler* masm); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 464 | static void Generate_JSEntryTrampoline(MacroAssembler* masm); |
| 465 | static void Generate_JSConstructEntryTrampoline(MacroAssembler* masm); |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 466 | static void Generate_ResumeGeneratorTrampoline(MacroAssembler* masm); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 467 | static void Generate_NotifyDeoptimized(MacroAssembler* masm); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 468 | static void Generate_NotifySoftDeoptimized(MacroAssembler* masm); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 469 | static void Generate_NotifyLazyDeoptimized(MacroAssembler* masm); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 470 | static void Generate_NotifyStubFailure(MacroAssembler* masm); |
| 471 | static void Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 472 | static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm); |
| 473 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 474 | static void Generate_Apply(MacroAssembler* masm); |
| 475 | |
| 476 | // ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) |
| 477 | static void Generate_CallFunction(MacroAssembler* masm, |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 478 | ConvertReceiverMode mode, |
| 479 | TailCallMode tail_call_mode); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 480 | static void Generate_CallFunction_ReceiverIsNullOrUndefined( |
| 481 | MacroAssembler* masm) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 482 | Generate_CallFunction(masm, ConvertReceiverMode::kNullOrUndefined, |
| 483 | TailCallMode::kDisallow); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 484 | } |
| 485 | static void Generate_CallFunction_ReceiverIsNotNullOrUndefined( |
| 486 | MacroAssembler* masm) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 487 | Generate_CallFunction(masm, ConvertReceiverMode::kNotNullOrUndefined, |
| 488 | TailCallMode::kDisallow); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 489 | } |
| 490 | static void Generate_CallFunction_ReceiverIsAny(MacroAssembler* masm) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 491 | Generate_CallFunction(masm, ConvertReceiverMode::kAny, |
| 492 | TailCallMode::kDisallow); |
| 493 | } |
| 494 | static void Generate_TailCallFunction_ReceiverIsNullOrUndefined( |
| 495 | MacroAssembler* masm) { |
| 496 | Generate_CallFunction(masm, ConvertReceiverMode::kNullOrUndefined, |
| 497 | TailCallMode::kAllow); |
| 498 | } |
| 499 | static void Generate_TailCallFunction_ReceiverIsNotNullOrUndefined( |
| 500 | MacroAssembler* masm) { |
| 501 | Generate_CallFunction(masm, ConvertReceiverMode::kNotNullOrUndefined, |
| 502 | TailCallMode::kAllow); |
| 503 | } |
| 504 | static void Generate_TailCallFunction_ReceiverIsAny(MacroAssembler* masm) { |
| 505 | Generate_CallFunction(masm, ConvertReceiverMode::kAny, |
| 506 | TailCallMode::kAllow); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 507 | } |
| 508 | // ES6 section 9.4.1.1 [[Call]] ( thisArgument, argumentsList) |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 509 | static void Generate_CallBoundFunctionImpl(MacroAssembler* masm, |
| 510 | TailCallMode tail_call_mode); |
| 511 | static void Generate_CallBoundFunction(MacroAssembler* masm) { |
| 512 | Generate_CallBoundFunctionImpl(masm, TailCallMode::kDisallow); |
| 513 | } |
| 514 | static void Generate_TailCallBoundFunction(MacroAssembler* masm) { |
| 515 | Generate_CallBoundFunctionImpl(masm, TailCallMode::kAllow); |
| 516 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 517 | // ES6 section 7.3.12 Call(F, V, [argumentsList]) |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 518 | static void Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode, |
| 519 | TailCallMode tail_call_mode); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 520 | static void Generate_Call_ReceiverIsNullOrUndefined(MacroAssembler* masm) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 521 | Generate_Call(masm, ConvertReceiverMode::kNullOrUndefined, |
| 522 | TailCallMode::kDisallow); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 523 | } |
| 524 | static void Generate_Call_ReceiverIsNotNullOrUndefined(MacroAssembler* masm) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 525 | Generate_Call(masm, ConvertReceiverMode::kNotNullOrUndefined, |
| 526 | TailCallMode::kDisallow); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 527 | } |
| 528 | static void Generate_Call_ReceiverIsAny(MacroAssembler* masm) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 529 | Generate_Call(masm, ConvertReceiverMode::kAny, TailCallMode::kDisallow); |
| 530 | } |
| 531 | static void Generate_TailCall_ReceiverIsNullOrUndefined( |
| 532 | MacroAssembler* masm) { |
| 533 | Generate_Call(masm, ConvertReceiverMode::kNullOrUndefined, |
| 534 | TailCallMode::kAllow); |
| 535 | } |
| 536 | static void Generate_TailCall_ReceiverIsNotNullOrUndefined( |
| 537 | MacroAssembler* masm) { |
| 538 | Generate_Call(masm, ConvertReceiverMode::kNotNullOrUndefined, |
| 539 | TailCallMode::kAllow); |
| 540 | } |
| 541 | static void Generate_TailCall_ReceiverIsAny(MacroAssembler* masm) { |
| 542 | Generate_Call(masm, ConvertReceiverMode::kAny, TailCallMode::kAllow); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | // ES6 section 9.2.2 [[Construct]] ( argumentsList, newTarget) |
| 546 | static void Generate_ConstructFunction(MacroAssembler* masm); |
| 547 | // ES6 section 9.4.1.2 [[Construct]] (argumentsList, newTarget) |
| 548 | static void Generate_ConstructBoundFunction(MacroAssembler* masm); |
| 549 | // ES6 section 9.5.14 [[Construct]] ( argumentsList, newTarget) |
| 550 | static void Generate_ConstructProxy(MacroAssembler* masm); |
| 551 | // ES6 section 7.3.13 Construct (F, [argumentsList], [newTarget]) |
| 552 | static void Generate_Construct(MacroAssembler* masm); |
| 553 | |
| 554 | static void Generate_HandleFastApiCall(MacroAssembler* masm); |
| 555 | |
| 556 | static void Generate_DatePrototype_GetField(MacroAssembler* masm, |
| 557 | int field_index); |
| 558 | // ES6 section 20.3.4.2 Date.prototype.getDate ( ) |
| 559 | static void Generate_DatePrototypeGetDate(MacroAssembler* masm); |
| 560 | // ES6 section 20.3.4.3 Date.prototype.getDay ( ) |
| 561 | static void Generate_DatePrototypeGetDay(MacroAssembler* masm); |
| 562 | // ES6 section 20.3.4.4 Date.prototype.getFullYear ( ) |
| 563 | static void Generate_DatePrototypeGetFullYear(MacroAssembler* masm); |
| 564 | // ES6 section 20.3.4.5 Date.prototype.getHours ( ) |
| 565 | static void Generate_DatePrototypeGetHours(MacroAssembler* masm); |
| 566 | // ES6 section 20.3.4.6 Date.prototype.getMilliseconds ( ) |
| 567 | static void Generate_DatePrototypeGetMilliseconds(MacroAssembler* masm); |
| 568 | // ES6 section 20.3.4.7 Date.prototype.getMinutes ( ) |
| 569 | static void Generate_DatePrototypeGetMinutes(MacroAssembler* masm); |
| 570 | // ES6 section 20.3.4.8 Date.prototype.getMonth ( ) |
| 571 | static void Generate_DatePrototypeGetMonth(MacroAssembler* masm); |
| 572 | // ES6 section 20.3.4.9 Date.prototype.getSeconds ( ) |
| 573 | static void Generate_DatePrototypeGetSeconds(MacroAssembler* masm); |
| 574 | // ES6 section 20.3.4.10 Date.prototype.getTime ( ) |
| 575 | static void Generate_DatePrototypeGetTime(MacroAssembler* masm); |
| 576 | // ES6 section 20.3.4.11 Date.prototype.getTimezoneOffset ( ) |
| 577 | static void Generate_DatePrototypeGetTimezoneOffset(MacroAssembler* masm); |
| 578 | // ES6 section 20.3.4.12 Date.prototype.getUTCDate ( ) |
| 579 | static void Generate_DatePrototypeGetUTCDate(MacroAssembler* masm); |
| 580 | // ES6 section 20.3.4.13 Date.prototype.getUTCDay ( ) |
| 581 | static void Generate_DatePrototypeGetUTCDay(MacroAssembler* masm); |
| 582 | // ES6 section 20.3.4.14 Date.prototype.getUTCFullYear ( ) |
| 583 | static void Generate_DatePrototypeGetUTCFullYear(MacroAssembler* masm); |
| 584 | // ES6 section 20.3.4.15 Date.prototype.getUTCHours ( ) |
| 585 | static void Generate_DatePrototypeGetUTCHours(MacroAssembler* masm); |
| 586 | // ES6 section 20.3.4.16 Date.prototype.getUTCMilliseconds ( ) |
| 587 | static void Generate_DatePrototypeGetUTCMilliseconds(MacroAssembler* masm); |
| 588 | // ES6 section 20.3.4.17 Date.prototype.getUTCMinutes ( ) |
| 589 | static void Generate_DatePrototypeGetUTCMinutes(MacroAssembler* masm); |
| 590 | // ES6 section 20.3.4.18 Date.prototype.getUTCMonth ( ) |
| 591 | static void Generate_DatePrototypeGetUTCMonth(MacroAssembler* masm); |
| 592 | // ES6 section 20.3.4.19 Date.prototype.getUTCSeconds ( ) |
| 593 | static void Generate_DatePrototypeGetUTCSeconds(MacroAssembler* masm); |
| 594 | |
| 595 | static void Generate_FunctionPrototypeApply(MacroAssembler* masm); |
| 596 | static void Generate_FunctionPrototypeCall(MacroAssembler* masm); |
| 597 | |
| 598 | static void Generate_ReflectApply(MacroAssembler* masm); |
| 599 | static void Generate_ReflectConstruct(MacroAssembler* masm); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 600 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 601 | static void Generate_InternalArrayCode(MacroAssembler* masm); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 602 | static void Generate_ArrayCode(MacroAssembler* masm); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 603 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 604 | // ES6 section 20.2.2.10 Math.ceil ( x ) |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 605 | static void Generate_MathCeil(CodeStubAssembler* assembler); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 606 | // ES6 section 20.2.2.11 Math.clz32 ( x ) |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 607 | static void Generate_MathClz32(CodeStubAssembler* assembler); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 608 | // ES6 section 20.2.2.16 Math.floor ( x ) |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 609 | static void Generate_MathFloor(CodeStubAssembler* assembler); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 610 | enum class MathMaxMinKind { kMax, kMin }; |
| 611 | static void Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind); |
| 612 | // ES6 section 20.2.2.24 Math.max ( value1, value2 , ...values ) |
| 613 | static void Generate_MathMax(MacroAssembler* masm) { |
| 614 | Generate_MathMaxMin(masm, MathMaxMinKind::kMax); |
| 615 | } |
| 616 | // ES6 section 20.2.2.25 Math.min ( value1, value2 , ...values ) |
| 617 | static void Generate_MathMin(MacroAssembler* masm) { |
| 618 | Generate_MathMaxMin(masm, MathMaxMinKind::kMin); |
| 619 | } |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 620 | // ES6 section 20.2.2.28 Math.round ( x ) |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 621 | static void Generate_MathRound(CodeStubAssembler* assembler); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 622 | // ES6 section 20.2.2.32 Math.sqrt ( x ) |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 623 | static void Generate_MathSqrt(CodeStubAssembler* assembler); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 624 | // ES6 section 20.2.2.35 Math.trunc ( x ) |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 625 | static void Generate_MathTrunc(CodeStubAssembler* assembler); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 626 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 627 | // ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Call]] case. |
| 628 | static void Generate_NumberConstructor(MacroAssembler* masm); |
| 629 | // ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Construct]] case. |
| 630 | static void Generate_NumberConstructor_ConstructStub(MacroAssembler* masm); |
| 631 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 632 | // ES6 section 19.2.3.6 Function.prototype [ @@hasInstance ] ( V ) |
| 633 | static void Generate_FunctionPrototypeHasInstance( |
| 634 | CodeStubAssembler* assembler); |
| 635 | |
| 636 | // ES6 section 25.3.1.2 Generator.prototype.next ( value ) |
| 637 | static void Generate_GeneratorPrototypeNext(CodeStubAssembler* assembler); |
| 638 | // ES6 section 25.3.1.3 Generator.prototype.return ( value ) |
| 639 | static void Generate_GeneratorPrototypeReturn(CodeStubAssembler* assembler); |
| 640 | // ES6 section 25.3.1.4 Generator.prototype.throw ( exception ) |
| 641 | static void Generate_GeneratorPrototypeThrow(CodeStubAssembler* assembler); |
| 642 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 643 | // ES6 section 19.1.3.2 Object.prototype.hasOwnProperty |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 644 | static void Generate_ObjectHasOwnProperty(CodeStubAssembler* assembler); |
| 645 | |
| 646 | // ES6 section 22.1.2.2 Array.isArray |
| 647 | static void Generate_ArrayIsArray(CodeStubAssembler* assembler); |
| 648 | |
| 649 | // ES6 section 21.1.3.1 String.prototype.charAt ( pos ) |
| 650 | static void Generate_StringPrototypeCharAt(CodeStubAssembler* assembler); |
| 651 | // ES6 section 21.1.3.2 String.prototype.charCodeAt ( pos ) |
| 652 | static void Generate_StringPrototypeCharCodeAt(CodeStubAssembler* assembler); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 653 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 654 | static void Generate_StringConstructor(MacroAssembler* masm); |
| 655 | static void Generate_StringConstructor_ConstructStub(MacroAssembler* masm); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 656 | static void Generate_OnStackReplacement(MacroAssembler* masm); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 657 | static void Generate_InterruptCheck(MacroAssembler* masm); |
| 658 | static void Generate_StackCheck(MacroAssembler* masm); |
| 659 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 660 | static void Generate_InterpreterEntryTrampoline(MacroAssembler* masm); |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 661 | static void Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 662 | static void Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { |
| 663 | return Generate_InterpreterPushArgsAndCallImpl(masm, |
| 664 | TailCallMode::kDisallow); |
| 665 | } |
| 666 | static void Generate_InterpreterPushArgsAndTailCall(MacroAssembler* masm) { |
| 667 | return Generate_InterpreterPushArgsAndCallImpl(masm, TailCallMode::kAllow); |
| 668 | } |
| 669 | static void Generate_InterpreterPushArgsAndCallImpl( |
| 670 | MacroAssembler* masm, TailCallMode tail_call_mode); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 671 | static void Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 672 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 673 | #define DECLARE_CODE_AGE_BUILTIN_GENERATOR(C) \ |
| 674 | static void Generate_Make##C##CodeYoungAgainEvenMarking( \ |
| 675 | MacroAssembler* masm); \ |
| 676 | static void Generate_Make##C##CodeYoungAgainOddMarking( \ |
| 677 | MacroAssembler* masm); |
| 678 | CODE_AGE_LIST(DECLARE_CODE_AGE_BUILTIN_GENERATOR) |
| 679 | #undef DECLARE_CODE_AGE_BUILTIN_GENERATOR |
| 680 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 681 | static void Generate_MarkCodeAsToBeExecutedOnce(MacroAssembler* masm); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 682 | static void Generate_MarkCodeAsExecutedOnce(MacroAssembler* masm); |
| 683 | static void Generate_MarkCodeAsExecutedTwice(MacroAssembler* masm); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 684 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 685 | static void Generate_AtomicsLoad(CodeStubAssembler* assembler); |
| 686 | static void Generate_AtomicsStore(CodeStubAssembler* assembler); |
| 687 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 688 | static void InitBuiltinFunctionTable(); |
| 689 | |
| 690 | bool initialized_; |
| 691 | |
| 692 | friend class BuiltinFunctionTable; |
| 693 | friend class Isolate; |
| 694 | |
| 695 | DISALLOW_COPY_AND_ASSIGN(Builtins); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 696 | }; |
| 697 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 698 | } // namespace internal |
| 699 | } // namespace v8 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 700 | |
| 701 | #endif // V8_BUILTINS_H_ |