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