ulan@chromium.org | 65a89c2 | 2012-02-14 11:46:07 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_CODE_STUBS_H_ |
| 29 | #define V8_CODE_STUBS_H_ |
| 30 | |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 31 | #include "allocation.h" |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 32 | #include "assembler.h" |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 33 | #include "codegen.h" |
bmeurer@chromium.org | 0fdb2a6 | 2013-10-21 07:19:36 +0000 | [diff] [blame] | 34 | #include "globals.h" |
| 35 | #include "macro-assembler.h" |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 36 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 37 | namespace v8 { |
| 38 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 39 | |
ricow@chromium.org | c54d365 | 2011-05-30 09:20:16 +0000 | [diff] [blame] | 40 | // List of code stubs used on all platforms. |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 41 | #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
| 42 | V(CallFunction) \ |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 43 | V(CallConstruct) \ |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 44 | V(BinaryOpIC) \ |
ulan@chromium.org | 0f13e74 | 2014-01-03 15:51:11 +0000 | [diff] [blame^] | 45 | V(BinaryOpICWithAllocationSite) \ |
| 46 | V(BinaryOpWithAllocationSite) \ |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 47 | V(StringAdd) \ |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 48 | V(NewStringAdd) \ |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 49 | V(SubString) \ |
| 50 | V(StringCompare) \ |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 51 | V(Compare) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 52 | V(CompareIC) \ |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 53 | V(CompareNilIC) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 54 | V(MathPow) \ |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 55 | V(StringLength) \ |
| 56 | V(FunctionPrototype) \ |
mvstanton@chromium.org | d16d853 | 2013-01-25 13:29:10 +0000 | [diff] [blame] | 57 | V(StoreArrayLength) \ |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 58 | V(RecordWrite) \ |
| 59 | V(StoreBufferOverflow) \ |
| 60 | V(RegExpExec) \ |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 61 | V(Instanceof) \ |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 62 | V(ConvertToDouble) \ |
| 63 | V(WriteInt32ToHeapNumber) \ |
| 64 | V(StackCheck) \ |
yangguo@chromium.org | 5645471 | 2012-02-16 15:33:53 +0000 | [diff] [blame] | 65 | V(Interrupt) \ |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 66 | V(FastNewClosure) \ |
| 67 | V(FastNewContext) \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 68 | V(FastNewBlockContext) \ |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 69 | V(FastCloneShallowArray) \ |
mstarzinger@chromium.org | f8c6bd5 | 2011-11-23 12:13:52 +0000 | [diff] [blame] | 70 | V(FastCloneShallowObject) \ |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 71 | V(CreateAllocationSite) \ |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 72 | V(ToBoolean) \ |
whesse@chromium.org | 7a392b3 | 2011-01-31 11:30:36 +0000 | [diff] [blame] | 73 | V(ToNumber) \ |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 74 | V(ArgumentsAccess) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 75 | V(RegExpConstructResult) \ |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 76 | V(NumberToString) \ |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 77 | V(DoubleToI) \ |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 78 | V(CEntry) \ |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 79 | V(JSEntry) \ |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 80 | V(KeyedLoadElement) \ |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 81 | V(ArrayNoArgumentConstructor) \ |
| 82 | V(ArraySingleArgumentConstructor) \ |
| 83 | V(ArrayNArgumentsConstructor) \ |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 84 | V(InternalArrayNoArgumentConstructor) \ |
| 85 | V(InternalArraySingleArgumentConstructor) \ |
| 86 | V(InternalArrayNArgumentsConstructor) \ |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 87 | V(KeyedStoreElement) \ |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 88 | V(DebuggerStatement) \ |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 89 | V(NameDictionaryLookup) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 90 | V(ElementsTransitionAndStore) \ |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 91 | V(TransitionElementsKind) \ |
verwaest@chromium.org | 753aee4 | 2012-07-17 16:15:42 +0000 | [diff] [blame] | 92 | V(StoreArrayLiteralElement) \ |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 93 | V(StubFailureTrampoline) \ |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 94 | V(StubFailureTailCallTrampoline) \ |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 95 | V(ArrayConstructor) \ |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 96 | V(InternalArrayConstructor) \ |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 97 | V(ProfileEntryHook) \ |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 98 | V(StoreGlobal) \ |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 99 | /* IC Handler stubs */ \ |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 100 | V(LoadField) \ |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 101 | V(KeyedLoadField) \ |
| 102 | V(KeyedArrayCall) |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 103 | |
| 104 | // List of code stubs only used on ARM platforms. |
jkummerow@chromium.org | 93a47f4 | 2013-07-02 14:43:41 +0000 | [diff] [blame] | 105 | #if V8_TARGET_ARCH_ARM |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 106 | #define CODE_STUB_LIST_ARM(V) \ |
| 107 | V(GetProperty) \ |
| 108 | V(SetProperty) \ |
| 109 | V(InvokeBuiltin) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 110 | V(DirectCEntry) |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 111 | #else |
| 112 | #define CODE_STUB_LIST_ARM(V) |
| 113 | #endif |
| 114 | |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 115 | // List of code stubs only used on MIPS platforms. |
jkummerow@chromium.org | 93a47f4 | 2013-07-02 14:43:41 +0000 | [diff] [blame] | 116 | #if V8_TARGET_ARCH_MIPS |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 117 | #define CODE_STUB_LIST_MIPS(V) \ |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 118 | V(RegExpCEntry) \ |
yangguo@chromium.org | 4954674 | 2013-12-23 16:17:49 +0000 | [diff] [blame] | 119 | V(DirectCEntry) \ |
| 120 | V(StoreRegistersState) \ |
| 121 | V(RestoreRegistersState) |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 122 | #else |
| 123 | #define CODE_STUB_LIST_MIPS(V) |
| 124 | #endif |
| 125 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 126 | // Combined list of code stubs. |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 127 | #define CODE_STUB_LIST(V) \ |
| 128 | CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 129 | CODE_STUB_LIST_ARM(V) \ |
| 130 | CODE_STUB_LIST_MIPS(V) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 131 | |
| 132 | // Stub is base classes of all stubs. |
| 133 | class CodeStub BASE_EMBEDDED { |
| 134 | public: |
| 135 | enum Major { |
jkummerow@chromium.org | 113035e | 2013-12-13 15:13:40 +0000 | [diff] [blame] | 136 | UninitializedMajorKey = 0, |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 137 | #define DEF_ENUM(name) name, |
| 138 | CODE_STUB_LIST(DEF_ENUM) |
| 139 | #undef DEF_ENUM |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 140 | NoCache, // marker for stubs that do custom caching |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 141 | NUMBER_OF_IDS |
| 142 | }; |
| 143 | |
| 144 | // Retrieve the code for the stub. Generate the code if needed. |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 145 | Handle<Code> GetCode(Isolate* isolate); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 146 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 147 | // Retrieve the code for the stub, make and return a copy of the code. |
| 148 | Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 149 | static Major MajorKeyFromKey(uint32_t key) { |
| 150 | return static_cast<Major>(MajorKeyBits::decode(key)); |
kmillikin@chromium.org | 3cdd9e1 | 2010-09-06 11:39:48 +0000 | [diff] [blame] | 151 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 152 | static int MinorKeyFromKey(uint32_t key) { |
| 153 | return MinorKeyBits::decode(key); |
kmillikin@chromium.org | 3cdd9e1 | 2010-09-06 11:39:48 +0000 | [diff] [blame] | 154 | } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 155 | |
| 156 | // Gets the major key from a code object that is a code stub or binary op IC. |
| 157 | static Major GetMajorKey(Code* code_stub) { |
| 158 | return static_cast<Major>(code_stub->major_key()); |
| 159 | } |
| 160 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 161 | static const char* MajorName(Major major_key, bool allow_unknown_keys); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 162 | |
| 163 | virtual ~CodeStub() {} |
| 164 | |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 165 | static void GenerateStubsAheadOfTime(Isolate* isolate); |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 166 | static void GenerateStubsRequiringBuiltinsAheadOfTime(Isolate* isolate); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 167 | static void GenerateFPStubs(Isolate* isolate); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 168 | |
| 169 | // Some stubs put untagged junk on the stack that cannot be scanned by the |
| 170 | // GC. This means that we must be statically sure that no GC can occur while |
| 171 | // they are running. If that is the case they should override this to return |
| 172 | // true, which will cause an assertion if we try to call something that can |
| 173 | // GC or if we try to put a stack frame on top of the junk, which would not |
| 174 | // result in a traversable stack. |
| 175 | virtual bool SometimesSetsUpAFrame() { return true; } |
| 176 | |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 177 | // Lookup the code in the (possibly custom) cache. |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 178 | bool FindCodeInCache(Code** code_out, Isolate* isolate); |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 179 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 180 | // Returns information for computing the number key. |
| 181 | virtual Major MajorKey() = 0; |
| 182 | virtual int MinorKey() = 0; |
| 183 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 184 | virtual InlineCacheState GetICState() { |
| 185 | return UNINITIALIZED; |
| 186 | } |
yangguo@chromium.org | cc53605 | 2013-11-29 11:43:20 +0000 | [diff] [blame] | 187 | virtual ExtraICState GetExtraICState() { |
| 188 | return kNoExtraICState; |
mvstanton@chromium.org | d16d853 | 2013-01-25 13:29:10 +0000 | [diff] [blame] | 189 | } |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 190 | virtual Code::StubType GetStubType() { |
| 191 | return Code::NORMAL; |
| 192 | } |
| 193 | virtual int GetStubFlags() { |
| 194 | return -1; |
| 195 | } |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 196 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 197 | virtual void PrintName(StringStream* stream); |
| 198 | |
jkummerow@chromium.org | d8a3a14 | 2013-10-03 12:15:05 +0000 | [diff] [blame] | 199 | // Returns a name for logging/debugging purposes. |
| 200 | SmartArrayPointer<const char> GetName(); |
| 201 | |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 202 | protected: |
| 203 | static bool CanUseFPRegisters(); |
| 204 | |
| 205 | // Generates the assembler code for the stub. |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 206 | virtual Handle<Code> GenerateCode(Isolate* isolate) = 0; |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 207 | |
mvstanton@chromium.org | 63ea3d2 | 2013-10-10 09:24:12 +0000 | [diff] [blame] | 208 | virtual void VerifyPlatformFeatures(Isolate* isolate); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 209 | |
| 210 | // Returns whether the code generated for this stub needs to be allocated as |
| 211 | // a fixed (non-moveable) code object. |
| 212 | virtual bool NeedsImmovableCode() { return false; } |
| 213 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 214 | virtual void PrintBaseName(StringStream* stream); |
| 215 | virtual void PrintState(StringStream* stream) { } |
| 216 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 217 | private: |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 218 | // Perform bookkeeping required after code generation when stub code is |
| 219 | // initially generated. |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 220 | void RecordCodeGeneration(Code* code, Isolate* isolate); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 221 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 222 | // Finish the code object after it has been generated. |
jkummerow@chromium.org | 04e4f1e | 2011-11-14 13:36:17 +0000 | [diff] [blame] | 223 | virtual void FinishCode(Handle<Code> code) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 224 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 225 | // Activate newly generated stub. Is called after |
| 226 | // registering stub in the stub cache. |
| 227 | virtual void Activate(Code* code) { } |
| 228 | |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 229 | // BinaryOpStub needs to override this. |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 230 | virtual Code::Kind GetCodeKind() const; |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 231 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 232 | // Add the code to a specialized cache, specific to an individual |
| 233 | // stub type. Please note, this method must add the code object to a |
| 234 | // roots object, otherwise we will remove the code during GC. |
| 235 | virtual void AddToSpecialCache(Handle<Code> new_object) { } |
| 236 | |
| 237 | // Find code in a specialized cache, work is delegated to the specific stub. |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 238 | virtual bool FindCodeInSpecialCache(Code** code_out, Isolate* isolate) { |
| 239 | return false; |
| 240 | } |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 241 | |
| 242 | // If a stub uses a special cache override this. |
| 243 | virtual bool UseSpecialCache() { return false; } |
| 244 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 245 | // Computes the key based on major and minor. |
| 246 | uint32_t GetKey() { |
| 247 | ASSERT(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); |
| 248 | return MinorKeyBits::encode(MinorKey()) | |
| 249 | MajorKeyBits::encode(MajorKey()); |
| 250 | } |
| 251 | |
jkummerow@chromium.org | 113035e | 2013-12-13 15:13:40 +0000 | [diff] [blame] | 252 | STATIC_ASSERT(NUMBER_OF_IDS < (1 << kStubMajorKeyBits)); |
danno@chromium.org | 81cac2b | 2012-07-10 11:28:27 +0000 | [diff] [blame] | 253 | class MajorKeyBits: public BitField<uint32_t, 0, kStubMajorKeyBits> {}; |
| 254 | class MinorKeyBits: public BitField<uint32_t, |
| 255 | kStubMajorKeyBits, kStubMinorKeyBits> {}; // NOLINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 256 | |
| 257 | friend class BreakPointIterator; |
| 258 | }; |
| 259 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 260 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 261 | class PlatformCodeStub : public CodeStub { |
| 262 | public: |
| 263 | // Retrieve the code for the stub. Generate the code if needed. |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 264 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 265 | |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 266 | virtual Code::Kind GetCodeKind() const { return Code::STUB; } |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 267 | |
| 268 | protected: |
| 269 | // Generates the assembler code for the stub. |
| 270 | virtual void Generate(MacroAssembler* masm) = 0; |
| 271 | }; |
| 272 | |
| 273 | |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 274 | enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 275 | enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 276 | |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 277 | enum ContinuationType { NORMAL_CONTINUATION, TAIL_CALL_CONTINUATION }; |
| 278 | |
| 279 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 280 | struct CodeStubInterfaceDescriptor { |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 281 | CodeStubInterfaceDescriptor(); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 282 | int register_param_count_; |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 283 | |
bmeurer@chromium.org | 0fdb2a6 | 2013-10-21 07:19:36 +0000 | [diff] [blame] | 284 | Register stack_parameter_count_; |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 285 | // if hint_stack_parameter_count_ > 0, the code stub can optimize the |
| 286 | // return sequence. Default value is -1, which means it is ignored. |
| 287 | int hint_stack_parameter_count_; |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 288 | ContinuationType continuation_type_; |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 289 | StubFunctionMode function_mode_; |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 290 | Register* register_params_; |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 291 | |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 292 | Address deoptimization_handler_; |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 293 | HandlerArgumentsMode handler_arguments_mode_; |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 294 | |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 295 | bool initialized() const { return register_param_count_ >= 0; } |
| 296 | |
| 297 | bool HasTailCallContinuation() const { |
| 298 | return continuation_type_ == TAIL_CALL_CONTINUATION; |
| 299 | } |
| 300 | |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 301 | int environment_length() const { |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 302 | return register_param_count_; |
| 303 | } |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 304 | |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 305 | void SetMissHandler(ExternalReference handler) { |
| 306 | miss_handler_ = handler; |
| 307 | has_miss_handler_ = true; |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 308 | // Our miss handler infrastructure doesn't currently support |
| 309 | // variable stack parameter counts. |
| 310 | ASSERT(!stack_parameter_count_.is_valid()); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | ExternalReference miss_handler() { |
| 314 | ASSERT(has_miss_handler_); |
| 315 | return miss_handler_; |
| 316 | } |
| 317 | |
| 318 | bool has_miss_handler() { |
| 319 | return has_miss_handler_; |
| 320 | } |
| 321 | |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 322 | Register GetParameterRegister(int index) { |
| 323 | return register_params_[index]; |
| 324 | } |
| 325 | |
| 326 | bool IsParameterCountRegister(int index) { |
| 327 | return GetParameterRegister(index).is(stack_parameter_count_); |
| 328 | } |
| 329 | |
| 330 | int GetHandlerParameterCount() { |
| 331 | int params = environment_length(); |
| 332 | if (handler_arguments_mode_ == PASS_ARGUMENTS) { |
| 333 | params += 1; |
| 334 | } |
| 335 | return params; |
| 336 | } |
| 337 | |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 338 | private: |
| 339 | ExternalReference miss_handler_; |
| 340 | bool has_miss_handler_; |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 341 | }; |
| 342 | |
| 343 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 344 | class HydrogenCodeStub : public CodeStub { |
| 345 | public: |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 346 | enum InitializationState { |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 347 | UNINITIALIZED, |
| 348 | INITIALIZED |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 349 | }; |
| 350 | |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 351 | explicit HydrogenCodeStub(InitializationState state = INITIALIZED) { |
| 352 | is_uninitialized_ = (state == UNINITIALIZED); |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 353 | } |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 354 | |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 355 | virtual Code::Kind GetCodeKind() const { return Code::STUB; } |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 356 | |
| 357 | CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate) { |
| 358 | return isolate->code_stub_interface_descriptor(MajorKey()); |
| 359 | } |
| 360 | |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 361 | bool IsUninitialized() { return is_uninitialized_; } |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 362 | |
| 363 | template<class SubClass> |
| 364 | static Handle<Code> GetUninitialized(Isolate* isolate) { |
| 365 | SubClass::GenerateAheadOfTime(isolate); |
| 366 | return SubClass().GetCode(isolate); |
| 367 | } |
| 368 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 369 | virtual void InitializeInterfaceDescriptor( |
| 370 | Isolate* isolate, |
| 371 | CodeStubInterfaceDescriptor* descriptor) = 0; |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 372 | |
| 373 | // Retrieve the code for the stub. Generate the code if needed. |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 374 | virtual Handle<Code> GenerateCode(Isolate* isolate) = 0; |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 375 | |
| 376 | virtual int NotMissMinorKey() = 0; |
| 377 | |
| 378 | Handle<Code> GenerateLightweightMissCode(Isolate* isolate); |
| 379 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 380 | template<class StateType> |
| 381 | void TraceTransition(StateType from, StateType to); |
| 382 | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 383 | private: |
| 384 | class MinorKeyBits: public BitField<int, 0, kStubMinorKeyBits - 1> {}; |
| 385 | class IsMissBits: public BitField<bool, kStubMinorKeyBits - 1, 1> {}; |
| 386 | |
| 387 | void GenerateLightweightMiss(MacroAssembler* masm); |
| 388 | virtual int MinorKey() { |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 389 | return IsMissBits::encode(is_uninitialized_) | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 390 | MinorKeyBits::encode(NotMissMinorKey()); |
| 391 | } |
| 392 | |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 393 | bool is_uninitialized_; |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 394 | }; |
| 395 | |
| 396 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 397 | // Helper interface to prepare to/restore after making runtime calls. |
| 398 | class RuntimeCallHelper { |
| 399 | public: |
| 400 | virtual ~RuntimeCallHelper() {} |
| 401 | |
| 402 | virtual void BeforeCall(MacroAssembler* masm) const = 0; |
| 403 | |
| 404 | virtual void AfterCall(MacroAssembler* masm) const = 0; |
| 405 | |
| 406 | protected: |
| 407 | RuntimeCallHelper() {} |
| 408 | |
| 409 | private: |
| 410 | DISALLOW_COPY_AND_ASSIGN(RuntimeCallHelper); |
| 411 | }; |
| 412 | |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 413 | |
| 414 | // TODO(bmeurer): Move to the StringAddStub declaration once we're |
| 415 | // done with the translation to a hydrogen code stub. |
| 416 | enum StringAddFlags { |
| 417 | // Omit both parameter checks. |
| 418 | STRING_ADD_CHECK_NONE = 0, |
| 419 | // Check left parameter. |
| 420 | STRING_ADD_CHECK_LEFT = 1 << 0, |
| 421 | // Check right parameter. |
| 422 | STRING_ADD_CHECK_RIGHT = 1 << 1, |
| 423 | // Check both parameters. |
bmeurer@chromium.org | e94b5ff | 2013-10-25 09:22:31 +0000 | [diff] [blame] | 424 | STRING_ADD_CHECK_BOTH = STRING_ADD_CHECK_LEFT | STRING_ADD_CHECK_RIGHT |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 425 | }; |
| 426 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 427 | } } // namespace v8::internal |
| 428 | |
| 429 | #if V8_TARGET_ARCH_IA32 |
| 430 | #include "ia32/code-stubs-ia32.h" |
| 431 | #elif V8_TARGET_ARCH_X64 |
| 432 | #include "x64/code-stubs-x64.h" |
| 433 | #elif V8_TARGET_ARCH_ARM |
| 434 | #include "arm/code-stubs-arm.h" |
| 435 | #elif V8_TARGET_ARCH_MIPS |
| 436 | #include "mips/code-stubs-mips.h" |
| 437 | #else |
| 438 | #error Unsupported target architecture. |
| 439 | #endif |
| 440 | |
| 441 | namespace v8 { |
| 442 | namespace internal { |
| 443 | |
| 444 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 445 | // RuntimeCallHelper implementation used in stubs: enters/leaves a |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 446 | // newly created internal frame before/after the runtime call. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 447 | class StubRuntimeCallHelper : public RuntimeCallHelper { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 448 | public: |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 449 | StubRuntimeCallHelper() {} |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 450 | |
| 451 | virtual void BeforeCall(MacroAssembler* masm) const; |
| 452 | |
| 453 | virtual void AfterCall(MacroAssembler* masm) const; |
| 454 | }; |
| 455 | |
| 456 | |
| 457 | // Trivial RuntimeCallHelper implementation. |
| 458 | class NopRuntimeCallHelper : public RuntimeCallHelper { |
| 459 | public: |
| 460 | NopRuntimeCallHelper() {} |
| 461 | |
| 462 | virtual void BeforeCall(MacroAssembler* masm) const {} |
| 463 | |
| 464 | virtual void AfterCall(MacroAssembler* masm) const {} |
| 465 | }; |
| 466 | |
| 467 | |
yangguo@chromium.org | c73d55b | 2013-07-24 08:18:28 +0000 | [diff] [blame] | 468 | class ToNumberStub: public HydrogenCodeStub { |
whesse@chromium.org | 7a392b3 | 2011-01-31 11:30:36 +0000 | [diff] [blame] | 469 | public: |
| 470 | ToNumberStub() { } |
| 471 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 472 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
yangguo@chromium.org | c73d55b | 2013-07-24 08:18:28 +0000 | [diff] [blame] | 473 | |
| 474 | virtual void InitializeInterfaceDescriptor( |
| 475 | Isolate* isolate, |
| 476 | CodeStubInterfaceDescriptor* descriptor); |
whesse@chromium.org | 7a392b3 | 2011-01-31 11:30:36 +0000 | [diff] [blame] | 477 | |
| 478 | private: |
| 479 | Major MajorKey() { return ToNumber; } |
yangguo@chromium.org | c73d55b | 2013-07-24 08:18:28 +0000 | [diff] [blame] | 480 | int NotMissMinorKey() { return 0; } |
whesse@chromium.org | 7a392b3 | 2011-01-31 11:30:36 +0000 | [diff] [blame] | 481 | }; |
| 482 | |
| 483 | |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 484 | class NumberToStringStub V8_FINAL : public HydrogenCodeStub { |
| 485 | public: |
| 486 | NumberToStringStub() {} |
| 487 | |
| 488 | virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; |
| 489 | |
| 490 | virtual void InitializeInterfaceDescriptor( |
| 491 | Isolate* isolate, |
| 492 | CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 493 | |
bmeurer@chromium.org | e7a0745 | 2013-10-21 13:27:29 +0000 | [diff] [blame] | 494 | static void InstallDescriptors(Isolate* isolate); |
| 495 | |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 496 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 497 | static const int kNumber = 0; |
| 498 | |
| 499 | private: |
| 500 | virtual Major MajorKey() V8_OVERRIDE { return NumberToString; } |
| 501 | virtual int NotMissMinorKey() V8_OVERRIDE { return 0; } |
| 502 | }; |
| 503 | |
| 504 | |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 505 | class FastNewClosureStub : public HydrogenCodeStub { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 506 | public: |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 507 | explicit FastNewClosureStub(LanguageMode language_mode, bool is_generator) |
| 508 | : language_mode_(language_mode), |
| 509 | is_generator_(is_generator) { } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 510 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 511 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 512 | |
| 513 | virtual void InitializeInterfaceDescriptor( |
| 514 | Isolate* isolate, |
| 515 | CodeStubInterfaceDescriptor* descriptor); |
| 516 | |
| 517 | static void InstallDescriptors(Isolate* isolate); |
| 518 | |
| 519 | LanguageMode language_mode() const { return language_mode_; } |
| 520 | bool is_generator() const { return is_generator_; } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 521 | |
| 522 | private: |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 523 | class StrictModeBits: public BitField<bool, 0, 1> {}; |
| 524 | class IsGeneratorBits: public BitField<bool, 1, 1> {}; |
| 525 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 526 | Major MajorKey() { return FastNewClosure; } |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 527 | int NotMissMinorKey() { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 528 | return StrictModeBits::encode(language_mode_ != CLASSIC_MODE) | |
| 529 | IsGeneratorBits::encode(is_generator_); |
| 530 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 531 | |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 532 | LanguageMode language_mode_; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 533 | bool is_generator_; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 534 | }; |
| 535 | |
| 536 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 537 | class FastNewContextStub : public PlatformCodeStub { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 538 | public: |
ager@chromium.org | 0ee099b | 2011-01-25 14:06:47 +0000 | [diff] [blame] | 539 | static const int kMaximumSlots = 64; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 540 | |
| 541 | explicit FastNewContextStub(int slots) : slots_(slots) { |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 542 | ASSERT(slots_ > 0 && slots_ <= kMaximumSlots); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | void Generate(MacroAssembler* masm); |
| 546 | |
| 547 | private: |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 548 | int slots_; |
ager@chromium.org | 0ee099b | 2011-01-25 14:06:47 +0000 | [diff] [blame] | 549 | |
ager@chromium.org | 0ee099b | 2011-01-25 14:06:47 +0000 | [diff] [blame] | 550 | Major MajorKey() { return FastNewContext; } |
| 551 | int MinorKey() { return slots_; } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 552 | }; |
| 553 | |
| 554 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 555 | class FastNewBlockContextStub : public PlatformCodeStub { |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 556 | public: |
| 557 | static const int kMaximumSlots = 64; |
| 558 | |
| 559 | explicit FastNewBlockContextStub(int slots) : slots_(slots) { |
| 560 | ASSERT(slots_ > 0 && slots_ <= kMaximumSlots); |
| 561 | } |
| 562 | |
| 563 | void Generate(MacroAssembler* masm); |
| 564 | |
| 565 | private: |
| 566 | int slots_; |
| 567 | |
| 568 | Major MajorKey() { return FastNewBlockContext; } |
| 569 | int MinorKey() { return slots_; } |
| 570 | }; |
| 571 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 572 | class FastCloneShallowArrayStub : public HydrogenCodeStub { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 573 | public: |
| 574 | // Maximum length of copied elements array. |
| 575 | static const int kMaximumClonedLength = 8; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 576 | enum Mode { |
| 577 | CLONE_ELEMENTS, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 578 | CLONE_DOUBLE_ELEMENTS, |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 579 | COPY_ON_WRITE_ELEMENTS, |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 580 | CLONE_ANY_ELEMENTS, |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 581 | LAST_CLONE_MODE = CLONE_ANY_ELEMENTS |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 582 | }; |
| 583 | |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 584 | static const int kFastCloneModeCount = LAST_CLONE_MODE + 1; |
| 585 | |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 586 | FastCloneShallowArrayStub(Mode mode, |
| 587 | AllocationSiteMode allocation_site_mode, |
| 588 | int length) |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 589 | : mode_(mode), |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 590 | allocation_site_mode_(allocation_site_mode), |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 591 | length_((mode == COPY_ON_WRITE_ELEMENTS) ? 0 : length) { |
mstarzinger@chromium.org | f8c6bd5 | 2011-11-23 12:13:52 +0000 | [diff] [blame] | 592 | ASSERT_GE(length_, 0); |
| 593 | ASSERT_LE(length_, kMaximumClonedLength); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 594 | } |
| 595 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 596 | Mode mode() const { return mode_; } |
| 597 | int length() const { return length_; } |
| 598 | AllocationSiteMode allocation_site_mode() const { |
| 599 | return allocation_site_mode_; |
| 600 | } |
| 601 | |
| 602 | ElementsKind ComputeElementsKind() const { |
| 603 | switch (mode()) { |
| 604 | case CLONE_ELEMENTS: |
| 605 | case COPY_ON_WRITE_ELEMENTS: |
| 606 | return FAST_ELEMENTS; |
| 607 | case CLONE_DOUBLE_ELEMENTS: |
| 608 | return FAST_DOUBLE_ELEMENTS; |
| 609 | case CLONE_ANY_ELEMENTS: |
| 610 | /*fall-through*/; |
| 611 | } |
| 612 | UNREACHABLE(); |
| 613 | return LAST_ELEMENTS_KIND; |
| 614 | } |
| 615 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 616 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 617 | |
| 618 | virtual void InitializeInterfaceDescriptor( |
| 619 | Isolate* isolate, |
| 620 | CodeStubInterfaceDescriptor* descriptor); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 621 | |
| 622 | private: |
| 623 | Mode mode_; |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 624 | AllocationSiteMode allocation_site_mode_; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 625 | int length_; |
| 626 | |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 627 | class AllocationSiteModeBits: public BitField<AllocationSiteMode, 0, 1> {}; |
| 628 | class ModeBits: public BitField<Mode, 1, 4> {}; |
| 629 | class LengthBits: public BitField<int, 5, 4> {}; |
| 630 | // Ensure data fits within available bits. |
| 631 | STATIC_ASSERT(LAST_ALLOCATION_SITE_MODE == 1); |
| 632 | STATIC_ASSERT(kFastCloneModeCount < 16); |
| 633 | STATIC_ASSERT(kMaximumClonedLength < 16); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 634 | Major MajorKey() { return FastCloneShallowArray; } |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 635 | int NotMissMinorKey() { |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 636 | return AllocationSiteModeBits::encode(allocation_site_mode_) |
| 637 | | ModeBits::encode(mode_) |
| 638 | | LengthBits::encode(length_); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 639 | } |
| 640 | }; |
| 641 | |
| 642 | |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 643 | class FastCloneShallowObjectStub : public HydrogenCodeStub { |
mstarzinger@chromium.org | f8c6bd5 | 2011-11-23 12:13:52 +0000 | [diff] [blame] | 644 | public: |
| 645 | // Maximum number of properties in copied object. |
| 646 | static const int kMaximumClonedProperties = 6; |
| 647 | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 648 | explicit FastCloneShallowObjectStub(int length) |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 649 | : length_(length) { |
mstarzinger@chromium.org | f8c6bd5 | 2011-11-23 12:13:52 +0000 | [diff] [blame] | 650 | ASSERT_GE(length_, 0); |
| 651 | ASSERT_LE(length_, kMaximumClonedProperties); |
| 652 | } |
| 653 | |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 654 | int length() const { return length_; } |
| 655 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 656 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 657 | |
| 658 | virtual void InitializeInterfaceDescriptor( |
| 659 | Isolate* isolate, |
| 660 | CodeStubInterfaceDescriptor* descriptor); |
mstarzinger@chromium.org | f8c6bd5 | 2011-11-23 12:13:52 +0000 | [diff] [blame] | 661 | |
| 662 | private: |
| 663 | int length_; |
| 664 | |
| 665 | Major MajorKey() { return FastCloneShallowObject; } |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 666 | int NotMissMinorKey() { return length_; } |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 667 | |
| 668 | DISALLOW_COPY_AND_ASSIGN(FastCloneShallowObjectStub); |
mstarzinger@chromium.org | f8c6bd5 | 2011-11-23 12:13:52 +0000 | [diff] [blame] | 669 | }; |
| 670 | |
| 671 | |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 672 | class CreateAllocationSiteStub : public HydrogenCodeStub { |
| 673 | public: |
| 674 | explicit CreateAllocationSiteStub() { } |
| 675 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 676 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 677 | |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 678 | static void GenerateAheadOfTime(Isolate* isolate); |
| 679 | |
| 680 | virtual void InitializeInterfaceDescriptor( |
| 681 | Isolate* isolate, |
| 682 | CodeStubInterfaceDescriptor* descriptor); |
| 683 | |
| 684 | private: |
| 685 | Major MajorKey() { return CreateAllocationSite; } |
| 686 | int NotMissMinorKey() { return 0; } |
| 687 | |
| 688 | DISALLOW_COPY_AND_ASSIGN(CreateAllocationSiteStub); |
| 689 | }; |
| 690 | |
| 691 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 692 | class InstanceofStub: public PlatformCodeStub { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 693 | public: |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 694 | enum Flags { |
| 695 | kNoFlags = 0, |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 696 | kArgsInRegisters = 1 << 0, |
| 697 | kCallSiteInlineCheck = 1 << 1, |
| 698 | kReturnTrueFalseObject = 1 << 2 |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 699 | }; |
| 700 | |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 701 | explicit InstanceofStub(Flags flags) : flags_(flags) { } |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 702 | |
| 703 | static Register left(); |
| 704 | static Register right(); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 705 | |
| 706 | void Generate(MacroAssembler* masm); |
| 707 | |
| 708 | private: |
| 709 | Major MajorKey() { return Instanceof; } |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 710 | int MinorKey() { return static_cast<int>(flags_); } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 711 | |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 712 | bool HasArgsInRegisters() const { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 713 | return (flags_ & kArgsInRegisters) != 0; |
| 714 | } |
| 715 | |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 716 | bool HasCallSiteInlineCheck() const { |
| 717 | return (flags_ & kCallSiteInlineCheck) != 0; |
| 718 | } |
| 719 | |
| 720 | bool ReturnTrueFalseObject() const { |
| 721 | return (flags_ & kReturnTrueFalseObject) != 0; |
| 722 | } |
| 723 | |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 724 | virtual void PrintName(StringStream* stream); |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 725 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 726 | Flags flags_; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 727 | }; |
| 728 | |
| 729 | |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 730 | enum AllocationSiteOverrideMode { |
| 731 | DONT_OVERRIDE, |
| 732 | DISABLE_ALLOCATION_SITES, |
| 733 | LAST_ALLOCATION_SITE_OVERRIDE_MODE = DISABLE_ALLOCATION_SITES |
| 734 | }; |
| 735 | |
| 736 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 737 | class ArrayConstructorStub: public PlatformCodeStub { |
| 738 | public: |
| 739 | enum ArgumentCountKey { ANY, NONE, ONE, MORE_THAN_ONE }; |
| 740 | ArrayConstructorStub(Isolate* isolate, int argument_count); |
| 741 | explicit ArrayConstructorStub(Isolate* isolate); |
| 742 | |
| 743 | void Generate(MacroAssembler* masm); |
| 744 | |
| 745 | private: |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 746 | void GenerateDispatchToArrayStub(MacroAssembler* masm, |
| 747 | AllocationSiteOverrideMode mode); |
hpayer@chromium.org | 71ea97f | 2013-12-19 16:03:26 +0000 | [diff] [blame] | 748 | virtual void PrintName(StringStream* stream); |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 749 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 750 | virtual CodeStub::Major MajorKey() { return ArrayConstructor; } |
| 751 | virtual int MinorKey() { return argument_count_; } |
| 752 | |
| 753 | ArgumentCountKey argument_count_; |
| 754 | }; |
| 755 | |
| 756 | |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 757 | class InternalArrayConstructorStub: public PlatformCodeStub { |
| 758 | public: |
| 759 | explicit InternalArrayConstructorStub(Isolate* isolate); |
| 760 | |
| 761 | void Generate(MacroAssembler* masm); |
| 762 | |
| 763 | private: |
| 764 | virtual CodeStub::Major MajorKey() { return InternalArrayConstructor; } |
| 765 | virtual int MinorKey() { return 0; } |
| 766 | |
| 767 | void GenerateCase(MacroAssembler* masm, ElementsKind kind); |
| 768 | }; |
| 769 | |
| 770 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 771 | class MathPowStub: public PlatformCodeStub { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 772 | public: |
jkummerow@chromium.org | c118402 | 2013-05-28 16:58:15 +0000 | [diff] [blame] | 773 | enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK }; |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 774 | |
| 775 | explicit MathPowStub(ExponentType exponent_type) |
| 776 | : exponent_type_(exponent_type) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 777 | virtual void Generate(MacroAssembler* masm); |
| 778 | |
| 779 | private: |
| 780 | virtual CodeStub::Major MajorKey() { return MathPow; } |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 781 | virtual int MinorKey() { return exponent_type_; } |
| 782 | |
| 783 | ExponentType exponent_type_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 784 | }; |
| 785 | |
| 786 | |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 787 | class ICStub: public PlatformCodeStub { |
| 788 | public: |
| 789 | explicit ICStub(Code::Kind kind) : kind_(kind) { } |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 790 | virtual Code::Kind GetCodeKind() const { return kind_; } |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 791 | virtual InlineCacheState GetICState() { return MONOMORPHIC; } |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 792 | |
| 793 | bool Describes(Code* code) { |
| 794 | return GetMajorKey(code) == MajorKey() && code->stub_info() == MinorKey(); |
| 795 | } |
| 796 | |
| 797 | protected: |
| 798 | class KindBits: public BitField<Code::Kind, 0, 4> {}; |
| 799 | virtual void FinishCode(Handle<Code> code) { |
| 800 | code->set_stub_info(MinorKey()); |
| 801 | } |
| 802 | Code::Kind kind() { return kind_; } |
| 803 | |
| 804 | virtual int MinorKey() { |
| 805 | return KindBits::encode(kind_); |
| 806 | } |
| 807 | |
| 808 | private: |
| 809 | Code::Kind kind_; |
| 810 | }; |
| 811 | |
| 812 | |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 813 | class FunctionPrototypeStub: public ICStub { |
| 814 | public: |
| 815 | explicit FunctionPrototypeStub(Code::Kind kind) : ICStub(kind) { } |
| 816 | virtual void Generate(MacroAssembler* masm); |
| 817 | |
| 818 | private: |
| 819 | virtual CodeStub::Major MajorKey() { return FunctionPrototype; } |
| 820 | }; |
| 821 | |
| 822 | |
| 823 | class StringLengthStub: public ICStub { |
| 824 | public: |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 825 | explicit StringLengthStub(Code::Kind kind) : ICStub(kind) { } |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 826 | virtual void Generate(MacroAssembler* masm); |
| 827 | |
| 828 | private: |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 829 | STATIC_ASSERT(KindBits::kSize == 4); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 830 | virtual CodeStub::Major MajorKey() { return StringLength; } |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 831 | }; |
| 832 | |
| 833 | |
mvstanton@chromium.org | d16d853 | 2013-01-25 13:29:10 +0000 | [diff] [blame] | 834 | class StoreICStub: public ICStub { |
| 835 | public: |
| 836 | StoreICStub(Code::Kind kind, StrictModeFlag strict_mode) |
| 837 | : ICStub(kind), strict_mode_(strict_mode) { } |
| 838 | |
| 839 | protected: |
yangguo@chromium.org | cc53605 | 2013-11-29 11:43:20 +0000 | [diff] [blame] | 840 | virtual ExtraICState GetExtraICState() { |
| 841 | return StoreIC::ComputeExtraICState(strict_mode_); |
mvstanton@chromium.org | d16d853 | 2013-01-25 13:29:10 +0000 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | private: |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 845 | STATIC_ASSERT(KindBits::kSize == 4); |
mvstanton@chromium.org | d16d853 | 2013-01-25 13:29:10 +0000 | [diff] [blame] | 846 | class StrictModeBits: public BitField<bool, 4, 1> {}; |
| 847 | virtual int MinorKey() { |
| 848 | return KindBits::encode(kind()) | StrictModeBits::encode(strict_mode_); |
| 849 | } |
| 850 | |
| 851 | StrictModeFlag strict_mode_; |
| 852 | }; |
| 853 | |
| 854 | |
| 855 | class StoreArrayLengthStub: public StoreICStub { |
| 856 | public: |
| 857 | explicit StoreArrayLengthStub(Code::Kind kind, StrictModeFlag strict_mode) |
| 858 | : StoreICStub(kind, strict_mode) { } |
| 859 | virtual void Generate(MacroAssembler* masm); |
| 860 | |
| 861 | private: |
| 862 | virtual CodeStub::Major MajorKey() { return StoreArrayLength; } |
| 863 | }; |
| 864 | |
| 865 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 866 | class HICStub: public HydrogenCodeStub { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 867 | public: |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 868 | virtual Code::Kind GetCodeKind() const { return kind(); } |
| 869 | virtual InlineCacheState GetICState() { return MONOMORPHIC; } |
| 870 | |
| 871 | protected: |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 872 | class KindBits: public BitField<Code::Kind, 0, 4> {}; |
| 873 | virtual Code::Kind kind() const = 0; |
| 874 | }; |
| 875 | |
| 876 | |
| 877 | class HandlerStub: public HICStub { |
| 878 | public: |
jkummerow@chromium.org | 32aa03c | 2013-10-01 08:21:50 +0000 | [diff] [blame] | 879 | virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 880 | virtual int GetStubFlags() { return kind(); } |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 881 | |
| 882 | protected: |
| 883 | HandlerStub() : HICStub() { } |
| 884 | virtual int NotMissMinorKey() { return bit_field_; } |
| 885 | int bit_field_; |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 886 | }; |
| 887 | |
| 888 | |
| 889 | class LoadFieldStub: public HandlerStub { |
| 890 | public: |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 891 | LoadFieldStub(bool inobject, int index, Representation representation) { |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 892 | Initialize(Code::LOAD_IC, inobject, index, representation); |
| 893 | } |
| 894 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 895 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 896 | |
| 897 | virtual void InitializeInterfaceDescriptor( |
| 898 | Isolate* isolate, |
| 899 | CodeStubInterfaceDescriptor* descriptor); |
| 900 | |
| 901 | Representation representation() { |
| 902 | if (unboxed_double()) return Representation::Double(); |
| 903 | return Representation::Tagged(); |
| 904 | } |
| 905 | |
| 906 | virtual Code::Kind kind() const { |
| 907 | return KindBits::decode(bit_field_); |
| 908 | } |
| 909 | |
| 910 | bool is_inobject() { |
| 911 | return InobjectBits::decode(bit_field_); |
| 912 | } |
| 913 | |
| 914 | int offset() { |
| 915 | int index = IndexBits::decode(bit_field_); |
| 916 | int offset = index * kPointerSize; |
| 917 | if (is_inobject()) return offset; |
| 918 | return FixedArray::kHeaderSize + offset; |
| 919 | } |
| 920 | |
| 921 | bool unboxed_double() { |
| 922 | return UnboxedDoubleBits::decode(bit_field_); |
| 923 | } |
| 924 | |
machenbach@chromium.org | 9af454f | 2013-11-20 09:25:57 +0000 | [diff] [blame] | 925 | virtual Code::StubType GetStubType() { return Code::FAST; } |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 926 | |
| 927 | protected: |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 928 | LoadFieldStub() : HandlerStub() { } |
| 929 | |
| 930 | void Initialize(Code::Kind kind, |
| 931 | bool inobject, |
| 932 | int index, |
| 933 | Representation representation) { |
| 934 | bool unboxed_double = FLAG_track_double_fields && representation.IsDouble(); |
| 935 | bit_field_ = KindBits::encode(kind) |
| 936 | | InobjectBits::encode(inobject) |
| 937 | | IndexBits::encode(index) |
| 938 | | UnboxedDoubleBits::encode(unboxed_double); |
| 939 | } |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 940 | |
| 941 | private: |
| 942 | STATIC_ASSERT(KindBits::kSize == 4); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 943 | class InobjectBits: public BitField<bool, 4, 1> {}; |
| 944 | class IndexBits: public BitField<int, 5, 11> {}; |
| 945 | class UnboxedDoubleBits: public BitField<bool, 16, 1> {}; |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 946 | virtual CodeStub::Major MajorKey() { return LoadField; } |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 947 | }; |
| 948 | |
| 949 | |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 950 | class StoreGlobalStub : public HandlerStub { |
| 951 | public: |
machenbach@chromium.org | c86e8c2 | 2013-11-27 15:11:04 +0000 | [diff] [blame] | 952 | explicit StoreGlobalStub(bool is_constant) { |
| 953 | bit_field_ = IsConstantBits::encode(is_constant); |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 954 | } |
| 955 | |
| 956 | Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate, |
| 957 | Map* receiver_map, |
| 958 | PropertyCell* cell) { |
| 959 | Handle<Code> code = CodeStub::GetCodeCopyFromTemplate(isolate); |
| 960 | // Replace the placeholder cell and global object map with the actual global |
| 961 | // cell and receiver map. |
| 962 | Map* cell_map = isolate->heap()->global_property_cell_map(); |
| 963 | code->ReplaceNthObject(1, cell_map, cell); |
| 964 | code->ReplaceNthObject(1, isolate->heap()->meta_map(), receiver_map); |
| 965 | return code; |
| 966 | } |
| 967 | |
| 968 | virtual Code::Kind kind() const { return Code::STORE_IC; } |
| 969 | |
| 970 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 971 | |
| 972 | virtual void InitializeInterfaceDescriptor( |
| 973 | Isolate* isolate, |
| 974 | CodeStubInterfaceDescriptor* descriptor); |
| 975 | |
yangguo@chromium.org | cc53605 | 2013-11-29 11:43:20 +0000 | [diff] [blame] | 976 | virtual ExtraICState GetExtraICState() { return bit_field_; } |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 977 | |
| 978 | bool is_constant() { |
| 979 | return IsConstantBits::decode(bit_field_); |
| 980 | } |
| 981 | void set_is_constant(bool value) { |
| 982 | bit_field_ = IsConstantBits::update(bit_field_, value); |
| 983 | } |
| 984 | |
| 985 | Representation representation() { |
| 986 | return Representation::FromKind(RepresentationBits::decode(bit_field_)); |
| 987 | } |
| 988 | void set_representation(Representation r) { |
| 989 | bit_field_ = RepresentationBits::update(bit_field_, r.kind()); |
| 990 | } |
| 991 | |
| 992 | private: |
| 993 | virtual int NotMissMinorKey() { return GetExtraICState(); } |
| 994 | Major MajorKey() { return StoreGlobal; } |
| 995 | |
machenbach@chromium.org | c86e8c2 | 2013-11-27 15:11:04 +0000 | [diff] [blame] | 996 | class IsConstantBits: public BitField<bool, 0, 1> {}; |
| 997 | class RepresentationBits: public BitField<Representation::Kind, 1, 8> {}; |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 998 | |
| 999 | int bit_field_; |
| 1000 | |
| 1001 | DISALLOW_COPY_AND_ASSIGN(StoreGlobalStub); |
| 1002 | }; |
| 1003 | |
| 1004 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 1005 | class KeyedLoadFieldStub: public LoadFieldStub { |
| 1006 | public: |
| 1007 | KeyedLoadFieldStub(bool inobject, int index, Representation representation) |
| 1008 | : LoadFieldStub() { |
| 1009 | Initialize(Code::KEYED_LOAD_IC, inobject, index, representation); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1010 | } |
| 1011 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 1012 | virtual void InitializeInterfaceDescriptor( |
| 1013 | Isolate* isolate, |
| 1014 | CodeStubInterfaceDescriptor* descriptor); |
| 1015 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 1016 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 1017 | |
| 1018 | private: |
| 1019 | virtual CodeStub::Major MajorKey() { return KeyedLoadField; } |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1020 | }; |
| 1021 | |
| 1022 | |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 1023 | class KeyedArrayCallStub: public HICStub { |
| 1024 | public: |
| 1025 | KeyedArrayCallStub(bool holey, int argc) : HICStub(), argc_(argc) { |
| 1026 | bit_field_ = ContextualBits::encode(false) | HoleyBits::encode(holey); |
| 1027 | } |
| 1028 | |
| 1029 | virtual Code::Kind kind() const { return Code::KEYED_CALL_IC; } |
yangguo@chromium.org | cc53605 | 2013-11-29 11:43:20 +0000 | [diff] [blame] | 1030 | virtual ExtraICState GetExtraICState() { return bit_field_; } |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 1031 | |
| 1032 | ElementsKind elements_kind() { |
| 1033 | return HoleyBits::decode(bit_field_) ? FAST_HOLEY_ELEMENTS : FAST_ELEMENTS; |
| 1034 | } |
| 1035 | |
| 1036 | int argc() { return argc_; } |
| 1037 | virtual int GetStubFlags() { return argc(); } |
| 1038 | |
| 1039 | static bool IsHoley(Handle<Code> code) { |
yangguo@chromium.org | cc53605 | 2013-11-29 11:43:20 +0000 | [diff] [blame] | 1040 | ExtraICState state = code->extra_ic_state(); |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 1041 | return HoleyBits::decode(state); |
| 1042 | } |
| 1043 | |
| 1044 | virtual void InitializeInterfaceDescriptor( |
| 1045 | Isolate* isolate, |
| 1046 | CodeStubInterfaceDescriptor* descriptor); |
| 1047 | |
| 1048 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
| 1049 | |
| 1050 | private: |
| 1051 | virtual int NotMissMinorKey() { |
| 1052 | return GetExtraICState() | ArgcBits::encode(argc_); |
| 1053 | } |
| 1054 | |
| 1055 | class ContextualBits: public BitField<bool, 0, 1> {}; |
| 1056 | STATIC_ASSERT(CallICBase::Contextual::kShift == ContextualBits::kShift); |
| 1057 | STATIC_ASSERT(CallICBase::Contextual::kSize == ContextualBits::kSize); |
| 1058 | class HoleyBits: public BitField<bool, 1, 1> {}; |
| 1059 | STATIC_ASSERT(Code::kArgumentsBits <= kStubMinorKeyBits - 2); |
| 1060 | class ArgcBits: public BitField<int, 2, Code::kArgumentsBits> {}; |
| 1061 | virtual CodeStub::Major MajorKey() { return KeyedArrayCall; } |
| 1062 | int bit_field_; |
| 1063 | int argc_; |
| 1064 | }; |
| 1065 | |
| 1066 | |
ulan@chromium.org | 0f13e74 | 2014-01-03 15:51:11 +0000 | [diff] [blame^] | 1067 | class BinaryOpICStub : public HydrogenCodeStub { |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1068 | public: |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 1069 | BinaryOpICStub(Token::Value op, OverwriteMode mode) |
| 1070 | : HydrogenCodeStub(UNINITIALIZED), state_(op, mode) {} |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1071 | |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 1072 | explicit BinaryOpICStub(const BinaryOpIC::State& state) : state_(state) {} |
jkummerow@chromium.org | 25b0e21 | 2013-10-04 15:38:52 +0000 | [diff] [blame] | 1073 | |
| 1074 | static void GenerateAheadOfTime(Isolate* isolate); |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 1075 | |
jkummerow@chromium.org | 25b0e21 | 2013-10-04 15:38:52 +0000 | [diff] [blame] | 1076 | virtual void InitializeInterfaceDescriptor( |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 1077 | Isolate* isolate, CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 1078 | |
| 1079 | static void InstallDescriptors(Isolate* isolate); |
| 1080 | |
| 1081 | virtual Code::Kind GetCodeKind() const V8_OVERRIDE { |
| 1082 | return Code::BINARY_OP_IC; |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1083 | } |
| 1084 | |
ulan@chromium.org | 0f13e74 | 2014-01-03 15:51:11 +0000 | [diff] [blame^] | 1085 | virtual InlineCacheState GetICState() V8_FINAL V8_OVERRIDE { |
| 1086 | return state_.GetICState(); |
| 1087 | } |
| 1088 | |
| 1089 | virtual ExtraICState GetExtraICState() V8_FINAL V8_OVERRIDE { |
| 1090 | return state_.GetExtraICState(); |
| 1091 | } |
| 1092 | |
| 1093 | virtual void VerifyPlatformFeatures(Isolate* isolate) V8_FINAL V8_OVERRIDE { |
| 1094 | ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); |
| 1095 | } |
| 1096 | |
| 1097 | virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; |
| 1098 | |
| 1099 | const BinaryOpIC::State& state() const { return state_; } |
| 1100 | |
| 1101 | virtual void PrintState(StringStream* stream) V8_FINAL V8_OVERRIDE; |
| 1102 | |
| 1103 | virtual Major MajorKey() V8_OVERRIDE { return BinaryOpIC; } |
| 1104 | virtual int NotMissMinorKey() V8_FINAL V8_OVERRIDE { |
| 1105 | return GetExtraICState(); |
| 1106 | } |
| 1107 | |
| 1108 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 1109 | static const int kLeft = 0; |
| 1110 | static const int kRight = 1; |
| 1111 | |
| 1112 | private: |
| 1113 | static void GenerateAheadOfTime(Isolate* isolate, |
| 1114 | const BinaryOpIC::State& state); |
| 1115 | |
| 1116 | BinaryOpIC::State state_; |
| 1117 | |
| 1118 | DISALLOW_COPY_AND_ASSIGN(BinaryOpICStub); |
| 1119 | }; |
| 1120 | |
| 1121 | |
| 1122 | // TODO(bmeurer): Merge this into the BinaryOpICStub once we have proper tail |
| 1123 | // call support for stubs in Hydrogen. |
| 1124 | class BinaryOpICWithAllocationSiteStub V8_FINAL : public PlatformCodeStub { |
| 1125 | public: |
| 1126 | explicit BinaryOpICWithAllocationSiteStub(const BinaryOpIC::State& state) |
| 1127 | : state_(state) {} |
| 1128 | |
| 1129 | static void GenerateAheadOfTime(Isolate* isolate); |
| 1130 | |
| 1131 | Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate, |
| 1132 | Handle<AllocationSite> allocation_site) { |
| 1133 | Handle<Code> code = CodeStub::GetCodeCopyFromTemplate(isolate); |
| 1134 | // Replace the placeholder oddball with the actual allocation site. |
| 1135 | code->ReplaceNthObject(1, isolate->heap()->oddball_map(), *allocation_site); |
| 1136 | return code; |
| 1137 | } |
| 1138 | |
| 1139 | virtual Code::Kind GetCodeKind() const V8_OVERRIDE { |
| 1140 | return Code::BINARY_OP_IC; |
| 1141 | } |
| 1142 | |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 1143 | virtual InlineCacheState GetICState() V8_OVERRIDE { |
| 1144 | return state_.GetICState(); |
| 1145 | } |
| 1146 | |
| 1147 | virtual ExtraICState GetExtraICState() V8_OVERRIDE { |
| 1148 | return state_.GetExtraICState(); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1149 | } |
| 1150 | |
mvstanton@chromium.org | 63ea3d2 | 2013-10-10 09:24:12 +0000 | [diff] [blame] | 1151 | virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { |
| 1152 | ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); |
| 1153 | } |
| 1154 | |
ulan@chromium.org | 0f13e74 | 2014-01-03 15:51:11 +0000 | [diff] [blame^] | 1155 | virtual void Generate(MacroAssembler* masm) V8_OVERRIDE; |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1156 | |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 1157 | virtual void PrintState(StringStream* stream) V8_OVERRIDE; |
jkummerow@chromium.org | 25b0e21 | 2013-10-04 15:38:52 +0000 | [diff] [blame] | 1158 | |
ulan@chromium.org | 0f13e74 | 2014-01-03 15:51:11 +0000 | [diff] [blame^] | 1159 | virtual Major MajorKey() V8_OVERRIDE { return BinaryOpICWithAllocationSite; } |
| 1160 | virtual int MinorKey() V8_OVERRIDE { return GetExtraICState(); } |
jkummerow@chromium.org | 25b0e21 | 2013-10-04 15:38:52 +0000 | [diff] [blame] | 1161 | |
| 1162 | private: |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 1163 | static void GenerateAheadOfTime(Isolate* isolate, |
| 1164 | const BinaryOpIC::State& state); |
jkummerow@chromium.org | 25b0e21 | 2013-10-04 15:38:52 +0000 | [diff] [blame] | 1165 | |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 1166 | BinaryOpIC::State state_; |
jkummerow@chromium.org | 25b0e21 | 2013-10-04 15:38:52 +0000 | [diff] [blame] | 1167 | |
ulan@chromium.org | 0f13e74 | 2014-01-03 15:51:11 +0000 | [diff] [blame^] | 1168 | DISALLOW_COPY_AND_ASSIGN(BinaryOpICWithAllocationSiteStub); |
| 1169 | }; |
| 1170 | |
| 1171 | |
| 1172 | class BinaryOpWithAllocationSiteStub V8_FINAL : public BinaryOpICStub { |
| 1173 | public: |
| 1174 | explicit BinaryOpWithAllocationSiteStub(const BinaryOpIC::State& state) |
| 1175 | : BinaryOpICStub(state) {} |
| 1176 | |
| 1177 | virtual void InitializeInterfaceDescriptor( |
| 1178 | Isolate* isolate, CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 1179 | |
| 1180 | static void InstallDescriptors(Isolate* isolate); |
| 1181 | |
| 1182 | virtual Code::Kind GetCodeKind() const V8_FINAL V8_OVERRIDE { |
| 1183 | return Code::STUB; |
| 1184 | } |
| 1185 | |
| 1186 | virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; |
| 1187 | |
| 1188 | virtual Major MajorKey() V8_OVERRIDE { |
| 1189 | return BinaryOpWithAllocationSite; |
| 1190 | } |
| 1191 | |
| 1192 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 1193 | static const int kAllocationSite = 0; |
| 1194 | static const int kLeft = 1; |
| 1195 | static const int kRight = 2; |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1196 | }; |
| 1197 | |
| 1198 | |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 1199 | // TODO(bmeurer): Rename to StringAddStub once we dropped the old StringAddStub. |
| 1200 | class NewStringAddStub V8_FINAL : public HydrogenCodeStub { |
| 1201 | public: |
| 1202 | NewStringAddStub(StringAddFlags flags, PretenureFlag pretenure_flag) |
| 1203 | : bit_field_(StringAddFlagsBits::encode(flags) | |
| 1204 | PretenureFlagBits::encode(pretenure_flag)) {} |
| 1205 | |
| 1206 | StringAddFlags flags() const { |
| 1207 | return StringAddFlagsBits::decode(bit_field_); |
| 1208 | } |
| 1209 | |
| 1210 | PretenureFlag pretenure_flag() const { |
| 1211 | return PretenureFlagBits::decode(bit_field_); |
| 1212 | } |
| 1213 | |
ulan@chromium.org | 0f13e74 | 2014-01-03 15:51:11 +0000 | [diff] [blame^] | 1214 | virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { |
| 1215 | ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); |
| 1216 | } |
| 1217 | |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 1218 | virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; |
| 1219 | |
| 1220 | virtual void InitializeInterfaceDescriptor( |
| 1221 | Isolate* isolate, |
| 1222 | CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 1223 | |
| 1224 | static void InstallDescriptors(Isolate* isolate); |
| 1225 | |
| 1226 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 1227 | static const int kLeft = 0; |
| 1228 | static const int kRight = 1; |
| 1229 | |
| 1230 | private: |
| 1231 | class StringAddFlagsBits: public BitField<StringAddFlags, 0, 2> {}; |
| 1232 | class PretenureFlagBits: public BitField<PretenureFlag, 2, 1> {}; |
| 1233 | uint32_t bit_field_; |
| 1234 | |
| 1235 | virtual Major MajorKey() V8_OVERRIDE { return NewStringAdd; } |
| 1236 | virtual int NotMissMinorKey() V8_OVERRIDE { return bit_field_; } |
| 1237 | |
| 1238 | virtual void PrintBaseName(StringStream* stream) V8_OVERRIDE; |
| 1239 | |
| 1240 | DISALLOW_COPY_AND_ASSIGN(NewStringAddStub); |
| 1241 | }; |
| 1242 | |
| 1243 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1244 | class ICCompareStub: public PlatformCodeStub { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1245 | public: |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1246 | ICCompareStub(Token::Value op, |
| 1247 | CompareIC::State left, |
| 1248 | CompareIC::State right, |
| 1249 | CompareIC::State handler) |
| 1250 | : op_(op), |
| 1251 | left_(left), |
| 1252 | right_(right), |
| 1253 | state_(handler) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1254 | ASSERT(Token::IsCompareOp(op)); |
| 1255 | } |
| 1256 | |
| 1257 | virtual void Generate(MacroAssembler* masm); |
| 1258 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 1259 | void set_known_map(Handle<Map> map) { known_map_ = map; } |
| 1260 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1261 | static void DecodeMinorKey(int minor_key, |
| 1262 | CompareIC::State* left_state, |
| 1263 | CompareIC::State* right_state, |
| 1264 | CompareIC::State* handler_state, |
| 1265 | Token::Value* op); |
| 1266 | |
danno@chromium.org | 1fd77d5 | 2013-06-07 16:01:45 +0000 | [diff] [blame] | 1267 | virtual InlineCacheState GetICState(); |
| 1268 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1269 | private: |
| 1270 | class OpField: public BitField<int, 0, 3> { }; |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1271 | class LeftStateField: public BitField<int, 3, 4> { }; |
| 1272 | class RightStateField: public BitField<int, 7, 4> { }; |
| 1273 | class HandlerStateField: public BitField<int, 11, 4> { }; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1274 | |
jkummerow@chromium.org | 04e4f1e | 2011-11-14 13:36:17 +0000 | [diff] [blame] | 1275 | virtual void FinishCode(Handle<Code> code) { |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1276 | code->set_stub_info(MinorKey()); |
jkummerow@chromium.org | 04e4f1e | 2011-11-14 13:36:17 +0000 | [diff] [blame] | 1277 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1278 | |
| 1279 | virtual CodeStub::Major MajorKey() { return CompareIC; } |
| 1280 | virtual int MinorKey(); |
| 1281 | |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 1282 | virtual Code::Kind GetCodeKind() const { return Code::COMPARE_IC; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1283 | |
| 1284 | void GenerateSmis(MacroAssembler* masm); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1285 | void GenerateNumbers(MacroAssembler* masm); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1286 | void GenerateInternalizedStrings(MacroAssembler* masm); |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 1287 | void GenerateStrings(MacroAssembler* masm); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1288 | void GenerateUniqueNames(MacroAssembler* masm); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1289 | void GenerateObjects(MacroAssembler* masm); |
| 1290 | void GenerateMiss(MacroAssembler* masm); |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 1291 | void GenerateKnownObjects(MacroAssembler* masm); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1292 | void GenerateGeneric(MacroAssembler* masm); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1293 | |
| 1294 | bool strict() const { return op_ == Token::EQ_STRICT; } |
| 1295 | Condition GetCondition() const { return CompareIC::ComputeCondition(op_); } |
| 1296 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 1297 | virtual void AddToSpecialCache(Handle<Code> new_object); |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 1298 | virtual bool FindCodeInSpecialCache(Code** code_out, Isolate* isolate); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1299 | virtual bool UseSpecialCache() { return state_ == CompareIC::KNOWN_OBJECT; } |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 1300 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1301 | Token::Value op_; |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1302 | CompareIC::State left_; |
| 1303 | CompareIC::State right_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1304 | CompareIC::State state_; |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 1305 | Handle<Map> known_map_; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1306 | }; |
| 1307 | |
| 1308 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 1309 | class CompareNilICStub : public HydrogenCodeStub { |
| 1310 | public: |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1311 | Handle<Type> GetType(Isolate* isolate, Handle<Map> map = Handle<Map>()); |
| 1312 | Handle<Type> GetInputType(Isolate* isolate, Handle<Map> map); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 1313 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1314 | explicit CompareNilICStub(NilValue nil) : nil_value_(nil) { } |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 1315 | |
yangguo@chromium.org | cc53605 | 2013-11-29 11:43:20 +0000 | [diff] [blame] | 1316 | CompareNilICStub(ExtraICState ic_state, |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 1317 | InitializationState init_state = INITIALIZED) |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1318 | : HydrogenCodeStub(init_state), |
| 1319 | nil_value_(NilValueField::decode(ic_state)), |
| 1320 | state_(State(TypesField::decode(ic_state))) { |
| 1321 | } |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 1322 | |
| 1323 | static Handle<Code> GetUninitialized(Isolate* isolate, |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 1324 | NilValue nil) { |
ulan@chromium.org | 837a67e | 2013-06-11 15:39:48 +0000 | [diff] [blame] | 1325 | return CompareNilICStub(nil, UNINITIALIZED).GetCode(isolate); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 1326 | } |
| 1327 | |
| 1328 | virtual void InitializeInterfaceDescriptor( |
| 1329 | Isolate* isolate, |
| 1330 | CodeStubInterfaceDescriptor* descriptor); |
| 1331 | |
| 1332 | static void InitializeForIsolate(Isolate* isolate) { |
ulan@chromium.org | 837a67e | 2013-06-11 15:39:48 +0000 | [diff] [blame] | 1333 | CompareNilICStub compare_stub(kNullValue, UNINITIALIZED); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 1334 | compare_stub.InitializeInterfaceDescriptor( |
| 1335 | isolate, |
| 1336 | isolate->code_stub_interface_descriptor(CodeStub::CompareNilIC)); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 1337 | } |
| 1338 | |
| 1339 | virtual InlineCacheState GetICState() { |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1340 | if (state_.Contains(GENERIC)) { |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 1341 | return MEGAMORPHIC; |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 1342 | } else if (state_.Contains(MONOMORPHIC_MAP)) { |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 1343 | return MONOMORPHIC; |
| 1344 | } else { |
| 1345 | return PREMONOMORPHIC; |
| 1346 | } |
| 1347 | } |
| 1348 | |
| 1349 | virtual Code::Kind GetCodeKind() const { return Code::COMPARE_NIL_IC; } |
| 1350 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 1351 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 1352 | |
yangguo@chromium.org | cc53605 | 2013-11-29 11:43:20 +0000 | [diff] [blame] | 1353 | virtual ExtraICState GetExtraICState() { |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1354 | return NilValueField::encode(nil_value_) | |
| 1355 | TypesField::encode(state_.ToIntegral()); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1356 | } |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 1357 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 1358 | void UpdateStatus(Handle<Object> object); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 1359 | |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 1360 | bool IsMonomorphic() const { return state_.Contains(MONOMORPHIC_MAP); } |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 1361 | NilValue GetNilValue() const { return nil_value_; } |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 1362 | void ClearState() { state_.RemoveAll(); } |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 1363 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 1364 | virtual void PrintState(StringStream* stream); |
| 1365 | virtual void PrintBaseName(StringStream* stream); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 1366 | |
| 1367 | private: |
| 1368 | friend class CompareNilIC; |
| 1369 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1370 | enum CompareNilType { |
| 1371 | UNDEFINED, |
| 1372 | NULL_TYPE, |
| 1373 | MONOMORPHIC_MAP, |
| 1374 | GENERIC, |
| 1375 | NUMBER_OF_TYPES |
| 1376 | }; |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 1377 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1378 | // At most 6 different types can be distinguished, because the Code object |
| 1379 | // only has room for a single byte to hold a set and there are two more |
| 1380 | // boolean flags we need to store. :-P |
| 1381 | STATIC_ASSERT(NUMBER_OF_TYPES <= 6); |
| 1382 | |
| 1383 | class State : public EnumSet<CompareNilType, byte> { |
| 1384 | public: |
| 1385 | State() : EnumSet<CompareNilType, byte>(0) { } |
| 1386 | explicit State(byte bits) : EnumSet<CompareNilType, byte>(bits) { } |
| 1387 | |
| 1388 | void Print(StringStream* stream) const; |
| 1389 | }; |
| 1390 | |
| 1391 | CompareNilICStub(NilValue nil, InitializationState init_state) |
| 1392 | : HydrogenCodeStub(init_state), nil_value_(nil) { } |
| 1393 | |
| 1394 | class NilValueField : public BitField<NilValue, 0, 1> {}; |
| 1395 | class TypesField : public BitField<byte, 1, NUMBER_OF_TYPES> {}; |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 1396 | |
| 1397 | virtual CodeStub::Major MajorKey() { return CompareNilIC; } |
| 1398 | virtual int NotMissMinorKey() { return GetExtraICState(); } |
| 1399 | |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 1400 | NilValue nil_value_; |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 1401 | State state_; |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 1402 | |
| 1403 | DISALLOW_COPY_AND_ASSIGN(CompareNilICStub); |
| 1404 | }; |
| 1405 | |
| 1406 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1407 | class CEntryStub : public PlatformCodeStub { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1408 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1409 | explicit CEntryStub(int result_size, |
| 1410 | SaveFPRegsMode save_doubles = kDontSaveFPRegs) |
| 1411 | : result_size_(result_size), save_doubles_(save_doubles) { } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1412 | |
| 1413 | void Generate(MacroAssembler* masm); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1414 | |
| 1415 | // The version of this stub that doesn't save doubles is generated ahead of |
| 1416 | // time, so it's OK to call it from other stubs that can't cope with GC during |
| 1417 | // their code generation. On machines that always have gp registers (x64) we |
| 1418 | // can generate both variants ahead of time. |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1419 | static void GenerateAheadOfTime(Isolate* isolate); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1420 | |
mvstanton@chromium.org | 63ea3d2 | 2013-10-10 09:24:12 +0000 | [diff] [blame] | 1421 | protected: |
| 1422 | virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { |
| 1423 | ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); |
| 1424 | }; |
| 1425 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1426 | private: |
| 1427 | void GenerateCore(MacroAssembler* masm, |
| 1428 | Label* throw_normal_exception, |
| 1429 | Label* throw_termination_exception, |
| 1430 | Label* throw_out_of_memory_exception, |
| 1431 | bool do_gc, |
ager@chromium.org | 0ee099b | 2011-01-25 14:06:47 +0000 | [diff] [blame] | 1432 | bool always_allocate_scope); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1433 | |
| 1434 | // Number of pointers/values returned. |
dslomov@chromium.org | e97852d | 2013-09-12 09:02:59 +0000 | [diff] [blame] | 1435 | Isolate* isolate_; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1436 | const int result_size_; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1437 | SaveFPRegsMode save_doubles_; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1438 | |
| 1439 | Major MajorKey() { return CEntry; } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1440 | int MinorKey(); |
| 1441 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 1442 | bool NeedsImmovableCode(); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1443 | }; |
| 1444 | |
| 1445 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1446 | class JSEntryStub : public PlatformCodeStub { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1447 | public: |
| 1448 | JSEntryStub() { } |
| 1449 | |
| 1450 | void Generate(MacroAssembler* masm) { GenerateBody(masm, false); } |
| 1451 | |
| 1452 | protected: |
| 1453 | void GenerateBody(MacroAssembler* masm, bool is_construct); |
| 1454 | |
| 1455 | private: |
| 1456 | Major MajorKey() { return JSEntry; } |
| 1457 | int MinorKey() { return 0; } |
jkummerow@chromium.org | 04e4f1e | 2011-11-14 13:36:17 +0000 | [diff] [blame] | 1458 | |
| 1459 | virtual void FinishCode(Handle<Code> code); |
| 1460 | |
| 1461 | int handler_offset_; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1462 | }; |
| 1463 | |
| 1464 | |
| 1465 | class JSConstructEntryStub : public JSEntryStub { |
| 1466 | public: |
| 1467 | JSConstructEntryStub() { } |
| 1468 | |
| 1469 | void Generate(MacroAssembler* masm) { GenerateBody(masm, true); } |
| 1470 | |
| 1471 | private: |
| 1472 | int MinorKey() { return 1; } |
| 1473 | |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 1474 | virtual void PrintName(StringStream* stream) { |
| 1475 | stream->Add("JSConstructEntryStub"); |
| 1476 | } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1477 | }; |
| 1478 | |
| 1479 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1480 | class ArgumentsAccessStub: public PlatformCodeStub { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1481 | public: |
| 1482 | enum Type { |
| 1483 | READ_ELEMENT, |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1484 | NEW_NON_STRICT_FAST, |
| 1485 | NEW_NON_STRICT_SLOW, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1486 | NEW_STRICT |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1487 | }; |
| 1488 | |
| 1489 | explicit ArgumentsAccessStub(Type type) : type_(type) { } |
| 1490 | |
| 1491 | private: |
| 1492 | Type type_; |
| 1493 | |
| 1494 | Major MajorKey() { return ArgumentsAccess; } |
| 1495 | int MinorKey() { return type_; } |
| 1496 | |
| 1497 | void Generate(MacroAssembler* masm); |
| 1498 | void GenerateReadElement(MacroAssembler* masm); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1499 | void GenerateNewStrict(MacroAssembler* masm); |
| 1500 | void GenerateNewNonStrictFast(MacroAssembler* masm); |
| 1501 | void GenerateNewNonStrictSlow(MacroAssembler* masm); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1502 | |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 1503 | virtual void PrintName(StringStream* stream); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1504 | }; |
| 1505 | |
| 1506 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1507 | class RegExpExecStub: public PlatformCodeStub { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1508 | public: |
| 1509 | RegExpExecStub() { } |
| 1510 | |
| 1511 | private: |
| 1512 | Major MajorKey() { return RegExpExec; } |
| 1513 | int MinorKey() { return 0; } |
| 1514 | |
| 1515 | void Generate(MacroAssembler* masm); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1516 | }; |
| 1517 | |
| 1518 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1519 | class RegExpConstructResultStub: public PlatformCodeStub { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1520 | public: |
| 1521 | RegExpConstructResultStub() { } |
| 1522 | |
| 1523 | private: |
| 1524 | Major MajorKey() { return RegExpConstructResult; } |
| 1525 | int MinorKey() { return 0; } |
| 1526 | |
| 1527 | void Generate(MacroAssembler* masm); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1528 | }; |
| 1529 | |
| 1530 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1531 | class CallFunctionStub: public PlatformCodeStub { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1532 | public: |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 1533 | CallFunctionStub(int argc, CallFunctionFlags flags) |
| 1534 | : argc_(argc), flags_(flags) { } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1535 | |
| 1536 | void Generate(MacroAssembler* masm); |
| 1537 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 1538 | virtual void FinishCode(Handle<Code> code) { |
| 1539 | code->set_has_function_cache(RecordCallTarget()); |
| 1540 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1541 | |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 1542 | static int ExtractArgcFromMinorKey(int minor_key) { |
| 1543 | return ArgcBits::decode(minor_key); |
| 1544 | } |
| 1545 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1546 | private: |
| 1547 | int argc_; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1548 | CallFunctionFlags flags_; |
| 1549 | |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 1550 | virtual void PrintName(StringStream* stream); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1551 | |
| 1552 | // Minor key encoding in 32 bits with Bitfield <Type, shift, size>. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1553 | class FlagBits: public BitField<CallFunctionFlags, 0, 2> {}; |
| 1554 | class ArgcBits: public BitField<unsigned, 2, 32 - 2> {}; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1555 | |
| 1556 | Major MajorKey() { return CallFunction; } |
| 1557 | int MinorKey() { |
| 1558 | // Encode the parameters in a unique 32 bit value. |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 1559 | return FlagBits::encode(flags_) | ArgcBits::encode(argc_); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1560 | } |
| 1561 | |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1562 | bool ReceiverMightBeImplicit() { |
| 1563 | return (flags_ & RECEIVER_MIGHT_BE_IMPLICIT) != 0; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1564 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1565 | |
| 1566 | bool RecordCallTarget() { |
| 1567 | return (flags_ & RECORD_CALL_TARGET) != 0; |
| 1568 | } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1569 | }; |
| 1570 | |
| 1571 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1572 | class CallConstructStub: public PlatformCodeStub { |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 1573 | public: |
| 1574 | explicit CallConstructStub(CallFunctionFlags flags) : flags_(flags) {} |
| 1575 | |
| 1576 | void Generate(MacroAssembler* masm); |
| 1577 | |
| 1578 | virtual void FinishCode(Handle<Code> code) { |
| 1579 | code->set_has_function_cache(RecordCallTarget()); |
| 1580 | } |
| 1581 | |
| 1582 | private: |
| 1583 | CallFunctionFlags flags_; |
| 1584 | |
| 1585 | virtual void PrintName(StringStream* stream); |
| 1586 | |
| 1587 | Major MajorKey() { return CallConstruct; } |
| 1588 | int MinorKey() { return flags_; } |
| 1589 | |
| 1590 | bool RecordCallTarget() { |
| 1591 | return (flags_ & RECORD_CALL_TARGET) != 0; |
| 1592 | } |
| 1593 | }; |
| 1594 | |
| 1595 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1596 | enum StringIndexFlags { |
| 1597 | // Accepts smis or heap numbers. |
| 1598 | STRING_INDEX_IS_NUMBER, |
| 1599 | |
| 1600 | // Accepts smis or heap numbers that are valid array indices |
| 1601 | // (ECMA-262 15.4). Invalid indices are reported as being out of |
| 1602 | // range. |
| 1603 | STRING_INDEX_IS_ARRAY_INDEX |
| 1604 | }; |
| 1605 | |
| 1606 | |
| 1607 | // Generates code implementing String.prototype.charCodeAt. |
| 1608 | // |
| 1609 | // Only supports the case when the receiver is a string and the index |
| 1610 | // is a number (smi or heap number) that is a valid index into the |
| 1611 | // string. Additional index constraints are specified by the |
| 1612 | // flags. Otherwise, bails out to the provided labels. |
| 1613 | // |
| 1614 | // Register usage: |object| may be changed to another string in a way |
| 1615 | // that doesn't affect charCodeAt/charAt semantics, |index| is |
| 1616 | // preserved, |scratch| and |result| are clobbered. |
| 1617 | class StringCharCodeAtGenerator { |
| 1618 | public: |
| 1619 | StringCharCodeAtGenerator(Register object, |
| 1620 | Register index, |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1621 | Register result, |
| 1622 | Label* receiver_not_string, |
| 1623 | Label* index_not_number, |
| 1624 | Label* index_out_of_range, |
| 1625 | StringIndexFlags index_flags) |
| 1626 | : object_(object), |
| 1627 | index_(index), |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1628 | result_(result), |
| 1629 | receiver_not_string_(receiver_not_string), |
| 1630 | index_not_number_(index_not_number), |
| 1631 | index_out_of_range_(index_out_of_range), |
| 1632 | index_flags_(index_flags) { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1633 | ASSERT(!result_.is(object_)); |
| 1634 | ASSERT(!result_.is(index_)); |
| 1635 | } |
| 1636 | |
| 1637 | // Generates the fast case code. On the fallthrough path |result| |
| 1638 | // register contains the result. |
| 1639 | void GenerateFast(MacroAssembler* masm); |
| 1640 | |
| 1641 | // Generates the slow case code. Must not be naturally |
| 1642 | // reachable. Expected to be put after a ret instruction (e.g., in |
| 1643 | // deferred code). Always jumps back to the fast case. |
| 1644 | void GenerateSlow(MacroAssembler* masm, |
| 1645 | const RuntimeCallHelper& call_helper); |
| 1646 | |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 1647 | // Skip handling slow case and directly jump to bailout. |
| 1648 | void SkipSlow(MacroAssembler* masm, Label* bailout) { |
| 1649 | masm->bind(&index_not_smi_); |
| 1650 | masm->bind(&call_runtime_); |
| 1651 | masm->jmp(bailout); |
| 1652 | } |
| 1653 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1654 | private: |
| 1655 | Register object_; |
| 1656 | Register index_; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1657 | Register result_; |
| 1658 | |
| 1659 | Label* receiver_not_string_; |
| 1660 | Label* index_not_number_; |
| 1661 | Label* index_out_of_range_; |
| 1662 | |
| 1663 | StringIndexFlags index_flags_; |
| 1664 | |
| 1665 | Label call_runtime_; |
| 1666 | Label index_not_smi_; |
| 1667 | Label got_smi_index_; |
| 1668 | Label exit_; |
| 1669 | |
| 1670 | DISALLOW_COPY_AND_ASSIGN(StringCharCodeAtGenerator); |
| 1671 | }; |
| 1672 | |
| 1673 | |
| 1674 | // Generates code for creating a one-char string from a char code. |
| 1675 | class StringCharFromCodeGenerator { |
| 1676 | public: |
| 1677 | StringCharFromCodeGenerator(Register code, |
| 1678 | Register result) |
| 1679 | : code_(code), |
| 1680 | result_(result) { |
| 1681 | ASSERT(!code_.is(result_)); |
| 1682 | } |
| 1683 | |
| 1684 | // Generates the fast case code. On the fallthrough path |result| |
| 1685 | // register contains the result. |
| 1686 | void GenerateFast(MacroAssembler* masm); |
| 1687 | |
| 1688 | // Generates the slow case code. Must not be naturally |
| 1689 | // reachable. Expected to be put after a ret instruction (e.g., in |
| 1690 | // deferred code). Always jumps back to the fast case. |
| 1691 | void GenerateSlow(MacroAssembler* masm, |
| 1692 | const RuntimeCallHelper& call_helper); |
| 1693 | |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 1694 | // Skip handling slow case and directly jump to bailout. |
| 1695 | void SkipSlow(MacroAssembler* masm, Label* bailout) { |
| 1696 | masm->bind(&slow_case_); |
| 1697 | masm->jmp(bailout); |
| 1698 | } |
| 1699 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1700 | private: |
| 1701 | Register code_; |
| 1702 | Register result_; |
| 1703 | |
| 1704 | Label slow_case_; |
| 1705 | Label exit_; |
| 1706 | |
| 1707 | DISALLOW_COPY_AND_ASSIGN(StringCharFromCodeGenerator); |
| 1708 | }; |
| 1709 | |
| 1710 | |
| 1711 | // Generates code implementing String.prototype.charAt. |
| 1712 | // |
| 1713 | // Only supports the case when the receiver is a string and the index |
| 1714 | // is a number (smi or heap number) that is a valid index into the |
| 1715 | // string. Additional index constraints are specified by the |
| 1716 | // flags. Otherwise, bails out to the provided labels. |
| 1717 | // |
| 1718 | // Register usage: |object| may be changed to another string in a way |
| 1719 | // that doesn't affect charCodeAt/charAt semantics, |index| is |
| 1720 | // preserved, |scratch1|, |scratch2|, and |result| are clobbered. |
| 1721 | class StringCharAtGenerator { |
| 1722 | public: |
| 1723 | StringCharAtGenerator(Register object, |
| 1724 | Register index, |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1725 | Register scratch, |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1726 | Register result, |
| 1727 | Label* receiver_not_string, |
| 1728 | Label* index_not_number, |
| 1729 | Label* index_out_of_range, |
| 1730 | StringIndexFlags index_flags) |
| 1731 | : char_code_at_generator_(object, |
| 1732 | index, |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1733 | scratch, |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1734 | receiver_not_string, |
| 1735 | index_not_number, |
| 1736 | index_out_of_range, |
| 1737 | index_flags), |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1738 | char_from_code_generator_(scratch, result) {} |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1739 | |
| 1740 | // Generates the fast case code. On the fallthrough path |result| |
| 1741 | // register contains the result. |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 1742 | void GenerateFast(MacroAssembler* masm) { |
| 1743 | char_code_at_generator_.GenerateFast(masm); |
| 1744 | char_from_code_generator_.GenerateFast(masm); |
| 1745 | } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1746 | |
| 1747 | // Generates the slow case code. Must not be naturally |
| 1748 | // reachable. Expected to be put after a ret instruction (e.g., in |
| 1749 | // deferred code). Always jumps back to the fast case. |
| 1750 | void GenerateSlow(MacroAssembler* masm, |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 1751 | const RuntimeCallHelper& call_helper) { |
| 1752 | char_code_at_generator_.GenerateSlow(masm, call_helper); |
| 1753 | char_from_code_generator_.GenerateSlow(masm, call_helper); |
| 1754 | } |
| 1755 | |
| 1756 | // Skip handling slow case and directly jump to bailout. |
| 1757 | void SkipSlow(MacroAssembler* masm, Label* bailout) { |
| 1758 | char_code_at_generator_.SkipSlow(masm, bailout); |
| 1759 | char_from_code_generator_.SkipSlow(masm, bailout); |
| 1760 | } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1761 | |
| 1762 | private: |
| 1763 | StringCharCodeAtGenerator char_code_at_generator_; |
| 1764 | StringCharFromCodeGenerator char_from_code_generator_; |
| 1765 | |
| 1766 | DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); |
| 1767 | }; |
| 1768 | |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 1769 | |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 1770 | class KeyedLoadDictionaryElementStub : public HydrogenCodeStub { |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 1771 | public: |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1772 | KeyedLoadDictionaryElementStub() {} |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 1773 | |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 1774 | virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; |
| 1775 | |
| 1776 | virtual void InitializeInterfaceDescriptor( |
| 1777 | Isolate* isolate, |
| 1778 | CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 1779 | |
| 1780 | private: |
| 1781 | Major MajorKey() { return KeyedLoadElement; } |
| 1782 | int NotMissMinorKey() { return DICTIONARY_ELEMENTS; } |
| 1783 | |
| 1784 | DISALLOW_COPY_AND_ASSIGN(KeyedLoadDictionaryElementStub); |
| 1785 | }; |
| 1786 | |
| 1787 | |
| 1788 | class KeyedLoadDictionaryElementPlatformStub : public PlatformCodeStub { |
| 1789 | public: |
| 1790 | KeyedLoadDictionaryElementPlatformStub() {} |
| 1791 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 1792 | void Generate(MacroAssembler* masm); |
| 1793 | |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 1794 | private: |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 1795 | Major MajorKey() { return KeyedLoadElement; } |
| 1796 | int MinorKey() { return DICTIONARY_ELEMENTS; } |
| 1797 | |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 1798 | DISALLOW_COPY_AND_ASSIGN(KeyedLoadDictionaryElementPlatformStub); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 1799 | }; |
| 1800 | |
| 1801 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1802 | class DoubleToIStub : public PlatformCodeStub { |
| 1803 | public: |
| 1804 | DoubleToIStub(Register source, |
| 1805 | Register destination, |
| 1806 | int offset, |
jkummerow@chromium.org | 1e8da74 | 2013-08-26 17:13:35 +0000 | [diff] [blame] | 1807 | bool is_truncating, |
| 1808 | bool skip_fastpath = false) : bit_field_(0) { |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1809 | bit_field_ = SourceRegisterBits::encode(source.code_) | |
| 1810 | DestinationRegisterBits::encode(destination.code_) | |
| 1811 | OffsetBits::encode(offset) | |
jkummerow@chromium.org | 1e8da74 | 2013-08-26 17:13:35 +0000 | [diff] [blame] | 1812 | IsTruncatingBits::encode(is_truncating) | |
jkummerow@chromium.org | 25b0e21 | 2013-10-04 15:38:52 +0000 | [diff] [blame] | 1813 | SkipFastPathBits::encode(skip_fastpath) | |
| 1814 | SSEBits::encode(CpuFeatures::IsSafeForSnapshot(SSE2) ? |
| 1815 | CpuFeatures::IsSafeForSnapshot(SSE3) ? 2 : 1 : 0); |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1816 | } |
| 1817 | |
| 1818 | Register source() { |
| 1819 | Register result = { SourceRegisterBits::decode(bit_field_) }; |
| 1820 | return result; |
| 1821 | } |
| 1822 | |
| 1823 | Register destination() { |
| 1824 | Register result = { DestinationRegisterBits::decode(bit_field_) }; |
| 1825 | return result; |
| 1826 | } |
| 1827 | |
| 1828 | bool is_truncating() { |
| 1829 | return IsTruncatingBits::decode(bit_field_); |
| 1830 | } |
| 1831 | |
jkummerow@chromium.org | 1e8da74 | 2013-08-26 17:13:35 +0000 | [diff] [blame] | 1832 | bool skip_fastpath() { |
| 1833 | return SkipFastPathBits::decode(bit_field_); |
| 1834 | } |
| 1835 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1836 | int offset() { |
| 1837 | return OffsetBits::decode(bit_field_); |
| 1838 | } |
| 1839 | |
| 1840 | void Generate(MacroAssembler* masm); |
| 1841 | |
jkummerow@chromium.org | 1e8da74 | 2013-08-26 17:13:35 +0000 | [diff] [blame] | 1842 | virtual bool SometimesSetsUpAFrame() { return false; } |
| 1843 | |
mvstanton@chromium.org | 63ea3d2 | 2013-10-10 09:24:12 +0000 | [diff] [blame] | 1844 | protected: |
| 1845 | virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { |
| 1846 | ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); |
| 1847 | } |
| 1848 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1849 | private: |
| 1850 | static const int kBitsPerRegisterNumber = 6; |
| 1851 | STATIC_ASSERT((1L << kBitsPerRegisterNumber) >= Register::kNumRegisters); |
| 1852 | class SourceRegisterBits: |
| 1853 | public BitField<int, 0, kBitsPerRegisterNumber> {}; // NOLINT |
| 1854 | class DestinationRegisterBits: |
| 1855 | public BitField<int, kBitsPerRegisterNumber, |
| 1856 | kBitsPerRegisterNumber> {}; // NOLINT |
| 1857 | class IsTruncatingBits: |
| 1858 | public BitField<bool, 2 * kBitsPerRegisterNumber, 1> {}; // NOLINT |
| 1859 | class OffsetBits: |
| 1860 | public BitField<int, 2 * kBitsPerRegisterNumber + 1, 3> {}; // NOLINT |
jkummerow@chromium.org | 1e8da74 | 2013-08-26 17:13:35 +0000 | [diff] [blame] | 1861 | class SkipFastPathBits: |
| 1862 | public BitField<int, 2 * kBitsPerRegisterNumber + 4, 1> {}; // NOLINT |
jkummerow@chromium.org | 25b0e21 | 2013-10-04 15:38:52 +0000 | [diff] [blame] | 1863 | class SSEBits: |
| 1864 | public BitField<int, 2 * kBitsPerRegisterNumber + 5, 2> {}; // NOLINT |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1865 | |
| 1866 | Major MajorKey() { return DoubleToI; } |
| 1867 | int MinorKey() { return bit_field_; } |
| 1868 | |
| 1869 | int bit_field_; |
| 1870 | |
| 1871 | DISALLOW_COPY_AND_ASSIGN(DoubleToIStub); |
| 1872 | }; |
| 1873 | |
| 1874 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1875 | class KeyedLoadFastElementStub : public HydrogenCodeStub { |
| 1876 | public: |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 1877 | KeyedLoadFastElementStub(bool is_js_array, ElementsKind elements_kind) { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1878 | bit_field_ = ElementsKindBits::encode(elements_kind) | |
| 1879 | IsJSArrayBits::encode(is_js_array); |
| 1880 | } |
| 1881 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1882 | bool is_js_array() const { |
| 1883 | return IsJSArrayBits::decode(bit_field_); |
| 1884 | } |
| 1885 | |
| 1886 | ElementsKind elements_kind() const { |
| 1887 | return ElementsKindBits::decode(bit_field_); |
| 1888 | } |
| 1889 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 1890 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1891 | |
| 1892 | virtual void InitializeInterfaceDescriptor( |
| 1893 | Isolate* isolate, |
| 1894 | CodeStubInterfaceDescriptor* descriptor); |
| 1895 | |
| 1896 | private: |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1897 | class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 1898 | class IsJSArrayBits: public BitField<bool, 8, 1> {}; |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1899 | uint32_t bit_field_; |
| 1900 | |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 1901 | Major MajorKey() { return KeyedLoadElement; } |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 1902 | int NotMissMinorKey() { return bit_field_; } |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 1903 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 1904 | DISALLOW_COPY_AND_ASSIGN(KeyedLoadFastElementStub); |
| 1905 | }; |
| 1906 | |
| 1907 | |
jkummerow@chromium.org | 7bd87f0 | 2013-03-20 18:06:29 +0000 | [diff] [blame] | 1908 | class KeyedStoreFastElementStub : public HydrogenCodeStub { |
| 1909 | public: |
| 1910 | KeyedStoreFastElementStub(bool is_js_array, |
| 1911 | ElementsKind elements_kind, |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 1912 | KeyedAccessStoreMode mode) { |
jkummerow@chromium.org | 7bd87f0 | 2013-03-20 18:06:29 +0000 | [diff] [blame] | 1913 | bit_field_ = ElementsKindBits::encode(elements_kind) | |
| 1914 | IsJSArrayBits::encode(is_js_array) | |
| 1915 | StoreModeBits::encode(mode); |
| 1916 | } |
| 1917 | |
jkummerow@chromium.org | 7bd87f0 | 2013-03-20 18:06:29 +0000 | [diff] [blame] | 1918 | bool is_js_array() const { |
| 1919 | return IsJSArrayBits::decode(bit_field_); |
| 1920 | } |
| 1921 | |
| 1922 | ElementsKind elements_kind() const { |
| 1923 | return ElementsKindBits::decode(bit_field_); |
| 1924 | } |
| 1925 | |
| 1926 | KeyedAccessStoreMode store_mode() const { |
| 1927 | return StoreModeBits::decode(bit_field_); |
| 1928 | } |
| 1929 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 1930 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
jkummerow@chromium.org | 7bd87f0 | 2013-03-20 18:06:29 +0000 | [diff] [blame] | 1931 | |
| 1932 | virtual void InitializeInterfaceDescriptor( |
| 1933 | Isolate* isolate, |
| 1934 | CodeStubInterfaceDescriptor* descriptor); |
| 1935 | |
| 1936 | private: |
| 1937 | class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; |
| 1938 | class StoreModeBits: public BitField<KeyedAccessStoreMode, 8, 4> {}; |
| 1939 | class IsJSArrayBits: public BitField<bool, 12, 1> {}; |
| 1940 | uint32_t bit_field_; |
| 1941 | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 1942 | Major MajorKey() { return KeyedStoreElement; } |
| 1943 | int NotMissMinorKey() { return bit_field_; } |
| 1944 | |
jkummerow@chromium.org | 7bd87f0 | 2013-03-20 18:06:29 +0000 | [diff] [blame] | 1945 | DISALLOW_COPY_AND_ASSIGN(KeyedStoreFastElementStub); |
| 1946 | }; |
| 1947 | |
| 1948 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 1949 | class TransitionElementsKindStub : public HydrogenCodeStub { |
| 1950 | public: |
| 1951 | TransitionElementsKindStub(ElementsKind from_kind, |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 1952 | ElementsKind to_kind) { |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 1953 | bit_field_ = FromKindBits::encode(from_kind) | |
| 1954 | ToKindBits::encode(to_kind); |
| 1955 | } |
| 1956 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 1957 | ElementsKind from_kind() const { |
| 1958 | return FromKindBits::decode(bit_field_); |
| 1959 | } |
| 1960 | |
| 1961 | ElementsKind to_kind() const { |
| 1962 | return ToKindBits::decode(bit_field_); |
| 1963 | } |
| 1964 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 1965 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 1966 | |
| 1967 | virtual void InitializeInterfaceDescriptor( |
| 1968 | Isolate* isolate, |
| 1969 | CodeStubInterfaceDescriptor* descriptor); |
| 1970 | |
| 1971 | private: |
| 1972 | class FromKindBits: public BitField<ElementsKind, 8, 8> {}; |
| 1973 | class ToKindBits: public BitField<ElementsKind, 0, 8> {}; |
| 1974 | uint32_t bit_field_; |
| 1975 | |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 1976 | Major MajorKey() { return TransitionElementsKind; } |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 1977 | int NotMissMinorKey() { return bit_field_; } |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 1978 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 1979 | DISALLOW_COPY_AND_ASSIGN(TransitionElementsKindStub); |
| 1980 | }; |
| 1981 | |
| 1982 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1983 | enum ContextCheckMode { |
| 1984 | CONTEXT_CHECK_REQUIRED, |
| 1985 | CONTEXT_CHECK_NOT_REQUIRED, |
| 1986 | LAST_CONTEXT_CHECK_MODE = CONTEXT_CHECK_NOT_REQUIRED |
| 1987 | }; |
| 1988 | |
| 1989 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 1990 | class ArrayConstructorStubBase : public HydrogenCodeStub { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1991 | public: |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1992 | ArrayConstructorStubBase(ElementsKind kind, ContextCheckMode context_mode, |
| 1993 | AllocationSiteOverrideMode override_mode) { |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 1994 | // It only makes sense to override local allocation site behavior |
| 1995 | // if there is a difference between the global allocation site policy |
| 1996 | // for an ElementsKind and the desired usage of the stub. |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 1997 | ASSERT(!(FLAG_track_allocation_sites && |
| 1998 | override_mode == DISABLE_ALLOCATION_SITES) || |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1999 | AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2000 | bit_field_ = ElementsKindBits::encode(kind) | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2001 | AllocationSiteOverrideModeBits::encode(override_mode) | |
| 2002 | ContextCheckModeBits::encode(context_mode); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2003 | } |
| 2004 | |
| 2005 | ElementsKind elements_kind() const { |
| 2006 | return ElementsKindBits::decode(bit_field_); |
| 2007 | } |
| 2008 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2009 | AllocationSiteOverrideMode override_mode() const { |
| 2010 | return AllocationSiteOverrideModeBits::decode(bit_field_); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2011 | } |
| 2012 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2013 | ContextCheckMode context_mode() const { |
| 2014 | return ContextCheckModeBits::decode(bit_field_); |
| 2015 | } |
| 2016 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2017 | static void GenerateStubsAheadOfTime(Isolate* isolate); |
| 2018 | static void InstallDescriptors(Isolate* isolate); |
| 2019 | |
| 2020 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 2021 | static const int kConstructor = 0; |
| 2022 | static const int kPropertyCell = 1; |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2023 | |
hpayer@chromium.org | 71ea97f | 2013-12-19 16:03:26 +0000 | [diff] [blame] | 2024 | protected: |
| 2025 | void BasePrintName(const char* name, StringStream* stream); |
| 2026 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2027 | private: |
| 2028 | int NotMissMinorKey() { return bit_field_; } |
| 2029 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2030 | // Ensure data fits within available bits. |
| 2031 | STATIC_ASSERT(LAST_ALLOCATION_SITE_OVERRIDE_MODE == 1); |
| 2032 | STATIC_ASSERT(LAST_CONTEXT_CHECK_MODE == 1); |
| 2033 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2034 | class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2035 | class AllocationSiteOverrideModeBits: public |
| 2036 | BitField<AllocationSiteOverrideMode, 8, 1> {}; // NOLINT |
| 2037 | class ContextCheckModeBits: public BitField<ContextCheckMode, 9, 1> {}; |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2038 | uint32_t bit_field_; |
| 2039 | |
| 2040 | DISALLOW_COPY_AND_ASSIGN(ArrayConstructorStubBase); |
| 2041 | }; |
| 2042 | |
| 2043 | |
| 2044 | class ArrayNoArgumentConstructorStub : public ArrayConstructorStubBase { |
| 2045 | public: |
| 2046 | ArrayNoArgumentConstructorStub( |
| 2047 | ElementsKind kind, |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2048 | ContextCheckMode context_mode = CONTEXT_CHECK_REQUIRED, |
| 2049 | AllocationSiteOverrideMode override_mode = DONT_OVERRIDE) |
| 2050 | : ArrayConstructorStubBase(kind, context_mode, override_mode) { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2051 | } |
| 2052 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 2053 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2054 | |
| 2055 | virtual void InitializeInterfaceDescriptor( |
| 2056 | Isolate* isolate, |
| 2057 | CodeStubInterfaceDescriptor* descriptor); |
| 2058 | |
| 2059 | private: |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2060 | Major MajorKey() { return ArrayNoArgumentConstructor; } |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2061 | |
hpayer@chromium.org | 71ea97f | 2013-12-19 16:03:26 +0000 | [diff] [blame] | 2062 | virtual void PrintName(StringStream* stream) { |
| 2063 | BasePrintName("ArrayNoArgumentConstructorStub", stream); |
| 2064 | } |
| 2065 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2066 | DISALLOW_COPY_AND_ASSIGN(ArrayNoArgumentConstructorStub); |
| 2067 | }; |
| 2068 | |
| 2069 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2070 | class ArraySingleArgumentConstructorStub : public ArrayConstructorStubBase { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2071 | public: |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2072 | ArraySingleArgumentConstructorStub( |
| 2073 | ElementsKind kind, |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2074 | ContextCheckMode context_mode = CONTEXT_CHECK_REQUIRED, |
| 2075 | AllocationSiteOverrideMode override_mode = DONT_OVERRIDE) |
| 2076 | : ArrayConstructorStubBase(kind, context_mode, override_mode) { |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2077 | } |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2078 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 2079 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2080 | |
| 2081 | virtual void InitializeInterfaceDescriptor( |
| 2082 | Isolate* isolate, |
| 2083 | CodeStubInterfaceDescriptor* descriptor); |
| 2084 | |
| 2085 | private: |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2086 | Major MajorKey() { return ArraySingleArgumentConstructor; } |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2087 | |
hpayer@chromium.org | 71ea97f | 2013-12-19 16:03:26 +0000 | [diff] [blame] | 2088 | virtual void PrintName(StringStream* stream) { |
| 2089 | BasePrintName("ArraySingleArgumentConstructorStub", stream); |
| 2090 | } |
| 2091 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2092 | DISALLOW_COPY_AND_ASSIGN(ArraySingleArgumentConstructorStub); |
| 2093 | }; |
| 2094 | |
| 2095 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2096 | class ArrayNArgumentsConstructorStub : public ArrayConstructorStubBase { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2097 | public: |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2098 | ArrayNArgumentsConstructorStub( |
| 2099 | ElementsKind kind, |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2100 | ContextCheckMode context_mode = CONTEXT_CHECK_REQUIRED, |
| 2101 | AllocationSiteOverrideMode override_mode = DONT_OVERRIDE) |
| 2102 | : ArrayConstructorStubBase(kind, context_mode, override_mode) { |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2103 | } |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2104 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 2105 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2106 | |
| 2107 | virtual void InitializeInterfaceDescriptor( |
| 2108 | Isolate* isolate, |
| 2109 | CodeStubInterfaceDescriptor* descriptor); |
| 2110 | |
| 2111 | private: |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2112 | Major MajorKey() { return ArrayNArgumentsConstructor; } |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2113 | |
hpayer@chromium.org | 71ea97f | 2013-12-19 16:03:26 +0000 | [diff] [blame] | 2114 | virtual void PrintName(StringStream* stream) { |
| 2115 | BasePrintName("ArrayNArgumentsConstructorStub", stream); |
| 2116 | } |
| 2117 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2118 | DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub); |
| 2119 | }; |
| 2120 | |
| 2121 | |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 2122 | class InternalArrayConstructorStubBase : public HydrogenCodeStub { |
| 2123 | public: |
| 2124 | explicit InternalArrayConstructorStubBase(ElementsKind kind) { |
| 2125 | kind_ = kind; |
| 2126 | } |
| 2127 | |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 2128 | static void GenerateStubsAheadOfTime(Isolate* isolate); |
| 2129 | static void InstallDescriptors(Isolate* isolate); |
| 2130 | |
| 2131 | // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
| 2132 | static const int kConstructor = 0; |
| 2133 | |
| 2134 | ElementsKind elements_kind() const { return kind_; } |
| 2135 | |
| 2136 | private: |
| 2137 | int NotMissMinorKey() { return kind_; } |
| 2138 | |
| 2139 | ElementsKind kind_; |
| 2140 | |
| 2141 | DISALLOW_COPY_AND_ASSIGN(InternalArrayConstructorStubBase); |
| 2142 | }; |
| 2143 | |
| 2144 | |
| 2145 | class InternalArrayNoArgumentConstructorStub : public |
| 2146 | InternalArrayConstructorStubBase { |
| 2147 | public: |
| 2148 | explicit InternalArrayNoArgumentConstructorStub(ElementsKind kind) |
| 2149 | : InternalArrayConstructorStubBase(kind) { } |
| 2150 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 2151 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 2152 | |
| 2153 | virtual void InitializeInterfaceDescriptor( |
| 2154 | Isolate* isolate, |
| 2155 | CodeStubInterfaceDescriptor* descriptor); |
| 2156 | |
| 2157 | private: |
| 2158 | Major MajorKey() { return InternalArrayNoArgumentConstructor; } |
| 2159 | |
| 2160 | DISALLOW_COPY_AND_ASSIGN(InternalArrayNoArgumentConstructorStub); |
| 2161 | }; |
| 2162 | |
| 2163 | |
| 2164 | class InternalArraySingleArgumentConstructorStub : public |
| 2165 | InternalArrayConstructorStubBase { |
| 2166 | public: |
| 2167 | explicit InternalArraySingleArgumentConstructorStub(ElementsKind kind) |
| 2168 | : InternalArrayConstructorStubBase(kind) { } |
| 2169 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 2170 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 2171 | |
| 2172 | virtual void InitializeInterfaceDescriptor( |
| 2173 | Isolate* isolate, |
| 2174 | CodeStubInterfaceDescriptor* descriptor); |
| 2175 | |
| 2176 | private: |
| 2177 | Major MajorKey() { return InternalArraySingleArgumentConstructor; } |
| 2178 | |
| 2179 | DISALLOW_COPY_AND_ASSIGN(InternalArraySingleArgumentConstructorStub); |
| 2180 | }; |
| 2181 | |
| 2182 | |
| 2183 | class InternalArrayNArgumentsConstructorStub : public |
| 2184 | InternalArrayConstructorStubBase { |
| 2185 | public: |
| 2186 | explicit InternalArrayNArgumentsConstructorStub(ElementsKind kind) |
| 2187 | : InternalArrayConstructorStubBase(kind) { } |
| 2188 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 2189 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 2190 | |
| 2191 | virtual void InitializeInterfaceDescriptor( |
| 2192 | Isolate* isolate, |
| 2193 | CodeStubInterfaceDescriptor* descriptor); |
| 2194 | |
| 2195 | private: |
| 2196 | Major MajorKey() { return InternalArrayNArgumentsConstructor; } |
| 2197 | |
| 2198 | DISALLOW_COPY_AND_ASSIGN(InternalArrayNArgumentsConstructorStub); |
| 2199 | }; |
| 2200 | |
| 2201 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 2202 | class KeyedStoreElementStub : public PlatformCodeStub { |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 2203 | public: |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 2204 | KeyedStoreElementStub(bool is_js_array, |
ulan@chromium.org | 65a89c2 | 2012-02-14 11:46:07 +0000 | [diff] [blame] | 2205 | ElementsKind elements_kind, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2206 | KeyedAccessStoreMode store_mode) |
ulan@chromium.org | 65a89c2 | 2012-02-14 11:46:07 +0000 | [diff] [blame] | 2207 | : is_js_array_(is_js_array), |
| 2208 | elements_kind_(elements_kind), |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2209 | store_mode_(store_mode), |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 2210 | fp_registers_(CanUseFPRegisters()) { } |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 2211 | |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 2212 | Major MajorKey() { return KeyedStoreElement; } |
| 2213 | int MinorKey() { |
ulan@chromium.org | 65a89c2 | 2012-02-14 11:46:07 +0000 | [diff] [blame] | 2214 | return ElementsKindBits::encode(elements_kind_) | |
| 2215 | IsJSArrayBits::encode(is_js_array_) | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2216 | StoreModeBits::encode(store_mode_) | |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 2217 | FPRegisters::encode(fp_registers_); |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 2218 | } |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 2219 | |
| 2220 | void Generate(MacroAssembler* masm); |
| 2221 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 2222 | private: |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2223 | class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; |
| 2224 | class StoreModeBits: public BitField<KeyedAccessStoreMode, 8, 4> {}; |
| 2225 | class IsJSArrayBits: public BitField<bool, 12, 1> {}; |
| 2226 | class FPRegisters: public BitField<bool, 13, 1> {}; |
ulan@chromium.org | 65a89c2 | 2012-02-14 11:46:07 +0000 | [diff] [blame] | 2227 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 2228 | bool is_js_array_; |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 2229 | ElementsKind elements_kind_; |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2230 | KeyedAccessStoreMode store_mode_; |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 2231 | bool fp_registers_; |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 2232 | |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 2233 | DISALLOW_COPY_AND_ASSIGN(KeyedStoreElementStub); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 2234 | }; |
| 2235 | |
| 2236 | |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2237 | class ToBooleanStub: public HydrogenCodeStub { |
lrn@chromium.org | ac2828d | 2011-06-23 06:29:21 +0000 | [diff] [blame] | 2238 | public: |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2239 | enum Type { |
| 2240 | UNDEFINED, |
| 2241 | BOOLEAN, |
| 2242 | NULL_TYPE, |
| 2243 | SMI, |
| 2244 | SPEC_OBJECT, |
| 2245 | STRING, |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 2246 | SYMBOL, |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2247 | HEAP_NUMBER, |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2248 | NUMBER_OF_TYPES |
| 2249 | }; |
| 2250 | |
| 2251 | // At most 8 different types can be distinguished, because the Code object |
| 2252 | // only has room for a single byte to hold a set of these types. :-P |
| 2253 | STATIC_ASSERT(NUMBER_OF_TYPES <= 8); |
| 2254 | |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2255 | class Types : public EnumSet<Type, byte> { |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2256 | public: |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2257 | Types() : EnumSet<Type, byte>(0) {} |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2258 | explicit Types(byte bits) : EnumSet<Type, byte>(bits) {} |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2259 | |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2260 | byte ToByte() const { return ToIntegral(); } |
vegorov@chromium.org | 7943d46 | 2011-08-01 11:41:52 +0000 | [diff] [blame] | 2261 | void Print(StringStream* stream) const; |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 2262 | bool UpdateStatus(Handle<Object> object); |
vegorov@chromium.org | 7943d46 | 2011-08-01 11:41:52 +0000 | [diff] [blame] | 2263 | bool NeedsMap() const; |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 2264 | bool CanBeUndetectable() const; |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2265 | bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2266 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2267 | static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } |
| 2268 | }; |
ricow@chromium.org | 2c99e28 | 2011-07-28 09:15:17 +0000 | [diff] [blame] | 2269 | |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2270 | explicit ToBooleanStub(Types types = Types()) |
| 2271 | : types_(types) { } |
yangguo@chromium.org | cc53605 | 2013-11-29 11:43:20 +0000 | [diff] [blame] | 2272 | explicit ToBooleanStub(ExtraICState state) |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2273 | : types_(static_cast<byte>(state)) { } |
lrn@chromium.org | ac2828d | 2011-06-23 06:29:21 +0000 | [diff] [blame] | 2274 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 2275 | bool UpdateStatus(Handle<Object> object); |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2276 | Types GetTypes() { return types_; } |
| 2277 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 2278 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2279 | virtual void InitializeInterfaceDescriptor( |
| 2280 | Isolate* isolate, |
| 2281 | CodeStubInterfaceDescriptor* descriptor); |
| 2282 | |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 2283 | virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; } |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 2284 | virtual void PrintState(StringStream* stream); |
lrn@chromium.org | ac2828d | 2011-06-23 06:29:21 +0000 | [diff] [blame] | 2285 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2286 | virtual bool SometimesSetsUpAFrame() { return false; } |
| 2287 | |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2288 | static void InitializeForIsolate(Isolate* isolate) { |
| 2289 | ToBooleanStub stub; |
| 2290 | stub.InitializeInterfaceDescriptor( |
| 2291 | isolate, |
| 2292 | isolate->code_stub_interface_descriptor(CodeStub::ToBoolean)); |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2293 | } |
| 2294 | |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2295 | static Handle<Code> GetUninitialized(Isolate* isolate) { |
| 2296 | return ToBooleanStub(UNINITIALIZED).GetCode(isolate); |
| 2297 | } |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2298 | |
yangguo@chromium.org | cc53605 | 2013-11-29 11:43:20 +0000 | [diff] [blame] | 2299 | virtual ExtraICState GetExtraICState() { |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2300 | return types_.ToIntegral(); |
| 2301 | } |
| 2302 | |
danno@chromium.org | 1fd77d5 | 2013-06-07 16:01:45 +0000 | [diff] [blame] | 2303 | virtual InlineCacheState GetICState() { |
| 2304 | if (types_.IsEmpty()) { |
| 2305 | return ::v8::internal::UNINITIALIZED; |
| 2306 | } else { |
| 2307 | return MONOMORPHIC; |
| 2308 | } |
| 2309 | } |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2310 | |
| 2311 | private: |
| 2312 | Major MajorKey() { return ToBoolean; } |
| 2313 | int NotMissMinorKey() { return GetExtraICState(); } |
| 2314 | |
| 2315 | explicit ToBooleanStub(InitializationState init_state) : |
| 2316 | HydrogenCodeStub(init_state) {} |
| 2317 | |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2318 | Types types_; |
lrn@chromium.org | ac2828d | 2011-06-23 06:29:21 +0000 | [diff] [blame] | 2319 | }; |
| 2320 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2321 | |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 2322 | class ElementsTransitionAndStoreStub : public HydrogenCodeStub { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2323 | public: |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 2324 | ElementsTransitionAndStoreStub(ElementsKind from_kind, |
| 2325 | ElementsKind to_kind, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2326 | bool is_jsarray, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2327 | KeyedAccessStoreMode store_mode) |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 2328 | : from_kind_(from_kind), |
| 2329 | to_kind_(to_kind), |
| 2330 | is_jsarray_(is_jsarray), |
| 2331 | store_mode_(store_mode) {} |
| 2332 | |
| 2333 | ElementsKind from_kind() const { return from_kind_; } |
| 2334 | ElementsKind to_kind() const { return to_kind_; } |
| 2335 | bool is_jsarray() const { return is_jsarray_; } |
| 2336 | KeyedAccessStoreMode store_mode() const { return store_mode_; } |
| 2337 | |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 2338 | virtual Handle<Code> GenerateCode(Isolate* isolate); |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 2339 | |
| 2340 | void InitializeInterfaceDescriptor( |
| 2341 | Isolate* isolate, |
| 2342 | CodeStubInterfaceDescriptor* descriptor); |
| 2343 | |
| 2344 | private: |
| 2345 | class FromBits: public BitField<ElementsKind, 0, 8> {}; |
| 2346 | class ToBits: public BitField<ElementsKind, 8, 8> {}; |
| 2347 | class IsJSArrayBits: public BitField<bool, 16, 1> {}; |
| 2348 | class StoreModeBits: public BitField<KeyedAccessStoreMode, 17, 4> {}; |
| 2349 | |
| 2350 | Major MajorKey() { return ElementsTransitionAndStore; } |
| 2351 | int NotMissMinorKey() { |
| 2352 | return FromBits::encode(from_kind_) | |
| 2353 | ToBits::encode(to_kind_) | |
| 2354 | IsJSArrayBits::encode(is_jsarray_) | |
| 2355 | StoreModeBits::encode(store_mode_); |
| 2356 | } |
| 2357 | |
| 2358 | ElementsKind from_kind_; |
| 2359 | ElementsKind to_kind_; |
| 2360 | bool is_jsarray_; |
| 2361 | KeyedAccessStoreMode store_mode_; |
| 2362 | |
| 2363 | DISALLOW_COPY_AND_ASSIGN(ElementsTransitionAndStoreStub); |
| 2364 | }; |
| 2365 | |
| 2366 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 2367 | class StoreArrayLiteralElementStub : public PlatformCodeStub { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2368 | public: |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 2369 | StoreArrayLiteralElementStub() |
| 2370 | : fp_registers_(CanUseFPRegisters()) { } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2371 | |
| 2372 | private: |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 2373 | class FPRegisters: public BitField<bool, 0, 1> {}; |
| 2374 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2375 | Major MajorKey() { return StoreArrayLiteralElement; } |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 2376 | int MinorKey() { return FPRegisters::encode(fp_registers_); } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2377 | |
| 2378 | void Generate(MacroAssembler* masm); |
| 2379 | |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 2380 | bool fp_registers_; |
| 2381 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2382 | DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub); |
| 2383 | }; |
| 2384 | |
verwaest@chromium.org | 753aee4 | 2012-07-17 16:15:42 +0000 | [diff] [blame] | 2385 | |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 2386 | class StubFailureTrampolineStub : public PlatformCodeStub { |
| 2387 | public: |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 2388 | explicit StubFailureTrampolineStub(StubFunctionMode function_mode) |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2389 | : fp_registers_(CanUseFPRegisters()), function_mode_(function_mode) {} |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2390 | |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 2391 | static void GenerateAheadOfTime(Isolate* isolate); |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 2392 | |
| 2393 | private: |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2394 | class FPRegisters: public BitField<bool, 0, 1> {}; |
| 2395 | class FunctionModeField: public BitField<StubFunctionMode, 1, 1> {}; |
| 2396 | |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 2397 | Major MajorKey() { return StubFailureTrampoline; } |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2398 | int MinorKey() { |
| 2399 | return FPRegisters::encode(fp_registers_) | |
| 2400 | FunctionModeField::encode(function_mode_); |
| 2401 | } |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 2402 | |
| 2403 | void Generate(MacroAssembler* masm); |
| 2404 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2405 | bool fp_registers_; |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 2406 | StubFunctionMode function_mode_; |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2407 | |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 2408 | DISALLOW_COPY_AND_ASSIGN(StubFailureTrampolineStub); |
| 2409 | }; |
| 2410 | |
| 2411 | |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 2412 | class StubFailureTailCallTrampolineStub : public PlatformCodeStub { |
| 2413 | public: |
| 2414 | StubFailureTailCallTrampolineStub() : fp_registers_(CanUseFPRegisters()) {} |
| 2415 | |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame] | 2416 | static void GenerateAheadOfTime(Isolate* isolate); |
| 2417 | |
| 2418 | private: |
| 2419 | class FPRegisters: public BitField<bool, 0, 1> {}; |
| 2420 | Major MajorKey() { return StubFailureTailCallTrampoline; } |
| 2421 | int MinorKey() { return FPRegisters::encode(fp_registers_); } |
| 2422 | |
| 2423 | void Generate(MacroAssembler* masm); |
| 2424 | |
| 2425 | bool fp_registers_; |
| 2426 | |
| 2427 | DISALLOW_COPY_AND_ASSIGN(StubFailureTailCallTrampolineStub); |
| 2428 | }; |
| 2429 | |
| 2430 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 2431 | class ProfileEntryHookStub : public PlatformCodeStub { |
verwaest@chromium.org | 753aee4 | 2012-07-17 16:15:42 +0000 | [diff] [blame] | 2432 | public: |
| 2433 | explicit ProfileEntryHookStub() {} |
| 2434 | |
| 2435 | // The profile entry hook function is not allowed to cause a GC. |
| 2436 | virtual bool SometimesSetsUpAFrame() { return false; } |
| 2437 | |
| 2438 | // Generates a call to the entry hook if it's enabled. |
| 2439 | static void MaybeCallEntryHook(MacroAssembler* masm); |
| 2440 | |
verwaest@chromium.org | 753aee4 | 2012-07-17 16:15:42 +0000 | [diff] [blame] | 2441 | private: |
| 2442 | static void EntryHookTrampoline(intptr_t function, |
hpayer@chromium.org | c5d4971 | 2013-09-11 08:25:48 +0000 | [diff] [blame] | 2443 | intptr_t stack_pointer, |
| 2444 | Isolate* isolate); |
verwaest@chromium.org | 753aee4 | 2012-07-17 16:15:42 +0000 | [diff] [blame] | 2445 | |
| 2446 | Major MajorKey() { return ProfileEntryHook; } |
| 2447 | int MinorKey() { return 0; } |
| 2448 | |
| 2449 | void Generate(MacroAssembler* masm); |
| 2450 | |
verwaest@chromium.org | 753aee4 | 2012-07-17 16:15:42 +0000 | [diff] [blame] | 2451 | DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
| 2452 | }; |
| 2453 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2454 | } } // namespace v8::internal |
| 2455 | |
| 2456 | #endif // V8_CODE_STUBS_H_ |