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