| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 case BinaryOpIC::GENERIC: | 532 case BinaryOpIC::GENERIC: |
| 533 return unknown; | 533 return unknown; |
| 534 default: | 534 default: |
| 535 return unknown; | 535 return unknown; |
| 536 } | 536 } |
| 537 UNREACHABLE(); | 537 UNREACHABLE(); |
| 538 return unknown; | 538 return unknown; |
| 539 } | 539 } |
| 540 | 540 |
| 541 | 541 |
| 542 static void AddMapIfMissing(Handle<Map> map, SmallMapList* list, | |
| 543 Zone* zone) { | |
| 544 for (int i = 0; i < list->length(); ++i) { | |
| 545 if (list->at(i).is_identical_to(map)) return; | |
| 546 } | |
| 547 list->Add(map, zone); | |
| 548 } | |
| 549 | |
| 550 | |
| 551 void TypeFeedbackOracle::CollectPolymorphicMaps(Handle<Code> code, | 542 void TypeFeedbackOracle::CollectPolymorphicMaps(Handle<Code> code, |
| 552 SmallMapList* types) { | 543 SmallMapList* types) { |
| 553 MapHandleList maps; | 544 MapHandleList maps; |
| 554 code->FindAllMaps(&maps); | 545 code->FindAllMaps(&maps); |
| 555 types->Reserve(maps.length(), zone()); | 546 types->Reserve(maps.length(), zone()); |
| 556 for (int i = 0; i < maps.length(); i++) { | 547 for (int i = 0; i < maps.length(); i++) { |
| 557 Handle<Map> map(maps.at(i)); | 548 Handle<Map> map(maps.at(i)); |
| 558 if (!CanRetainOtherContext(*map, *native_context_)) { | 549 if (!CanRetainOtherContext(*map, *native_context_)) { |
| 559 AddMapIfMissing(map, types, zone()); | 550 types->AddMapIfMissing(map, zone()); |
| 560 } | 551 } |
| 561 } | 552 } |
| 562 } | 553 } |
| 563 | 554 |
| 564 | 555 |
| 565 void TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id, | 556 void TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id, |
| 566 Handle<String> name, | 557 Handle<String> name, |
| 567 Code::Flags flags, | 558 Code::Flags flags, |
| 568 SmallMapList* types) { | 559 SmallMapList* types) { |
| 569 Handle<Object> object = GetInfo(ast_id); | 560 Handle<Object> object = GetInfo(ast_id); |
| 570 if (object->IsUndefined() || object->IsSmi()) return; | 561 if (object->IsUndefined() || object->IsSmi()) return; |
| 571 | 562 |
| 572 if (object.is_identical_to(isolate_->builtins()->StoreIC_GlobalProxy())) { | 563 if (object.is_identical_to(isolate_->builtins()->StoreIC_GlobalProxy())) { |
| 573 // TODO(fschneider): We could collect the maps and signal that | 564 // TODO(fschneider): We could collect the maps and signal that |
| 574 // we need a generic store (or load) here. | 565 // we need a generic store (or load) here. |
| 575 ASSERT(Handle<Code>::cast(object)->ic_state() == GENERIC); | 566 ASSERT(Handle<Code>::cast(object)->ic_state() == GENERIC); |
| 576 } else if (object->IsMap()) { | 567 } else if (object->IsMap()) { |
| 577 types->Add(Handle<Map>::cast(object), zone()); | 568 types->AddMapIfMissing(Handle<Map>::cast(object), zone()); |
| 578 } else if (Handle<Code>::cast(object)->ic_state() == POLYMORPHIC) { | 569 } else if (Handle<Code>::cast(object)->ic_state() == POLYMORPHIC) { |
| 579 CollectPolymorphicMaps(Handle<Code>::cast(object), types); | 570 CollectPolymorphicMaps(Handle<Code>::cast(object), types); |
| 580 } else if (FLAG_collect_megamorphic_maps_from_stub_cache && | 571 } else if (FLAG_collect_megamorphic_maps_from_stub_cache && |
| 581 Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { | 572 Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { |
| 582 types->Reserve(4, zone()); | 573 types->Reserve(4, zone()); |
| 583 ASSERT(object->IsCode()); | 574 ASSERT(object->IsCode()); |
| 584 isolate_->stub_cache()->CollectMatchingMaps(types, | 575 isolate_->stub_cache()->CollectMatchingMaps(types, |
| 585 *name, | 576 name, |
| 586 flags, | 577 flags, |
| 587 native_context_, | 578 native_context_, |
| 588 zone()); | 579 zone()); |
| 589 } | 580 } |
| 590 } | 581 } |
| 591 | 582 |
| 592 | 583 |
| 593 // Check if a map originates from a given native context. We use this | 584 // Check if a map originates from a given native context. We use this |
| 594 // information to filter out maps from different context to avoid | 585 // information to filter out maps from different context to avoid |
| 595 // retaining objects from different tabs in Chrome via optimized code. | 586 // retaining objects from different tabs in Chrome via optimized code. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 USE(maybe_result); | 773 USE(maybe_result); |
| 783 #ifdef DEBUG | 774 #ifdef DEBUG |
| 784 Object* result = NULL; | 775 Object* result = NULL; |
| 785 // Dictionary has been allocated with sufficient size for all elements. | 776 // Dictionary has been allocated with sufficient size for all elements. |
| 786 ASSERT(maybe_result->ToObject(&result)); | 777 ASSERT(maybe_result->ToObject(&result)); |
| 787 ASSERT(*dictionary_ == result); | 778 ASSERT(*dictionary_ == result); |
| 788 #endif | 779 #endif |
| 789 } | 780 } |
| 790 | 781 |
| 791 } } // namespace v8::internal | 782 } } // namespace v8::internal |
| OLD | NEW |