Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1 | // Copyright 2012 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_CODE_STUBS_H_ |
| 6 | #define V8_CODE_STUBS_H_ |
| 7 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 8 | #include "src/allocation.h" |
| 9 | #include "src/assembler.h" |
| 10 | #include "src/codegen.h" |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 11 | #include "src/compiler/code-stub-assembler.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 12 | #include "src/globals.h" |
| 13 | #include "src/ic/ic-state.h" |
| 14 | #include "src/interface-descriptors.h" |
| 15 | #include "src/macro-assembler.h" |
| 16 | #include "src/ostreams.h" |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 17 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 18 | namespace v8 { |
| 19 | namespace internal { |
| 20 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 21 | // List of code stubs used on all platforms. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 22 | #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
| 23 | /* PlatformCodeStubs */ \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 24 | V(ArrayConstructor) \ |
| 25 | V(BinaryOpICWithAllocationSite) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 26 | V(CallApiCallback) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 27 | V(CallApiGetter) \ |
| 28 | V(CallConstruct) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 29 | V(CallIC) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 30 | V(CEntry) \ |
| 31 | V(CompareIC) \ |
| 32 | V(DoubleToI) \ |
| 33 | V(FunctionPrototype) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 34 | V(InstanceOf) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 35 | V(InternalArrayConstructor) \ |
| 36 | V(JSEntry) \ |
| 37 | V(KeyedLoadICTrampoline) \ |
| 38 | V(LoadICTrampoline) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 39 | V(CallICTrampoline) \ |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 40 | V(LoadIndexedString) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 41 | V(MathPow) \ |
| 42 | V(ProfileEntryHook) \ |
| 43 | V(RecordWrite) \ |
| 44 | V(RegExpExec) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 45 | V(StoreBufferOverflow) \ |
| 46 | V(StoreElement) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 47 | V(StubFailureTrampoline) \ |
| 48 | V(SubString) \ |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 49 | V(ToNumber) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 50 | V(NonNumberToNumber) \ |
| 51 | V(StringToNumber) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 52 | V(ToString) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 53 | V(ToName) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 54 | V(ToObject) \ |
| 55 | V(VectorStoreICTrampoline) \ |
| 56 | V(VectorKeyedStoreICTrampoline) \ |
| 57 | V(VectorStoreIC) \ |
| 58 | V(VectorKeyedStoreIC) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 59 | /* HydrogenCodeStubs */ \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 60 | V(AllocateInNewSpace) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 61 | V(ArrayNArgumentsConstructor) \ |
| 62 | V(ArrayNoArgumentConstructor) \ |
| 63 | V(ArraySingleArgumentConstructor) \ |
| 64 | V(BinaryOpIC) \ |
| 65 | V(BinaryOpWithAllocationSite) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 66 | V(CreateAllocationSite) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 67 | V(CreateWeakCell) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 68 | V(ElementsTransitionAndStore) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 69 | V(FastArrayPush) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 70 | V(FastCloneRegExp) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 71 | V(FastCloneShallowArray) \ |
| 72 | V(FastCloneShallowObject) \ |
| 73 | V(FastNewClosure) \ |
| 74 | V(FastNewContext) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 75 | V(FastNewObject) \ |
| 76 | V(FastNewRestParameter) \ |
| 77 | V(FastNewSloppyArguments) \ |
| 78 | V(FastNewStrictArguments) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 79 | V(GrowArrayElements) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 80 | V(InternalArrayNArgumentsConstructor) \ |
| 81 | V(InternalArrayNoArgumentConstructor) \ |
| 82 | V(InternalArraySingleArgumentConstructor) \ |
| 83 | V(KeyedLoadGeneric) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 84 | V(LoadGlobalViaContext) \ |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 85 | V(LoadScriptContextField) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 86 | V(LoadDictionaryElement) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 87 | V(NameDictionaryLookup) \ |
| 88 | V(NumberToString) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 89 | V(Typeof) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 90 | V(RegExpConstructResult) \ |
| 91 | V(StoreFastElement) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 92 | V(StoreGlobalViaContext) \ |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 93 | V(StoreScriptContextField) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 94 | V(StringAdd) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 95 | V(ToBooleanIC) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 96 | V(TransitionElementsKind) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 97 | V(KeyedLoadIC) \ |
| 98 | V(LoadIC) \ |
| 99 | /* TurboFanCodeStubs */ \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 100 | V(AllocateHeapNumber) \ |
| 101 | V(AllocateMutableHeapNumber) \ |
| 102 | V(AllocateFloat32x4) \ |
| 103 | V(AllocateInt32x4) \ |
| 104 | V(AllocateUint32x4) \ |
| 105 | V(AllocateBool32x4) \ |
| 106 | V(AllocateInt16x8) \ |
| 107 | V(AllocateUint16x8) \ |
| 108 | V(AllocateBool16x8) \ |
| 109 | V(AllocateInt8x16) \ |
| 110 | V(AllocateUint8x16) \ |
| 111 | V(AllocateBool8x16) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 112 | V(StringLength) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 113 | V(Add) \ |
| 114 | V(Subtract) \ |
| 115 | V(BitwiseAnd) \ |
| 116 | V(BitwiseOr) \ |
| 117 | V(BitwiseXor) \ |
| 118 | V(LessThan) \ |
| 119 | V(LessThanOrEqual) \ |
| 120 | V(GreaterThan) \ |
| 121 | V(GreaterThanOrEqual) \ |
| 122 | V(Equal) \ |
| 123 | V(NotEqual) \ |
| 124 | V(StrictEqual) \ |
| 125 | V(StrictNotEqual) \ |
| 126 | V(StringEqual) \ |
| 127 | V(StringNotEqual) \ |
| 128 | V(StringLessThan) \ |
| 129 | V(StringLessThanOrEqual) \ |
| 130 | V(StringGreaterThan) \ |
| 131 | V(StringGreaterThanOrEqual) \ |
| 132 | V(ToBoolean) \ |
| 133 | V(ToInteger) \ |
| 134 | V(ToLength) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 135 | /* IC Handler stubs */ \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 136 | V(ArrayBufferViewLoadField) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 137 | V(LoadConstant) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 138 | V(LoadFastElement) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 139 | V(LoadField) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 140 | V(LoadIndexedInterceptor) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 141 | V(KeyedLoadSloppyArguments) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 142 | V(KeyedStoreSloppyArguments) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 143 | V(StoreField) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 144 | V(StoreInterceptor) \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 145 | V(StoreGlobal) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 146 | V(StoreTransition) |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 147 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 148 | // List of code stubs only used on ARM 32 bits platforms. |
| 149 | #if V8_TARGET_ARCH_ARM |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 150 | #define CODE_STUB_LIST_ARM(V) V(DirectCEntry) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 151 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 152 | #else |
| 153 | #define CODE_STUB_LIST_ARM(V) |
| 154 | #endif |
| 155 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 156 | // List of code stubs only used on ARM 64 bits platforms. |
| 157 | #if V8_TARGET_ARCH_ARM64 |
| 158 | #define CODE_STUB_LIST_ARM64(V) \ |
| 159 | V(DirectCEntry) \ |
| 160 | V(RestoreRegistersState) \ |
| 161 | V(StoreRegistersState) |
| 162 | |
| 163 | #else |
| 164 | #define CODE_STUB_LIST_ARM64(V) |
| 165 | #endif |
| 166 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 167 | // List of code stubs only used on PPC platforms. |
| 168 | #ifdef V8_TARGET_ARCH_PPC |
| 169 | #define CODE_STUB_LIST_PPC(V) \ |
| 170 | V(DirectCEntry) \ |
| 171 | V(StoreRegistersState) \ |
| 172 | V(RestoreRegistersState) |
| 173 | #else |
| 174 | #define CODE_STUB_LIST_PPC(V) |
| 175 | #endif |
| 176 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 177 | // List of code stubs only used on MIPS platforms. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 178 | #if V8_TARGET_ARCH_MIPS |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 179 | #define CODE_STUB_LIST_MIPS(V) \ |
| 180 | V(DirectCEntry) \ |
| 181 | V(RestoreRegistersState) \ |
| 182 | V(StoreRegistersState) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 183 | #elif V8_TARGET_ARCH_MIPS64 |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 184 | #define CODE_STUB_LIST_MIPS(V) \ |
| 185 | V(DirectCEntry) \ |
| 186 | V(RestoreRegistersState) \ |
| 187 | V(StoreRegistersState) |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 188 | #else |
| 189 | #define CODE_STUB_LIST_MIPS(V) |
| 190 | #endif |
| 191 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 192 | // List of code stubs only used on S390 platforms. |
| 193 | #ifdef V8_TARGET_ARCH_S390 |
| 194 | #define CODE_STUB_LIST_S390(V) \ |
| 195 | V(DirectCEntry) \ |
| 196 | V(StoreRegistersState) \ |
| 197 | V(RestoreRegistersState) |
| 198 | #else |
| 199 | #define CODE_STUB_LIST_S390(V) |
| 200 | #endif |
| 201 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 202 | // Combined list of code stubs. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 203 | #define CODE_STUB_LIST(V) \ |
| 204 | CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
| 205 | CODE_STUB_LIST_ARM(V) \ |
| 206 | CODE_STUB_LIST_ARM64(V) \ |
| 207 | CODE_STUB_LIST_PPC(V) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 208 | CODE_STUB_LIST_MIPS(V) \ |
| 209 | CODE_STUB_LIST_S390(V) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 210 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 211 | static const int kHasReturnedMinusZeroSentinel = 1; |
| 212 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 213 | // Stub is base classes of all stubs. |
| 214 | class CodeStub BASE_EMBEDDED { |
| 215 | public: |
| 216 | enum Major { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 217 | // TODO(mvstanton): eliminate the NoCache key by getting rid |
| 218 | // of the non-monomorphic-cache. |
| 219 | NoCache = 0, // marker for stubs that do custom caching] |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 220 | #define DEF_ENUM(name) name, |
| 221 | CODE_STUB_LIST(DEF_ENUM) |
| 222 | #undef DEF_ENUM |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 223 | NUMBER_OF_IDS |
| 224 | }; |
| 225 | |
| 226 | // Retrieve the code for the stub. Generate the code if needed. |
| 227 | Handle<Code> GetCode(); |
| 228 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 229 | // Retrieve the code for the stub, make and return a copy of the code. |
| 230 | Handle<Code> GetCodeCopy(const Code::FindAndReplacePattern& pattern); |
| 231 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 232 | static Major MajorKeyFromKey(uint32_t key) { |
| 233 | return static_cast<Major>(MajorKeyBits::decode(key)); |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 234 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 235 | static uint32_t MinorKeyFromKey(uint32_t key) { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 236 | return MinorKeyBits::decode(key); |
Iain Merrick | 9ac36c9 | 2010-09-13 15:29:50 +0100 | [diff] [blame] | 237 | } |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 238 | |
| 239 | // Gets the major key from a code object that is a code stub or binary op IC. |
| 240 | static Major GetMajorKey(Code* code_stub) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 241 | return MajorKeyFromKey(code_stub->stub_key()); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 242 | } |
| 243 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 244 | static uint32_t NoCacheKey() { return MajorKeyBits::encode(NoCache); } |
| 245 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 246 | static const char* MajorName(Major major_key); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 247 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 248 | explicit CodeStub(Isolate* isolate) : minor_key_(0), isolate_(isolate) {} |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 249 | virtual ~CodeStub() {} |
| 250 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 251 | static void GenerateStubsAheadOfTime(Isolate* isolate); |
| 252 | static void GenerateFPStubs(Isolate* isolate); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 253 | |
| 254 | // Some stubs put untagged junk on the stack that cannot be scanned by the |
| 255 | // GC. This means that we must be statically sure that no GC can occur while |
| 256 | // they are running. If that is the case they should override this to return |
| 257 | // true, which will cause an assertion if we try to call something that can |
| 258 | // GC or if we try to put a stack frame on top of the junk, which would not |
| 259 | // result in a traversable stack. |
| 260 | virtual bool SometimesSetsUpAFrame() { return true; } |
| 261 | |
| 262 | // Lookup the code in the (possibly custom) cache. |
| 263 | bool FindCodeInCache(Code** code_out); |
| 264 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 265 | virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() const = 0; |
| 266 | |
| 267 | virtual int GetStackParameterCount() const { |
| 268 | return GetCallInterfaceDescriptor().GetStackParameterCount(); |
| 269 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 270 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 271 | virtual void InitializeDescriptor(CodeStubDescriptor* descriptor) {} |
| 272 | |
| 273 | static void InitializeDescriptor(Isolate* isolate, uint32_t key, |
| 274 | CodeStubDescriptor* desc); |
| 275 | |
| 276 | static MaybeHandle<Code> GetCode(Isolate* isolate, uint32_t key); |
| 277 | |
| 278 | // Returns information for computing the number key. |
| 279 | virtual Major MajorKey() const = 0; |
| 280 | uint32_t MinorKey() const { return minor_key_; } |
| 281 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 282 | // BinaryOpStub needs to override this. |
| 283 | virtual Code::Kind GetCodeKind() const; |
| 284 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 285 | virtual InlineCacheState GetICState() const { return UNINITIALIZED; } |
| 286 | virtual ExtraICState GetExtraICState() const { return kNoExtraICState; } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 287 | virtual Code::StubType GetStubType() const { return Code::NORMAL; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 288 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 289 | Code::Flags GetCodeFlags() const; |
| 290 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 291 | friend std::ostream& operator<<(std::ostream& os, const CodeStub& s) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 292 | s.PrintName(os); |
| 293 | return os; |
| 294 | } |
| 295 | |
| 296 | Isolate* isolate() const { return isolate_; } |
| 297 | |
| 298 | protected: |
| 299 | CodeStub(uint32_t key, Isolate* isolate) |
| 300 | : minor_key_(MinorKeyFromKey(key)), isolate_(isolate) {} |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 301 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 302 | // Generates the assembler code for the stub. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 303 | virtual Handle<Code> GenerateCode() = 0; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 304 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 305 | // Returns whether the code generated for this stub needs to be allocated as |
| 306 | // a fixed (non-moveable) code object. |
| 307 | virtual bool NeedsImmovableCode() { return false; } |
| 308 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 309 | virtual void PrintName(std::ostream& os) const; // NOLINT |
| 310 | virtual void PrintBaseName(std::ostream& os) const; // NOLINT |
| 311 | virtual void PrintState(std::ostream& os) const { ; } // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 312 | |
| 313 | // Computes the key based on major and minor. |
| 314 | uint32_t GetKey() { |
| 315 | DCHECK(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); |
| 316 | return MinorKeyBits::encode(MinorKey()) | MajorKeyBits::encode(MajorKey()); |
| 317 | } |
| 318 | |
| 319 | uint32_t minor_key_; |
| 320 | |
| 321 | private: |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 322 | // Perform bookkeeping required after code generation when stub code is |
| 323 | // initially generated. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 324 | void RecordCodeGeneration(Handle<Code> code); |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 325 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 326 | // Finish the code object after it has been generated. |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 327 | virtual void FinishCode(Handle<Code> code) { } |
| 328 | |
| 329 | // Activate newly generated stub. Is called after |
| 330 | // registering stub in the stub cache. |
| 331 | virtual void Activate(Code* code) { } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 332 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 333 | // Add the code to a specialized cache, specific to an individual |
| 334 | // stub type. Please note, this method must add the code object to a |
| 335 | // roots object, otherwise we will remove the code during GC. |
| 336 | virtual void AddToSpecialCache(Handle<Code> new_object) { } |
| 337 | |
| 338 | // Find code in a specialized cache, work is delegated to the specific stub. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 339 | virtual bool FindCodeInSpecialCache(Code** code_out) { |
| 340 | return false; |
| 341 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 342 | |
| 343 | // If a stub uses a special cache override this. |
| 344 | virtual bool UseSpecialCache() { return false; } |
| 345 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 346 | // We use this dispatch to statically instantiate the correct code stub for |
| 347 | // the given stub key and call the passed function with that code stub. |
| 348 | typedef void (*DispatchedCall)(CodeStub* stub, void** value_out); |
| 349 | static void Dispatch(Isolate* isolate, uint32_t key, void** value_out, |
| 350 | DispatchedCall call); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 351 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 352 | static void GetCodeDispatchCall(CodeStub* stub, void** value_out); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 353 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 354 | STATIC_ASSERT(NUMBER_OF_IDS < (1 << kStubMajorKeyBits)); |
| 355 | class MajorKeyBits: public BitField<uint32_t, 0, kStubMajorKeyBits> {}; |
| 356 | class MinorKeyBits: public BitField<uint32_t, |
| 357 | kStubMajorKeyBits, kStubMinorKeyBits> {}; // NOLINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 358 | |
| 359 | friend class BreakPointIterator; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 360 | |
| 361 | Isolate* isolate_; |
| 362 | }; |
| 363 | |
| 364 | |
| 365 | #define DEFINE_CODE_STUB_BASE(NAME, SUPER) \ |
| 366 | public: \ |
| 367 | NAME(uint32_t key, Isolate* isolate) : SUPER(key, isolate) {} \ |
| 368 | \ |
| 369 | private: \ |
| 370 | DISALLOW_COPY_AND_ASSIGN(NAME) |
| 371 | |
| 372 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 373 | #define DEFINE_CODE_STUB(NAME, SUPER) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 374 | public: \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 375 | inline Major MajorKey() const override { return NAME; }; \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 376 | \ |
| 377 | protected: \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 378 | DEFINE_CODE_STUB_BASE(NAME##Stub, SUPER) |
| 379 | |
| 380 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 381 | #define DEFINE_PLATFORM_CODE_STUB(NAME, SUPER) \ |
| 382 | private: \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 383 | void Generate(MacroAssembler* masm) override; \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 384 | DEFINE_CODE_STUB(NAME, SUPER) |
| 385 | |
| 386 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 387 | #define DEFINE_HYDROGEN_CODE_STUB(NAME, SUPER) \ |
| 388 | public: \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 389 | void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \ |
| 390 | Handle<Code> GenerateCode() override; \ |
| 391 | DEFINE_CODE_STUB(NAME, SUPER) |
| 392 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 393 | #define DEFINE_TURBOFAN_CODE_STUB(NAME, SUPER) \ |
| 394 | public: \ |
| 395 | void GenerateAssembly(compiler::CodeStubAssembler* assembler) \ |
| 396 | const override; \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 397 | DEFINE_CODE_STUB(NAME, SUPER) |
| 398 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 399 | #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \ |
| 400 | public: \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 401 | Handle<Code> GenerateCode() override; \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 402 | DEFINE_CODE_STUB(NAME, SUPER) |
| 403 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 404 | #define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \ |
| 405 | public: \ |
| 406 | CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ |
| 407 | return NAME##Descriptor(isolate()); \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | // There are some code stubs we just can't describe right now with a |
| 411 | // CallInterfaceDescriptor. Isolate behavior for those cases with this macro. |
| 412 | // An attempt to retrieve a descriptor will fail. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 413 | #define DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR() \ |
| 414 | public: \ |
| 415 | CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \ |
| 416 | UNREACHABLE(); \ |
| 417 | return CallInterfaceDescriptor(); \ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | |
| 421 | class PlatformCodeStub : public CodeStub { |
| 422 | public: |
| 423 | // Retrieve the code for the stub. Generate the code if needed. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 424 | Handle<Code> GenerateCode() override; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 425 | |
| 426 | protected: |
| 427 | explicit PlatformCodeStub(Isolate* isolate) : CodeStub(isolate) {} |
| 428 | |
| 429 | // Generates the assembler code for the stub. |
| 430 | virtual void Generate(MacroAssembler* masm) = 0; |
| 431 | |
| 432 | DEFINE_CODE_STUB_BASE(PlatformCodeStub, CodeStub); |
| 433 | }; |
| 434 | |
| 435 | |
| 436 | enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 437 | |
| 438 | |
| 439 | class CodeStubDescriptor { |
| 440 | public: |
| 441 | explicit CodeStubDescriptor(CodeStub* stub); |
| 442 | |
| 443 | CodeStubDescriptor(Isolate* isolate, uint32_t stub_key); |
| 444 | |
| 445 | void Initialize(Address deoptimization_handler = NULL, |
| 446 | int hint_stack_parameter_count = -1, |
| 447 | StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); |
| 448 | void Initialize(Register stack_parameter_count, |
| 449 | Address deoptimization_handler = NULL, |
| 450 | int hint_stack_parameter_count = -1, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 451 | StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 452 | |
| 453 | void SetMissHandler(ExternalReference handler) { |
| 454 | miss_handler_ = handler; |
| 455 | has_miss_handler_ = true; |
| 456 | // Our miss handler infrastructure doesn't currently support |
| 457 | // variable stack parameter counts. |
| 458 | DCHECK(!stack_parameter_count_.is_valid()); |
| 459 | } |
| 460 | |
| 461 | void set_call_descriptor(CallInterfaceDescriptor d) { call_descriptor_ = d; } |
| 462 | CallInterfaceDescriptor call_descriptor() const { return call_descriptor_; } |
| 463 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 464 | int GetRegisterParameterCount() const { |
| 465 | return call_descriptor().GetRegisterParameterCount(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 466 | } |
| 467 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 468 | int GetStackParameterCount() const { |
| 469 | return call_descriptor().GetStackParameterCount(); |
| 470 | } |
| 471 | |
| 472 | int GetParameterCount() const { |
| 473 | return call_descriptor().GetParameterCount(); |
| 474 | } |
| 475 | |
| 476 | Register GetRegisterParameter(int index) const { |
| 477 | return call_descriptor().GetRegisterParameter(index); |
| 478 | } |
| 479 | |
| 480 | Type* GetParameterType(int index) const { |
| 481 | return call_descriptor().GetParameterType(index); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | ExternalReference miss_handler() const { |
| 485 | DCHECK(has_miss_handler_); |
| 486 | return miss_handler_; |
| 487 | } |
| 488 | |
| 489 | bool has_miss_handler() const { |
| 490 | return has_miss_handler_; |
| 491 | } |
| 492 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 493 | int GetHandlerParameterCount() const { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 494 | int params = GetParameterCount(); |
| 495 | if (PassesArgumentsToDeoptimizationHandler()) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 496 | params += 1; |
| 497 | } |
| 498 | return params; |
| 499 | } |
| 500 | |
| 501 | int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } |
| 502 | Register stack_parameter_count() const { return stack_parameter_count_; } |
| 503 | StubFunctionMode function_mode() const { return function_mode_; } |
| 504 | Address deoptimization_handler() const { return deoptimization_handler_; } |
| 505 | |
| 506 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 507 | bool PassesArgumentsToDeoptimizationHandler() const { |
| 508 | return stack_parameter_count_.is_valid(); |
| 509 | } |
| 510 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 511 | CallInterfaceDescriptor call_descriptor_; |
| 512 | Register stack_parameter_count_; |
| 513 | // If hint_stack_parameter_count_ > 0, the code stub can optimize the |
| 514 | // return sequence. Default value is -1, which means it is ignored. |
| 515 | int hint_stack_parameter_count_; |
| 516 | StubFunctionMode function_mode_; |
| 517 | |
| 518 | Address deoptimization_handler_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 519 | |
| 520 | ExternalReference miss_handler_; |
| 521 | bool has_miss_handler_; |
| 522 | }; |
| 523 | |
| 524 | |
| 525 | class HydrogenCodeStub : public CodeStub { |
| 526 | public: |
| 527 | enum InitializationState { |
| 528 | UNINITIALIZED, |
| 529 | INITIALIZED |
| 530 | }; |
| 531 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 532 | template<class SubClass> |
| 533 | static Handle<Code> GetUninitialized(Isolate* isolate) { |
| 534 | SubClass::GenerateAheadOfTime(isolate); |
| 535 | return SubClass().GetCode(isolate); |
| 536 | } |
| 537 | |
| 538 | // Retrieve the code for the stub. Generate the code if needed. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 539 | Handle<Code> GenerateCode() override = 0; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 540 | |
| 541 | bool IsUninitialized() const { return IsMissBits::decode(minor_key_); } |
| 542 | |
| 543 | Handle<Code> GenerateLightweightMissCode(ExternalReference miss); |
| 544 | |
| 545 | template<class StateType> |
| 546 | void TraceTransition(StateType from, StateType to); |
| 547 | |
| 548 | protected: |
| 549 | explicit HydrogenCodeStub(Isolate* isolate, |
| 550 | InitializationState state = INITIALIZED) |
| 551 | : CodeStub(isolate) { |
| 552 | minor_key_ = IsMissBits::encode(state == UNINITIALIZED); |
| 553 | } |
| 554 | |
| 555 | void set_sub_minor_key(uint32_t key) { |
| 556 | minor_key_ = SubMinorKeyBits::update(minor_key_, key); |
| 557 | } |
| 558 | |
| 559 | uint32_t sub_minor_key() const { return SubMinorKeyBits::decode(minor_key_); } |
| 560 | |
| 561 | static const int kSubMinorKeyBits = kStubMinorKeyBits - 1; |
| 562 | |
| 563 | private: |
| 564 | class IsMissBits : public BitField<bool, kSubMinorKeyBits, 1> {}; |
| 565 | class SubMinorKeyBits : public BitField<int, 0, kSubMinorKeyBits> {}; |
| 566 | |
| 567 | void GenerateLightweightMiss(MacroAssembler* masm, ExternalReference miss); |
| 568 | |
| 569 | DEFINE_CODE_STUB_BASE(HydrogenCodeStub, CodeStub); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 570 | }; |
| 571 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 572 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 573 | class TurboFanCodeStub : public CodeStub { |
| 574 | public: |
| 575 | // Retrieve the code for the stub. Generate the code if needed. |
| 576 | Handle<Code> GenerateCode() override; |
| 577 | |
| 578 | int GetStackParameterCount() const override { |
| 579 | return GetCallInterfaceDescriptor().GetStackParameterCount(); |
| 580 | } |
| 581 | |
| 582 | Code::StubType GetStubType() const override { return Code::FAST; } |
| 583 | |
| 584 | protected: |
| 585 | explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {} |
| 586 | |
| 587 | virtual void GenerateAssembly( |
| 588 | compiler::CodeStubAssembler* assembler) const = 0; |
| 589 | |
| 590 | private: |
| 591 | DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub); |
| 592 | }; |
| 593 | |
| 594 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 595 | // Helper interface to prepare to/restore after making runtime calls. |
| 596 | class RuntimeCallHelper { |
| 597 | public: |
| 598 | virtual ~RuntimeCallHelper() {} |
| 599 | |
| 600 | virtual void BeforeCall(MacroAssembler* masm) const = 0; |
| 601 | |
| 602 | virtual void AfterCall(MacroAssembler* masm) const = 0; |
| 603 | |
| 604 | protected: |
| 605 | RuntimeCallHelper() {} |
| 606 | |
| 607 | private: |
| 608 | DISALLOW_COPY_AND_ASSIGN(RuntimeCallHelper); |
| 609 | }; |
| 610 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 611 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 612 | } // namespace internal |
| 613 | } // namespace v8 |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 614 | |
| 615 | #if V8_TARGET_ARCH_IA32 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 616 | #include "src/ia32/code-stubs-ia32.h" |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 617 | #elif V8_TARGET_ARCH_X64 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 618 | #include "src/x64/code-stubs-x64.h" |
| 619 | #elif V8_TARGET_ARCH_ARM64 |
| 620 | #include "src/arm64/code-stubs-arm64.h" |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 621 | #elif V8_TARGET_ARCH_ARM |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 622 | #include "src/arm/code-stubs-arm.h" |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 623 | #elif V8_TARGET_ARCH_PPC |
| 624 | #include "src/ppc/code-stubs-ppc.h" |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 625 | #elif V8_TARGET_ARCH_MIPS |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 626 | #include "src/mips/code-stubs-mips.h" |
| 627 | #elif V8_TARGET_ARCH_MIPS64 |
| 628 | #include "src/mips64/code-stubs-mips64.h" |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 629 | #elif V8_TARGET_ARCH_S390 |
| 630 | #include "src/s390/code-stubs-s390.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 631 | #elif V8_TARGET_ARCH_X87 |
| 632 | #include "src/x87/code-stubs-x87.h" |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 633 | #else |
| 634 | #error Unsupported target architecture. |
| 635 | #endif |
| 636 | |
| 637 | namespace v8 { |
| 638 | namespace internal { |
| 639 | |
| 640 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 641 | // RuntimeCallHelper implementation used in stubs: enters/leaves a |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 642 | // newly created internal frame before/after the runtime call. |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 643 | class StubRuntimeCallHelper : public RuntimeCallHelper { |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 644 | public: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 645 | StubRuntimeCallHelper() {} |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 646 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 647 | void BeforeCall(MacroAssembler* masm) const override; |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 648 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 649 | void AfterCall(MacroAssembler* masm) const override; |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 650 | }; |
| 651 | |
| 652 | |
| 653 | // Trivial RuntimeCallHelper implementation. |
| 654 | class NopRuntimeCallHelper : public RuntimeCallHelper { |
| 655 | public: |
| 656 | NopRuntimeCallHelper() {} |
| 657 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 658 | void BeforeCall(MacroAssembler* masm) const override {} |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 659 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 660 | void AfterCall(MacroAssembler* masm) const override {} |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 661 | }; |
| 662 | |
| 663 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 664 | class StringLengthStub : public TurboFanCodeStub { |
| 665 | public: |
| 666 | explicit StringLengthStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 667 | |
| 668 | Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 669 | InlineCacheState GetICState() const override { return MONOMORPHIC; } |
| 670 | ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } |
| 671 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 672 | DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 673 | DEFINE_TURBOFAN_CODE_STUB(StringLength, TurboFanCodeStub); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 674 | }; |
| 675 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 676 | class AddStub final : public TurboFanCodeStub { |
| 677 | public: |
| 678 | explicit AddStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 679 | |
| 680 | DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); |
| 681 | DEFINE_TURBOFAN_CODE_STUB(Add, TurboFanCodeStub); |
| 682 | }; |
| 683 | |
| 684 | class SubtractStub final : public TurboFanCodeStub { |
| 685 | public: |
| 686 | explicit SubtractStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 687 | |
| 688 | DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); |
| 689 | DEFINE_TURBOFAN_CODE_STUB(Subtract, TurboFanCodeStub); |
| 690 | }; |
| 691 | |
| 692 | class BitwiseAndStub final : public TurboFanCodeStub { |
| 693 | public: |
| 694 | explicit BitwiseAndStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 695 | |
| 696 | DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); |
| 697 | DEFINE_TURBOFAN_CODE_STUB(BitwiseAnd, TurboFanCodeStub); |
| 698 | }; |
| 699 | |
| 700 | class BitwiseOrStub final : public TurboFanCodeStub { |
| 701 | public: |
| 702 | explicit BitwiseOrStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 703 | |
| 704 | DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); |
| 705 | DEFINE_TURBOFAN_CODE_STUB(BitwiseOr, TurboFanCodeStub); |
| 706 | }; |
| 707 | |
| 708 | class BitwiseXorStub final : public TurboFanCodeStub { |
| 709 | public: |
| 710 | explicit BitwiseXorStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 711 | |
| 712 | DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); |
| 713 | DEFINE_TURBOFAN_CODE_STUB(BitwiseXor, TurboFanCodeStub); |
| 714 | }; |
| 715 | |
| 716 | class LessThanStub final : public TurboFanCodeStub { |
| 717 | public: |
| 718 | explicit LessThanStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 719 | |
| 720 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 721 | DEFINE_TURBOFAN_CODE_STUB(LessThan, TurboFanCodeStub); |
| 722 | }; |
| 723 | |
| 724 | class LessThanOrEqualStub final : public TurboFanCodeStub { |
| 725 | public: |
| 726 | explicit LessThanOrEqualStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 727 | |
| 728 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 729 | DEFINE_TURBOFAN_CODE_STUB(LessThanOrEqual, TurboFanCodeStub); |
| 730 | }; |
| 731 | |
| 732 | class GreaterThanStub final : public TurboFanCodeStub { |
| 733 | public: |
| 734 | explicit GreaterThanStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 735 | |
| 736 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 737 | DEFINE_TURBOFAN_CODE_STUB(GreaterThan, TurboFanCodeStub); |
| 738 | }; |
| 739 | |
| 740 | class GreaterThanOrEqualStub final : public TurboFanCodeStub { |
| 741 | public: |
| 742 | explicit GreaterThanOrEqualStub(Isolate* isolate) |
| 743 | : TurboFanCodeStub(isolate) {} |
| 744 | |
| 745 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 746 | DEFINE_TURBOFAN_CODE_STUB(GreaterThanOrEqual, TurboFanCodeStub); |
| 747 | }; |
| 748 | |
| 749 | class EqualStub final : public TurboFanCodeStub { |
| 750 | public: |
| 751 | explicit EqualStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 752 | |
| 753 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 754 | DEFINE_TURBOFAN_CODE_STUB(Equal, TurboFanCodeStub); |
| 755 | }; |
| 756 | |
| 757 | class NotEqualStub final : public TurboFanCodeStub { |
| 758 | public: |
| 759 | explicit NotEqualStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 760 | |
| 761 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 762 | DEFINE_TURBOFAN_CODE_STUB(NotEqual, TurboFanCodeStub); |
| 763 | }; |
| 764 | |
| 765 | class StrictEqualStub final : public TurboFanCodeStub { |
| 766 | public: |
| 767 | explicit StrictEqualStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 768 | |
| 769 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 770 | DEFINE_TURBOFAN_CODE_STUB(StrictEqual, TurboFanCodeStub); |
| 771 | }; |
| 772 | |
| 773 | class StrictNotEqualStub final : public TurboFanCodeStub { |
| 774 | public: |
| 775 | explicit StrictNotEqualStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 776 | |
| 777 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 778 | DEFINE_TURBOFAN_CODE_STUB(StrictNotEqual, TurboFanCodeStub); |
| 779 | }; |
| 780 | |
| 781 | class StringEqualStub final : public TurboFanCodeStub { |
| 782 | public: |
| 783 | explicit StringEqualStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 784 | |
| 785 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 786 | DEFINE_TURBOFAN_CODE_STUB(StringEqual, TurboFanCodeStub); |
| 787 | }; |
| 788 | |
| 789 | class StringNotEqualStub final : public TurboFanCodeStub { |
| 790 | public: |
| 791 | explicit StringNotEqualStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 792 | |
| 793 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 794 | DEFINE_TURBOFAN_CODE_STUB(StringNotEqual, TurboFanCodeStub); |
| 795 | }; |
| 796 | |
| 797 | class StringLessThanStub final : public TurboFanCodeStub { |
| 798 | public: |
| 799 | explicit StringLessThanStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 800 | |
| 801 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 802 | DEFINE_TURBOFAN_CODE_STUB(StringLessThan, TurboFanCodeStub); |
| 803 | }; |
| 804 | |
| 805 | class StringLessThanOrEqualStub final : public TurboFanCodeStub { |
| 806 | public: |
| 807 | explicit StringLessThanOrEqualStub(Isolate* isolate) |
| 808 | : TurboFanCodeStub(isolate) {} |
| 809 | |
| 810 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 811 | DEFINE_TURBOFAN_CODE_STUB(StringLessThanOrEqual, TurboFanCodeStub); |
| 812 | }; |
| 813 | |
| 814 | class StringGreaterThanStub final : public TurboFanCodeStub { |
| 815 | public: |
| 816 | explicit StringGreaterThanStub(Isolate* isolate) |
| 817 | : TurboFanCodeStub(isolate) {} |
| 818 | |
| 819 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 820 | DEFINE_TURBOFAN_CODE_STUB(StringGreaterThan, TurboFanCodeStub); |
| 821 | }; |
| 822 | |
| 823 | class StringGreaterThanOrEqualStub final : public TurboFanCodeStub { |
| 824 | public: |
| 825 | explicit StringGreaterThanOrEqualStub(Isolate* isolate) |
| 826 | : TurboFanCodeStub(isolate) {} |
| 827 | |
| 828 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Compare); |
| 829 | DEFINE_TURBOFAN_CODE_STUB(StringGreaterThanOrEqual, TurboFanCodeStub); |
| 830 | }; |
| 831 | |
| 832 | class ToBooleanStub final : public TurboFanCodeStub { |
| 833 | public: |
| 834 | explicit ToBooleanStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 835 | |
| 836 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
| 837 | DEFINE_TURBOFAN_CODE_STUB(ToBoolean, TurboFanCodeStub); |
| 838 | }; |
| 839 | |
| 840 | class ToIntegerStub final : public TurboFanCodeStub { |
| 841 | public: |
| 842 | explicit ToIntegerStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 843 | |
| 844 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
| 845 | DEFINE_TURBOFAN_CODE_STUB(ToInteger, TurboFanCodeStub); |
| 846 | }; |
| 847 | |
| 848 | class ToLengthStub final : public TurboFanCodeStub { |
| 849 | public: |
| 850 | explicit ToLengthStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 851 | |
| 852 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
| 853 | DEFINE_TURBOFAN_CODE_STUB(ToLength, TurboFanCodeStub); |
| 854 | }; |
| 855 | |
| 856 | class StoreInterceptorStub : public TurboFanCodeStub { |
| 857 | public: |
| 858 | explicit StoreInterceptorStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} |
| 859 | |
| 860 | void GenerateAssembly(compiler::CodeStubAssembler* assember) const override; |
| 861 | |
| 862 | Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 863 | |
| 864 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Store); |
| 865 | DEFINE_CODE_STUB(StoreInterceptor, TurboFanCodeStub); |
| 866 | }; |
| 867 | |
| 868 | class LoadIndexedInterceptorStub : public TurboFanCodeStub { |
| 869 | public: |
| 870 | explicit LoadIndexedInterceptorStub(Isolate* isolate) |
| 871 | : TurboFanCodeStub(isolate) {} |
| 872 | |
| 873 | Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 874 | |
| 875 | DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector); |
| 876 | DEFINE_TURBOFAN_CODE_STUB(LoadIndexedInterceptor, TurboFanCodeStub); |
| 877 | }; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 878 | |
| 879 | enum StringAddFlags { |
| 880 | // Omit both parameter checks. |
| 881 | STRING_ADD_CHECK_NONE = 0, |
| 882 | // Check left parameter. |
| 883 | STRING_ADD_CHECK_LEFT = 1 << 0, |
| 884 | // Check right parameter. |
| 885 | STRING_ADD_CHECK_RIGHT = 1 << 1, |
| 886 | // Check both parameters. |
| 887 | STRING_ADD_CHECK_BOTH = STRING_ADD_CHECK_LEFT | STRING_ADD_CHECK_RIGHT, |
| 888 | // Convert parameters when check fails (instead of throwing an exception). |
| 889 | STRING_ADD_CONVERT = 1 << 2, |
| 890 | STRING_ADD_CONVERT_LEFT = STRING_ADD_CHECK_LEFT | STRING_ADD_CONVERT, |
| 891 | STRING_ADD_CONVERT_RIGHT = STRING_ADD_CHECK_RIGHT | STRING_ADD_CONVERT |
| 892 | }; |
| 893 | |
| 894 | |
| 895 | std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags); |
| 896 | |
| 897 | |
| 898 | class NumberToStringStub final : public HydrogenCodeStub { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 899 | public: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 900 | explicit NumberToStringStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 901 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 902 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 903 | static const int kNumber = 0; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 904 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 905 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 906 | DEFINE_HYDROGEN_CODE_STUB(NumberToString, HydrogenCodeStub); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 907 | }; |
| 908 | |
| 909 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 910 | class TypeofStub final : public HydrogenCodeStub { |
| 911 | public: |
| 912 | explicit TypeofStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} |
| 913 | |
| 914 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 915 | static const int kObject = 0; |
| 916 | |
| 917 | static void GenerateAheadOfTime(Isolate* isolate); |
| 918 | |
| 919 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Typeof); |
| 920 | DEFINE_HYDROGEN_CODE_STUB(Typeof, HydrogenCodeStub); |
| 921 | }; |
| 922 | |
| 923 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 924 | class FastNewClosureStub : public HydrogenCodeStub { |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 925 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 926 | FastNewClosureStub(Isolate* isolate, LanguageMode language_mode, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 927 | FunctionKind kind) |
| 928 | : HydrogenCodeStub(isolate) { |
| 929 | DCHECK(IsValidFunctionKind(kind)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 930 | set_sub_minor_key(LanguageModeBits::encode(language_mode) | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 931 | FunctionKindBits::encode(kind)); |
| 932 | } |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 933 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 934 | LanguageMode language_mode() const { |
| 935 | return LanguageModeBits::decode(sub_minor_key()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | FunctionKind kind() const { |
| 939 | return FunctionKindBits::decode(sub_minor_key()); |
| 940 | } |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 941 | |
| 942 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 943 | STATIC_ASSERT(LANGUAGE_END == 3); |
| 944 | class LanguageModeBits : public BitField<LanguageMode, 0, 2> {}; |
| 945 | class FunctionKindBits : public BitField<FunctionKind, 2, 8> {}; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 946 | |
| 947 | DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewClosure); |
| 948 | DEFINE_HYDROGEN_CODE_STUB(FastNewClosure, HydrogenCodeStub); |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 949 | }; |
| 950 | |
| 951 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 952 | class FastNewContextStub final : public HydrogenCodeStub { |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 953 | public: |
| 954 | static const int kMaximumSlots = 64; |
| 955 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 956 | FastNewContextStub(Isolate* isolate, int slots) : HydrogenCodeStub(isolate) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 957 | DCHECK(slots >= 0 && slots <= kMaximumSlots); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 958 | set_sub_minor_key(SlotsBits::encode(slots)); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 959 | } |
| 960 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 961 | int slots() const { return SlotsBits::decode(sub_minor_key()); } |
| 962 | |
| 963 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 964 | static const int kFunction = 0; |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 965 | |
| 966 | private: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 967 | class SlotsBits : public BitField<int, 0, 8> {}; |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 968 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 969 | DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewContext); |
| 970 | DEFINE_HYDROGEN_CODE_STUB(FastNewContext, HydrogenCodeStub); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 971 | }; |
| 972 | |
| 973 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 974 | class FastNewObjectStub final : public PlatformCodeStub { |
| 975 | public: |
| 976 | explicit FastNewObjectStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
| 977 | |
| 978 | DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewObject); |
| 979 | DEFINE_PLATFORM_CODE_STUB(FastNewObject, PlatformCodeStub); |
| 980 | }; |
| 981 | |
| 982 | |
| 983 | // TODO(turbofan): This stub should be possible to write in TurboFan |
| 984 | // using the CodeStubAssembler very soon in a way that is as efficient |
| 985 | // and easy as the current handwritten version, which is partly a copy |
| 986 | // of the strict arguments object materialization code. |
| 987 | class FastNewRestParameterStub final : public PlatformCodeStub { |
| 988 | public: |
| 989 | explicit FastNewRestParameterStub(Isolate* isolate) |
| 990 | : PlatformCodeStub(isolate) {} |
| 991 | |
| 992 | DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewRestParameter); |
| 993 | DEFINE_PLATFORM_CODE_STUB(FastNewRestParameter, PlatformCodeStub); |
| 994 | }; |
| 995 | |
| 996 | |
| 997 | // TODO(turbofan): This stub should be possible to write in TurboFan |
| 998 | // using the CodeStubAssembler very soon in a way that is as efficient |
| 999 | // and easy as the current handwritten version. |
| 1000 | class FastNewSloppyArgumentsStub final : public PlatformCodeStub { |
| 1001 | public: |
| 1002 | explicit FastNewSloppyArgumentsStub(Isolate* isolate) |
| 1003 | : PlatformCodeStub(isolate) {} |
| 1004 | |
| 1005 | DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewSloppyArguments); |
| 1006 | DEFINE_PLATFORM_CODE_STUB(FastNewSloppyArguments, PlatformCodeStub); |
| 1007 | }; |
| 1008 | |
| 1009 | |
| 1010 | // TODO(turbofan): This stub should be possible to write in TurboFan |
| 1011 | // using the CodeStubAssembler very soon in a way that is as efficient |
| 1012 | // and easy as the current handwritten version. |
| 1013 | class FastNewStrictArgumentsStub final : public PlatformCodeStub { |
| 1014 | public: |
| 1015 | explicit FastNewStrictArgumentsStub(Isolate* isolate) |
| 1016 | : PlatformCodeStub(isolate) {} |
| 1017 | |
| 1018 | DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewStrictArguments); |
| 1019 | DEFINE_PLATFORM_CODE_STUB(FastNewStrictArguments, PlatformCodeStub); |
| 1020 | }; |
| 1021 | |
| 1022 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1023 | class FastCloneRegExpStub final : public HydrogenCodeStub { |
| 1024 | public: |
| 1025 | explicit FastCloneRegExpStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} |
| 1026 | |
| 1027 | private: |
| 1028 | DEFINE_CALL_INTERFACE_DESCRIPTOR(FastCloneRegExp); |
| 1029 | DEFINE_HYDROGEN_CODE_STUB(FastCloneRegExp, HydrogenCodeStub); |
| 1030 | }; |
| 1031 | |
| 1032 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1033 | class FastCloneShallowArrayStub : public HydrogenCodeStub { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1034 | public: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1035 | FastCloneShallowArrayStub(Isolate* isolate, |
| 1036 | AllocationSiteMode allocation_site_mode) |
| 1037 | : HydrogenCodeStub(isolate) { |
| 1038 | set_sub_minor_key(AllocationSiteModeBits::encode(allocation_site_mode)); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1039 | } |
| 1040 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1041 | AllocationSiteMode allocation_site_mode() const { |
| 1042 | return AllocationSiteModeBits::decode(sub_minor_key()); |
| 1043 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1044 | |
| 1045 | private: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1046 | class AllocationSiteModeBits: public BitField<AllocationSiteMode, 0, 1> {}; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1047 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1048 | DEFINE_CALL_INTERFACE_DESCRIPTOR(FastCloneShallowArray); |
| 1049 | DEFINE_HYDROGEN_CODE_STUB(FastCloneShallowArray, HydrogenCodeStub); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1050 | }; |
| 1051 | |
| 1052 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1053 | class FastCloneShallowObjectStub : public HydrogenCodeStub { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1054 | public: |
| 1055 | // Maximum number of properties in copied object. |
| 1056 | static const int kMaximumClonedProperties = 6; |
| 1057 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1058 | FastCloneShallowObjectStub(Isolate* isolate, int length) |
| 1059 | : HydrogenCodeStub(isolate) { |
| 1060 | DCHECK_GE(length, 0); |
| 1061 | DCHECK_LE(length, kMaximumClonedProperties); |
| 1062 | set_sub_minor_key(LengthBits::encode(length)); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1063 | } |
| 1064 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1065 | int length() const { return LengthBits::decode(sub_minor_key()); } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1066 | |
| 1067 | private: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1068 | class LengthBits : public BitField<int, 0, 4> {}; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1069 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1070 | DEFINE_CALL_INTERFACE_DESCRIPTOR(FastCloneShallowObject); |
| 1071 | DEFINE_HYDROGEN_CODE_STUB(FastCloneShallowObject, HydrogenCodeStub); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1072 | }; |
| 1073 | |
| 1074 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1075 | class CreateAllocationSiteStub : public HydrogenCodeStub { |
| 1076 | public: |
| 1077 | explicit CreateAllocationSiteStub(Isolate* isolate) |
| 1078 | : HydrogenCodeStub(isolate) { } |
| 1079 | |
| 1080 | static void GenerateAheadOfTime(Isolate* isolate); |
| 1081 | |
| 1082 | DEFINE_CALL_INTERFACE_DESCRIPTOR(CreateAllocationSite); |
| 1083 | DEFINE_HYDROGEN_CODE_STUB(CreateAllocationSite, HydrogenCodeStub); |
| 1084 | }; |
| 1085 | |
| 1086 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1087 | class CreateWeakCellStub : public HydrogenCodeStub { |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1088 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1089 | explicit CreateWeakCellStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1090 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1091 | static void GenerateAheadOfTime(Isolate* isolate); |
| 1092 | |
| 1093 | DEFINE_CALL_INTERFACE_DESCRIPTOR(CreateWeakCell); |
| 1094 | DEFINE_HYDROGEN_CODE_STUB(CreateWeakCell, HydrogenCodeStub); |
| 1095 | }; |
| 1096 | |
| 1097 | |
| 1098 | class GrowArrayElementsStub : public HydrogenCodeStub { |
| 1099 | public: |
| 1100 | GrowArrayElementsStub(Isolate* isolate, bool is_js_array, ElementsKind kind) |
| 1101 | : HydrogenCodeStub(isolate) { |
| 1102 | set_sub_minor_key(ElementsKindBits::encode(kind) | |
| 1103 | IsJsArrayBits::encode(is_js_array)); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1104 | } |
| 1105 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1106 | ElementsKind elements_kind() const { |
| 1107 | return ElementsKindBits::decode(sub_minor_key()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1108 | } |
| 1109 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1110 | bool is_js_array() const { return IsJsArrayBits::decode(sub_minor_key()); } |
| 1111 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1112 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1113 | class ElementsKindBits : public BitField<ElementsKind, 0, 8> {}; |
| 1114 | class IsJsArrayBits : public BitField<bool, ElementsKindBits::kNext, 1> {}; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1115 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1116 | DEFINE_CALL_INTERFACE_DESCRIPTOR(GrowArrayElements); |
| 1117 | DEFINE_HYDROGEN_CODE_STUB(GrowArrayElements, HydrogenCodeStub); |
| 1118 | }; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1119 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1120 | class FastArrayPushStub : public HydrogenCodeStub { |
| 1121 | public: |
| 1122 | explicit FastArrayPushStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} |
| 1123 | |
| 1124 | private: |
| 1125 | DEFINE_CALL_INTERFACE_DESCRIPTOR(FastArrayPush); |
| 1126 | DEFINE_HYDROGEN_CODE_STUB(FastArrayPush, HydrogenCodeStub); |
| 1127 | }; |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 1128 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1129 | class InstanceOfStub final : public PlatformCodeStub { |
| 1130 | public: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1131 | explicit InstanceOfStub(Isolate* isolate, bool es6_instanceof = false) |
| 1132 | : PlatformCodeStub(isolate) { |
| 1133 | minor_key_ = IsES6InstanceOfBits::encode(es6_instanceof); |
| 1134 | } |
| 1135 | |
| 1136 | bool is_es6_instanceof() const { |
| 1137 | return IsES6InstanceOfBits::decode(minor_key_); |
| 1138 | } |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 1139 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1140 | private: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1141 | class IsES6InstanceOfBits : public BitField<bool, 0, 1> {}; |
| 1142 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1143 | DEFINE_CALL_INTERFACE_DESCRIPTOR(InstanceOf); |
| 1144 | DEFINE_PLATFORM_CODE_STUB(InstanceOf, PlatformCodeStub); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1145 | }; |
| 1146 | |
| 1147 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1148 | enum AllocationSiteOverrideMode { |
| 1149 | DONT_OVERRIDE, |
| 1150 | DISABLE_ALLOCATION_SITES, |
| 1151 | LAST_ALLOCATION_SITE_OVERRIDE_MODE = DISABLE_ALLOCATION_SITES |
| 1152 | }; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1153 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1154 | |
| 1155 | class ArrayConstructorStub: public PlatformCodeStub { |
| 1156 | public: |
| 1157 | enum ArgumentCountKey { ANY, NONE, ONE, MORE_THAN_ONE }; |
| 1158 | |
| 1159 | ArrayConstructorStub(Isolate* isolate, int argument_count); |
| 1160 | |
| 1161 | explicit ArrayConstructorStub(Isolate* isolate); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1162 | |
| 1163 | private: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1164 | ArgumentCountKey argument_count() const { |
| 1165 | return ArgumentCountBits::decode(minor_key_); |
| 1166 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1167 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1168 | void GenerateDispatchToArrayStub(MacroAssembler* masm, |
| 1169 | AllocationSiteOverrideMode mode); |
| 1170 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1171 | void PrintName(std::ostream& os) const override; // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1172 | |
| 1173 | class ArgumentCountBits : public BitField<ArgumentCountKey, 0, 2> {}; |
| 1174 | |
| 1175 | DEFINE_CALL_INTERFACE_DESCRIPTOR(ArrayConstructor); |
| 1176 | DEFINE_PLATFORM_CODE_STUB(ArrayConstructor, PlatformCodeStub); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1177 | }; |
| 1178 | |
| 1179 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1180 | class InternalArrayConstructorStub: public PlatformCodeStub { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1181 | public: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1182 | explicit InternalArrayConstructorStub(Isolate* isolate); |
| 1183 | |
| 1184 | private: |
| 1185 | void GenerateCase(MacroAssembler* masm, ElementsKind kind); |
| 1186 | |
| 1187 | DEFINE_CALL_INTERFACE_DESCRIPTOR(InternalArrayConstructor); |
| 1188 | DEFINE_PLATFORM_CODE_STUB(InternalArrayConstructor, PlatformCodeStub); |
| 1189 | }; |
| 1190 | |
| 1191 | |
| 1192 | class MathPowStub: public PlatformCodeStub { |
| 1193 | public: |
| 1194 | enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK }; |
| 1195 | |
| 1196 | MathPowStub(Isolate* isolate, ExponentType exponent_type) |
| 1197 | : PlatformCodeStub(isolate) { |
| 1198 | minor_key_ = ExponentTypeBits::encode(exponent_type); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1199 | } |
| 1200 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1201 | CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1202 | if (exponent_type() == TAGGED) { |
| 1203 | return MathPowTaggedDescriptor(isolate()); |
| 1204 | } else if (exponent_type() == INTEGER) { |
| 1205 | return MathPowIntegerDescriptor(isolate()); |
| 1206 | } |
| 1207 | // A CallInterfaceDescriptor doesn't specify double registers (yet). |
| 1208 | return ContextOnlyDescriptor(isolate()); |
| 1209 | } |
| 1210 | |
| 1211 | private: |
| 1212 | ExponentType exponent_type() const { |
| 1213 | return ExponentTypeBits::decode(minor_key_); |
| 1214 | } |
| 1215 | |
| 1216 | class ExponentTypeBits : public BitField<ExponentType, 0, 2> {}; |
| 1217 | |
| 1218 | DEFINE_PLATFORM_CODE_STUB(MathPow, PlatformCodeStub); |
| 1219 | }; |
| 1220 | |
| 1221 | |
| 1222 | class CallICStub: public PlatformCodeStub { |
| 1223 | public: |
| 1224 | CallICStub(Isolate* isolate, const CallICState& state) |
| 1225 | : PlatformCodeStub(isolate) { |
| 1226 | minor_key_ = state.GetExtraICState(); |
| 1227 | } |
| 1228 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1229 | Code::Kind GetCodeKind() const override { return Code::CALL_IC; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1230 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1231 | InlineCacheState GetICState() const override { return GENERIC; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1232 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1233 | ExtraICState GetExtraICState() const final { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1234 | return static_cast<ExtraICState>(minor_key_); |
| 1235 | } |
| 1236 | |
| 1237 | protected: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1238 | int arg_count() const { return state().argc(); } |
| 1239 | ConvertReceiverMode convert_mode() const { return state().convert_mode(); } |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1240 | TailCallMode tail_call_mode() const { return state().tail_call_mode(); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1241 | |
| 1242 | CallICState state() const { |
| 1243 | return CallICState(static_cast<ExtraICState>(minor_key_)); |
| 1244 | } |
| 1245 | |
| 1246 | // Code generation helpers. |
| 1247 | void GenerateMiss(MacroAssembler* masm); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1248 | void HandleArrayCase(MacroAssembler* masm, Label* miss); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1249 | |
| 1250 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1251 | void PrintState(std::ostream& os) const override; // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1252 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1253 | DEFINE_CALL_INTERFACE_DESCRIPTOR(CallFunctionWithFeedbackAndVector); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1254 | DEFINE_PLATFORM_CODE_STUB(CallIC, PlatformCodeStub); |
| 1255 | }; |
| 1256 | |
| 1257 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1258 | // TODO(verwaest): Translate to hydrogen code stub. |
| 1259 | class FunctionPrototypeStub : public PlatformCodeStub { |
| 1260 | public: |
| 1261 | explicit FunctionPrototypeStub(Isolate* isolate) |
| 1262 | : PlatformCodeStub(isolate) {} |
| 1263 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1264 | Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1265 | |
| 1266 | // TODO(mvstanton): only the receiver register is accessed. When this is |
| 1267 | // translated to a hydrogen code stub, a new CallInterfaceDescriptor |
| 1268 | // should be created that just uses that register for more efficient code. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1269 | CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
| 1270 | return LoadWithVectorDescriptor(isolate()); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1271 | } |
| 1272 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1273 | DEFINE_PLATFORM_CODE_STUB(FunctionPrototype, PlatformCodeStub); |
| 1274 | }; |
| 1275 | |
| 1276 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1277 | class LoadIndexedStringStub : public PlatformCodeStub { |
| 1278 | public: |
| 1279 | explicit LoadIndexedStringStub(Isolate* isolate) |
| 1280 | : PlatformCodeStub(isolate) {} |
| 1281 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1282 | Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 1283 | Code::StubType GetStubType() const override { return Code::FAST; } |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1284 | |
| 1285 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Load); |
| 1286 | DEFINE_PLATFORM_CODE_STUB(LoadIndexedString, PlatformCodeStub); |
| 1287 | }; |
| 1288 | |
| 1289 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1290 | class HandlerStub : public HydrogenCodeStub { |
| 1291 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1292 | Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 1293 | ExtraICState GetExtraICState() const override { return kind(); } |
| 1294 | InlineCacheState GetICState() const override { return MONOMORPHIC; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1295 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1296 | void InitializeDescriptor(CodeStubDescriptor* descriptor) override; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1297 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1298 | CallInterfaceDescriptor GetCallInterfaceDescriptor() const override; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1299 | |
| 1300 | protected: |
| 1301 | explicit HandlerStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} |
| 1302 | |
| 1303 | virtual Code::Kind kind() const = 0; |
| 1304 | |
| 1305 | DEFINE_CODE_STUB_BASE(HandlerStub, HydrogenCodeStub); |
| 1306 | }; |
| 1307 | |
| 1308 | |
| 1309 | class LoadFieldStub: public HandlerStub { |
| 1310 | public: |
| 1311 | LoadFieldStub(Isolate* isolate, FieldIndex index) : HandlerStub(isolate) { |
| 1312 | int property_index_key = index.GetFieldAccessStubKey(); |
| 1313 | set_sub_minor_key(LoadFieldByIndexBits::encode(property_index_key)); |
| 1314 | } |
| 1315 | |
| 1316 | FieldIndex index() const { |
| 1317 | int property_index_key = LoadFieldByIndexBits::decode(sub_minor_key()); |
| 1318 | return FieldIndex::FromFieldAccessStubKey(property_index_key); |
| 1319 | } |
| 1320 | |
| 1321 | protected: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1322 | Code::Kind kind() const override { return Code::LOAD_IC; } |
| 1323 | Code::StubType GetStubType() const override { return Code::FAST; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1324 | |
| 1325 | private: |
| 1326 | class LoadFieldByIndexBits : public BitField<int, 0, 13> {}; |
| 1327 | |
| 1328 | DEFINE_HANDLER_CODE_STUB(LoadField, HandlerStub); |
| 1329 | }; |
| 1330 | |
| 1331 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1332 | class ArrayBufferViewLoadFieldStub : public HandlerStub { |
| 1333 | public: |
| 1334 | ArrayBufferViewLoadFieldStub(Isolate* isolate, FieldIndex index) |
| 1335 | : HandlerStub(isolate) { |
| 1336 | int property_index_key = index.GetFieldAccessStubKey(); |
| 1337 | set_sub_minor_key( |
| 1338 | ArrayBufferViewLoadFieldByIndexBits::encode(property_index_key)); |
| 1339 | } |
| 1340 | |
| 1341 | FieldIndex index() const { |
| 1342 | int property_index_key = |
| 1343 | ArrayBufferViewLoadFieldByIndexBits::decode(sub_minor_key()); |
| 1344 | return FieldIndex::FromFieldAccessStubKey(property_index_key); |
| 1345 | } |
| 1346 | |
| 1347 | protected: |
| 1348 | Code::Kind kind() const override { return Code::LOAD_IC; } |
| 1349 | Code::StubType GetStubType() const override { return Code::FAST; } |
| 1350 | |
| 1351 | private: |
| 1352 | class ArrayBufferViewLoadFieldByIndexBits : public BitField<int, 0, 13> {}; |
| 1353 | |
| 1354 | DEFINE_HANDLER_CODE_STUB(ArrayBufferViewLoadField, HandlerStub); |
| 1355 | }; |
| 1356 | |
| 1357 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1358 | class KeyedLoadSloppyArgumentsStub : public HandlerStub { |
| 1359 | public: |
| 1360 | explicit KeyedLoadSloppyArgumentsStub(Isolate* isolate) |
| 1361 | : HandlerStub(isolate) {} |
| 1362 | |
| 1363 | protected: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1364 | Code::Kind kind() const override { return Code::KEYED_LOAD_IC; } |
| 1365 | Code::StubType GetStubType() const override { return Code::FAST; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1366 | |
| 1367 | private: |
| 1368 | DEFINE_HANDLER_CODE_STUB(KeyedLoadSloppyArguments, HandlerStub); |
| 1369 | }; |
| 1370 | |
| 1371 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1372 | class CommonStoreModeBits : public BitField<KeyedAccessStoreMode, 0, 3> {}; |
| 1373 | |
| 1374 | class KeyedStoreSloppyArgumentsStub : public HandlerStub { |
| 1375 | public: |
| 1376 | explicit KeyedStoreSloppyArgumentsStub(Isolate* isolate, |
| 1377 | KeyedAccessStoreMode mode) |
| 1378 | : HandlerStub(isolate) { |
| 1379 | set_sub_minor_key(CommonStoreModeBits::encode(mode)); |
| 1380 | } |
| 1381 | |
| 1382 | protected: |
| 1383 | Code::Kind kind() const override { return Code::KEYED_STORE_IC; } |
| 1384 | Code::StubType GetStubType() const override { return Code::FAST; } |
| 1385 | |
| 1386 | private: |
| 1387 | DEFINE_HANDLER_CODE_STUB(KeyedStoreSloppyArguments, HandlerStub); |
| 1388 | }; |
| 1389 | |
| 1390 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1391 | class LoadConstantStub : public HandlerStub { |
| 1392 | public: |
| 1393 | LoadConstantStub(Isolate* isolate, int constant_index) |
| 1394 | : HandlerStub(isolate) { |
| 1395 | set_sub_minor_key(ConstantIndexBits::encode(constant_index)); |
| 1396 | } |
| 1397 | |
| 1398 | int constant_index() const { |
| 1399 | return ConstantIndexBits::decode(sub_minor_key()); |
| 1400 | } |
| 1401 | |
| 1402 | protected: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1403 | Code::Kind kind() const override { return Code::LOAD_IC; } |
| 1404 | Code::StubType GetStubType() const override { return Code::FAST; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1405 | |
| 1406 | private: |
| 1407 | class ConstantIndexBits : public BitField<int, 0, kSubMinorKeyBits> {}; |
| 1408 | |
| 1409 | DEFINE_HANDLER_CODE_STUB(LoadConstant, HandlerStub); |
| 1410 | }; |
| 1411 | |
| 1412 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1413 | class StoreFieldStub : public HandlerStub { |
| 1414 | public: |
| 1415 | StoreFieldStub(Isolate* isolate, FieldIndex index, |
| 1416 | Representation representation) |
| 1417 | : HandlerStub(isolate) { |
| 1418 | int property_index_key = index.GetFieldAccessStubKey(); |
| 1419 | uint8_t repr = PropertyDetails::EncodeRepresentation(representation); |
| 1420 | set_sub_minor_key(StoreFieldByIndexBits::encode(property_index_key) | |
| 1421 | RepresentationBits::encode(repr)); |
| 1422 | } |
| 1423 | |
| 1424 | FieldIndex index() const { |
| 1425 | int property_index_key = StoreFieldByIndexBits::decode(sub_minor_key()); |
| 1426 | return FieldIndex::FromFieldAccessStubKey(property_index_key); |
| 1427 | } |
| 1428 | |
| 1429 | Representation representation() { |
| 1430 | uint8_t repr = RepresentationBits::decode(sub_minor_key()); |
| 1431 | return PropertyDetails::DecodeRepresentation(repr); |
| 1432 | } |
| 1433 | |
| 1434 | protected: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1435 | Code::Kind kind() const override { return Code::STORE_IC; } |
| 1436 | Code::StubType GetStubType() const override { return Code::FAST; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1437 | |
| 1438 | private: |
| 1439 | class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; |
| 1440 | class RepresentationBits : public BitField<uint8_t, 13, 4> {}; |
| 1441 | |
| 1442 | DEFINE_HANDLER_CODE_STUB(StoreField, HandlerStub); |
| 1443 | }; |
| 1444 | |
| 1445 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1446 | // Register and parameter access methods are specified here instead of in |
| 1447 | // the CallInterfaceDescriptor because the stub uses a different descriptor |
| 1448 | // if FLAG_vector_stores is on. |
| 1449 | class StoreTransitionHelper { |
| 1450 | public: |
| 1451 | static Register ReceiverRegister() { |
| 1452 | return StoreTransitionDescriptor::ReceiverRegister(); |
| 1453 | } |
| 1454 | |
| 1455 | static Register NameRegister() { |
| 1456 | return StoreTransitionDescriptor::NameRegister(); |
| 1457 | } |
| 1458 | |
| 1459 | static Register ValueRegister() { |
| 1460 | return StoreTransitionDescriptor::ValueRegister(); |
| 1461 | } |
| 1462 | |
| 1463 | static Register SlotRegister() { |
| 1464 | return VectorStoreTransitionDescriptor::SlotRegister(); |
| 1465 | } |
| 1466 | |
| 1467 | static Register VectorRegister() { |
| 1468 | return VectorStoreTransitionDescriptor::VectorRegister(); |
| 1469 | } |
| 1470 | |
| 1471 | static Register MapRegister() { |
| 1472 | return VectorStoreTransitionDescriptor::MapRegister(); |
| 1473 | } |
| 1474 | |
| 1475 | static int ReceiverIndex() { |
| 1476 | return StoreTransitionDescriptor::kReceiverIndex; |
| 1477 | } |
| 1478 | |
| 1479 | static int NameIndex() { return StoreTransitionDescriptor::kReceiverIndex; } |
| 1480 | |
| 1481 | static int ValueIndex() { return StoreTransitionDescriptor::kValueIndex; } |
| 1482 | |
| 1483 | static int MapIndex() { |
| 1484 | DCHECK(static_cast<int>(VectorStoreTransitionDescriptor::kMapIndex) == |
| 1485 | static_cast<int>(StoreTransitionDescriptor::kMapIndex)); |
| 1486 | return StoreTransitionDescriptor::kMapIndex; |
| 1487 | } |
| 1488 | |
| 1489 | static int VectorIndex() { |
| 1490 | if (HasVirtualSlotArg()) { |
| 1491 | return VectorStoreTransitionDescriptor::kVirtualSlotVectorIndex; |
| 1492 | } |
| 1493 | return VectorStoreTransitionDescriptor::kVectorIndex; |
| 1494 | } |
| 1495 | |
| 1496 | // Some platforms don't have a slot arg. |
| 1497 | static bool HasVirtualSlotArg() { |
| 1498 | return SlotRegister().is(no_reg); |
| 1499 | } |
| 1500 | }; |
| 1501 | |
| 1502 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1503 | class StoreTransitionStub : public HandlerStub { |
| 1504 | public: |
| 1505 | enum StoreMode { |
| 1506 | StoreMapOnly, |
| 1507 | StoreMapAndValue, |
| 1508 | ExtendStorageAndStoreMapAndValue |
| 1509 | }; |
| 1510 | |
| 1511 | explicit StoreTransitionStub(Isolate* isolate) : HandlerStub(isolate) { |
| 1512 | set_sub_minor_key(StoreModeBits::encode(StoreMapOnly)); |
| 1513 | } |
| 1514 | |
| 1515 | StoreTransitionStub(Isolate* isolate, FieldIndex index, |
| 1516 | Representation representation, StoreMode store_mode) |
| 1517 | : HandlerStub(isolate) { |
| 1518 | DCHECK(store_mode != StoreMapOnly); |
| 1519 | int property_index_key = index.GetFieldAccessStubKey(); |
| 1520 | uint8_t repr = PropertyDetails::EncodeRepresentation(representation); |
| 1521 | set_sub_minor_key(StoreFieldByIndexBits::encode(property_index_key) | |
| 1522 | RepresentationBits::encode(repr) | |
| 1523 | StoreModeBits::encode(store_mode)); |
| 1524 | } |
| 1525 | |
| 1526 | FieldIndex index() const { |
| 1527 | DCHECK(store_mode() != StoreMapOnly); |
| 1528 | int property_index_key = StoreFieldByIndexBits::decode(sub_minor_key()); |
| 1529 | return FieldIndex::FromFieldAccessStubKey(property_index_key); |
| 1530 | } |
| 1531 | |
| 1532 | Representation representation() { |
| 1533 | DCHECK(store_mode() != StoreMapOnly); |
| 1534 | uint8_t repr = RepresentationBits::decode(sub_minor_key()); |
| 1535 | return PropertyDetails::DecodeRepresentation(repr); |
| 1536 | } |
| 1537 | |
| 1538 | StoreMode store_mode() const { |
| 1539 | return StoreModeBits::decode(sub_minor_key()); |
| 1540 | } |
| 1541 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1542 | CallInterfaceDescriptor GetCallInterfaceDescriptor() const override; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1543 | |
| 1544 | protected: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1545 | Code::Kind kind() const override { return Code::STORE_IC; } |
| 1546 | Code::StubType GetStubType() const override { return Code::FAST; } |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1547 | |
| 1548 | private: |
| 1549 | class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; |
| 1550 | class RepresentationBits : public BitField<uint8_t, 13, 4> {}; |
| 1551 | class StoreModeBits : public BitField<StoreMode, 17, 2> {}; |
| 1552 | |
| 1553 | DEFINE_HANDLER_CODE_STUB(StoreTransition, HandlerStub); |
| 1554 | }; |
| 1555 | |
| 1556 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1557 | class StoreGlobalStub : public HandlerStub { |
| 1558 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1559 | StoreGlobalStub(Isolate* isolate, PropertyCellType type, |
| 1560 | Maybe<PropertyCellConstantType> constant_type, |
| 1561 | bool check_global) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1562 | : HandlerStub(isolate) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1563 | PropertyCellConstantType encoded_constant_type = |
| 1564 | constant_type.FromMaybe(PropertyCellConstantType::kSmi); |
| 1565 | set_sub_minor_key(CellTypeBits::encode(type) | |
| 1566 | ConstantTypeBits::encode(encoded_constant_type) | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1567 | CheckGlobalBits::encode(check_global)); |
| 1568 | } |
| 1569 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1570 | static Handle<HeapObject> property_cell_placeholder(Isolate* isolate) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1571 | return isolate->factory()->uninitialized_value(); |
| 1572 | } |
| 1573 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1574 | static Handle<HeapObject> global_map_placeholder(Isolate* isolate) { |
| 1575 | return isolate->factory()->termination_exception(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1576 | } |
| 1577 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1578 | Handle<Code> GetCodeCopyFromTemplate(Handle<JSGlobalObject> global, |
| 1579 | Handle<PropertyCell> cell) { |
| 1580 | Code::FindAndReplacePattern pattern; |
| 1581 | if (check_global()) { |
| 1582 | pattern.Add(handle(global_map_placeholder(isolate())->map()), |
| 1583 | Map::WeakCellForMap(Handle<Map>(global->map()))); |
| 1584 | } |
| 1585 | pattern.Add(handle(property_cell_placeholder(isolate())->map()), |
| 1586 | isolate()->factory()->NewWeakCell(cell)); |
| 1587 | return CodeStub::GetCodeCopy(pattern); |
| 1588 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1589 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1590 | Code::Kind kind() const override { return Code::STORE_IC; } |
| 1591 | |
| 1592 | PropertyCellType cell_type() const { |
| 1593 | return CellTypeBits::decode(sub_minor_key()); |
| 1594 | } |
| 1595 | |
| 1596 | PropertyCellConstantType constant_type() const { |
| 1597 | DCHECK(PropertyCellType::kConstantType == cell_type()); |
| 1598 | return ConstantTypeBits::decode(sub_minor_key()); |
| 1599 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1600 | |
| 1601 | bool check_global() const { return CheckGlobalBits::decode(sub_minor_key()); } |
| 1602 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1603 | Representation representation() { |
| 1604 | return Representation::FromKind( |
| 1605 | RepresentationBits::decode(sub_minor_key())); |
| 1606 | } |
| 1607 | |
| 1608 | void set_representation(Representation r) { |
| 1609 | set_sub_minor_key(RepresentationBits::update(sub_minor_key(), r.kind())); |
| 1610 | } |
| 1611 | |
| 1612 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1613 | class CellTypeBits : public BitField<PropertyCellType, 0, 2> {}; |
| 1614 | class ConstantTypeBits : public BitField<PropertyCellConstantType, 2, 2> {}; |
| 1615 | class RepresentationBits : public BitField<Representation::Kind, 4, 8> {}; |
| 1616 | class CheckGlobalBits : public BitField<bool, 12, 1> {}; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1617 | |
| 1618 | DEFINE_HANDLER_CODE_STUB(StoreGlobal, HandlerStub); |
| 1619 | }; |
| 1620 | |
| 1621 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1622 | class LoadGlobalViaContextStub final : public PlatformCodeStub { |
| 1623 | public: |
| 1624 | static const int kMaximumDepth = 15; |
| 1625 | |
| 1626 | LoadGlobalViaContextStub(Isolate* isolate, int depth) |
| 1627 | : PlatformCodeStub(isolate) { |
| 1628 | minor_key_ = DepthBits::encode(depth); |
| 1629 | } |
| 1630 | |
| 1631 | int depth() const { return DepthBits::decode(minor_key_); } |
| 1632 | |
| 1633 | private: |
| 1634 | class DepthBits : public BitField<int, 0, 4> {}; |
| 1635 | STATIC_ASSERT(DepthBits::kMax == kMaximumDepth); |
| 1636 | |
| 1637 | DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadGlobalViaContext); |
| 1638 | DEFINE_PLATFORM_CODE_STUB(LoadGlobalViaContext, PlatformCodeStub); |
| 1639 | }; |
| 1640 | |
| 1641 | |
| 1642 | class StoreGlobalViaContextStub final : public PlatformCodeStub { |
| 1643 | public: |
| 1644 | static const int kMaximumDepth = 15; |
| 1645 | |
| 1646 | StoreGlobalViaContextStub(Isolate* isolate, int depth, |
| 1647 | LanguageMode language_mode) |
| 1648 | : PlatformCodeStub(isolate) { |
| 1649 | minor_key_ = |
| 1650 | DepthBits::encode(depth) | LanguageModeBits::encode(language_mode); |
| 1651 | } |
| 1652 | |
| 1653 | int depth() const { return DepthBits::decode(minor_key_); } |
| 1654 | LanguageMode language_mode() const { |
| 1655 | return LanguageModeBits::decode(minor_key_); |
| 1656 | } |
| 1657 | |
| 1658 | private: |
| 1659 | class DepthBits : public BitField<int, 0, 4> {}; |
| 1660 | STATIC_ASSERT(DepthBits::kMax == kMaximumDepth); |
| 1661 | class LanguageModeBits : public BitField<LanguageMode, 4, 2> {}; |
| 1662 | STATIC_ASSERT(LANGUAGE_END == 3); |
| 1663 | |
| 1664 | DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreGlobalViaContext); |
| 1665 | DEFINE_PLATFORM_CODE_STUB(StoreGlobalViaContext, PlatformCodeStub); |
| 1666 | }; |
| 1667 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1668 | class CallApiCallbackStub : public PlatformCodeStub { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1669 | public: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1670 | static const int kArgBits = 3; |
| 1671 | static const int kArgMax = (1 << kArgBits) - 1; |
| 1672 | |
| 1673 | // CallApiCallbackStub for regular setters and getters. |
| 1674 | CallApiCallbackStub(Isolate* isolate, bool is_store, bool call_data_undefined, |
| 1675 | bool is_lazy) |
| 1676 | : CallApiCallbackStub(isolate, is_store ? 1 : 0, is_store, |
| 1677 | call_data_undefined, is_lazy) {} |
| 1678 | |
| 1679 | // CallApiCallbackStub for callback functions. |
| 1680 | CallApiCallbackStub(Isolate* isolate, int argc, bool call_data_undefined) |
| 1681 | : CallApiCallbackStub(isolate, argc, false, call_data_undefined, false) {} |
| 1682 | |
| 1683 | CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
| 1684 | return ApiCallbackDescriptorBase::ForArgs(isolate(), argc()); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1685 | } |
| 1686 | |
| 1687 | private: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1688 | CallApiCallbackStub(Isolate* isolate, int argc, bool is_store, |
| 1689 | bool call_data_undefined, bool is_lazy) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1690 | : PlatformCodeStub(isolate) { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1691 | CHECK(0 <= argc && argc <= kArgMax); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1692 | minor_key_ = IsStoreBits::encode(is_store) | |
| 1693 | CallDataUndefinedBits::encode(call_data_undefined) | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1694 | ArgumentBits::encode(argc) | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1695 | IsLazyAccessorBits::encode(is_lazy); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1696 | } |
| 1697 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1698 | bool is_store() const { return IsStoreBits::decode(minor_key_); } |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1699 | bool is_lazy() const { return IsLazyAccessorBits::decode(minor_key_); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1700 | bool call_data_undefined() const { |
| 1701 | return CallDataUndefinedBits::decode(minor_key_); |
| 1702 | } |
| 1703 | int argc() const { return ArgumentBits::decode(minor_key_); } |
| 1704 | |
| 1705 | class IsStoreBits: public BitField<bool, 0, 1> {}; |
| 1706 | class CallDataUndefinedBits: public BitField<bool, 1, 1> {}; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1707 | class ArgumentBits : public BitField<int, 2, kArgBits> {}; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1708 | class IsLazyAccessorBits : public BitField<bool, 3 + kArgBits, 1> {}; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1709 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1710 | DEFINE_PLATFORM_CODE_STUB(CallApiCallback, PlatformCodeStub); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1711 | }; |
| 1712 | |
| 1713 | |
| 1714 | class CallApiGetterStub : public PlatformCodeStub { |
| 1715 | public: |
| 1716 | explicit CallApiGetterStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
| 1717 | |
| 1718 | DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiGetter); |
| 1719 | DEFINE_PLATFORM_CODE_STUB(CallApiGetter, PlatformCodeStub); |
| 1720 | }; |
| 1721 | |
| 1722 | |
| 1723 | class BinaryOpICStub : public HydrogenCodeStub { |
| 1724 | public: |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1725 | BinaryOpICStub(Isolate* isolate, Token::Value op) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1726 | : HydrogenCodeStub(isolate, UNINITIALIZED) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1727 | BinaryOpICState state(isolate, op); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1728 | set_sub_minor_key(state.GetExtraICState()); |
| 1729 | } |
| 1730 | |
| 1731 | BinaryOpICStub(Isolate* isolate, const BinaryOpICState& state) |
| 1732 | : HydrogenCodeStub(isolate) { |
| 1733 | set_sub_minor_key(state.GetExtraICState()); |
| 1734 | } |
| 1735 | |
| 1736 | static void GenerateAheadOfTime(Isolate* isolate); |
| 1737 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1738 | Code::Kind GetCodeKind() const override { return Code::BINARY_OP_IC; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1739 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1740 | InlineCacheState GetICState() const final { return state().GetICState(); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1741 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1742 | ExtraICState GetExtraICState() const final { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1743 | return static_cast<ExtraICState>(sub_minor_key()); |
| 1744 | } |
| 1745 | |
| 1746 | BinaryOpICState state() const { |
| 1747 | return BinaryOpICState(isolate(), GetExtraICState()); |
| 1748 | } |
| 1749 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1750 | void PrintState(std::ostream& os) const final; // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1751 | |
| 1752 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 1753 | static const int kLeft = 0; |
| 1754 | static const int kRight = 1; |
| 1755 | |
| 1756 | private: |
| 1757 | static void GenerateAheadOfTime(Isolate* isolate, |
| 1758 | const BinaryOpICState& state); |
| 1759 | |
| 1760 | DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); |
| 1761 | DEFINE_HYDROGEN_CODE_STUB(BinaryOpIC, HydrogenCodeStub); |
| 1762 | }; |
| 1763 | |
| 1764 | |
| 1765 | // TODO(bmeurer): Merge this into the BinaryOpICStub once we have proper tail |
| 1766 | // call support for stubs in Hydrogen. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1767 | class BinaryOpICWithAllocationSiteStub final : public PlatformCodeStub { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1768 | public: |
| 1769 | BinaryOpICWithAllocationSiteStub(Isolate* isolate, |
| 1770 | const BinaryOpICState& state) |
| 1771 | : PlatformCodeStub(isolate) { |
| 1772 | minor_key_ = state.GetExtraICState(); |
| 1773 | } |
| 1774 | |
| 1775 | static void GenerateAheadOfTime(Isolate* isolate); |
| 1776 | |
| 1777 | Handle<Code> GetCodeCopyFromTemplate(Handle<AllocationSite> allocation_site) { |
| 1778 | Code::FindAndReplacePattern pattern; |
| 1779 | pattern.Add(isolate()->factory()->undefined_map(), allocation_site); |
| 1780 | return CodeStub::GetCodeCopy(pattern); |
| 1781 | } |
| 1782 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1783 | Code::Kind GetCodeKind() const override { return Code::BINARY_OP_IC; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1784 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1785 | InlineCacheState GetICState() const override { return state().GetICState(); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1786 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1787 | ExtraICState GetExtraICState() const override { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1788 | return static_cast<ExtraICState>(minor_key_); |
| 1789 | } |
| 1790 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1791 | void PrintState(std::ostream& os) const override; // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1792 | |
| 1793 | private: |
| 1794 | BinaryOpICState state() const { |
| 1795 | return BinaryOpICState(isolate(), static_cast<ExtraICState>(minor_key_)); |
| 1796 | } |
| 1797 | |
| 1798 | static void GenerateAheadOfTime(Isolate* isolate, |
| 1799 | const BinaryOpICState& state); |
| 1800 | |
| 1801 | DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOpWithAllocationSite); |
| 1802 | DEFINE_PLATFORM_CODE_STUB(BinaryOpICWithAllocationSite, PlatformCodeStub); |
| 1803 | }; |
| 1804 | |
| 1805 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1806 | class BinaryOpWithAllocationSiteStub final : public BinaryOpICStub { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1807 | public: |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1808 | BinaryOpWithAllocationSiteStub(Isolate* isolate, Token::Value op) |
| 1809 | : BinaryOpICStub(isolate, op) {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1810 | |
| 1811 | BinaryOpWithAllocationSiteStub(Isolate* isolate, const BinaryOpICState& state) |
| 1812 | : BinaryOpICStub(isolate, state) {} |
| 1813 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1814 | Code::Kind GetCodeKind() const final { return Code::STUB; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1815 | |
| 1816 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 1817 | static const int kAllocationSite = 0; |
| 1818 | static const int kLeft = 1; |
| 1819 | static const int kRight = 2; |
| 1820 | |
| 1821 | DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOpWithAllocationSite); |
| 1822 | DEFINE_HYDROGEN_CODE_STUB(BinaryOpWithAllocationSite, BinaryOpICStub); |
| 1823 | }; |
| 1824 | |
| 1825 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1826 | class StringAddStub final : public HydrogenCodeStub { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1827 | public: |
| 1828 | StringAddStub(Isolate* isolate, StringAddFlags flags, |
| 1829 | PretenureFlag pretenure_flag) |
| 1830 | : HydrogenCodeStub(isolate) { |
| 1831 | set_sub_minor_key(StringAddFlagsBits::encode(flags) | |
| 1832 | PretenureFlagBits::encode(pretenure_flag)); |
| 1833 | } |
| 1834 | |
| 1835 | StringAddFlags flags() const { |
| 1836 | return StringAddFlagsBits::decode(sub_minor_key()); |
| 1837 | } |
| 1838 | |
| 1839 | PretenureFlag pretenure_flag() const { |
| 1840 | return PretenureFlagBits::decode(sub_minor_key()); |
| 1841 | } |
| 1842 | |
| 1843 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 1844 | static const int kLeft = 0; |
| 1845 | static const int kRight = 1; |
| 1846 | |
| 1847 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1848 | class StringAddFlagsBits : public BitField<StringAddFlags, 0, 3> {}; |
| 1849 | class PretenureFlagBits : public BitField<PretenureFlag, 3, 1> {}; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1850 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1851 | void PrintBaseName(std::ostream& os) const override; // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1852 | |
| 1853 | DEFINE_CALL_INTERFACE_DESCRIPTOR(StringAdd); |
| 1854 | DEFINE_HYDROGEN_CODE_STUB(StringAdd, HydrogenCodeStub); |
| 1855 | }; |
| 1856 | |
| 1857 | |
| 1858 | class CompareICStub : public PlatformCodeStub { |
| 1859 | public: |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1860 | CompareICStub(Isolate* isolate, Token::Value op, CompareICState::State left, |
| 1861 | CompareICState::State right, CompareICState::State state) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1862 | : PlatformCodeStub(isolate) { |
| 1863 | DCHECK(Token::IsCompareOp(op)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1864 | minor_key_ = OpBits::encode(op - Token::EQ) | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1865 | LeftStateBits::encode(left) | RightStateBits::encode(right) | |
| 1866 | StateBits::encode(state); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1867 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1868 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1869 | void set_known_map(Handle<Map> map) { known_map_ = map; } |
| 1870 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1871 | InlineCacheState GetICState() const override; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1872 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1873 | Token::Value op() const { |
| 1874 | return static_cast<Token::Value>(Token::EQ + OpBits::decode(minor_key_)); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1875 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1876 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1877 | CompareICState::State left() const { |
| 1878 | return LeftStateBits::decode(minor_key_); |
| 1879 | } |
| 1880 | CompareICState::State right() const { |
| 1881 | return RightStateBits::decode(minor_key_); |
| 1882 | } |
| 1883 | CompareICState::State state() const { return StateBits::decode(minor_key_); } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1884 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1885 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1886 | Code::Kind GetCodeKind() const override { return Code::COMPARE_IC; } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1887 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1888 | void GenerateBooleans(MacroAssembler* masm); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1889 | void GenerateSmis(MacroAssembler* masm); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1890 | void GenerateNumbers(MacroAssembler* masm); |
| 1891 | void GenerateInternalizedStrings(MacroAssembler* masm); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1892 | void GenerateStrings(MacroAssembler* masm); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1893 | void GenerateUniqueNames(MacroAssembler* masm); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1894 | void GenerateReceivers(MacroAssembler* masm); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1895 | void GenerateMiss(MacroAssembler* masm); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1896 | void GenerateKnownReceivers(MacroAssembler* masm); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1897 | void GenerateGeneric(MacroAssembler* masm); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1898 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1899 | bool strict() const { return op() == Token::EQ_STRICT; } |
| 1900 | Condition GetCondition() const; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1901 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1902 | void AddToSpecialCache(Handle<Code> new_object) override; |
| 1903 | bool FindCodeInSpecialCache(Code** code_out) override; |
| 1904 | bool UseSpecialCache() override { |
| 1905 | return state() == CompareICState::KNOWN_RECEIVER; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1906 | } |
| 1907 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1908 | class OpBits : public BitField<int, 0, 3> {}; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1909 | class LeftStateBits : public BitField<CompareICState::State, 3, 4> {}; |
| 1910 | class RightStateBits : public BitField<CompareICState::State, 7, 4> {}; |
| 1911 | class StateBits : public BitField<CompareICState::State, 11, 4> {}; |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1912 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1913 | Handle<Map> known_map_; |
| 1914 | |
| 1915 | DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOp); |
| 1916 | DEFINE_PLATFORM_CODE_STUB(CompareIC, PlatformCodeStub); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1917 | }; |
| 1918 | |
| 1919 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1920 | class CEntryStub : public PlatformCodeStub { |
| 1921 | public: |
| 1922 | CEntryStub(Isolate* isolate, int result_size, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1923 | SaveFPRegsMode save_doubles = kDontSaveFPRegs, |
| 1924 | ArgvMode argv_mode = kArgvOnStack) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1925 | : PlatformCodeStub(isolate) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1926 | minor_key_ = SaveDoublesBits::encode(save_doubles == kSaveFPRegs) | |
| 1927 | ArgvMode::encode(argv_mode == kArgvInRegister); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1928 | DCHECK(result_size == 1 || result_size == 2 || result_size == 3); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1929 | minor_key_ = ResultSizeBits::update(minor_key_, result_size); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1930 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1931 | |
| 1932 | // The version of this stub that doesn't save doubles is generated ahead of |
| 1933 | // time, so it's OK to call it from other stubs that can't cope with GC during |
| 1934 | // their code generation. On machines that always have gp registers (x64) we |
| 1935 | // can generate both variants ahead of time. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1936 | static void GenerateAheadOfTime(Isolate* isolate); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1937 | |
| 1938 | private: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1939 | bool save_doubles() const { return SaveDoublesBits::decode(minor_key_); } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1940 | bool argv_in_register() const { return ArgvMode::decode(minor_key_); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1941 | int result_size() const { return ResultSizeBits::decode(minor_key_); } |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1942 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1943 | bool NeedsImmovableCode() override; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1944 | |
| 1945 | class SaveDoublesBits : public BitField<bool, 0, 1> {}; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1946 | class ArgvMode : public BitField<bool, 1, 1> {}; |
| 1947 | class ResultSizeBits : public BitField<int, 2, 3> {}; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1948 | |
| 1949 | DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); |
| 1950 | DEFINE_PLATFORM_CODE_STUB(CEntry, PlatformCodeStub); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1951 | }; |
| 1952 | |
| 1953 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1954 | class JSEntryStub : public PlatformCodeStub { |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1955 | public: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1956 | JSEntryStub(Isolate* isolate, StackFrame::Type type) |
| 1957 | : PlatformCodeStub(isolate) { |
| 1958 | DCHECK(type == StackFrame::ENTRY || type == StackFrame::ENTRY_CONSTRUCT); |
| 1959 | minor_key_ = StackFrameTypeBits::encode(type); |
| 1960 | } |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1961 | |
| 1962 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1963 | void FinishCode(Handle<Code> code) override; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1964 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1965 | void PrintName(std::ostream& os) const override { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1966 | os << (type() == StackFrame::ENTRY ? "JSEntryStub" |
| 1967 | : "JSConstructEntryStub"); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1968 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1969 | |
| 1970 | StackFrame::Type type() const { |
| 1971 | return StackFrameTypeBits::decode(minor_key_); |
| 1972 | } |
| 1973 | |
| 1974 | class StackFrameTypeBits : public BitField<StackFrame::Type, 0, 5> {}; |
| 1975 | |
| 1976 | int handler_offset_; |
| 1977 | |
| 1978 | DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); |
| 1979 | DEFINE_PLATFORM_CODE_STUB(JSEntry, PlatformCodeStub); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1980 | }; |
| 1981 | |
| 1982 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1983 | class RegExpExecStub: public PlatformCodeStub { |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1984 | public: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1985 | explicit RegExpExecStub(Isolate* isolate) : PlatformCodeStub(isolate) { } |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1986 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1987 | DEFINE_CALL_INTERFACE_DESCRIPTOR(ContextOnly); |
| 1988 | DEFINE_PLATFORM_CODE_STUB(RegExpExec, PlatformCodeStub); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1989 | }; |
| 1990 | |
| 1991 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1992 | class RegExpConstructResultStub final : public HydrogenCodeStub { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1993 | public: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1994 | explicit RegExpConstructResultStub(Isolate* isolate) |
| 1995 | : HydrogenCodeStub(isolate) { } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 1996 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1997 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 1998 | static const int kLength = 0; |
| 1999 | static const int kIndex = 1; |
| 2000 | static const int kInput = 2; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 2001 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2002 | DEFINE_CALL_INTERFACE_DESCRIPTOR(RegExpConstructResult); |
| 2003 | DEFINE_HYDROGEN_CODE_STUB(RegExpConstructResult, HydrogenCodeStub); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 2004 | }; |
| 2005 | |
| 2006 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2007 | // TODO(bmeurer/mvstanton): Turn CallConstructStub into ConstructICStub. |
| 2008 | class CallConstructStub final : public PlatformCodeStub { |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2009 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2010 | explicit CallConstructStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2011 | |
| 2012 | DEFINE_CALL_INTERFACE_DESCRIPTOR(CallConstruct); |
| 2013 | DEFINE_PLATFORM_CODE_STUB(CallConstruct, PlatformCodeStub); |
Ben Murdoch | 5d4cdbf | 2012-04-11 10:23:59 +0100 | [diff] [blame] | 2014 | }; |
| 2015 | |
| 2016 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2017 | enum StringIndexFlags { |
| 2018 | // Accepts smis or heap numbers. |
| 2019 | STRING_INDEX_IS_NUMBER, |
| 2020 | |
| 2021 | // Accepts smis or heap numbers that are valid array indices |
| 2022 | // (ECMA-262 15.4). Invalid indices are reported as being out of |
| 2023 | // range. |
| 2024 | STRING_INDEX_IS_ARRAY_INDEX |
| 2025 | }; |
| 2026 | |
| 2027 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2028 | enum ReceiverCheckMode { |
| 2029 | // We don't know anything about the receiver. |
| 2030 | RECEIVER_IS_UNKNOWN, |
| 2031 | |
| 2032 | // We know the receiver is a string. |
| 2033 | RECEIVER_IS_STRING |
| 2034 | }; |
| 2035 | |
| 2036 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2037 | enum EmbedMode { |
| 2038 | // The code being generated is part of an IC handler, which may MISS |
| 2039 | // to an IC in failure cases. |
| 2040 | PART_OF_IC_HANDLER, |
| 2041 | |
| 2042 | NOT_PART_OF_IC_HANDLER |
| 2043 | }; |
| 2044 | |
| 2045 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2046 | // Generates code implementing String.prototype.charCodeAt. |
| 2047 | // |
| 2048 | // Only supports the case when the receiver is a string and the index |
| 2049 | // is a number (smi or heap number) that is a valid index into the |
| 2050 | // string. Additional index constraints are specified by the |
| 2051 | // flags. Otherwise, bails out to the provided labels. |
| 2052 | // |
| 2053 | // Register usage: |object| may be changed to another string in a way |
| 2054 | // that doesn't affect charCodeAt/charAt semantics, |index| is |
| 2055 | // preserved, |scratch| and |result| are clobbered. |
| 2056 | class StringCharCodeAtGenerator { |
| 2057 | public: |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2058 | StringCharCodeAtGenerator(Register object, Register index, Register result, |
| 2059 | Label* receiver_not_string, Label* index_not_number, |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2060 | Label* index_out_of_range, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2061 | StringIndexFlags index_flags, |
| 2062 | ReceiverCheckMode check_mode = RECEIVER_IS_UNKNOWN) |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2063 | : object_(object), |
| 2064 | index_(index), |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2065 | result_(result), |
| 2066 | receiver_not_string_(receiver_not_string), |
| 2067 | index_not_number_(index_not_number), |
| 2068 | index_out_of_range_(index_out_of_range), |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2069 | index_flags_(index_flags), |
| 2070 | check_mode_(check_mode) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2071 | DCHECK(!result_.is(object_)); |
| 2072 | DCHECK(!result_.is(index_)); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2073 | } |
| 2074 | |
| 2075 | // Generates the fast case code. On the fallthrough path |result| |
| 2076 | // register contains the result. |
| 2077 | void GenerateFast(MacroAssembler* masm); |
| 2078 | |
| 2079 | // Generates the slow case code. Must not be naturally |
| 2080 | // reachable. Expected to be put after a ret instruction (e.g., in |
| 2081 | // deferred code). Always jumps back to the fast case. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2082 | void GenerateSlow(MacroAssembler* masm, EmbedMode embed_mode, |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2083 | const RuntimeCallHelper& call_helper); |
| 2084 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2085 | // Skip handling slow case and directly jump to bailout. |
| 2086 | void SkipSlow(MacroAssembler* masm, Label* bailout) { |
| 2087 | masm->bind(&index_not_smi_); |
| 2088 | masm->bind(&call_runtime_); |
| 2089 | masm->jmp(bailout); |
| 2090 | } |
| 2091 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2092 | private: |
| 2093 | Register object_; |
| 2094 | Register index_; |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2095 | Register result_; |
| 2096 | |
| 2097 | Label* receiver_not_string_; |
| 2098 | Label* index_not_number_; |
| 2099 | Label* index_out_of_range_; |
| 2100 | |
| 2101 | StringIndexFlags index_flags_; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2102 | ReceiverCheckMode check_mode_; |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2103 | |
| 2104 | Label call_runtime_; |
| 2105 | Label index_not_smi_; |
| 2106 | Label got_smi_index_; |
| 2107 | Label exit_; |
| 2108 | |
| 2109 | DISALLOW_COPY_AND_ASSIGN(StringCharCodeAtGenerator); |
| 2110 | }; |
| 2111 | |
| 2112 | |
| 2113 | // Generates code for creating a one-char string from a char code. |
| 2114 | class StringCharFromCodeGenerator { |
| 2115 | public: |
| 2116 | StringCharFromCodeGenerator(Register code, |
| 2117 | Register result) |
| 2118 | : code_(code), |
| 2119 | result_(result) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2120 | DCHECK(!code_.is(result_)); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2121 | } |
| 2122 | |
| 2123 | // Generates the fast case code. On the fallthrough path |result| |
| 2124 | // register contains the result. |
| 2125 | void GenerateFast(MacroAssembler* masm); |
| 2126 | |
| 2127 | // Generates the slow case code. Must not be naturally |
| 2128 | // reachable. Expected to be put after a ret instruction (e.g., in |
| 2129 | // deferred code). Always jumps back to the fast case. |
| 2130 | void GenerateSlow(MacroAssembler* masm, |
| 2131 | const RuntimeCallHelper& call_helper); |
| 2132 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2133 | // Skip handling slow case and directly jump to bailout. |
| 2134 | void SkipSlow(MacroAssembler* masm, Label* bailout) { |
| 2135 | masm->bind(&slow_case_); |
| 2136 | masm->jmp(bailout); |
| 2137 | } |
| 2138 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2139 | private: |
| 2140 | Register code_; |
| 2141 | Register result_; |
| 2142 | |
| 2143 | Label slow_case_; |
| 2144 | Label exit_; |
| 2145 | |
| 2146 | DISALLOW_COPY_AND_ASSIGN(StringCharFromCodeGenerator); |
| 2147 | }; |
| 2148 | |
| 2149 | |
| 2150 | // Generates code implementing String.prototype.charAt. |
| 2151 | // |
| 2152 | // Only supports the case when the receiver is a string and the index |
| 2153 | // is a number (smi or heap number) that is a valid index into the |
| 2154 | // string. Additional index constraints are specified by the |
| 2155 | // flags. Otherwise, bails out to the provided labels. |
| 2156 | // |
| 2157 | // Register usage: |object| may be changed to another string in a way |
| 2158 | // that doesn't affect charCodeAt/charAt semantics, |index| is |
| 2159 | // preserved, |scratch1|, |scratch2|, and |result| are clobbered. |
| 2160 | class StringCharAtGenerator { |
| 2161 | public: |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2162 | StringCharAtGenerator(Register object, Register index, Register scratch, |
| 2163 | Register result, Label* receiver_not_string, |
| 2164 | Label* index_not_number, Label* index_out_of_range, |
| 2165 | StringIndexFlags index_flags, |
| 2166 | ReceiverCheckMode check_mode = RECEIVER_IS_UNKNOWN) |
| 2167 | : char_code_at_generator_(object, index, scratch, receiver_not_string, |
| 2168 | index_not_number, index_out_of_range, |
| 2169 | index_flags, check_mode), |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 2170 | char_from_code_generator_(scratch, result) {} |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2171 | |
| 2172 | // Generates the fast case code. On the fallthrough path |result| |
| 2173 | // register contains the result. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2174 | void GenerateFast(MacroAssembler* masm) { |
| 2175 | char_code_at_generator_.GenerateFast(masm); |
| 2176 | char_from_code_generator_.GenerateFast(masm); |
| 2177 | } |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2178 | |
| 2179 | // Generates the slow case code. Must not be naturally |
| 2180 | // reachable. Expected to be put after a ret instruction (e.g., in |
| 2181 | // deferred code). Always jumps back to the fast case. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2182 | void GenerateSlow(MacroAssembler* masm, EmbedMode embed_mode, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2183 | const RuntimeCallHelper& call_helper) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2184 | char_code_at_generator_.GenerateSlow(masm, embed_mode, call_helper); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2185 | char_from_code_generator_.GenerateSlow(masm, call_helper); |
| 2186 | } |
| 2187 | |
| 2188 | // Skip handling slow case and directly jump to bailout. |
| 2189 | void SkipSlow(MacroAssembler* masm, Label* bailout) { |
| 2190 | char_code_at_generator_.SkipSlow(masm, bailout); |
| 2191 | char_from_code_generator_.SkipSlow(masm, bailout); |
| 2192 | } |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 2193 | |
| 2194 | private: |
| 2195 | StringCharCodeAtGenerator char_code_at_generator_; |
| 2196 | StringCharFromCodeGenerator char_from_code_generator_; |
| 2197 | |
| 2198 | DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); |
| 2199 | }; |
| 2200 | |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 2201 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2202 | class LoadDictionaryElementStub : public HydrogenCodeStub { |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 2203 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2204 | explicit LoadDictionaryElementStub(Isolate* isolate, const LoadICState& state) |
| 2205 | : HydrogenCodeStub(isolate) { |
| 2206 | minor_key_ = state.GetExtraICState(); |
| 2207 | } |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 2208 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2209 | CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
| 2210 | return LoadWithVectorDescriptor(isolate()); |
| 2211 | } |
| 2212 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2213 | DEFINE_HYDROGEN_CODE_STUB(LoadDictionaryElement, HydrogenCodeStub); |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 2214 | }; |
| 2215 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2216 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2217 | class KeyedLoadGenericStub : public HydrogenCodeStub { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2218 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2219 | explicit KeyedLoadGenericStub(Isolate* isolate, const LoadICState& state) |
| 2220 | : HydrogenCodeStub(isolate) { |
| 2221 | minor_key_ = state.GetExtraICState(); |
| 2222 | } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2223 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2224 | Code::Kind GetCodeKind() const override { return Code::KEYED_LOAD_IC; } |
| 2225 | InlineCacheState GetICState() const override { return GENERIC; } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2226 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2227 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Load); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2228 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2229 | DEFINE_HYDROGEN_CODE_STUB(KeyedLoadGeneric, HydrogenCodeStub); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2230 | }; |
| 2231 | |
| 2232 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2233 | class LoadICTrampolineStub : public PlatformCodeStub { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2234 | public: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2235 | LoadICTrampolineStub(Isolate* isolate, const LoadICState& state) |
| 2236 | : PlatformCodeStub(isolate) { |
| 2237 | minor_key_ = state.GetExtraICState(); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 2238 | } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2239 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2240 | Code::Kind GetCodeKind() const override { return Code::LOAD_IC; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2241 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2242 | InlineCacheState GetICState() const final { return GENERIC; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2243 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2244 | ExtraICState GetExtraICState() const final { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2245 | return static_cast<ExtraICState>(minor_key_); |
| 2246 | } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2247 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2248 | protected: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2249 | LoadICState state() const { |
| 2250 | return LoadICState(static_cast<ExtraICState>(minor_key_)); |
| 2251 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 2252 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2253 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Load); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2254 | DEFINE_PLATFORM_CODE_STUB(LoadICTrampoline, PlatformCodeStub); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2255 | }; |
| 2256 | |
| 2257 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2258 | class KeyedLoadICTrampolineStub : public LoadICTrampolineStub { |
| 2259 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2260 | explicit KeyedLoadICTrampolineStub(Isolate* isolate, const LoadICState& state) |
| 2261 | : LoadICTrampolineStub(isolate, state) {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2262 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2263 | Code::Kind GetCodeKind() const override { return Code::KEYED_LOAD_IC; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2264 | |
| 2265 | DEFINE_PLATFORM_CODE_STUB(KeyedLoadICTrampoline, LoadICTrampolineStub); |
| 2266 | }; |
| 2267 | |
| 2268 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2269 | class VectorStoreICTrampolineStub : public PlatformCodeStub { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2270 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2271 | VectorStoreICTrampolineStub(Isolate* isolate, const StoreICState& state) |
| 2272 | : PlatformCodeStub(isolate) { |
| 2273 | minor_key_ = state.GetExtraICState(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2274 | } |
| 2275 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2276 | Code::Kind GetCodeKind() const override { return Code::STORE_IC; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2277 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2278 | InlineCacheState GetICState() const final { return GENERIC; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2279 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2280 | ExtraICState GetExtraICState() const final { |
| 2281 | return static_cast<ExtraICState>(minor_key_); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2282 | } |
| 2283 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2284 | protected: |
| 2285 | StoreICState state() const { |
| 2286 | return StoreICState(static_cast<ExtraICState>(minor_key_)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2287 | } |
| 2288 | |
| 2289 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2290 | DEFINE_CALL_INTERFACE_DESCRIPTOR(VectorStoreICTrampoline); |
| 2291 | DEFINE_PLATFORM_CODE_STUB(VectorStoreICTrampoline, PlatformCodeStub); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2292 | }; |
| 2293 | |
| 2294 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2295 | class VectorKeyedStoreICTrampolineStub : public VectorStoreICTrampolineStub { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2296 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2297 | VectorKeyedStoreICTrampolineStub(Isolate* isolate, const StoreICState& state) |
| 2298 | : VectorStoreICTrampolineStub(isolate, state) {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2299 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2300 | Code::Kind GetCodeKind() const override { return Code::KEYED_STORE_IC; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2301 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2302 | DEFINE_PLATFORM_CODE_STUB(VectorKeyedStoreICTrampoline, |
| 2303 | VectorStoreICTrampolineStub); |
| 2304 | }; |
| 2305 | |
| 2306 | |
| 2307 | class CallICTrampolineStub : public PlatformCodeStub { |
| 2308 | public: |
| 2309 | CallICTrampolineStub(Isolate* isolate, const CallICState& state) |
| 2310 | : PlatformCodeStub(isolate) { |
| 2311 | minor_key_ = state.GetExtraICState(); |
| 2312 | } |
| 2313 | |
| 2314 | Code::Kind GetCodeKind() const override { return Code::CALL_IC; } |
| 2315 | |
| 2316 | InlineCacheState GetICState() const final { return GENERIC; } |
| 2317 | |
| 2318 | ExtraICState GetExtraICState() const final { |
| 2319 | return static_cast<ExtraICState>(minor_key_); |
| 2320 | } |
| 2321 | |
| 2322 | protected: |
| 2323 | CallICState state() const { |
| 2324 | return CallICState(static_cast<ExtraICState>(minor_key_)); |
| 2325 | } |
| 2326 | |
| 2327 | DEFINE_CALL_INTERFACE_DESCRIPTOR(CallFunctionWithFeedback); |
| 2328 | DEFINE_PLATFORM_CODE_STUB(CallICTrampoline, PlatformCodeStub); |
| 2329 | }; |
| 2330 | |
| 2331 | |
| 2332 | class LoadICStub : public PlatformCodeStub { |
| 2333 | public: |
| 2334 | explicit LoadICStub(Isolate* isolate, const LoadICState& state) |
| 2335 | : PlatformCodeStub(isolate) { |
| 2336 | minor_key_ = state.GetExtraICState(); |
| 2337 | } |
| 2338 | |
| 2339 | void GenerateForTrampoline(MacroAssembler* masm); |
| 2340 | |
| 2341 | Code::Kind GetCodeKind() const override { return Code::LOAD_IC; } |
| 2342 | InlineCacheState GetICState() const final { return GENERIC; } |
| 2343 | ExtraICState GetExtraICState() const final { |
| 2344 | return static_cast<ExtraICState>(minor_key_); |
| 2345 | } |
| 2346 | |
| 2347 | DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector); |
| 2348 | DEFINE_PLATFORM_CODE_STUB(LoadIC, PlatformCodeStub); |
| 2349 | |
| 2350 | protected: |
| 2351 | void GenerateImpl(MacroAssembler* masm, bool in_frame); |
| 2352 | }; |
| 2353 | |
| 2354 | |
| 2355 | class KeyedLoadICStub : public PlatformCodeStub { |
| 2356 | public: |
| 2357 | explicit KeyedLoadICStub(Isolate* isolate, const LoadICState& state) |
| 2358 | : PlatformCodeStub(isolate) { |
| 2359 | minor_key_ = state.GetExtraICState(); |
| 2360 | } |
| 2361 | |
| 2362 | void GenerateForTrampoline(MacroAssembler* masm); |
| 2363 | |
| 2364 | Code::Kind GetCodeKind() const override { return Code::KEYED_LOAD_IC; } |
| 2365 | InlineCacheState GetICState() const final { return GENERIC; } |
| 2366 | ExtraICState GetExtraICState() const final { |
| 2367 | return static_cast<ExtraICState>(minor_key_); |
| 2368 | } |
| 2369 | |
| 2370 | DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector); |
| 2371 | DEFINE_PLATFORM_CODE_STUB(KeyedLoadIC, PlatformCodeStub); |
| 2372 | |
| 2373 | protected: |
| 2374 | void GenerateImpl(MacroAssembler* masm, bool in_frame); |
| 2375 | }; |
| 2376 | |
| 2377 | |
| 2378 | class VectorStoreICStub : public PlatformCodeStub { |
| 2379 | public: |
| 2380 | VectorStoreICStub(Isolate* isolate, const StoreICState& state) |
| 2381 | : PlatformCodeStub(isolate) { |
| 2382 | minor_key_ = state.GetExtraICState(); |
| 2383 | } |
| 2384 | |
| 2385 | void GenerateForTrampoline(MacroAssembler* masm); |
| 2386 | |
| 2387 | Code::Kind GetCodeKind() const final { return Code::STORE_IC; } |
| 2388 | InlineCacheState GetICState() const final { return GENERIC; } |
| 2389 | ExtraICState GetExtraICState() const final { |
| 2390 | return static_cast<ExtraICState>(minor_key_); |
| 2391 | } |
| 2392 | |
| 2393 | DEFINE_CALL_INTERFACE_DESCRIPTOR(VectorStoreIC); |
| 2394 | DEFINE_PLATFORM_CODE_STUB(VectorStoreIC, PlatformCodeStub); |
| 2395 | |
| 2396 | protected: |
| 2397 | void GenerateImpl(MacroAssembler* masm, bool in_frame); |
| 2398 | }; |
| 2399 | |
| 2400 | |
| 2401 | class VectorKeyedStoreICStub : public PlatformCodeStub { |
| 2402 | public: |
| 2403 | VectorKeyedStoreICStub(Isolate* isolate, const StoreICState& state) |
| 2404 | : PlatformCodeStub(isolate) { |
| 2405 | minor_key_ = state.GetExtraICState(); |
| 2406 | } |
| 2407 | |
| 2408 | void GenerateForTrampoline(MacroAssembler* masm); |
| 2409 | |
| 2410 | Code::Kind GetCodeKind() const final { return Code::KEYED_STORE_IC; } |
| 2411 | InlineCacheState GetICState() const final { return GENERIC; } |
| 2412 | ExtraICState GetExtraICState() const final { |
| 2413 | return static_cast<ExtraICState>(minor_key_); |
| 2414 | } |
| 2415 | |
| 2416 | DEFINE_CALL_INTERFACE_DESCRIPTOR(VectorStoreIC); |
| 2417 | DEFINE_PLATFORM_CODE_STUB(VectorKeyedStoreIC, PlatformCodeStub); |
| 2418 | |
| 2419 | protected: |
| 2420 | void GenerateImpl(MacroAssembler* masm, bool in_frame); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2421 | }; |
| 2422 | |
| 2423 | |
| 2424 | class DoubleToIStub : public PlatformCodeStub { |
| 2425 | public: |
| 2426 | DoubleToIStub(Isolate* isolate, Register source, Register destination, |
| 2427 | int offset, bool is_truncating, bool skip_fastpath = false) |
| 2428 | : PlatformCodeStub(isolate) { |
| 2429 | minor_key_ = SourceRegisterBits::encode(source.code()) | |
| 2430 | DestinationRegisterBits::encode(destination.code()) | |
| 2431 | OffsetBits::encode(offset) | |
| 2432 | IsTruncatingBits::encode(is_truncating) | |
| 2433 | SkipFastPathBits::encode(skip_fastpath) | |
| 2434 | SSE3Bits::encode(CpuFeatures::IsSupported(SSE3) ? 1 : 0); |
| 2435 | } |
| 2436 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2437 | bool SometimesSetsUpAFrame() override { return false; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2438 | |
| 2439 | private: |
| 2440 | Register source() const { |
| 2441 | return Register::from_code(SourceRegisterBits::decode(minor_key_)); |
| 2442 | } |
| 2443 | Register destination() const { |
| 2444 | return Register::from_code(DestinationRegisterBits::decode(minor_key_)); |
| 2445 | } |
| 2446 | bool is_truncating() const { return IsTruncatingBits::decode(minor_key_); } |
| 2447 | bool skip_fastpath() const { return SkipFastPathBits::decode(minor_key_); } |
| 2448 | int offset() const { return OffsetBits::decode(minor_key_); } |
| 2449 | |
| 2450 | static const int kBitsPerRegisterNumber = 6; |
| 2451 | STATIC_ASSERT((1L << kBitsPerRegisterNumber) >= Register::kNumRegisters); |
| 2452 | class SourceRegisterBits: |
| 2453 | public BitField<int, 0, kBitsPerRegisterNumber> {}; // NOLINT |
| 2454 | class DestinationRegisterBits: |
| 2455 | public BitField<int, kBitsPerRegisterNumber, |
| 2456 | kBitsPerRegisterNumber> {}; // NOLINT |
| 2457 | class IsTruncatingBits: |
| 2458 | public BitField<bool, 2 * kBitsPerRegisterNumber, 1> {}; // NOLINT |
| 2459 | class OffsetBits: |
| 2460 | public BitField<int, 2 * kBitsPerRegisterNumber + 1, 3> {}; // NOLINT |
| 2461 | class SkipFastPathBits: |
| 2462 | public BitField<int, 2 * kBitsPerRegisterNumber + 4, 1> {}; // NOLINT |
| 2463 | class SSE3Bits: |
| 2464 | public BitField<int, 2 * kBitsPerRegisterNumber + 5, 1> {}; // NOLINT |
| 2465 | |
| 2466 | DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); |
| 2467 | DEFINE_PLATFORM_CODE_STUB(DoubleToI, PlatformCodeStub); |
| 2468 | }; |
| 2469 | |
| 2470 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2471 | class ScriptContextFieldStub : public HandlerStub { |
| 2472 | public: |
| 2473 | ScriptContextFieldStub(Isolate* isolate, |
| 2474 | const ScriptContextTable::LookupResult* lookup_result) |
| 2475 | : HandlerStub(isolate) { |
| 2476 | DCHECK(Accepted(lookup_result)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2477 | STATIC_ASSERT(kContextIndexBits + kSlotIndexBits <= kSubMinorKeyBits); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2478 | set_sub_minor_key(ContextIndexBits::encode(lookup_result->context_index) | |
| 2479 | SlotIndexBits::encode(lookup_result->slot_index)); |
| 2480 | } |
| 2481 | |
| 2482 | int context_index() const { |
| 2483 | return ContextIndexBits::decode(sub_minor_key()); |
| 2484 | } |
| 2485 | |
| 2486 | int slot_index() const { return SlotIndexBits::decode(sub_minor_key()); } |
| 2487 | |
| 2488 | static bool Accepted(const ScriptContextTable::LookupResult* lookup_result) { |
| 2489 | return ContextIndexBits::is_valid(lookup_result->context_index) && |
| 2490 | SlotIndexBits::is_valid(lookup_result->slot_index); |
| 2491 | } |
| 2492 | |
| 2493 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2494 | static const int kContextIndexBits = 9; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2495 | static const int kSlotIndexBits = 13; |
| 2496 | class ContextIndexBits : public BitField<int, 0, kContextIndexBits> {}; |
| 2497 | class SlotIndexBits |
| 2498 | : public BitField<int, kContextIndexBits, kSlotIndexBits> {}; |
| 2499 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2500 | Code::StubType GetStubType() const override { return Code::FAST; } |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2501 | |
| 2502 | DEFINE_CODE_STUB_BASE(ScriptContextFieldStub, HandlerStub); |
| 2503 | }; |
| 2504 | |
| 2505 | |
| 2506 | class LoadScriptContextFieldStub : public ScriptContextFieldStub { |
| 2507 | public: |
| 2508 | LoadScriptContextFieldStub( |
| 2509 | Isolate* isolate, const ScriptContextTable::LookupResult* lookup_result) |
| 2510 | : ScriptContextFieldStub(isolate, lookup_result) {} |
| 2511 | |
| 2512 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2513 | Code::Kind kind() const override { return Code::LOAD_IC; } |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2514 | |
| 2515 | DEFINE_HANDLER_CODE_STUB(LoadScriptContextField, ScriptContextFieldStub); |
| 2516 | }; |
| 2517 | |
| 2518 | |
| 2519 | class StoreScriptContextFieldStub : public ScriptContextFieldStub { |
| 2520 | public: |
| 2521 | StoreScriptContextFieldStub( |
| 2522 | Isolate* isolate, const ScriptContextTable::LookupResult* lookup_result) |
| 2523 | : ScriptContextFieldStub(isolate, lookup_result) {} |
| 2524 | |
| 2525 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2526 | Code::Kind kind() const override { return Code::STORE_IC; } |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2527 | |
| 2528 | DEFINE_HANDLER_CODE_STUB(StoreScriptContextField, ScriptContextFieldStub); |
| 2529 | }; |
| 2530 | |
| 2531 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2532 | class LoadFastElementStub : public HandlerStub { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2533 | public: |
| 2534 | LoadFastElementStub(Isolate* isolate, bool is_js_array, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2535 | ElementsKind elements_kind, |
| 2536 | bool convert_hole_to_undefined = false) |
| 2537 | : HandlerStub(isolate) { |
| 2538 | set_sub_minor_key( |
| 2539 | ElementsKindBits::encode(elements_kind) | |
| 2540 | IsJSArrayBits::encode(is_js_array) | |
| 2541 | CanConvertHoleToUndefined::encode(convert_hole_to_undefined)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2542 | } |
| 2543 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2544 | Code::Kind kind() const override { return Code::KEYED_LOAD_IC; } |
| 2545 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2546 | bool is_js_array() const { return IsJSArrayBits::decode(sub_minor_key()); } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2547 | bool convert_hole_to_undefined() const { |
| 2548 | return CanConvertHoleToUndefined::decode(sub_minor_key()); |
| 2549 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2550 | |
| 2551 | ElementsKind elements_kind() const { |
| 2552 | return ElementsKindBits::decode(sub_minor_key()); |
| 2553 | } |
| 2554 | |
| 2555 | private: |
| 2556 | class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; |
| 2557 | class IsJSArrayBits: public BitField<bool, 8, 1> {}; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2558 | class CanConvertHoleToUndefined : public BitField<bool, 9, 1> {}; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2559 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2560 | DEFINE_HANDLER_CODE_STUB(LoadFastElement, HandlerStub); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2561 | }; |
| 2562 | |
| 2563 | |
| 2564 | class StoreFastElementStub : public HydrogenCodeStub { |
| 2565 | public: |
| 2566 | StoreFastElementStub(Isolate* isolate, bool is_js_array, |
| 2567 | ElementsKind elements_kind, KeyedAccessStoreMode mode) |
| 2568 | : HydrogenCodeStub(isolate) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2569 | set_sub_minor_key(CommonStoreModeBits::encode(mode) | |
| 2570 | ElementsKindBits::encode(elements_kind) | |
| 2571 | IsJSArrayBits::encode(is_js_array)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2572 | } |
| 2573 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2574 | static void GenerateAheadOfTime(Isolate* isolate); |
| 2575 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2576 | bool is_js_array() const { return IsJSArrayBits::decode(sub_minor_key()); } |
| 2577 | |
| 2578 | ElementsKind elements_kind() const { |
| 2579 | return ElementsKindBits::decode(sub_minor_key()); |
| 2580 | } |
| 2581 | |
| 2582 | KeyedAccessStoreMode store_mode() const { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2583 | return CommonStoreModeBits::decode(sub_minor_key()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2584 | } |
| 2585 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2586 | CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
| 2587 | return VectorStoreICDescriptor(isolate()); |
| 2588 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2589 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2590 | Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 2591 | |
| 2592 | private: |
| 2593 | class ElementsKindBits : public BitField<ElementsKind, 3, 8> {}; |
| 2594 | class IsJSArrayBits : public BitField<bool, 11, 1> {}; |
| 2595 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2596 | DEFINE_HYDROGEN_CODE_STUB(StoreFastElement, HydrogenCodeStub); |
| 2597 | }; |
| 2598 | |
| 2599 | |
| 2600 | class TransitionElementsKindStub : public HydrogenCodeStub { |
| 2601 | public: |
| 2602 | TransitionElementsKindStub(Isolate* isolate, |
| 2603 | ElementsKind from_kind, |
| 2604 | ElementsKind to_kind, |
| 2605 | bool is_js_array) : HydrogenCodeStub(isolate) { |
| 2606 | set_sub_minor_key(FromKindBits::encode(from_kind) | |
| 2607 | ToKindBits::encode(to_kind) | |
| 2608 | IsJSArrayBits::encode(is_js_array)); |
| 2609 | } |
| 2610 | |
| 2611 | ElementsKind from_kind() const { |
| 2612 | return FromKindBits::decode(sub_minor_key()); |
| 2613 | } |
| 2614 | |
| 2615 | ElementsKind to_kind() const { return ToKindBits::decode(sub_minor_key()); } |
| 2616 | |
| 2617 | bool is_js_array() const { return IsJSArrayBits::decode(sub_minor_key()); } |
| 2618 | |
| 2619 | private: |
| 2620 | class FromKindBits: public BitField<ElementsKind, 8, 8> {}; |
| 2621 | class ToKindBits: public BitField<ElementsKind, 0, 8> {}; |
| 2622 | class IsJSArrayBits: public BitField<bool, 16, 1> {}; |
| 2623 | |
| 2624 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TransitionElementsKind); |
| 2625 | DEFINE_HYDROGEN_CODE_STUB(TransitionElementsKind, HydrogenCodeStub); |
| 2626 | }; |
| 2627 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2628 | class AllocateHeapNumberStub : public TurboFanCodeStub { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2629 | public: |
| 2630 | explicit AllocateHeapNumberStub(Isolate* isolate) |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2631 | : TurboFanCodeStub(isolate) {} |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2632 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2633 | void InitializeDescriptor(CodeStubDescriptor* descriptor) override; |
| 2634 | void GenerateAssembly(compiler::CodeStubAssembler* assembler) const override; |
| 2635 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2636 | DEFINE_CALL_INTERFACE_DESCRIPTOR(AllocateHeapNumber); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2637 | DEFINE_CODE_STUB(AllocateHeapNumber, TurboFanCodeStub); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2638 | }; |
| 2639 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2640 | class AllocateMutableHeapNumberStub : public TurboFanCodeStub { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2641 | public: |
| 2642 | explicit AllocateMutableHeapNumberStub(Isolate* isolate) |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2643 | : TurboFanCodeStub(isolate) {} |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2644 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2645 | void InitializeDescriptor(CodeStubDescriptor* descriptor) override; |
| 2646 | void GenerateAssembly(compiler::CodeStubAssembler* assembler) const override; |
| 2647 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2648 | DEFINE_CALL_INTERFACE_DESCRIPTOR(AllocateMutableHeapNumber); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2649 | DEFINE_CODE_STUB(AllocateMutableHeapNumber, TurboFanCodeStub); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2650 | }; |
| 2651 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2652 | #define SIMD128_ALLOC_STUB(TYPE, Type, type, lane_count, lane_type) \ |
| 2653 | class Allocate##Type##Stub : public TurboFanCodeStub { \ |
| 2654 | public: \ |
| 2655 | explicit Allocate##Type##Stub(Isolate* isolate) \ |
| 2656 | : TurboFanCodeStub(isolate) {} \ |
| 2657 | \ |
| 2658 | void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \ |
| 2659 | void GenerateAssembly( \ |
| 2660 | compiler::CodeStubAssembler* assembler) const override; \ |
| 2661 | \ |
| 2662 | DEFINE_CALL_INTERFACE_DESCRIPTOR(Allocate##Type); \ |
| 2663 | DEFINE_CODE_STUB(Allocate##Type, TurboFanCodeStub); \ |
| 2664 | }; |
| 2665 | SIMD128_TYPES(SIMD128_ALLOC_STUB) |
| 2666 | #undef SIMD128_ALLOC_STUB |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2667 | |
| 2668 | class AllocateInNewSpaceStub final : public HydrogenCodeStub { |
| 2669 | public: |
| 2670 | explicit AllocateInNewSpaceStub(Isolate* isolate) |
| 2671 | : HydrogenCodeStub(isolate) {} |
| 2672 | |
| 2673 | private: |
| 2674 | DEFINE_CALL_INTERFACE_DESCRIPTOR(AllocateInNewSpace); |
| 2675 | DEFINE_HYDROGEN_CODE_STUB(AllocateInNewSpace, HydrogenCodeStub); |
| 2676 | }; |
| 2677 | |
| 2678 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2679 | class ArrayConstructorStubBase : public HydrogenCodeStub { |
| 2680 | public: |
| 2681 | ArrayConstructorStubBase(Isolate* isolate, |
| 2682 | ElementsKind kind, |
| 2683 | AllocationSiteOverrideMode override_mode) |
| 2684 | : HydrogenCodeStub(isolate) { |
| 2685 | // It only makes sense to override local allocation site behavior |
| 2686 | // if there is a difference between the global allocation site policy |
| 2687 | // for an ElementsKind and the desired usage of the stub. |
| 2688 | DCHECK(override_mode != DISABLE_ALLOCATION_SITES || |
| 2689 | AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE); |
| 2690 | set_sub_minor_key(ElementsKindBits::encode(kind) | |
| 2691 | AllocationSiteOverrideModeBits::encode(override_mode)); |
| 2692 | } |
| 2693 | |
| 2694 | ElementsKind elements_kind() const { |
| 2695 | return ElementsKindBits::decode(sub_minor_key()); |
| 2696 | } |
| 2697 | |
| 2698 | AllocationSiteOverrideMode override_mode() const { |
| 2699 | return AllocationSiteOverrideModeBits::decode(sub_minor_key()); |
| 2700 | } |
| 2701 | |
| 2702 | static void GenerateStubsAheadOfTime(Isolate* isolate); |
| 2703 | |
| 2704 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 2705 | static const int kConstructor = 0; |
| 2706 | static const int kAllocationSite = 1; |
| 2707 | |
| 2708 | protected: |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2709 | std::ostream& BasePrintName(std::ostream& os, |
| 2710 | const char* name) const; // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2711 | |
| 2712 | private: |
| 2713 | // Ensure data fits within available bits. |
| 2714 | STATIC_ASSERT(LAST_ALLOCATION_SITE_OVERRIDE_MODE == 1); |
| 2715 | |
| 2716 | class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; |
| 2717 | class AllocationSiteOverrideModeBits: public |
| 2718 | BitField<AllocationSiteOverrideMode, 8, 1> {}; // NOLINT |
| 2719 | |
| 2720 | DEFINE_CODE_STUB_BASE(ArrayConstructorStubBase, HydrogenCodeStub); |
| 2721 | }; |
| 2722 | |
| 2723 | |
| 2724 | class ArrayNoArgumentConstructorStub : public ArrayConstructorStubBase { |
| 2725 | public: |
| 2726 | ArrayNoArgumentConstructorStub( |
| 2727 | Isolate* isolate, |
| 2728 | ElementsKind kind, |
| 2729 | AllocationSiteOverrideMode override_mode = DONT_OVERRIDE) |
| 2730 | : ArrayConstructorStubBase(isolate, kind, override_mode) { |
| 2731 | } |
| 2732 | |
| 2733 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2734 | void PrintName(std::ostream& os) const override { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2735 | BasePrintName(os, "ArrayNoArgumentConstructorStub"); |
| 2736 | } |
| 2737 | |
| 2738 | DEFINE_CALL_INTERFACE_DESCRIPTOR(ArrayConstructorConstantArgCount); |
| 2739 | DEFINE_HYDROGEN_CODE_STUB(ArrayNoArgumentConstructor, |
| 2740 | ArrayConstructorStubBase); |
| 2741 | }; |
| 2742 | |
| 2743 | |
| 2744 | class ArraySingleArgumentConstructorStub : public ArrayConstructorStubBase { |
| 2745 | public: |
| 2746 | ArraySingleArgumentConstructorStub( |
| 2747 | Isolate* isolate, |
| 2748 | ElementsKind kind, |
| 2749 | AllocationSiteOverrideMode override_mode = DONT_OVERRIDE) |
| 2750 | : ArrayConstructorStubBase(isolate, kind, override_mode) { |
| 2751 | } |
| 2752 | |
| 2753 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2754 | void PrintName(std::ostream& os) const override { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2755 | BasePrintName(os, "ArraySingleArgumentConstructorStub"); |
| 2756 | } |
| 2757 | |
| 2758 | DEFINE_CALL_INTERFACE_DESCRIPTOR(ArrayConstructor); |
| 2759 | DEFINE_HYDROGEN_CODE_STUB(ArraySingleArgumentConstructor, |
| 2760 | ArrayConstructorStubBase); |
| 2761 | }; |
| 2762 | |
| 2763 | |
| 2764 | class ArrayNArgumentsConstructorStub : public ArrayConstructorStubBase { |
| 2765 | public: |
| 2766 | ArrayNArgumentsConstructorStub( |
| 2767 | Isolate* isolate, |
| 2768 | ElementsKind kind, |
| 2769 | AllocationSiteOverrideMode override_mode = DONT_OVERRIDE) |
| 2770 | : ArrayConstructorStubBase(isolate, kind, override_mode) { |
| 2771 | } |
| 2772 | |
| 2773 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2774 | void PrintName(std::ostream& os) const override { // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2775 | BasePrintName(os, "ArrayNArgumentsConstructorStub"); |
| 2776 | } |
| 2777 | |
| 2778 | DEFINE_CALL_INTERFACE_DESCRIPTOR(ArrayConstructor); |
| 2779 | DEFINE_HYDROGEN_CODE_STUB(ArrayNArgumentsConstructor, |
| 2780 | ArrayConstructorStubBase); |
| 2781 | }; |
| 2782 | |
| 2783 | |
| 2784 | class InternalArrayConstructorStubBase : public HydrogenCodeStub { |
| 2785 | public: |
| 2786 | InternalArrayConstructorStubBase(Isolate* isolate, ElementsKind kind) |
| 2787 | : HydrogenCodeStub(isolate) { |
| 2788 | set_sub_minor_key(ElementsKindBits::encode(kind)); |
| 2789 | } |
| 2790 | |
| 2791 | static void GenerateStubsAheadOfTime(Isolate* isolate); |
| 2792 | |
| 2793 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 2794 | static const int kConstructor = 0; |
| 2795 | |
| 2796 | ElementsKind elements_kind() const { |
| 2797 | return ElementsKindBits::decode(sub_minor_key()); |
| 2798 | } |
| 2799 | |
| 2800 | private: |
| 2801 | class ElementsKindBits : public BitField<ElementsKind, 0, 8> {}; |
| 2802 | |
| 2803 | DEFINE_CODE_STUB_BASE(InternalArrayConstructorStubBase, HydrogenCodeStub); |
| 2804 | }; |
| 2805 | |
| 2806 | |
| 2807 | class InternalArrayNoArgumentConstructorStub : public |
| 2808 | InternalArrayConstructorStubBase { |
| 2809 | public: |
| 2810 | InternalArrayNoArgumentConstructorStub(Isolate* isolate, |
| 2811 | ElementsKind kind) |
| 2812 | : InternalArrayConstructorStubBase(isolate, kind) { } |
| 2813 | |
| 2814 | DEFINE_CALL_INTERFACE_DESCRIPTOR(InternalArrayConstructorConstantArgCount); |
| 2815 | DEFINE_HYDROGEN_CODE_STUB(InternalArrayNoArgumentConstructor, |
| 2816 | InternalArrayConstructorStubBase); |
| 2817 | }; |
| 2818 | |
| 2819 | |
| 2820 | class InternalArraySingleArgumentConstructorStub : public |
| 2821 | InternalArrayConstructorStubBase { |
| 2822 | public: |
| 2823 | InternalArraySingleArgumentConstructorStub(Isolate* isolate, |
| 2824 | ElementsKind kind) |
| 2825 | : InternalArrayConstructorStubBase(isolate, kind) { } |
| 2826 | |
| 2827 | DEFINE_CALL_INTERFACE_DESCRIPTOR(InternalArrayConstructor); |
| 2828 | DEFINE_HYDROGEN_CODE_STUB(InternalArraySingleArgumentConstructor, |
| 2829 | InternalArrayConstructorStubBase); |
| 2830 | }; |
| 2831 | |
| 2832 | |
| 2833 | class InternalArrayNArgumentsConstructorStub : public |
| 2834 | InternalArrayConstructorStubBase { |
| 2835 | public: |
| 2836 | InternalArrayNArgumentsConstructorStub(Isolate* isolate, ElementsKind kind) |
| 2837 | : InternalArrayConstructorStubBase(isolate, kind) { } |
| 2838 | |
| 2839 | DEFINE_CALL_INTERFACE_DESCRIPTOR(InternalArrayConstructor); |
| 2840 | DEFINE_HYDROGEN_CODE_STUB(InternalArrayNArgumentsConstructor, |
| 2841 | InternalArrayConstructorStubBase); |
| 2842 | }; |
| 2843 | |
| 2844 | |
| 2845 | class StoreElementStub : public PlatformCodeStub { |
| 2846 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2847 | StoreElementStub(Isolate* isolate, ElementsKind elements_kind, |
| 2848 | KeyedAccessStoreMode mode) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2849 | : PlatformCodeStub(isolate) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 2850 | // TODO(jkummerow): Rename this stub to StoreSlowElementStub, |
| 2851 | // drop elements_kind parameter. |
| 2852 | DCHECK_EQ(DICTIONARY_ELEMENTS, elements_kind); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2853 | minor_key_ = ElementsKindBits::encode(elements_kind) | |
| 2854 | CommonStoreModeBits::encode(mode); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2855 | } |
| 2856 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2857 | CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { |
| 2858 | return VectorStoreICDescriptor(isolate()); |
| 2859 | } |
| 2860 | |
| 2861 | Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
| 2862 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2863 | private: |
| 2864 | ElementsKind elements_kind() const { |
| 2865 | return ElementsKindBits::decode(minor_key_); |
| 2866 | } |
| 2867 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2868 | class ElementsKindBits : public BitField<ElementsKind, 3, 8> {}; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2869 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2870 | DEFINE_PLATFORM_CODE_STUB(StoreElement, PlatformCodeStub); |
| 2871 | }; |
| 2872 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2873 | class ToBooleanICStub : public HydrogenCodeStub { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2874 | public: |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 2875 | enum Type { |
| 2876 | UNDEFINED, |
| 2877 | BOOLEAN, |
| 2878 | NULL_TYPE, |
| 2879 | SMI, |
| 2880 | SPEC_OBJECT, |
| 2881 | STRING, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2882 | SYMBOL, |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 2883 | HEAP_NUMBER, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2884 | SIMD_VALUE, |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 2885 | NUMBER_OF_TYPES |
| 2886 | }; |
| 2887 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2888 | // At most 16 different types can be distinguished, because the Code object |
| 2889 | // only has room for two bytes to hold a set of these types. :-P |
| 2890 | STATIC_ASSERT(NUMBER_OF_TYPES <= 16); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2891 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2892 | class Types : public EnumSet<Type, uint16_t> { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 2893 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2894 | Types() : EnumSet<Type, uint16_t>(0) {} |
| 2895 | explicit Types(uint16_t bits) : EnumSet<Type, uint16_t>(bits) {} |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 2896 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2897 | bool UpdateStatus(Handle<Object> object); |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 2898 | bool NeedsMap() const; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2899 | bool CanBeUndetectable() const { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2900 | return Contains(ToBooleanICStub::SPEC_OBJECT); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2901 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2902 | bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 2903 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2904 | static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 2905 | }; |
| 2906 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2907 | ToBooleanICStub(Isolate* isolate, ExtraICState state) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2908 | : HydrogenCodeStub(isolate) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2909 | set_sub_minor_key(TypesBits::encode(static_cast<uint16_t>(state))); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2910 | } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2911 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2912 | bool UpdateStatus(Handle<Object> object); |
| 2913 | Types types() const { return Types(TypesBits::decode(sub_minor_key())); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2914 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2915 | Code::Kind GetCodeKind() const override { return Code::TO_BOOLEAN_IC; } |
| 2916 | void PrintState(std::ostream& os) const override; // NOLINT |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 2917 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2918 | bool SometimesSetsUpAFrame() override { return false; } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 2919 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2920 | static Handle<Code> GetUninitialized(Isolate* isolate) { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2921 | return ToBooleanICStub(isolate, UNINITIALIZED).GetCode(); |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 2922 | } |
| 2923 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2924 | ExtraICState GetExtraICState() const override { return types().ToIntegral(); } |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 2925 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2926 | InlineCacheState GetICState() const override { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2927 | if (types().IsEmpty()) { |
| 2928 | return ::v8::internal::UNINITIALIZED; |
| 2929 | } else { |
| 2930 | return MONOMORPHIC; |
| 2931 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 2932 | } |
| 2933 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2934 | private: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2935 | ToBooleanICStub(Isolate* isolate, InitializationState init_state) |
| 2936 | : HydrogenCodeStub(isolate, init_state) {} |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 2937 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2938 | class TypesBits : public BitField<uint16_t, 0, NUMBER_OF_TYPES> {}; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 2939 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2940 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
| 2941 | DEFINE_HYDROGEN_CODE_STUB(ToBooleanIC, HydrogenCodeStub); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 2942 | }; |
| 2943 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2944 | std::ostream& operator<<(std::ostream& os, const ToBooleanICStub::Types& t); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2945 | |
| 2946 | class ElementsTransitionAndStoreStub : public HydrogenCodeStub { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 2947 | public: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2948 | ElementsTransitionAndStoreStub(Isolate* isolate, ElementsKind from_kind, |
| 2949 | ElementsKind to_kind, bool is_jsarray, |
| 2950 | KeyedAccessStoreMode store_mode) |
| 2951 | : HydrogenCodeStub(isolate) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2952 | set_sub_minor_key(CommonStoreModeBits::encode(store_mode) | |
| 2953 | FromBits::encode(from_kind) | ToBits::encode(to_kind) | |
| 2954 | IsJSArrayBits::encode(is_jsarray)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2955 | } |
| 2956 | |
| 2957 | ElementsKind from_kind() const { return FromBits::decode(sub_minor_key()); } |
| 2958 | ElementsKind to_kind() const { return ToBits::decode(sub_minor_key()); } |
| 2959 | bool is_jsarray() const { return IsJSArrayBits::decode(sub_minor_key()); } |
| 2960 | KeyedAccessStoreMode store_mode() const { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2961 | return CommonStoreModeBits::decode(sub_minor_key()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2962 | } |
| 2963 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2964 | CallInterfaceDescriptor GetCallInterfaceDescriptor() const override; |
| 2965 | Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 2966 | |
| 2967 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2968 | class FromBits : public BitField<ElementsKind, 3, 8> {}; |
| 2969 | class ToBits : public BitField<ElementsKind, 11, 8> {}; |
| 2970 | class IsJSArrayBits : public BitField<bool, 19, 1> {}; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 2971 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2972 | DEFINE_HYDROGEN_CODE_STUB(ElementsTransitionAndStore, HydrogenCodeStub); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 2973 | }; |
| 2974 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2975 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2976 | class StubFailureTrampolineStub : public PlatformCodeStub { |
| 2977 | public: |
| 2978 | StubFailureTrampolineStub(Isolate* isolate, StubFunctionMode function_mode) |
| 2979 | : PlatformCodeStub(isolate) { |
| 2980 | minor_key_ = FunctionModeField::encode(function_mode); |
| 2981 | } |
| 2982 | |
| 2983 | static void GenerateAheadOfTime(Isolate* isolate); |
| 2984 | |
| 2985 | private: |
| 2986 | StubFunctionMode function_mode() const { |
| 2987 | return FunctionModeField::decode(minor_key_); |
| 2988 | } |
| 2989 | |
| 2990 | class FunctionModeField : public BitField<StubFunctionMode, 0, 1> {}; |
| 2991 | |
| 2992 | DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); |
| 2993 | DEFINE_PLATFORM_CODE_STUB(StubFailureTrampoline, PlatformCodeStub); |
| 2994 | }; |
| 2995 | |
| 2996 | |
| 2997 | class ProfileEntryHookStub : public PlatformCodeStub { |
| 2998 | public: |
| 2999 | explicit ProfileEntryHookStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
| 3000 | |
| 3001 | // The profile entry hook function is not allowed to cause a GC. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 3002 | bool SometimesSetsUpAFrame() override { return false; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 3003 | |
| 3004 | // Generates a call to the entry hook if it's enabled. |
| 3005 | static void MaybeCallEntryHook(MacroAssembler* masm); |
| 3006 | |
| 3007 | private: |
| 3008 | static void EntryHookTrampoline(intptr_t function, |
| 3009 | intptr_t stack_pointer, |
| 3010 | Isolate* isolate); |
| 3011 | |
| 3012 | // ProfileEntryHookStub is called at the start of a function, so it has the |
| 3013 | // same register set. |
| 3014 | DEFINE_CALL_INTERFACE_DESCRIPTOR(CallFunction) |
| 3015 | DEFINE_PLATFORM_CODE_STUB(ProfileEntryHook, PlatformCodeStub); |
| 3016 | }; |
| 3017 | |
| 3018 | |
| 3019 | class StoreBufferOverflowStub : public PlatformCodeStub { |
| 3020 | public: |
| 3021 | StoreBufferOverflowStub(Isolate* isolate, SaveFPRegsMode save_fp) |
| 3022 | : PlatformCodeStub(isolate) { |
| 3023 | minor_key_ = SaveDoublesBits::encode(save_fp == kSaveFPRegs); |
| 3024 | } |
| 3025 | |
| 3026 | static void GenerateFixedRegStubsAheadOfTime(Isolate* isolate); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 3027 | bool SometimesSetsUpAFrame() override { return false; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 3028 | |
| 3029 | private: |
| 3030 | bool save_doubles() const { return SaveDoublesBits::decode(minor_key_); } |
| 3031 | |
| 3032 | class SaveDoublesBits : public BitField<bool, 0, 1> {}; |
| 3033 | |
| 3034 | DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); |
| 3035 | DEFINE_PLATFORM_CODE_STUB(StoreBufferOverflow, PlatformCodeStub); |
| 3036 | }; |
| 3037 | |
| 3038 | |
| 3039 | class SubStringStub : public PlatformCodeStub { |
| 3040 | public: |
| 3041 | explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
| 3042 | |
| 3043 | DEFINE_CALL_INTERFACE_DESCRIPTOR(ContextOnly); |
| 3044 | DEFINE_PLATFORM_CODE_STUB(SubString, PlatformCodeStub); |
| 3045 | }; |
| 3046 | |
| 3047 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 3048 | class ToNumberStub final : public PlatformCodeStub { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 3049 | public: |
| 3050 | explicit ToNumberStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
| 3051 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 3052 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 3053 | DEFINE_PLATFORM_CODE_STUB(ToNumber, PlatformCodeStub); |
| 3054 | }; |
| 3055 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 3056 | class NonNumberToNumberStub final : public PlatformCodeStub { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 3057 | public: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 3058 | explicit NonNumberToNumberStub(Isolate* isolate) |
| 3059 | : PlatformCodeStub(isolate) {} |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 3060 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 3061 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
| 3062 | DEFINE_PLATFORM_CODE_STUB(NonNumberToNumber, PlatformCodeStub); |
| 3063 | }; |
| 3064 | |
| 3065 | class StringToNumberStub final : public PlatformCodeStub { |
| 3066 | public: |
| 3067 | explicit StringToNumberStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
| 3068 | |
| 3069 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
| 3070 | DEFINE_PLATFORM_CODE_STUB(StringToNumber, PlatformCodeStub); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 3071 | }; |
| 3072 | |
| 3073 | |
| 3074 | class ToStringStub final : public PlatformCodeStub { |
| 3075 | public: |
| 3076 | explicit ToStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
| 3077 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 3078 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 3079 | DEFINE_PLATFORM_CODE_STUB(ToString, PlatformCodeStub); |
| 3080 | }; |
| 3081 | |
| 3082 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 3083 | class ToNameStub final : public PlatformCodeStub { |
| 3084 | public: |
| 3085 | explicit ToNameStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
| 3086 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 3087 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 3088 | DEFINE_PLATFORM_CODE_STUB(ToName, PlatformCodeStub); |
| 3089 | }; |
| 3090 | |
| 3091 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 3092 | class ToObjectStub final : public HydrogenCodeStub { |
| 3093 | public: |
| 3094 | explicit ToObjectStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} |
| 3095 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 3096 | DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 3097 | DEFINE_HYDROGEN_CODE_STUB(ToObject, HydrogenCodeStub); |
| 3098 | }; |
| 3099 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 3100 | #undef DEFINE_CALL_INTERFACE_DESCRIPTOR |
| 3101 | #undef DEFINE_PLATFORM_CODE_STUB |
| 3102 | #undef DEFINE_HANDLER_CODE_STUB |
| 3103 | #undef DEFINE_HYDROGEN_CODE_STUB |
| 3104 | #undef DEFINE_CODE_STUB |
| 3105 | #undef DEFINE_CODE_STUB_BASE |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 3106 | |
| 3107 | extern Representation RepresentationFromType(Type* type); |
| 3108 | |
| 3109 | } // namespace internal |
| 3110 | } // namespace v8 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 3111 | |
| 3112 | #endif // V8_CODE_STUBS_H_ |