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