| 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 return CompareNilICStub::Types::FullCompare().ToIntegral(); | 626 return CompareNilICStub::Types::FullCompare().ToIntegral(); |
| 627 } | 627 } |
| 628 } | 628 } |
| 629 | 629 |
| 630 | 630 |
| 631 // Things are a bit tricky here: The iterator for the RelocInfos and the infos | 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 | 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 | 633 // dictionary (possibly triggering GC), and finally we relocate the collected |
| 634 // infos before we process them. | 634 // infos before we process them. |
| 635 void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) { | 635 void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) { |
| 636 AssertNoAllocation no_allocation; | 636 DisallowHeapAllocation no_allocation; |
| 637 ZoneList<RelocInfo> infos(16, zone()); | 637 ZoneList<RelocInfo> infos(16, zone()); |
| 638 HandleScope scope(isolate_); | 638 HandleScope scope(isolate_); |
| 639 GetRelocInfos(code, &infos); | 639 GetRelocInfos(code, &infos); |
| 640 CreateDictionary(code, &infos); | 640 CreateDictionary(code, &infos); |
| 641 ProcessRelocInfos(&infos); | 641 ProcessRelocInfos(&infos); |
| 642 ProcessTypeFeedbackCells(code); | 642 ProcessTypeFeedbackCells(code); |
| 643 // Allocate handle in the parent scope. | 643 // Allocate handle in the parent scope. |
| 644 dictionary_ = scope.CloseAndEscape(dictionary_); | 644 dictionary_ = scope.CloseAndEscape(dictionary_); |
| 645 } | 645 } |
| 646 | 646 |
| 647 | 647 |
| 648 void TypeFeedbackOracle::GetRelocInfos(Handle<Code> code, | 648 void TypeFeedbackOracle::GetRelocInfos(Handle<Code> code, |
| 649 ZoneList<RelocInfo>* infos) { | 649 ZoneList<RelocInfo>* infos) { |
| 650 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); | 650 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); |
| 651 for (RelocIterator it(*code, mask); !it.done(); it.next()) { | 651 for (RelocIterator it(*code, mask); !it.done(); it.next()) { |
| 652 infos->Add(*it.rinfo(), zone()); | 652 infos->Add(*it.rinfo(), zone()); |
| 653 } | 653 } |
| 654 } | 654 } |
| 655 | 655 |
| 656 | 656 |
| 657 void TypeFeedbackOracle::CreateDictionary(Handle<Code> code, | 657 void TypeFeedbackOracle::CreateDictionary(Handle<Code> code, |
| 658 ZoneList<RelocInfo>* infos) { | 658 ZoneList<RelocInfo>* infos) { |
| 659 DisableAssertNoAllocation allocation_allowed; | 659 AllowHeapAllocation allocation_allowed; |
| 660 int cell_count = code->type_feedback_info()->IsTypeFeedbackInfo() | 660 int cell_count = code->type_feedback_info()->IsTypeFeedbackInfo() |
| 661 ? TypeFeedbackInfo::cast(code->type_feedback_info())-> | 661 ? TypeFeedbackInfo::cast(code->type_feedback_info())-> |
| 662 type_feedback_cells()->CellCount() | 662 type_feedback_cells()->CellCount() |
| 663 : 0; | 663 : 0; |
| 664 int length = infos->length() + cell_count; | 664 int length = infos->length() + cell_count; |
| 665 byte* old_start = code->instruction_start(); | 665 byte* old_start = code->instruction_start(); |
| 666 dictionary_ = FACTORY->NewUnseededNumberDictionary(length); | 666 dictionary_ = FACTORY->NewUnseededNumberDictionary(length); |
| 667 byte* new_start = code->instruction_start(); | 667 byte* new_start = code->instruction_start(); |
| 668 RelocateRelocInfos(infos, old_start, new_start); | 668 RelocateRelocInfos(infos, old_start, new_start); |
| 669 } | 669 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 USE(maybe_result); | 758 USE(maybe_result); |
| 759 #ifdef DEBUG | 759 #ifdef DEBUG |
| 760 Object* result = NULL; | 760 Object* result = NULL; |
| 761 // Dictionary has been allocated with sufficient size for all elements. | 761 // Dictionary has been allocated with sufficient size for all elements. |
| 762 ASSERT(maybe_result->ToObject(&result)); | 762 ASSERT(maybe_result->ToObject(&result)); |
| 763 ASSERT(*dictionary_ == result); | 763 ASSERT(*dictionary_ == result); |
| 764 #endif | 764 #endif |
| 765 } | 765 } |
| 766 | 766 |
| 767 } } // namespace v8::internal | 767 } } // namespace v8::internal |
| OLD | NEW |