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