ulan@chromium.org | 65a89c2 | 2012-02-14 11:46:07 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
sgjesse@chromium.org | df7a284 | 2010-03-25 14:34: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 | |
ricow@chromium.org | aa1b616 | 2010-03-29 07:44:58 +0000 | [diff] [blame] | 28 | #include "v8.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 29 | |
| 30 | #include "ast.h" |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 31 | #include "code-stubs.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 32 | #include "compiler.h" |
| 33 | #include "ic.h" |
| 34 | #include "macro-assembler.h" |
| 35 | #include "stub-cache.h" |
sgjesse@chromium.org | df7a284 | 2010-03-25 14:34:15 +0000 | [diff] [blame] | 36 | #include "type-info.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 37 | |
| 38 | #include "ic-inl.h" |
sgjesse@chromium.org | df7a284 | 2010-03-25 14:34:15 +0000 | [diff] [blame] | 39 | #include "objects-inl.h" |
| 40 | |
| 41 | namespace v8 { |
| 42 | namespace internal { |
| 43 | |
| 44 | |
| 45 | TypeInfo TypeInfo::TypeFromValue(Handle<Object> value) { |
| 46 | TypeInfo info; |
| 47 | if (value->IsSmi()) { |
| 48 | info = TypeInfo::Smi(); |
| 49 | } else if (value->IsHeapNumber()) { |
| 50 | info = TypeInfo::IsInt32Double(HeapNumber::cast(*value)->value()) |
| 51 | ? TypeInfo::Integer32() |
| 52 | : TypeInfo::Double(); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 53 | } else if (value->IsString()) { |
| 54 | info = TypeInfo::String(); |
sgjesse@chromium.org | df7a284 | 2010-03-25 14:34:15 +0000 | [diff] [blame] | 55 | } else { |
| 56 | info = TypeInfo::Unknown(); |
| 57 | } |
| 58 | return info; |
| 59 | } |
| 60 | |
| 61 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 62 | TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code, |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 63 | Handle<Context> native_context, |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 64 | Isolate* isolate, |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 65 | Zone* zone) |
| 66 | : native_context_(native_context), |
| 67 | isolate_(isolate), |
| 68 | zone_(zone) { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 69 | BuildDictionary(code); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 70 | ASSERT(dictionary_->IsDictionary()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 74 | static uint32_t IdToKey(TypeFeedbackId ast_id) { |
| 75 | return static_cast<uint32_t>(ast_id.ToInt()); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) { |
| 80 | int entry = dictionary_->FindEntry(IdToKey(ast_id)); |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 81 | return entry != UnseededNumberDictionary::kNotFound |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 82 | ? Handle<Object>(dictionary_->ValueAt(entry), isolate_) |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 83 | : Handle<Object>::cast(isolate_->factory()->undefined_value()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | |
jkummerow@chromium.org | 531dfe8 | 2012-03-20 13:01:16 +0000 | [diff] [blame] | 87 | bool TypeFeedbackOracle::LoadIsUninitialized(Property* expr) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 88 | Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); |
jkummerow@chromium.org | 531dfe8 | 2012-03-20 13:01:16 +0000 | [diff] [blame] | 89 | if (map_or_code->IsMap()) return false; |
| 90 | if (map_or_code->IsCode()) { |
| 91 | Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 92 | return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED; |
| 93 | } |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 98 | bool TypeFeedbackOracle::LoadIsMonomorphicNormal(Property* expr) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 99 | Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 100 | if (map_or_code->IsMap()) return true; |
| 101 | if (map_or_code->IsCode()) { |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 102 | Handle<Code> code = Handle<Code>::cast(map_or_code); |
erik.corry@gmail.com | 8876724 | 2012-08-08 14:43:45 +0000 | [diff] [blame] | 103 | bool preliminary_checks = code->is_keyed_load_stub() && |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 104 | code->ic_state() == MONOMORPHIC && |
erik.corry@gmail.com | 8876724 | 2012-08-08 14:43:45 +0000 | [diff] [blame] | 105 | Code::ExtractTypeFromFlags(code->flags()) == Code::NORMAL; |
| 106 | if (!preliminary_checks) return false; |
| 107 | Map* map = code->FindFirstMap(); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 108 | if (map == NULL) return false; |
| 109 | map = map->CurrentMapForDeprecated(); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 110 | return map != NULL && !CanRetainOtherContext(map, *native_context_); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 111 | } |
| 112 | return false; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 116 | bool TypeFeedbackOracle::LoadIsPolymorphic(Property* expr) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 117 | Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 118 | if (map_or_code->IsCode()) { |
| 119 | Handle<Code> code = Handle<Code>::cast(map_or_code); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 120 | return code->is_keyed_load_stub() && code->ic_state() == POLYMORPHIC; |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 121 | } |
| 122 | return false; |
| 123 | } |
| 124 | |
| 125 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 126 | bool TypeFeedbackOracle::StoreIsMonomorphicNormal(TypeFeedbackId ast_id) { |
| 127 | Handle<Object> map_or_code = GetInfo(ast_id); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 128 | if (map_or_code->IsMap()) return true; |
| 129 | if (map_or_code->IsCode()) { |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 130 | Handle<Code> code = Handle<Code>::cast(map_or_code); |
jkummerow@chromium.org | 7bd87f0 | 2013-03-20 18:06:29 +0000 | [diff] [blame] | 131 | bool standard_store = FLAG_compiled_keyed_stores || |
| 132 | (Code::GetKeyedAccessStoreMode(code->extra_ic_state()) == |
| 133 | STANDARD_STORE); |
erik.corry@gmail.com | 8876724 | 2012-08-08 14:43:45 +0000 | [diff] [blame] | 134 | bool preliminary_checks = |
| 135 | code->is_keyed_store_stub() && |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 136 | standard_store && |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 137 | code->ic_state() == MONOMORPHIC && |
erik.corry@gmail.com | 8876724 | 2012-08-08 14:43:45 +0000 | [diff] [blame] | 138 | Code::ExtractTypeFromFlags(code->flags()) == Code::NORMAL; |
| 139 | if (!preliminary_checks) return false; |
| 140 | Map* map = code->FindFirstMap(); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 141 | if (map == NULL) return false; |
| 142 | map = map->CurrentMapForDeprecated(); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 143 | return map != NULL && !CanRetainOtherContext(map, *native_context_); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 144 | } |
| 145 | return false; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 149 | bool TypeFeedbackOracle::StoreIsPolymorphic(TypeFeedbackId ast_id) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 150 | Handle<Object> map_or_code = GetInfo(ast_id); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 151 | if (map_or_code->IsCode()) { |
| 152 | Handle<Code> code = Handle<Code>::cast(map_or_code); |
jkummerow@chromium.org | 7bd87f0 | 2013-03-20 18:06:29 +0000 | [diff] [blame] | 153 | bool standard_store = FLAG_compiled_keyed_stores || |
| 154 | (Code::GetKeyedAccessStoreMode(code->extra_ic_state()) == |
| 155 | STANDARD_STORE); |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 156 | return code->is_keyed_store_stub() && standard_store && |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 157 | code->ic_state() == POLYMORPHIC; |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 158 | } |
| 159 | return false; |
| 160 | } |
| 161 | |
| 162 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 163 | bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 164 | Handle<Object> value = GetInfo(expr->CallFeedbackId()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 165 | return value->IsMap() || value->IsSmi() || value->IsJSFunction(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 169 | bool TypeFeedbackOracle::CallNewIsMonomorphic(CallNew* expr) { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 170 | Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); |
| 171 | if (info->IsSmi()) { |
| 172 | ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <= |
| 173 | LAST_FAST_ELEMENTS_KIND); |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 174 | return isolate_->global_context()->array_function(); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 175 | } |
| 176 | return info->IsJSFunction(); |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | |
mstarzinger@chromium.org | 3233d2f | 2012-03-14 11:16:03 +0000 | [diff] [blame] | 180 | bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic( |
| 181 | ObjectLiteral::Property* prop) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 182 | Handle<Object> map_or_code = GetInfo(prop->key()->LiteralFeedbackId()); |
mstarzinger@chromium.org | 3233d2f | 2012-03-14 11:16:03 +0000 | [diff] [blame] | 183 | return map_or_code->IsMap(); |
| 184 | } |
| 185 | |
| 186 | |
jkummerow@chromium.org | c118402 | 2013-05-28 16:58:15 +0000 | [diff] [blame] | 187 | byte TypeFeedbackOracle::ForInType(ForInStatement* stmt) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 188 | Handle<Object> value = GetInfo(stmt->ForInFeedbackId()); |
ulan@chromium.org | 9a21ec4 | 2012-03-06 08:42:24 +0000 | [diff] [blame] | 189 | return value->IsSmi() && |
jkummerow@chromium.org | c118402 | 2013-05-28 16:58:15 +0000 | [diff] [blame] | 190 | Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker |
| 191 | ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; |
ulan@chromium.org | 9a21ec4 | 2012-03-06 08:42:24 +0000 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 195 | Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) { |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 196 | ASSERT(LoadIsMonomorphicNormal(expr)); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 197 | Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId()); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 198 | if (map_or_code->IsCode()) { |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 199 | Handle<Code> code = Handle<Code>::cast(map_or_code); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 200 | Map* map = code->FindFirstMap()->CurrentMapForDeprecated(); |
| 201 | return map == NULL || CanRetainOtherContext(map, *native_context_) |
danno@chromium.org | e78f9fc | 2011-12-21 08:29:34 +0000 | [diff] [blame] | 202 | ? Handle<Map>::null() |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 203 | : Handle<Map>(map); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 204 | } |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 205 | return Handle<Map>::cast(map_or_code); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 209 | Handle<Map> TypeFeedbackOracle::StoreMonomorphicReceiverType( |
| 210 | TypeFeedbackId ast_id) { |
| 211 | ASSERT(StoreIsMonomorphicNormal(ast_id)); |
| 212 | Handle<Object> map_or_code = GetInfo(ast_id); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 213 | if (map_or_code->IsCode()) { |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 214 | Handle<Code> code = Handle<Code>::cast(map_or_code); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 215 | Map* map = code->FindFirstMap()->CurrentMapForDeprecated(); |
| 216 | return map == NULL || CanRetainOtherContext(map, *native_context_) |
danno@chromium.org | e78f9fc | 2011-12-21 08:29:34 +0000 | [diff] [blame] | 217 | ? Handle<Map>::null() |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 218 | : Handle<Map>(map); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 219 | } |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 220 | return Handle<Map>::cast(map_or_code); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 224 | Handle<Map> TypeFeedbackOracle::CompareNilMonomorphicReceiverType( |
jkummerow@chromium.org | c118402 | 2013-05-28 16:58:15 +0000 | [diff] [blame] | 225 | CompareOperation* expr) { |
| 226 | Handle<Object> maybe_code = GetInfo(expr->CompareOperationFeedbackId()); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 227 | if (maybe_code->IsCode()) { |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 228 | Map* map = Handle<Code>::cast(maybe_code)->FindFirstMap(); |
| 229 | if (map == NULL) return Handle<Map>(); |
| 230 | map = map->CurrentMapForDeprecated(); |
| 231 | return map == NULL || CanRetainOtherContext(map, *native_context_) |
| 232 | ? Handle<Map>() |
| 233 | : Handle<Map>(map); |
| 234 | } else if (maybe_code->IsMap()) { |
| 235 | ASSERT(!Handle<Map>::cast(maybe_code)->is_deprecated()); |
| 236 | return Handle<Map>::cast(maybe_code); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 237 | } |
| 238 | return Handle<Map>(); |
| 239 | } |
| 240 | |
| 241 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 242 | KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode( |
| 243 | TypeFeedbackId ast_id) { |
| 244 | Handle<Object> map_or_code = GetInfo(ast_id); |
| 245 | if (map_or_code->IsCode()) { |
| 246 | Handle<Code> code = Handle<Code>::cast(map_or_code); |
| 247 | if (code->kind() == Code::KEYED_STORE_IC) { |
| 248 | return Code::GetKeyedAccessStoreMode(code->extra_ic_state()); |
| 249 | } |
| 250 | } |
| 251 | return STANDARD_STORE; |
| 252 | } |
| 253 | |
| 254 | |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 255 | void TypeFeedbackOracle::LoadReceiverTypes(Property* expr, |
| 256 | Handle<String> name, |
| 257 | SmallMapList* types) { |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 258 | Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 259 | CollectReceiverTypes(expr->PropertyFeedbackId(), name, flags, types); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 263 | void TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr, |
| 264 | Handle<String> name, |
| 265 | SmallMapList* types) { |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 266 | Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 267 | CollectReceiverTypes(expr->AssignmentFeedbackId(), name, flags, types); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 271 | void TypeFeedbackOracle::CallReceiverTypes(Call* expr, |
| 272 | Handle<String> name, |
| 273 | CallKind call_kind, |
| 274 | SmallMapList* types) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 275 | int arity = expr->arguments()->length(); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 276 | |
| 277 | // Note: Currently we do not take string extra ic data into account |
| 278 | // here. |
| 279 | Code::ExtraICState extra_ic_state = |
| 280 | CallIC::Contextual::encode(call_kind == CALL_AS_FUNCTION); |
| 281 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 282 | Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 283 | extra_ic_state, |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 284 | Code::NORMAL, |
| 285 | arity, |
| 286 | OWN_MAP); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 287 | CollectReceiverTypes(expr->CallFeedbackId(), name, flags, types); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 291 | CheckType TypeFeedbackOracle::GetCallCheckType(Call* expr) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 292 | Handle<Object> value = GetInfo(expr->CallFeedbackId()); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 293 | if (!value->IsSmi()) return RECEIVER_MAP_CHECK; |
| 294 | CheckType check = static_cast<CheckType>(Smi::cast(*value)->value()); |
| 295 | ASSERT(check != RECEIVER_MAP_CHECK); |
| 296 | return check; |
| 297 | } |
| 298 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 299 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 300 | Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(Call* expr) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 301 | return Handle<JSFunction>::cast(GetInfo(expr->CallFeedbackId())); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 305 | Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(CallNew* expr) { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 306 | Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); |
| 307 | if (info->IsSmi()) { |
| 308 | ASSERT(static_cast<ElementsKind>(Smi::cast(*info)->value()) <= |
| 309 | LAST_FAST_ELEMENTS_KIND); |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 310 | return Handle<JSFunction>(isolate_->global_context()->array_function()); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 311 | } else { |
| 312 | return Handle<JSFunction>::cast(info); |
| 313 | } |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 317 | ElementsKind TypeFeedbackOracle::GetCallNewElementsKind(CallNew* expr) { |
| 318 | Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); |
| 319 | if (info->IsSmi()) { |
| 320 | return static_cast<ElementsKind>(Smi::cast(*info)->value()); |
| 321 | } else { |
| 322 | // TODO(mvstanton): avoided calling GetInitialFastElementsKind() for perf |
| 323 | // reasons. Is there a better fix? |
| 324 | if (FLAG_packed_arrays) { |
| 325 | return FAST_SMI_ELEMENTS; |
| 326 | } else { |
| 327 | return FAST_HOLEY_SMI_ELEMENTS; |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | |
mstarzinger@chromium.org | 3233d2f | 2012-03-14 11:16:03 +0000 | [diff] [blame] | 332 | Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap( |
| 333 | ObjectLiteral::Property* prop) { |
| 334 | ASSERT(ObjectLiteralStoreIsMonomorphic(prop)); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 335 | return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId())); |
mstarzinger@chromium.org | 3233d2f | 2012-03-14 11:16:03 +0000 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 339 | bool TypeFeedbackOracle::LoadIsBuiltin(Property* expr, Builtins::Name id) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 340 | return *GetInfo(expr->PropertyFeedbackId()) == |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 341 | isolate_->builtins()->builtin(id); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 345 | bool TypeFeedbackOracle::LoadIsStub(Property* expr, ICStub* stub) { |
| 346 | Handle<Object> object = GetInfo(expr->PropertyFeedbackId()); |
| 347 | if (!object->IsCode()) return false; |
| 348 | Handle<Code> code = Handle<Code>::cast(object); |
| 349 | if (!code->is_load_stub()) return false; |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 350 | if (code->ic_state() != MONOMORPHIC) return false; |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 351 | return stub->Describes(*code); |
| 352 | } |
| 353 | |
| 354 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 355 | static TypeInfo TypeFromCompareType(CompareIC::State state) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 356 | switch (state) { |
| 357 | case CompareIC::UNINITIALIZED: |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 358 | // Uninitialized means never executed. |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 359 | return TypeInfo::Uninitialized(); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 360 | case CompareIC::SMI: |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 361 | return TypeInfo::Smi(); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 362 | case CompareIC::NUMBER: |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 363 | return TypeInfo::Number(); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 364 | case CompareIC::INTERNALIZED_STRING: |
| 365 | return TypeInfo::InternalizedString(); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 366 | case CompareIC::STRING: |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 367 | return TypeInfo::String(); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 368 | case CompareIC::OBJECT: |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 369 | case CompareIC::KNOWN_OBJECT: |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 370 | // TODO(kasperl): We really need a type for JS objects here. |
| 371 | return TypeInfo::NonPrimitive(); |
| 372 | case CompareIC::GENERIC: |
| 373 | default: |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 374 | return TypeInfo::Unknown(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 375 | } |
| 376 | } |
| 377 | |
| 378 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 379 | void TypeFeedbackOracle::CompareType(CompareOperation* expr, |
| 380 | TypeInfo* left_type, |
| 381 | TypeInfo* right_type, |
| 382 | TypeInfo* overall_type) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 383 | Handle<Object> object = GetInfo(expr->CompareOperationFeedbackId()); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 384 | TypeInfo unknown = TypeInfo::Unknown(); |
| 385 | if (!object->IsCode()) { |
| 386 | *left_type = *right_type = *overall_type = unknown; |
| 387 | return; |
| 388 | } |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 389 | Handle<Code> code = Handle<Code>::cast(object); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 390 | if (!code->is_compare_ic_stub()) { |
| 391 | *left_type = *right_type = *overall_type = unknown; |
| 392 | return; |
| 393 | } |
| 394 | |
| 395 | int stub_minor_key = code->stub_info(); |
| 396 | CompareIC::State left_state, right_state, handler_state; |
| 397 | ICCompareStub::DecodeMinorKey(stub_minor_key, &left_state, &right_state, |
| 398 | &handler_state, NULL); |
| 399 | *left_type = TypeFromCompareType(left_state); |
| 400 | *right_type = TypeFromCompareType(right_state); |
| 401 | *overall_type = TypeFromCompareType(handler_state); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 405 | Handle<Map> TypeFeedbackOracle::GetCompareMap(CompareOperation* expr) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 406 | Handle<Object> object = GetInfo(expr->CompareOperationFeedbackId()); |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 407 | if (!object->IsCode()) return Handle<Map>::null(); |
| 408 | Handle<Code> code = Handle<Code>::cast(object); |
| 409 | if (!code->is_compare_ic_stub()) return Handle<Map>::null(); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 410 | CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 411 | if (state != CompareIC::KNOWN_OBJECT) { |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 412 | return Handle<Map>::null(); |
| 413 | } |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 414 | Map* map = code->FindFirstMap()->CurrentMapForDeprecated(); |
| 415 | return map == NULL || CanRetainOtherContext(map, *native_context_) |
danno@chromium.org | e78f9fc | 2011-12-21 08:29:34 +0000 | [diff] [blame] | 416 | ? Handle<Map>::null() |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 417 | : Handle<Map>(map); |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 421 | TypeInfo TypeFeedbackOracle::UnaryType(UnaryOperation* expr) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 422 | Handle<Object> object = GetInfo(expr->UnaryOperationFeedbackId()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 423 | TypeInfo unknown = TypeInfo::Unknown(); |
| 424 | if (!object->IsCode()) return unknown; |
| 425 | Handle<Code> code = Handle<Code>::cast(object); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 426 | ASSERT(code->is_unary_op_stub()); |
| 427 | UnaryOpIC::TypeInfo type = static_cast<UnaryOpIC::TypeInfo>( |
| 428 | code->unary_op_type()); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 429 | switch (type) { |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 430 | case UnaryOpIC::SMI: |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 431 | return TypeInfo::Smi(); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 432 | case UnaryOpIC::NUMBER: |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 433 | return TypeInfo::Double(); |
| 434 | default: |
| 435 | return unknown; |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 440 | static TypeInfo TypeFromBinaryOpType(BinaryOpIC::TypeInfo binary_type) { |
| 441 | switch (binary_type) { |
| 442 | // Uninitialized means never executed. |
| 443 | case BinaryOpIC::UNINITIALIZED: return TypeInfo::Uninitialized(); |
| 444 | case BinaryOpIC::SMI: return TypeInfo::Smi(); |
| 445 | case BinaryOpIC::INT32: return TypeInfo::Integer32(); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 446 | case BinaryOpIC::NUMBER: return TypeInfo::Double(); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 447 | case BinaryOpIC::ODDBALL: return TypeInfo::Unknown(); |
| 448 | case BinaryOpIC::STRING: return TypeInfo::String(); |
| 449 | case BinaryOpIC::GENERIC: return TypeInfo::Unknown(); |
| 450 | } |
| 451 | UNREACHABLE(); |
| 452 | return TypeInfo::Unknown(); |
| 453 | } |
| 454 | |
| 455 | |
| 456 | void TypeFeedbackOracle::BinaryType(BinaryOperation* expr, |
| 457 | TypeInfo* left, |
| 458 | TypeInfo* right, |
| 459 | TypeInfo* result) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 460 | Handle<Object> object = GetInfo(expr->BinaryOperationFeedbackId()); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 461 | TypeInfo unknown = TypeInfo::Unknown(); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 462 | if (!object->IsCode()) { |
| 463 | *left = *right = *result = unknown; |
| 464 | return; |
| 465 | } |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 466 | Handle<Code> code = Handle<Code>::cast(object); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 467 | if (code->is_binary_op_stub()) { |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 468 | BinaryOpIC::TypeInfo left_type, right_type, result_type; |
| 469 | BinaryOpStub::decode_types_from_minor_key(code->stub_info(), &left_type, |
| 470 | &right_type, &result_type); |
| 471 | *left = TypeFromBinaryOpType(left_type); |
| 472 | *right = TypeFromBinaryOpType(right_type); |
| 473 | *result = TypeFromBinaryOpType(result_type); |
| 474 | return; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 475 | } |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 476 | // Not a binary op stub. |
| 477 | *left = *right = *result = unknown; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 478 | } |
| 479 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 480 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 481 | TypeInfo TypeFeedbackOracle::SwitchType(CaseClause* clause) { |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 482 | Handle<Object> object = GetInfo(clause->CompareId()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 483 | TypeInfo unknown = TypeInfo::Unknown(); |
| 484 | if (!object->IsCode()) return unknown; |
| 485 | Handle<Code> code = Handle<Code>::cast(object); |
| 486 | if (!code->is_compare_ic_stub()) return unknown; |
| 487 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 488 | CompareIC::State state = ICCompareStub::CompareState(code->stub_info()); |
| 489 | return TypeFromCompareType(state); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 493 | TypeInfo TypeFeedbackOracle::IncrementType(CountOperation* expr) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 494 | Handle<Object> object = GetInfo(expr->CountBinOpFeedbackId()); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 495 | TypeInfo unknown = TypeInfo::Unknown(); |
| 496 | if (!object->IsCode()) return unknown; |
| 497 | Handle<Code> code = Handle<Code>::cast(object); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 498 | if (!code->is_binary_op_stub()) return unknown; |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 499 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 500 | BinaryOpIC::TypeInfo left_type, right_type, unused_result_type; |
| 501 | BinaryOpStub::decode_types_from_minor_key(code->stub_info(), &left_type, |
| 502 | &right_type, &unused_result_type); |
| 503 | // CountOperations should always have +1 or -1 as their right input. |
| 504 | ASSERT(right_type == BinaryOpIC::SMI || |
| 505 | right_type == BinaryOpIC::UNINITIALIZED); |
| 506 | |
| 507 | switch (left_type) { |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 508 | case BinaryOpIC::UNINITIALIZED: |
| 509 | case BinaryOpIC::SMI: |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 510 | return TypeInfo::Smi(); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 511 | case BinaryOpIC::INT32: |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 512 | return TypeInfo::Integer32(); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 513 | case BinaryOpIC::NUMBER: |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 514 | return TypeInfo::Double(); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 515 | case BinaryOpIC::STRING: |
| 516 | case BinaryOpIC::GENERIC: |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 517 | return unknown; |
| 518 | default: |
| 519 | return unknown; |
| 520 | } |
| 521 | UNREACHABLE(); |
| 522 | return unknown; |
| 523 | } |
| 524 | |
| 525 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 526 | void TypeFeedbackOracle::CollectPolymorphicMaps(Handle<Code> code, |
| 527 | SmallMapList* types) { |
| 528 | MapHandleList maps; |
| 529 | code->FindAllMaps(&maps); |
| 530 | types->Reserve(maps.length(), zone()); |
| 531 | for (int i = 0; i < maps.length(); i++) { |
| 532 | Handle<Map> map(maps.at(i)); |
| 533 | if (!CanRetainOtherContext(*map, *native_context_)) { |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 534 | types->AddMapIfMissing(map, zone()); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 535 | } |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 540 | void TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id, |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 541 | Handle<String> name, |
| 542 | Code::Flags flags, |
| 543 | SmallMapList* types) { |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 544 | Handle<Object> object = GetInfo(ast_id); |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 545 | if (object->IsUndefined() || object->IsSmi()) return; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 546 | |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 547 | if (object.is_identical_to(isolate_->builtins()->StoreIC_GlobalProxy())) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 548 | // TODO(fschneider): We could collect the maps and signal that |
| 549 | // we need a generic store (or load) here. |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 550 | ASSERT(Handle<Code>::cast(object)->ic_state() == GENERIC); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 551 | } else if (object->IsMap()) { |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 552 | types->AddMapIfMissing(Handle<Map>::cast(object), zone()); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 553 | } else if (Handle<Code>::cast(object)->ic_state() == POLYMORPHIC) { |
| 554 | CollectPolymorphicMaps(Handle<Code>::cast(object), types); |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 555 | } else if (FLAG_collect_megamorphic_maps_from_stub_cache && |
| 556 | Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 557 | types->Reserve(4, zone()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 558 | ASSERT(object->IsCode()); |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 559 | isolate_->stub_cache()->CollectMatchingMaps(types, |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 560 | name, |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 561 | flags, |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 562 | native_context_, |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 563 | zone()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 564 | } |
| 565 | } |
| 566 | |
| 567 | |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 568 | // Check if a map originates from a given native context. We use this |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 569 | // information to filter out maps from different context to avoid |
| 570 | // retaining objects from different tabs in Chrome via optimized code. |
| 571 | bool TypeFeedbackOracle::CanRetainOtherContext(Map* map, |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 572 | Context* native_context) { |
danno@chromium.org | e78f9fc | 2011-12-21 08:29:34 +0000 | [diff] [blame] | 573 | Object* constructor = NULL; |
| 574 | while (!map->prototype()->IsNull()) { |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 575 | constructor = map->constructor(); |
danno@chromium.org | e78f9fc | 2011-12-21 08:29:34 +0000 | [diff] [blame] | 576 | if (!constructor->IsNull()) { |
| 577 | // If the constructor is not null or a JSFunction, we have to |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 578 | // conservatively assume that it may retain a native context. |
danno@chromium.org | e78f9fc | 2011-12-21 08:29:34 +0000 | [diff] [blame] | 579 | if (!constructor->IsJSFunction()) return true; |
| 580 | // Check if the constructor directly references a foreign context. |
| 581 | if (CanRetainOtherContext(JSFunction::cast(constructor), |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 582 | native_context)) { |
danno@chromium.org | e78f9fc | 2011-12-21 08:29:34 +0000 | [diff] [blame] | 583 | return true; |
| 584 | } |
| 585 | } |
| 586 | map = HeapObject::cast(map->prototype())->map(); |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 587 | } |
danno@chromium.org | e78f9fc | 2011-12-21 08:29:34 +0000 | [diff] [blame] | 588 | constructor = map->constructor(); |
| 589 | if (constructor->IsNull()) return false; |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 590 | JSFunction* function = JSFunction::cast(constructor); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 591 | return CanRetainOtherContext(function, native_context); |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | |
| 595 | bool TypeFeedbackOracle::CanRetainOtherContext(JSFunction* function, |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 596 | Context* native_context) { |
| 597 | return function->context()->global_object() != native_context->global_object() |
| 598 | && function->context()->global_object() != native_context->builtins(); |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 602 | void TypeFeedbackOracle::CollectKeyedReceiverTypes(TypeFeedbackId ast_id, |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 603 | SmallMapList* types) { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 604 | Handle<Object> object = GetInfo(ast_id); |
| 605 | if (!object->IsCode()) return; |
| 606 | Handle<Code> code = Handle<Code>::cast(object); |
| 607 | if (code->kind() == Code::KEYED_LOAD_IC || |
| 608 | code->kind() == Code::KEYED_STORE_IC) { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 609 | CollectPolymorphicMaps(code, types); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 610 | } |
| 611 | } |
| 612 | |
| 613 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 614 | byte TypeFeedbackOracle::ToBooleanTypes(TypeFeedbackId id) { |
| 615 | Handle<Object> object = GetInfo(id); |
ricow@chromium.org | 2c99e28 | 2011-07-28 09:15:17 +0000 | [diff] [blame] | 616 | return object->IsCode() ? Handle<Code>::cast(object)->to_boolean_state() : 0; |
| 617 | } |
| 618 | |
| 619 | |
jkummerow@chromium.org | c118402 | 2013-05-28 16:58:15 +0000 | [diff] [blame] | 620 | byte TypeFeedbackOracle::CompareNilTypes(CompareOperation* expr) { |
| 621 | Handle<Object> object = GetInfo(expr->CompareOperationFeedbackId()); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 622 | if (object->IsCode() && |
| 623 | Handle<Code>::cast(object)->is_compare_nil_ic_stub()) { |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 624 | return Handle<Code>::cast(object)->compare_nil_types(); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 625 | } else { |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 626 | return CompareNilICStub::Types::FullCompare().ToIntegral(); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 627 | } |
| 628 | } |
| 629 | |
| 630 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 631 | // Things are a bit tricky here: The iterator for the RelocInfos and the infos |
| 632 | // themselves are not GC-safe, so we first get all infos, then we create the |
| 633 | // dictionary (possibly triggering GC), and finally we relocate the collected |
| 634 | // infos before we process them. |
| 635 | void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) { |
rossberg@chromium.org | 79e7902 | 2013-06-03 15:43:46 +0000 | [diff] [blame^] | 636 | DisallowHeapAllocation no_allocation; |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 637 | ZoneList<RelocInfo> infos(16, zone()); |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 638 | HandleScope scope(isolate_); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 639 | GetRelocInfos(code, &infos); |
| 640 | CreateDictionary(code, &infos); |
| 641 | ProcessRelocInfos(&infos); |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 642 | ProcessTypeFeedbackCells(code); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 643 | // Allocate handle in the parent scope. |
| 644 | dictionary_ = scope.CloseAndEscape(dictionary_); |
| 645 | } |
| 646 | |
| 647 | |
| 648 | void TypeFeedbackOracle::GetRelocInfos(Handle<Code> code, |
| 649 | ZoneList<RelocInfo>* infos) { |
| 650 | int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); |
| 651 | for (RelocIterator it(*code, mask); !it.done(); it.next()) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 652 | infos->Add(*it.rinfo(), zone()); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 653 | } |
| 654 | } |
| 655 | |
| 656 | |
| 657 | void TypeFeedbackOracle::CreateDictionary(Handle<Code> code, |
| 658 | ZoneList<RelocInfo>* infos) { |
rossberg@chromium.org | 79e7902 | 2013-06-03 15:43:46 +0000 | [diff] [blame^] | 659 | AllowHeapAllocation allocation_allowed; |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 660 | int cell_count = code->type_feedback_info()->IsTypeFeedbackInfo() |
| 661 | ? TypeFeedbackInfo::cast(code->type_feedback_info())-> |
| 662 | type_feedback_cells()->CellCount() |
| 663 | : 0; |
| 664 | int length = infos->length() + cell_count; |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 665 | byte* old_start = code->instruction_start(); |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 666 | dictionary_ = FACTORY->NewUnseededNumberDictionary(length); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 667 | byte* new_start = code->instruction_start(); |
| 668 | RelocateRelocInfos(infos, old_start, new_start); |
| 669 | } |
| 670 | |
| 671 | |
| 672 | void TypeFeedbackOracle::RelocateRelocInfos(ZoneList<RelocInfo>* infos, |
| 673 | byte* old_start, |
| 674 | byte* new_start) { |
| 675 | for (int i = 0; i < infos->length(); i++) { |
| 676 | RelocInfo* info = &(*infos)[i]; |
| 677 | info->set_pc(new_start + (info->pc() - old_start)); |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | |
| 682 | void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) { |
| 683 | for (int i = 0; i < infos->length(); i++) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 684 | RelocInfo reloc_entry = (*infos)[i]; |
| 685 | Address target_address = reloc_entry.target_address(); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 686 | TypeFeedbackId ast_id = |
| 687 | TypeFeedbackId(static_cast<unsigned>((*infos)[i].data())); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 688 | Code* target = Code::GetCodeFromTargetAddress(target_address); |
| 689 | switch (target->kind()) { |
| 690 | case Code::LOAD_IC: |
| 691 | case Code::STORE_IC: |
| 692 | case Code::CALL_IC: |
| 693 | case Code::KEYED_CALL_IC: |
| 694 | if (target->ic_state() == MONOMORPHIC) { |
| 695 | if (target->kind() == Code::CALL_IC && |
| 696 | target->check_type() != RECEIVER_MAP_CHECK) { |
| 697 | SetInfo(ast_id, Smi::FromInt(target->check_type())); |
| 698 | } else { |
| 699 | Object* map = target->FindFirstMap(); |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 700 | if (map == NULL) { |
| 701 | SetInfo(ast_id, static_cast<Object*>(target)); |
| 702 | } else if (!CanRetainOtherContext(Map::cast(map), |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 703 | *native_context_)) { |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 704 | Map* feedback = Map::cast(map)->CurrentMapForDeprecated(); |
| 705 | if (feedback != NULL) SetInfo(ast_id, feedback); |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 706 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 707 | } |
jkummerow@chromium.org | 531dfe8 | 2012-03-20 13:01:16 +0000 | [diff] [blame] | 708 | } else { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 709 | SetInfo(ast_id, target); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 710 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 711 | break; |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 712 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 713 | case Code::KEYED_LOAD_IC: |
| 714 | case Code::KEYED_STORE_IC: |
| 715 | if (target->ic_state() == MONOMORPHIC || |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 716 | target->ic_state() == POLYMORPHIC) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 717 | SetInfo(ast_id, target); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 718 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 719 | break; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 720 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 721 | case Code::UNARY_OP_IC: |
| 722 | case Code::BINARY_OP_IC: |
| 723 | case Code::COMPARE_IC: |
| 724 | case Code::TO_BOOLEAN_IC: |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 725 | case Code::COMPARE_NIL_IC: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 726 | SetInfo(ast_id, target); |
| 727 | break; |
| 728 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 729 | default: |
| 730 | break; |
| 731 | } |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 732 | } |
| 733 | } |
| 734 | |
| 735 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 736 | void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) { |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 737 | Object* raw_info = code->type_feedback_info(); |
| 738 | if (!raw_info->IsTypeFeedbackInfo()) return; |
| 739 | Handle<TypeFeedbackCells> cache( |
| 740 | TypeFeedbackInfo::cast(raw_info)->type_feedback_cells()); |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 741 | for (int i = 0; i < cache->CellCount(); i++) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 742 | TypeFeedbackId ast_id = cache->AstId(i); |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 743 | Object* value = cache->Cell(i)->value(); |
ulan@chromium.org | 9a21ec4 | 2012-03-06 08:42:24 +0000 | [diff] [blame] | 744 | if (value->IsSmi() || |
| 745 | (value->IsJSFunction() && |
| 746 | !CanRetainOtherContext(JSFunction::cast(value), |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 747 | *native_context_))) { |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 748 | SetInfo(ast_id, value); |
| 749 | } |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 754 | void TypeFeedbackOracle::SetInfo(TypeFeedbackId ast_id, Object* target) { |
| 755 | ASSERT(dictionary_->FindEntry(IdToKey(ast_id)) == |
| 756 | UnseededNumberDictionary::kNotFound); |
| 757 | MaybeObject* maybe_result = dictionary_->AtNumberPut(IdToKey(ast_id), target); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 758 | USE(maybe_result); |
| 759 | #ifdef DEBUG |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 760 | Object* result = NULL; |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 761 | // Dictionary has been allocated with sufficient size for all elements. |
| 762 | ASSERT(maybe_result->ToObject(&result)); |
| 763 | ASSERT(*dictionary_ == result); |
| 764 | #endif |
| 765 | } |
| 766 | |
sgjesse@chromium.org | df7a284 | 2010-03-25 14:34:15 +0000 | [diff] [blame] | 767 | } } // namespace v8::internal |