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