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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); | 566 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); |
567 for (RelocIterator it(*code, mask); !it.done(); it.next()) { | 567 for (RelocIterator it(*code, mask); !it.done(); it.next()) { |
568 infos->Add(*it.rinfo()); | 568 infos->Add(*it.rinfo()); |
569 } | 569 } |
570 } | 570 } |
571 | 571 |
572 | 572 |
573 void TypeFeedbackOracle::CreateDictionary(Handle<Code> code, | 573 void TypeFeedbackOracle::CreateDictionary(Handle<Code> code, |
574 ZoneList<RelocInfo>* infos) { | 574 ZoneList<RelocInfo>* infos) { |
575 DisableAssertNoAllocation allocation_allowed; | 575 DisableAssertNoAllocation allocation_allowed; |
576 int length = infos->length() + code->type_feedback_cells()->CellCount(); | 576 int cell_count = code->type_feedback_info()->IsTypeFeedbackInfo() |
| 577 ? TypeFeedbackInfo::cast(code->type_feedback_info())-> |
| 578 type_feedback_cells()->CellCount() |
| 579 : 0; |
| 580 int length = infos->length() + cell_count; |
577 byte* old_start = code->instruction_start(); | 581 byte* old_start = code->instruction_start(); |
578 dictionary_ = FACTORY->NewUnseededNumberDictionary(length); | 582 dictionary_ = FACTORY->NewUnseededNumberDictionary(length); |
579 byte* new_start = code->instruction_start(); | 583 byte* new_start = code->instruction_start(); |
580 RelocateRelocInfos(infos, old_start, new_start); | 584 RelocateRelocInfos(infos, old_start, new_start); |
581 } | 585 } |
582 | 586 |
583 | 587 |
584 void TypeFeedbackOracle::RelocateRelocInfos(ZoneList<RelocInfo>* infos, | 588 void TypeFeedbackOracle::RelocateRelocInfos(ZoneList<RelocInfo>* infos, |
585 byte* old_start, | 589 byte* old_start, |
586 byte* new_start) { | 590 byte* new_start) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 break; | 640 break; |
637 | 641 |
638 default: | 642 default: |
639 break; | 643 break; |
640 } | 644 } |
641 } | 645 } |
642 } | 646 } |
643 | 647 |
644 | 648 |
645 void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) { | 649 void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) { |
646 Handle<TypeFeedbackCells> cache(code->type_feedback_cells()); | 650 Object* raw_info = code->type_feedback_info(); |
| 651 if (!raw_info->IsTypeFeedbackInfo()) return; |
| 652 Handle<TypeFeedbackCells> cache( |
| 653 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells()); |
647 for (int i = 0; i < cache->CellCount(); i++) { | 654 for (int i = 0; i < cache->CellCount(); i++) { |
648 unsigned ast_id = cache->AstId(i)->value(); | 655 unsigned ast_id = cache->AstId(i)->value(); |
649 Object* value = cache->Cell(i)->value(); | 656 Object* value = cache->Cell(i)->value(); |
650 if (value->IsJSFunction() && | 657 if (value->IsJSFunction() && |
651 !CanRetainOtherContext(JSFunction::cast(value), | 658 !CanRetainOtherContext(JSFunction::cast(value), |
652 *global_context_)) { | 659 *global_context_)) { |
653 SetInfo(ast_id, value); | 660 SetInfo(ast_id, value); |
654 } | 661 } |
655 } | 662 } |
656 } | 663 } |
657 | 664 |
658 | 665 |
659 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) { | 666 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) { |
660 ASSERT(dictionary_->FindEntry(ast_id) == UnseededNumberDictionary::kNotFound); | 667 ASSERT(dictionary_->FindEntry(ast_id) == UnseededNumberDictionary::kNotFound); |
661 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target); | 668 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target); |
662 USE(maybe_result); | 669 USE(maybe_result); |
663 #ifdef DEBUG | 670 #ifdef DEBUG |
664 Object* result = NULL; | 671 Object* result = NULL; |
665 // Dictionary has been allocated with sufficient size for all elements. | 672 // Dictionary has been allocated with sufficient size for all elements. |
666 ASSERT(maybe_result->ToObject(&result)); | 673 ASSERT(maybe_result->ToObject(&result)); |
667 ASSERT(*dictionary_ == result); | 674 ASSERT(*dictionary_ == result); |
668 #endif | 675 #endif |
669 } | 676 } |
670 | 677 |
671 } } // namespace v8::internal | 678 } } // namespace v8::internal |
OLD | NEW |