| OLD | NEW | 
|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 152   ASSERT(StoreIsMonomorphicNormal(expr)); | 152   ASSERT(StoreIsMonomorphicNormal(expr)); | 
| 153   Handle<Object> map_or_code(GetInfo(expr->id())); | 153   Handle<Object> map_or_code(GetInfo(expr->id())); | 
| 154   if (map_or_code->IsCode()) { | 154   if (map_or_code->IsCode()) { | 
| 155     Handle<Code> code = Handle<Code>::cast(map_or_code); | 155     Handle<Code> code = Handle<Code>::cast(map_or_code); | 
| 156     return Handle<Map>(code->FindFirstMap()); | 156     return Handle<Map>(code->FindFirstMap()); | 
| 157   } | 157   } | 
| 158   return Handle<Map>::cast(map_or_code); | 158   return Handle<Map>::cast(map_or_code); | 
| 159 } | 159 } | 
| 160 | 160 | 
| 161 | 161 | 
| 162 ZoneMapList* TypeFeedbackOracle::LoadReceiverTypes(Property* expr, | 162 void TypeFeedbackOracle::LoadReceiverTypes(Property* expr, | 
| 163                                                    Handle<String> name) { | 163                                            Handle<String> name, | 
|  | 164                                            SmallMapList* types) { | 
| 164   Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL); | 165   Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL); | 
| 165   return CollectReceiverTypes(expr->id(), name, flags); | 166   CollectReceiverTypes(expr->id(), name, flags, types); | 
| 166 } | 167 } | 
| 167 | 168 | 
| 168 | 169 | 
| 169 ZoneMapList* TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr, | 170 void TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr, | 
| 170                                                     Handle<String> name) { | 171                                             Handle<String> name, | 
|  | 172                                             SmallMapList* types) { | 
| 171   Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL); | 173   Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL); | 
| 172   return CollectReceiverTypes(expr->id(), name, flags); | 174   CollectReceiverTypes(expr->id(), name, flags, types); | 
| 173 } | 175 } | 
| 174 | 176 | 
| 175 | 177 | 
| 176 ZoneMapList* TypeFeedbackOracle::CallReceiverTypes(Call* expr, | 178 void TypeFeedbackOracle::CallReceiverTypes(Call* expr, | 
| 177                                                    Handle<String> name, | 179                                            Handle<String> name, | 
| 178                                                    CallKind call_kind) { | 180                                            CallKind call_kind, | 
|  | 181                                            SmallMapList* types) { | 
| 179   int arity = expr->arguments()->length(); | 182   int arity = expr->arguments()->length(); | 
| 180 | 183 | 
| 181   // Note: Currently we do not take string extra ic data into account | 184   // Note: Currently we do not take string extra ic data into account | 
| 182   // here. | 185   // here. | 
| 183   Code::ExtraICState extra_ic_state = | 186   Code::ExtraICState extra_ic_state = | 
| 184       CallIC::Contextual::encode(call_kind == CALL_AS_FUNCTION); | 187       CallIC::Contextual::encode(call_kind == CALL_AS_FUNCTION); | 
| 185 | 188 | 
| 186   Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, | 189   Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, | 
| 187                                                     NORMAL, | 190                                                     NORMAL, | 
| 188                                                     extra_ic_state, | 191                                                     extra_ic_state, | 
| 189                                                     OWN_MAP, | 192                                                     OWN_MAP, | 
| 190                                                     NOT_IN_LOOP, | 193                                                     NOT_IN_LOOP, | 
| 191                                                     arity); | 194                                                     arity); | 
| 192   return CollectReceiverTypes(expr->id(), name, flags); | 195   CollectReceiverTypes(expr->id(), name, flags, types); | 
| 193 } | 196 } | 
| 194 | 197 | 
| 195 | 198 | 
| 196 CheckType TypeFeedbackOracle::GetCallCheckType(Call* expr) { | 199 CheckType TypeFeedbackOracle::GetCallCheckType(Call* expr) { | 
| 197   Handle<Object> value = GetInfo(expr->id()); | 200   Handle<Object> value = GetInfo(expr->id()); | 
| 198   if (!value->IsSmi()) return RECEIVER_MAP_CHECK; | 201   if (!value->IsSmi()) return RECEIVER_MAP_CHECK; | 
| 199   CheckType check = static_cast<CheckType>(Smi::cast(*value)->value()); | 202   CheckType check = static_cast<CheckType>(Smi::cast(*value)->value()); | 
| 200   ASSERT(check != RECEIVER_MAP_CHECK); | 203   ASSERT(check != RECEIVER_MAP_CHECK); | 
| 201   return check; | 204   return check; | 
| 202 } | 205 } | 
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 384     case BinaryOpIC::GENERIC: | 387     case BinaryOpIC::GENERIC: | 
| 385       return unknown; | 388       return unknown; | 
| 386     default: | 389     default: | 
| 387       return unknown; | 390       return unknown; | 
| 388   } | 391   } | 
| 389   UNREACHABLE(); | 392   UNREACHABLE(); | 
| 390   return unknown; | 393   return unknown; | 
| 391 } | 394 } | 
| 392 | 395 | 
| 393 | 396 | 
| 394 ZoneMapList* TypeFeedbackOracle::CollectReceiverTypes(unsigned ast_id, | 397 void TypeFeedbackOracle::CollectReceiverTypes(unsigned ast_id, | 
| 395                                                       Handle<String> name, | 398                                               Handle<String> name, | 
| 396                                                       Code::Flags flags) { | 399                                               Code::Flags flags, | 
|  | 400                                               SmallMapList* types) { | 
| 397   Isolate* isolate = Isolate::Current(); | 401   Isolate* isolate = Isolate::Current(); | 
| 398   Handle<Object> object = GetInfo(ast_id); | 402   Handle<Object> object = GetInfo(ast_id); | 
| 399   if (object->IsUndefined() || object->IsSmi()) return NULL; | 403   if (object->IsUndefined() || object->IsSmi()) return; | 
| 400 | 404 | 
| 401   if (*object == isolate->builtins()->builtin(Builtins::kStoreIC_GlobalProxy)) { | 405   if (*object == isolate->builtins()->builtin(Builtins::kStoreIC_GlobalProxy)) { | 
| 402     // TODO(fschneider): We could collect the maps and signal that | 406     // TODO(fschneider): We could collect the maps and signal that | 
| 403     // we need a generic store (or load) here. | 407     // we need a generic store (or load) here. | 
| 404     ASSERT(Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC); | 408     ASSERT(Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC); | 
| 405     return NULL; |  | 
| 406   } else if (object->IsMap()) { | 409   } else if (object->IsMap()) { | 
| 407     ZoneMapList* types = new ZoneMapList(1); |  | 
| 408     types->Add(Handle<Map>::cast(object)); | 410     types->Add(Handle<Map>::cast(object)); | 
| 409     return types; |  | 
| 410   } else if (Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { | 411   } else if (Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { | 
| 411     ZoneMapList* types = new ZoneMapList(4); | 412     types->Reserve(4); | 
| 412     ASSERT(object->IsCode()); | 413     ASSERT(object->IsCode()); | 
| 413     isolate->stub_cache()->CollectMatchingMaps(types, *name, flags); | 414     isolate->stub_cache()->CollectMatchingMaps(types, *name, flags); | 
| 414     return types->length() > 0 ? types : NULL; |  | 
| 415   } else { |  | 
| 416     return NULL; |  | 
| 417   } | 415   } | 
| 418 } | 416 } | 
| 419 | 417 | 
| 420 | 418 | 
| 421 void TypeFeedbackOracle::CollectKeyedReceiverTypes( | 419 void TypeFeedbackOracle::CollectKeyedReceiverTypes(unsigned ast_id, | 
| 422     unsigned ast_id, | 420                                                    SmallMapList* types) { | 
| 423     ZoneMapList* types) { |  | 
| 424   Handle<Object> object = GetInfo(ast_id); | 421   Handle<Object> object = GetInfo(ast_id); | 
| 425   if (!object->IsCode()) return; | 422   if (!object->IsCode()) return; | 
| 426   Handle<Code> code = Handle<Code>::cast(object); | 423   Handle<Code> code = Handle<Code>::cast(object); | 
| 427   if (code->kind() == Code::KEYED_LOAD_IC || | 424   if (code->kind() == Code::KEYED_LOAD_IC || | 
| 428       code->kind() == Code::KEYED_STORE_IC) { | 425       code->kind() == Code::KEYED_STORE_IC) { | 
| 429     AssertNoAllocation no_allocation; | 426     AssertNoAllocation no_allocation; | 
| 430     int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 427     int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 
| 431     for (RelocIterator it(*code, mask); !it.done(); it.next()) { | 428     for (RelocIterator it(*code, mask); !it.done(); it.next()) { | 
| 432       RelocInfo* info = it.rinfo(); | 429       RelocInfo* info = it.rinfo(); | 
| 433       Object* object = info->target_object(); | 430       Object* object = info->target_object(); | 
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 545   USE(maybe_result); | 542   USE(maybe_result); | 
| 546 #ifdef DEBUG | 543 #ifdef DEBUG | 
| 547   Object* result = NULL; | 544   Object* result = NULL; | 
| 548   // Dictionary has been allocated with sufficient size for all elements. | 545   // Dictionary has been allocated with sufficient size for all elements. | 
| 549   ASSERT(maybe_result->ToObject(&result)); | 546   ASSERT(maybe_result->ToObject(&result)); | 
| 550   ASSERT(*dictionary_ == result); | 547   ASSERT(*dictionary_ == result); | 
| 551 #endif | 548 #endif | 
| 552 } | 549 } | 
| 553 | 550 | 
| 554 } }  // namespace v8::internal | 551 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|