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_STUB_CACHE_H_ |
| 29 | #define V8_STUB_CACHE_H_ |
| 30 | |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 31 | #include "allocation.h" |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 32 | #include "arguments.h" |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 33 | #include "ic-inl.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 34 | #include "macro-assembler.h" |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 35 | #include "objects.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 36 | #include "zone-inl.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 37 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 38 | namespace v8 { |
| 39 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 40 | |
| 41 | |
| 42 | // The stub cache is used for megamorphic calls and property accesses. |
| 43 | // It maps (map, name, type)->Code* |
| 44 | |
| 45 | // The design of the table uses the inline cache stubs used for |
| 46 | // mono-morphic calls. The beauty of this, we do not have to |
| 47 | // invalidate the cache whenever a prototype map is changed. The stub |
| 48 | // validates the map chain as in the mono-morphic case. |
| 49 | |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 50 | class SmallMapList; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 51 | class StubCache; |
| 52 | |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 53 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 54 | class SCTableReference { |
| 55 | public: |
| 56 | Address address() const { return address_; } |
| 57 | |
| 58 | private: |
| 59 | explicit SCTableReference(Address address) : address_(address) {} |
| 60 | |
| 61 | Address address_; |
| 62 | |
| 63 | friend class StubCache; |
| 64 | }; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 65 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 66 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 67 | class StubCache { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 68 | public: |
| 69 | struct Entry { |
| 70 | String* key; |
| 71 | Code* value; |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 72 | Map* map; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 75 | void Initialize(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 76 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 77 | |
| 78 | // Computes the right stub matching. Inserts the result in the |
| 79 | // cache before returning. This might compile a stub if needed. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 80 | Handle<Code> ComputeLoadNonexistent(Handle<String> name, |
| 81 | Handle<JSObject> receiver); |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 82 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 83 | Handle<Code> ComputeLoadField(Handle<String> name, |
| 84 | Handle<JSObject> receiver, |
| 85 | Handle<JSObject> holder, |
| 86 | int field_index); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 87 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 88 | Handle<Code> ComputeLoadCallback(Handle<String> name, |
| 89 | Handle<JSObject> receiver, |
| 90 | Handle<JSObject> holder, |
| 91 | Handle<AccessorInfo> callback); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 92 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 93 | Handle<Code> ComputeLoadViaGetter(Handle<String> name, |
| 94 | Handle<JSObject> receiver, |
| 95 | Handle<JSObject> holder, |
| 96 | Handle<JSFunction> getter); |
| 97 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 98 | Handle<Code> ComputeLoadConstant(Handle<String> name, |
| 99 | Handle<JSObject> receiver, |
| 100 | Handle<JSObject> holder, |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 101 | Handle<JSFunction> value); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 102 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 103 | Handle<Code> ComputeLoadInterceptor(Handle<String> name, |
| 104 | Handle<JSObject> receiver, |
| 105 | Handle<JSObject> holder); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 106 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 107 | Handle<Code> ComputeLoadNormal(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 108 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 109 | Handle<Code> ComputeLoadGlobal(Handle<String> name, |
| 110 | Handle<JSObject> receiver, |
| 111 | Handle<GlobalObject> holder, |
| 112 | Handle<JSGlobalPropertyCell> cell, |
| 113 | bool is_dont_delete); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 114 | |
| 115 | // --- |
| 116 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 117 | Handle<Code> ComputeKeyedLoadField(Handle<String> name, |
| 118 | Handle<JSObject> receiver, |
| 119 | Handle<JSObject> holder, |
| 120 | int field_index); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 121 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 122 | Handle<Code> ComputeKeyedLoadCallback(Handle<String> name, |
| 123 | Handle<JSObject> receiver, |
| 124 | Handle<JSObject> holder, |
| 125 | Handle<AccessorInfo> callback); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 126 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 127 | Handle<Code> ComputeKeyedLoadConstant(Handle<String> name, |
| 128 | Handle<JSObject> receiver, |
| 129 | Handle<JSObject> holder, |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 130 | Handle<JSFunction> value); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 131 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 132 | Handle<Code> ComputeKeyedLoadInterceptor(Handle<String> name, |
| 133 | Handle<JSObject> receiver, |
| 134 | Handle<JSObject> holder); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 135 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 136 | Handle<Code> ComputeKeyedLoadArrayLength(Handle<String> name, |
| 137 | Handle<JSArray> receiver); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 138 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 139 | Handle<Code> ComputeKeyedLoadStringLength(Handle<String> name, |
| 140 | Handle<String> receiver); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 141 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 142 | Handle<Code> ComputeKeyedLoadFunctionPrototype(Handle<String> name, |
| 143 | Handle<JSFunction> receiver); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 144 | |
| 145 | // --- |
| 146 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 147 | Handle<Code> ComputeStoreField(Handle<String> name, |
| 148 | Handle<JSObject> receiver, |
| 149 | int field_index, |
| 150 | Handle<Map> transition, |
| 151 | StrictModeFlag strict_mode); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 152 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 153 | Handle<Code> ComputeStoreNormal(StrictModeFlag strict_mode); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 154 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 155 | Handle<Code> ComputeStoreGlobal(Handle<String> name, |
| 156 | Handle<GlobalObject> receiver, |
| 157 | Handle<JSGlobalPropertyCell> cell, |
| 158 | StrictModeFlag strict_mode); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 159 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 160 | Handle<Code> ComputeStoreCallback(Handle<String> name, |
| 161 | Handle<JSObject> receiver, |
| 162 | Handle<AccessorInfo> callback, |
| 163 | StrictModeFlag strict_mode); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 164 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 165 | Handle<Code> ComputeStoreViaSetter(Handle<String> name, |
| 166 | Handle<JSObject> receiver, |
svenpanne@chromium.org | 619781a | 2012-07-05 08:22:44 +0000 | [diff] [blame] | 167 | Handle<JSObject> holder, |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 168 | Handle<JSFunction> setter, |
| 169 | StrictModeFlag strict_mode); |
| 170 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 171 | Handle<Code> ComputeStoreInterceptor(Handle<String> name, |
| 172 | Handle<JSObject> receiver, |
| 173 | StrictModeFlag strict_mode); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 174 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 175 | // --- |
| 176 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 177 | Handle<Code> ComputeKeyedStoreField(Handle<String> name, |
| 178 | Handle<JSObject> receiver, |
| 179 | int field_index, |
| 180 | Handle<Map> transition, |
| 181 | StrictModeFlag strict_mode); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 182 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 183 | Handle<Code> ComputeKeyedLoadOrStoreElement(Handle<Map> receiver_map, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 184 | KeyedIC::StubKind stub_kind, |
| 185 | StrictModeFlag strict_mode); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 186 | |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 187 | // --- |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 188 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 189 | Handle<Code> ComputeCallField(int argc, |
| 190 | Code::Kind, |
| 191 | Code::ExtraICState extra_state, |
| 192 | Handle<String> name, |
| 193 | Handle<Object> object, |
| 194 | Handle<JSObject> holder, |
| 195 | int index); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 196 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 197 | Handle<Code> ComputeCallConstant(int argc, |
| 198 | Code::Kind, |
| 199 | Code::ExtraICState extra_state, |
| 200 | Handle<String> name, |
| 201 | Handle<Object> object, |
| 202 | Handle<JSObject> holder, |
| 203 | Handle<JSFunction> function); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 204 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 205 | Handle<Code> ComputeCallInterceptor(int argc, |
| 206 | Code::Kind, |
| 207 | Code::ExtraICState extra_state, |
| 208 | Handle<String> name, |
| 209 | Handle<Object> object, |
| 210 | Handle<JSObject> holder); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 211 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 212 | Handle<Code> ComputeCallGlobal(int argc, |
| 213 | Code::Kind, |
| 214 | Code::ExtraICState extra_state, |
| 215 | Handle<String> name, |
| 216 | Handle<JSObject> receiver, |
| 217 | Handle<GlobalObject> holder, |
| 218 | Handle<JSGlobalPropertyCell> cell, |
| 219 | Handle<JSFunction> function); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 220 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 221 | // --- |
| 222 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 223 | Handle<Code> ComputeCallInitialize(int argc, RelocInfo::Mode mode); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 224 | |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 225 | Handle<Code> ComputeKeyedCallInitialize(int argc); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 226 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 227 | Handle<Code> ComputeCallPreMonomorphic(int argc, |
| 228 | Code::Kind kind, |
| 229 | Code::ExtraICState extra_state); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 230 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 231 | Handle<Code> ComputeCallNormal(int argc, |
| 232 | Code::Kind kind, |
| 233 | Code::ExtraICState state); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 234 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 235 | Handle<Code> ComputeCallArguments(int argc, Code::Kind kind); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 236 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 237 | Handle<Code> ComputeCallMegamorphic(int argc, |
| 238 | Code::Kind kind, |
| 239 | Code::ExtraICState state); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 240 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 241 | Handle<Code> ComputeCallMiss(int argc, |
| 242 | Code::Kind kind, |
| 243 | Code::ExtraICState state); |
| 244 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 245 | // Finds the Code object stored in the Heap::non_monomorphic_cache(). |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 246 | Code* FindCallInitialize(int argc, RelocInfo::Mode mode, Code::Kind kind); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 247 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 248 | #ifdef ENABLE_DEBUGGER_SUPPORT |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 249 | Handle<Code> ComputeCallDebugBreak(int argc, Code::Kind kind); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 250 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 251 | Handle<Code> ComputeCallDebugPrepareStepIn(int argc, Code::Kind kind); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 252 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 253 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 254 | // Update cache for entry hash(name, map). |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 255 | Code* Set(String* name, Map* map, Code* code); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 256 | |
| 257 | // Clear the lookup table (@ mark compact collection). |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 258 | void Clear(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 259 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 260 | // Collect all maps that match the name and flags. |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 261 | void CollectMatchingMaps(SmallMapList* types, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 262 | String* name, |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 263 | Code::Flags flags, |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 264 | Handle<Context> global_context, |
| 265 | Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 266 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 267 | // Generate code for probing the stub cache table. |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 268 | // Arguments extra, extra2 and extra3 may be used to pass additional scratch |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 269 | // registers. Set to no_reg if not needed. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 270 | void GenerateProbe(MacroAssembler* masm, |
| 271 | Code::Flags flags, |
| 272 | Register receiver, |
| 273 | Register name, |
| 274 | Register scratch, |
| 275 | Register extra, |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 276 | Register extra2 = no_reg, |
| 277 | Register extra3 = no_reg); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 278 | |
| 279 | enum Table { |
| 280 | kPrimary, |
| 281 | kSecondary |
| 282 | }; |
| 283 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 284 | |
| 285 | SCTableReference key_reference(StubCache::Table table) { |
| 286 | return SCTableReference( |
| 287 | reinterpret_cast<Address>(&first_entry(table)->key)); |
| 288 | } |
| 289 | |
| 290 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 291 | SCTableReference map_reference(StubCache::Table table) { |
| 292 | return SCTableReference( |
| 293 | reinterpret_cast<Address>(&first_entry(table)->map)); |
| 294 | } |
| 295 | |
| 296 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 297 | SCTableReference value_reference(StubCache::Table table) { |
| 298 | return SCTableReference( |
| 299 | reinterpret_cast<Address>(&first_entry(table)->value)); |
| 300 | } |
| 301 | |
| 302 | |
| 303 | StubCache::Entry* first_entry(StubCache::Table table) { |
| 304 | switch (table) { |
| 305 | case StubCache::kPrimary: return StubCache::primary_; |
| 306 | case StubCache::kSecondary: return StubCache::secondary_; |
| 307 | } |
| 308 | UNREACHABLE(); |
| 309 | return NULL; |
| 310 | } |
| 311 | |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 312 | Isolate* isolate() { return isolate_; } |
| 313 | Heap* heap() { return isolate()->heap(); } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 314 | Factory* factory() { return isolate()->factory(); } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 315 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 316 | private: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 317 | StubCache(Isolate* isolate, Zone* zone); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 318 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 319 | Handle<Code> ComputeCallInitialize(int argc, |
| 320 | RelocInfo::Mode mode, |
| 321 | Code::Kind kind); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 322 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 323 | // The stub cache has a primary and secondary level. The two levels have |
| 324 | // different hashing algorithms in order to avoid simultaneous collisions |
| 325 | // in both caches. Unlike a probing strategy (quadratic or otherwise) the |
| 326 | // update strategy on updates is fairly clear and simple: Any existing entry |
| 327 | // in the primary cache is moved to the secondary cache, and secondary cache |
| 328 | // entries are overwritten. |
| 329 | |
| 330 | // Hash algorithm for the primary table. This algorithm is replicated in |
| 331 | // assembler for every architecture. Returns an index into the table that |
| 332 | // is scaled by 1 << kHeapObjectTagSize. |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 333 | static int PrimaryOffset(String* name, Code::Flags flags, Map* map) { |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 334 | // This works well because the heap object tag size and the hash |
| 335 | // shift are equal. Shifting down the length field to get the |
| 336 | // hash code would effectively throw away two bits of the hash |
| 337 | // code. |
yangguo@chromium.org | 80c42ed | 2011-08-31 09:03:56 +0000 | [diff] [blame] | 338 | STATIC_ASSERT(kHeapObjectTagSize == String::kHashShift); |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 339 | // Compute the hash of the name (use entire hash field). |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 340 | ASSERT(name->HasHashCode()); |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 341 | uint32_t field = name->hash_field(); |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 342 | // Using only the low bits in 64-bit mode is unlikely to increase the |
| 343 | // risk of collision even if the heap is spread over an area larger than |
| 344 | // 4Gb (and not at all if it isn't). |
| 345 | uint32_t map_low32bits = |
| 346 | static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map)); |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 347 | // We always set the in_loop bit to zero when generating the lookup code |
| 348 | // so do it here too so the hash codes match. |
| 349 | uint32_t iflags = |
| 350 | (static_cast<uint32_t>(flags) & ~Code::kFlagsNotUsedInLookup); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 351 | // Base the offset on a simple combination of name, flags, and map. |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 352 | uint32_t key = (map_low32bits + field) ^ iflags; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 353 | return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize); |
| 354 | } |
| 355 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 356 | // Hash algorithm for the secondary table. This algorithm is replicated in |
| 357 | // assembler for every architecture. Returns an index into the table that |
| 358 | // is scaled by 1 << kHeapObjectTagSize. |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 359 | static int SecondaryOffset(String* name, Code::Flags flags, int seed) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 360 | // Use the seed from the primary cache in the secondary cache. |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 361 | uint32_t string_low32bits = |
| 362 | static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name)); |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 363 | // We always set the in_loop bit to zero when generating the lookup code |
| 364 | // so do it here too so the hash codes match. |
| 365 | uint32_t iflags = |
| 366 | (static_cast<uint32_t>(flags) & ~Code::kFlagsNotUsedInLookup); |
| 367 | uint32_t key = (seed - string_low32bits) + iflags; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 368 | return key & ((kSecondaryTableSize - 1) << kHeapObjectTagSize); |
| 369 | } |
| 370 | |
| 371 | // Compute the entry for a given offset in exactly the same way as |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 372 | // we do in generated code. We generate an hash code that already |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 373 | // ends in String::kHashShift 0s. Then we multiply it so it is a multiple |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 374 | // of sizeof(Entry). This makes it easier to avoid making mistakes |
| 375 | // in the hashed offset computations. |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 376 | static Entry* entry(Entry* table, int offset) { |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 377 | const int multiplier = sizeof(*table) >> String::kHashShift; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 378 | return reinterpret_cast<Entry*>( |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 379 | reinterpret_cast<Address>(table) + offset * multiplier); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 380 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 381 | |
jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 382 | static const int kPrimaryTableBits = 11; |
| 383 | static const int kPrimaryTableSize = (1 << kPrimaryTableBits); |
| 384 | static const int kSecondaryTableBits = 9; |
| 385 | static const int kSecondaryTableSize = (1 << kSecondaryTableBits); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 386 | |
| 387 | Entry primary_[kPrimaryTableSize]; |
| 388 | Entry secondary_[kSecondaryTableSize]; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 389 | Isolate* isolate_; |
| 390 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 391 | friend class Isolate; |
| 392 | friend class SCTableReference; |
| 393 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 394 | DISALLOW_COPY_AND_ASSIGN(StubCache); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 395 | }; |
| 396 | |
| 397 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 398 | // ------------------------------------------------------------------------ |
| 399 | |
| 400 | |
| 401 | // Support functions for IC stubs for callbacks. |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 402 | DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadCallbackProperty); |
| 403 | DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 404 | |
| 405 | |
| 406 | // Support functions for IC stubs for interceptors. |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 407 | DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly); |
| 408 | DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad); |
| 409 | DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall); |
| 410 | DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty); |
| 411 | DECLARE_RUNTIME_FUNCTION(MaybeObject*, CallInterceptorProperty); |
| 412 | DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 413 | |
| 414 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 415 | // The stub compilers compile stubs for the stub cache. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 416 | class StubCompiler BASE_EMBEDDED { |
| 417 | public: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 418 | explicit StubCompiler(Isolate* isolate) |
| 419 | : isolate_(isolate), masm_(isolate, NULL, 256), failure_(NULL) { } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 420 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 421 | // Functions to compile either CallIC or KeyedCallIC. The specific kind |
| 422 | // is extracted from the code flags. |
| 423 | Handle<Code> CompileCallInitialize(Code::Flags flags); |
| 424 | Handle<Code> CompileCallPreMonomorphic(Code::Flags flags); |
| 425 | Handle<Code> CompileCallNormal(Code::Flags flags); |
| 426 | Handle<Code> CompileCallMegamorphic(Code::Flags flags); |
| 427 | Handle<Code> CompileCallArguments(Code::Flags flags); |
| 428 | Handle<Code> CompileCallMiss(Code::Flags flags); |
| 429 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 430 | #ifdef ENABLE_DEBUGGER_SUPPORT |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 431 | Handle<Code> CompileCallDebugBreak(Code::Flags flags); |
| 432 | Handle<Code> CompileCallDebugPrepareStepIn(Code::Flags flags); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 433 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 434 | |
| 435 | // Static functions for generating parts of stubs. |
| 436 | static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, |
| 437 | int index, |
| 438 | Register prototype); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 439 | |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 440 | // Generates prototype loading code that uses the objects from the |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 441 | // context we were in when this function was called. If the context |
| 442 | // has changed, a jump to miss is performed. This ties the generated |
| 443 | // code to a particular context and so must not be used in cases |
| 444 | // where the generated code is not allowed to have references to |
| 445 | // objects from a context. |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 446 | static void GenerateDirectLoadGlobalFunctionPrototype(MacroAssembler* masm, |
| 447 | int index, |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 448 | Register prototype, |
| 449 | Label* miss); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 450 | |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 451 | static void GenerateFastPropertyLoad(MacroAssembler* masm, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 452 | Register dst, |
| 453 | Register src, |
| 454 | Handle<JSObject> holder, |
| 455 | int index); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 456 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 457 | static void GenerateLoadArrayLength(MacroAssembler* masm, |
| 458 | Register receiver, |
| 459 | Register scratch, |
| 460 | Label* miss_label); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 461 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 462 | static void GenerateLoadStringLength(MacroAssembler* masm, |
| 463 | Register receiver, |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 464 | Register scratch1, |
| 465 | Register scratch2, |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 466 | Label* miss_label, |
| 467 | bool support_wrappers); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 468 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 469 | static void GenerateLoadFunctionPrototype(MacroAssembler* masm, |
| 470 | Register receiver, |
| 471 | Register scratch1, |
| 472 | Register scratch2, |
| 473 | Label* miss_label); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 474 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 475 | void GenerateStoreField(MacroAssembler* masm, |
| 476 | Handle<JSObject> object, |
| 477 | int index, |
| 478 | Handle<Map> transition, |
| 479 | Handle<String> name, |
| 480 | Register receiver_reg, |
| 481 | Register name_reg, |
| 482 | Register scratch1, |
| 483 | Register scratch2, |
| 484 | Label* miss_label); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 485 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 486 | static void GenerateLoadMiss(MacroAssembler* masm, |
| 487 | Code::Kind kind); |
| 488 | |
| 489 | static void GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 490 | |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 491 | // Generates code that verifies that the property holder has not changed |
| 492 | // (checking maps of objects in the prototype chain for fast and global |
| 493 | // objects or doing negative lookup for slow objects, ensures that the |
| 494 | // property cells for global objects are still empty) and checks that the map |
| 495 | // of the holder has not changed. If necessary the function also generates |
| 496 | // code for security check in case of global object holders. Helps to make |
| 497 | // sure that the current IC is still valid. |
| 498 | // |
| 499 | // The scratch and holder registers are always clobbered, but the object |
| 500 | // register is only clobbered if it the same as the holder register. The |
| 501 | // function returns a register containing the holder - either object_reg or |
| 502 | // holder_reg. |
| 503 | // The function can optionally (when save_at_depth != |
| 504 | // kInvalidProtoDepth) save the object at the given depth by moving |
| 505 | // it to [esp + kPointerSize]. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 506 | Register CheckPrototypes(Handle<JSObject> object, |
| 507 | Register object_reg, |
| 508 | Handle<JSObject> holder, |
| 509 | Register holder_reg, |
| 510 | Register scratch1, |
| 511 | Register scratch2, |
| 512 | Handle<String> name, |
| 513 | Label* miss) { |
| 514 | return CheckPrototypes(object, object_reg, holder, holder_reg, scratch1, |
| 515 | scratch2, name, kInvalidProtoDepth, miss); |
| 516 | } |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 517 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 518 | Register CheckPrototypes(Handle<JSObject> object, |
| 519 | Register object_reg, |
| 520 | Handle<JSObject> holder, |
| 521 | Register holder_reg, |
| 522 | Register scratch1, |
| 523 | Register scratch2, |
| 524 | Handle<String> name, |
| 525 | int save_at_depth, |
| 526 | Label* miss); |
| 527 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 528 | |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 529 | protected: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 530 | Handle<Code> GetCodeWithFlags(Code::Flags flags, const char* name); |
| 531 | Handle<Code> GetCodeWithFlags(Code::Flags flags, Handle<String> name); |
| 532 | |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 533 | MacroAssembler* masm() { return &masm_; } |
| 534 | void set_failure(Failure* failure) { failure_ = failure; } |
| 535 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 536 | void GenerateLoadField(Handle<JSObject> object, |
| 537 | Handle<JSObject> holder, |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 538 | Register receiver, |
| 539 | Register scratch1, |
| 540 | Register scratch2, |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 541 | Register scratch3, |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 542 | int index, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 543 | Handle<String> name, |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 544 | Label* miss); |
| 545 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 546 | void GenerateLoadCallback(Handle<JSObject> object, |
| 547 | Handle<JSObject> holder, |
| 548 | Register receiver, |
| 549 | Register name_reg, |
| 550 | Register scratch1, |
| 551 | Register scratch2, |
| 552 | Register scratch3, |
| 553 | Handle<AccessorInfo> callback, |
| 554 | Handle<String> name, |
| 555 | Label* miss); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 556 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 557 | void GenerateLoadConstant(Handle<JSObject> object, |
| 558 | Handle<JSObject> holder, |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 559 | Register receiver, |
| 560 | Register scratch1, |
| 561 | Register scratch2, |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 562 | Register scratch3, |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 563 | Handle<JSFunction> value, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 564 | Handle<String> name, |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 565 | Label* miss); |
| 566 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 567 | void GenerateLoadInterceptor(Handle<JSObject> object, |
| 568 | Handle<JSObject> holder, |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 569 | LookupResult* lookup, |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 570 | Register receiver, |
| 571 | Register name_reg, |
| 572 | Register scratch1, |
| 573 | Register scratch2, |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 574 | Register scratch3, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 575 | Handle<String> name, |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 576 | Label* miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 577 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 578 | static void LookupPostInterceptor(Handle<JSObject> holder, |
| 579 | Handle<String> name, |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 580 | LookupResult* lookup); |
| 581 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 582 | Isolate* isolate() { return isolate_; } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 583 | Heap* heap() { return isolate()->heap(); } |
| 584 | Factory* factory() { return isolate()->factory(); } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 585 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 586 | private: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 587 | Isolate* isolate_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 588 | MacroAssembler masm_; |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 589 | Failure* failure_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 590 | }; |
| 591 | |
| 592 | |
| 593 | class LoadStubCompiler: public StubCompiler { |
| 594 | public: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 595 | explicit LoadStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 596 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 597 | Handle<Code> CompileLoadNonexistent(Handle<String> name, |
| 598 | Handle<JSObject> object, |
| 599 | Handle<JSObject> last); |
| 600 | |
| 601 | Handle<Code> CompileLoadField(Handle<JSObject> object, |
| 602 | Handle<JSObject> holder, |
| 603 | int index, |
| 604 | Handle<String> name); |
| 605 | |
| 606 | Handle<Code> CompileLoadCallback(Handle<String> name, |
| 607 | Handle<JSObject> object, |
| 608 | Handle<JSObject> holder, |
| 609 | Handle<AccessorInfo> callback); |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 610 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 611 | Handle<Code> CompileLoadViaGetter(Handle<String> name, |
| 612 | Handle<JSObject> receiver, |
| 613 | Handle<JSObject> holder, |
| 614 | Handle<JSFunction> getter); |
| 615 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 616 | Handle<Code> CompileLoadConstant(Handle<JSObject> object, |
| 617 | Handle<JSObject> holder, |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 618 | Handle<JSFunction> value, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 619 | Handle<String> name); |
| 620 | |
| 621 | Handle<Code> CompileLoadInterceptor(Handle<JSObject> object, |
| 622 | Handle<JSObject> holder, |
| 623 | Handle<String> name); |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 624 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 625 | Handle<Code> CompileLoadGlobal(Handle<JSObject> object, |
| 626 | Handle<GlobalObject> holder, |
| 627 | Handle<JSGlobalPropertyCell> cell, |
| 628 | Handle<String> name, |
| 629 | bool is_dont_delete); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 630 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 631 | private: |
jkummerow@chromium.org | 7a6fc81 | 2012-06-27 11:12:38 +0000 | [diff] [blame] | 632 | Handle<Code> GetCode(Code::StubType type, Handle<String> name); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 633 | }; |
| 634 | |
| 635 | |
| 636 | class KeyedLoadStubCompiler: public StubCompiler { |
| 637 | public: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 638 | explicit KeyedLoadStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } |
| 639 | |
| 640 | Handle<Code> CompileLoadField(Handle<String> name, |
| 641 | Handle<JSObject> object, |
| 642 | Handle<JSObject> holder, |
| 643 | int index); |
| 644 | |
| 645 | Handle<Code> CompileLoadCallback(Handle<String> name, |
| 646 | Handle<JSObject> object, |
| 647 | Handle<JSObject> holder, |
| 648 | Handle<AccessorInfo> callback); |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 649 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 650 | Handle<Code> CompileLoadConstant(Handle<String> name, |
| 651 | Handle<JSObject> object, |
| 652 | Handle<JSObject> holder, |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 653 | Handle<JSFunction> value); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 654 | |
| 655 | Handle<Code> CompileLoadInterceptor(Handle<JSObject> object, |
| 656 | Handle<JSObject> holder, |
| 657 | Handle<String> name); |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 658 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 659 | Handle<Code> CompileLoadArrayLength(Handle<String> name); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 660 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 661 | Handle<Code> CompileLoadStringLength(Handle<String> name); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 662 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 663 | Handle<Code> CompileLoadFunctionPrototype(Handle<String> name); |
| 664 | |
| 665 | Handle<Code> CompileLoadElement(Handle<Map> receiver_map); |
| 666 | |
| 667 | Handle<Code> CompileLoadPolymorphic(MapHandleList* receiver_maps, |
| 668 | CodeHandleList* handler_ics); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 669 | |
| 670 | static void GenerateLoadExternalArray(MacroAssembler* masm, |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 671 | ElementsKind elements_kind); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 672 | |
| 673 | static void GenerateLoadFastElement(MacroAssembler* masm); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 674 | |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 675 | static void GenerateLoadFastDoubleElement(MacroAssembler* masm); |
| 676 | |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 677 | static void GenerateLoadDictionaryElement(MacroAssembler* masm); |
| 678 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 679 | private: |
jkummerow@chromium.org | 7a6fc81 | 2012-06-27 11:12:38 +0000 | [diff] [blame] | 680 | Handle<Code> GetCode(Code::StubType type, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 681 | Handle<String> name, |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 682 | InlineCacheState state = MONOMORPHIC); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 683 | }; |
| 684 | |
| 685 | |
| 686 | class StoreStubCompiler: public StubCompiler { |
| 687 | public: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 688 | StoreStubCompiler(Isolate* isolate, StrictModeFlag strict_mode) |
| 689 | : StubCompiler(isolate), strict_mode_(strict_mode) { } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 690 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 691 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 692 | Handle<Code> CompileStoreField(Handle<JSObject> object, |
| 693 | int index, |
| 694 | Handle<Map> transition, |
| 695 | Handle<String> name); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 696 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 697 | Handle<Code> CompileStoreCallback(Handle<JSObject> object, |
| 698 | Handle<AccessorInfo> callback, |
| 699 | Handle<String> name); |
| 700 | |
svenpanne@chromium.org | 619781a | 2012-07-05 08:22:44 +0000 | [diff] [blame] | 701 | Handle<Code> CompileStoreViaSetter(Handle<String> name, |
| 702 | Handle<JSObject> receiver, |
| 703 | Handle<JSObject> holder, |
| 704 | Handle<JSFunction> setter); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 705 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 706 | Handle<Code> CompileStoreInterceptor(Handle<JSObject> object, |
| 707 | Handle<String> name); |
| 708 | |
| 709 | Handle<Code> CompileStoreGlobal(Handle<GlobalObject> object, |
| 710 | Handle<JSGlobalPropertyCell> holder, |
| 711 | Handle<String> name); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 712 | |
| 713 | private: |
jkummerow@chromium.org | 7a6fc81 | 2012-06-27 11:12:38 +0000 | [diff] [blame] | 714 | Handle<Code> GetCode(Code::StubType type, Handle<String> name); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 715 | |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 716 | StrictModeFlag strict_mode_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 717 | }; |
| 718 | |
| 719 | |
| 720 | class KeyedStoreStubCompiler: public StubCompiler { |
| 721 | public: |
ulan@chromium.org | 65a89c2 | 2012-02-14 11:46:07 +0000 | [diff] [blame] | 722 | KeyedStoreStubCompiler(Isolate* isolate, |
| 723 | StrictModeFlag strict_mode, |
| 724 | KeyedAccessGrowMode grow_mode) |
| 725 | : StubCompiler(isolate), |
| 726 | strict_mode_(strict_mode), |
| 727 | grow_mode_(grow_mode) { } |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 728 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 729 | Handle<Code> CompileStoreField(Handle<JSObject> object, |
| 730 | int index, |
| 731 | Handle<Map> transition, |
| 732 | Handle<String> name); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 733 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 734 | Handle<Code> CompileStoreElement(Handle<Map> receiver_map); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 735 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 736 | Handle<Code> CompileStorePolymorphic(MapHandleList* receiver_maps, |
| 737 | CodeHandleList* handler_stubs, |
| 738 | MapHandleList* transitioned_maps); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 739 | |
| 740 | static void GenerateStoreFastElement(MacroAssembler* masm, |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 741 | bool is_js_array, |
ulan@chromium.org | 65a89c2 | 2012-02-14 11:46:07 +0000 | [diff] [blame] | 742 | ElementsKind element_kind, |
| 743 | KeyedAccessGrowMode grow_mode); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 744 | |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 745 | static void GenerateStoreFastDoubleElement(MacroAssembler* masm, |
ulan@chromium.org | 65a89c2 | 2012-02-14 11:46:07 +0000 | [diff] [blame] | 746 | bool is_js_array, |
| 747 | KeyedAccessGrowMode grow_mode); |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 748 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 749 | static void GenerateStoreExternalArray(MacroAssembler* masm, |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 750 | ElementsKind elements_kind); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 751 | |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 752 | static void GenerateStoreDictionaryElement(MacroAssembler* masm); |
| 753 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 754 | private: |
jkummerow@chromium.org | 7a6fc81 | 2012-06-27 11:12:38 +0000 | [diff] [blame] | 755 | Handle<Code> GetCode(Code::StubType type, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 756 | Handle<String> name, |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 757 | InlineCacheState state = MONOMORPHIC); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 758 | |
| 759 | StrictModeFlag strict_mode_; |
ulan@chromium.org | 65a89c2 | 2012-02-14 11:46:07 +0000 | [diff] [blame] | 760 | KeyedAccessGrowMode grow_mode_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 761 | }; |
| 762 | |
| 763 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 764 | // Subset of FUNCTIONS_WITH_ID_LIST with custom constant/global call |
| 765 | // IC stubs. |
| 766 | #define CUSTOM_CALL_IC_GENERATORS(V) \ |
| 767 | V(ArrayPush) \ |
| 768 | V(ArrayPop) \ |
| 769 | V(StringCharCodeAt) \ |
| 770 | V(StringCharAt) \ |
| 771 | V(StringFromCharCode) \ |
| 772 | V(MathFloor) \ |
| 773 | V(MathAbs) |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 774 | |
| 775 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 776 | class CallOptimization; |
| 777 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 778 | class CallStubCompiler: public StubCompiler { |
| 779 | public: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 780 | CallStubCompiler(Isolate* isolate, |
| 781 | int argc, |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 782 | Code::Kind kind, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 783 | Code::ExtraICState extra_state, |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 784 | InlineCacheHolderFlag cache_holder); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 785 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 786 | Handle<Code> CompileCallField(Handle<JSObject> object, |
| 787 | Handle<JSObject> holder, |
| 788 | int index, |
| 789 | Handle<String> name); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 790 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 791 | Handle<Code> CompileCallConstant(Handle<Object> object, |
| 792 | Handle<JSObject> holder, |
| 793 | Handle<JSFunction> function, |
| 794 | Handle<String> name, |
| 795 | CheckType check); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 796 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 797 | Handle<Code> CompileCallInterceptor(Handle<JSObject> object, |
| 798 | Handle<JSObject> holder, |
| 799 | Handle<String> name); |
| 800 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 801 | Handle<Code> CompileCallGlobal(Handle<JSObject> object, |
| 802 | Handle<GlobalObject> holder, |
| 803 | Handle<JSGlobalPropertyCell> cell, |
| 804 | Handle<JSFunction> function, |
| 805 | Handle<String> name); |
| 806 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 807 | static bool HasCustomCallGenerator(Handle<JSFunction> function); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 808 | |
| 809 | private: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 810 | // Compiles a custom call constant/global IC. For constant calls cell is |
| 811 | // NULL. Returns an empty handle if there is no custom call code for the |
| 812 | // given function. |
| 813 | Handle<Code> CompileCustomCall(Handle<Object> object, |
| 814 | Handle<JSObject> holder, |
| 815 | Handle<JSGlobalPropertyCell> cell, |
| 816 | Handle<JSFunction> function, |
| 817 | Handle<String> name); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 818 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 819 | #define DECLARE_CALL_GENERATOR(name) \ |
| 820 | Handle<Code> Compile##name##Call(Handle<Object> object, \ |
| 821 | Handle<JSObject> holder, \ |
| 822 | Handle<JSGlobalPropertyCell> cell, \ |
| 823 | Handle<JSFunction> function, \ |
| 824 | Handle<String> fname); |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 825 | CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR) |
| 826 | #undef DECLARE_CALL_GENERATOR |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 827 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 828 | Handle<Code> CompileFastApiCall(const CallOptimization& optimization, |
| 829 | Handle<Object> object, |
| 830 | Handle<JSObject> holder, |
| 831 | Handle<JSGlobalPropertyCell> cell, |
| 832 | Handle<JSFunction> function, |
| 833 | Handle<String> name); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 834 | |
jkummerow@chromium.org | 7a6fc81 | 2012-06-27 11:12:38 +0000 | [diff] [blame] | 835 | Handle<Code> GetCode(Code::StubType type, Handle<String> name); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 836 | Handle<Code> GetCode(Handle<JSFunction> function); |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 837 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 838 | const ParameterCount& arguments() { return arguments_; } |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 839 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 840 | void GenerateNameCheck(Handle<String> name, Label* miss); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 841 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 842 | void GenerateGlobalReceiverCheck(Handle<JSObject> object, |
| 843 | Handle<JSObject> holder, |
| 844 | Handle<String> name, |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 845 | Label* miss); |
| 846 | |
| 847 | // Generates code to load the function from the cell checking that |
| 848 | // it still contains the same function. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 849 | void GenerateLoadFunctionFromCell(Handle<JSGlobalPropertyCell> cell, |
| 850 | Handle<JSFunction> function, |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 851 | Label* miss); |
| 852 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 853 | // Generates a jump to CallIC miss stub. |
| 854 | void GenerateMissBranch(); |
| 855 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 856 | const ParameterCount arguments_; |
| 857 | const Code::Kind kind_; |
| 858 | const Code::ExtraICState extra_state_; |
| 859 | const InlineCacheHolderFlag cache_holder_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 860 | }; |
| 861 | |
| 862 | |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 863 | class ConstructStubCompiler: public StubCompiler { |
| 864 | public: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 865 | explicit ConstructStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 866 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 867 | Handle<Code> CompileConstructStub(Handle<JSFunction> function); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 868 | |
| 869 | private: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 870 | Handle<Code> GetCode(); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 871 | }; |
| 872 | |
| 873 | |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 874 | // Holds information about possible function call optimizations. |
| 875 | class CallOptimization BASE_EMBEDDED { |
| 876 | public: |
| 877 | explicit CallOptimization(LookupResult* lookup); |
| 878 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 879 | explicit CallOptimization(Handle<JSFunction> function); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 880 | |
| 881 | bool is_constant_call() const { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 882 | return !constant_function_.is_null(); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 883 | } |
| 884 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 885 | Handle<JSFunction> constant_function() const { |
| 886 | ASSERT(is_constant_call()); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 887 | return constant_function_; |
| 888 | } |
| 889 | |
| 890 | bool is_simple_api_call() const { |
| 891 | return is_simple_api_call_; |
| 892 | } |
| 893 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 894 | Handle<FunctionTemplateInfo> expected_receiver_type() const { |
| 895 | ASSERT(is_simple_api_call()); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 896 | return expected_receiver_type_; |
| 897 | } |
| 898 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 899 | Handle<CallHandlerInfo> api_call_info() const { |
| 900 | ASSERT(is_simple_api_call()); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 901 | return api_call_info_; |
| 902 | } |
| 903 | |
| 904 | // Returns the depth of the object having the expected type in the |
| 905 | // prototype chain between the two arguments. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 906 | int GetPrototypeDepthOfExpectedType(Handle<JSObject> object, |
| 907 | Handle<JSObject> holder) const; |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 908 | |
| 909 | private: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 910 | void Initialize(Handle<JSFunction> function); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 911 | |
| 912 | // Determines whether the given function can be called using the |
| 913 | // fast api call builtin. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 914 | void AnalyzePossibleApiFunction(Handle<JSFunction> function); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 915 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 916 | Handle<JSFunction> constant_function_; |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 917 | bool is_simple_api_call_; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 918 | Handle<FunctionTemplateInfo> expected_receiver_type_; |
| 919 | Handle<CallHandlerInfo> api_call_info_; |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 920 | }; |
| 921 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 922 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 923 | } } // namespace v8::internal |
| 924 | |
| 925 | #endif // V8_STUB_CACHE_H_ |