OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following | 10 // copyright notice, this list of conditions and the following |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 offset = kStartOfLabelLinkChain; | 538 offset = kStartOfLabelLinkChain; |
539 } | 539 } |
540 // The instruction at pc is now the last link in the label's chain. | 540 // The instruction at pc is now the last link in the label's chain. |
541 label->link_to(pc_offset()); | 541 label->link_to(pc_offset()); |
542 } | 542 } |
543 | 543 |
544 return offset; | 544 return offset; |
545 } | 545 } |
546 | 546 |
547 | 547 |
548 void Assembler::DeleteUnresolvedBranchInfoForLabelIterate(Label* label) { | |
549 std::multimap<int, FarBranchInfo>::iterator it_tmp, it; | |
550 it = unresolved_branches_.begin(); | |
551 while (it != unresolved_branches_.end()) { | |
552 it_tmp = it++; | |
553 if (it_tmp->second.label_ == label) { | |
554 CHECK(it_tmp->first >= pc_offset()); | |
555 unresolved_branches_.erase(it_tmp); | |
556 } | |
557 } | |
558 } | |
559 | |
560 | |
561 void Assembler::DeleteUnresolvedBranchInfoForLabelTraverse(Label* label) { | |
562 ASSERT(label->is_linked()); | |
563 CheckLabelLinkChain(label); | |
564 | |
565 int link_offset = label->pos(); | |
566 int link_pcoffset; | |
567 bool end_of_chain = false; | |
568 | |
569 while (!end_of_chain) { | |
570 Instruction * link = InstructionAt(link_offset); | |
571 link_pcoffset = link->ImmPCOffset(); | |
572 | |
573 // ADR instructions are not handled by veneers. | |
574 if (link->IsImmBranch()) { | |
575 int max_reachable_pc = InstructionOffset(link) + | |
576 Instruction::ImmBranchRange(link->BranchType()); | |
577 typedef std::multimap<int, FarBranchInfo>::iterator unresolved_info_it; | |
578 std::pair<unresolved_info_it, unresolved_info_it> range; | |
579 range = unresolved_branches_.equal_range(max_reachable_pc); | |
580 unresolved_info_it it; | |
581 for (it = range.first; it != range.second; ++it) { | |
582 if (it->second.pc_offset_ == link_offset) { | |
583 unresolved_branches_.erase(it); | |
584 break; | |
585 } | |
586 } | |
587 } | |
588 | |
589 end_of_chain = (link_pcoffset == 0); | |
590 link_offset = link_offset + link_pcoffset; | |
591 } | |
592 } | |
593 | |
594 | |
548 void Assembler::DeleteUnresolvedBranchInfoForLabel(Label* label) { | 595 void Assembler::DeleteUnresolvedBranchInfoForLabel(Label* label) { |
549 if (unresolved_branches_.empty()) { | 596 if (unresolved_branches_.empty()) { |
550 ASSERT(next_veneer_pool_check_ == kMaxInt); | 597 ASSERT(next_veneer_pool_check_ == kMaxInt); |
551 return; | 598 return; |
552 } | 599 } |
553 | 600 |
554 if (label->is_linked()) { | 601 if (label->is_linked()) { |
555 // Branches to this label will be resolved when the label is bound below. | 602 // Branches to this label will be resolved when the label is bound, normally |
556 std::multimap<int, FarBranchInfo>::iterator it_tmp, it; | 603 // just after all the associated info has been deleted. |
557 it = unresolved_branches_.begin(); | 604 |
558 while (it != unresolved_branches_.end()) { | 605 // If there are too many unresolved branches pending, avoid iterating |
559 it_tmp = it++; | 606 // through all of them to find the information to delete. |
560 if (it_tmp->second.label_ == label) { | 607 static const int kMaxNInfoIterate = 128; |
561 CHECK(it_tmp->first >= pc_offset()); | 608 |
562 unresolved_branches_.erase(it_tmp); | 609 if (unresolved_branches_.size() < kMaxNInfoIterate) { |
563 } | 610 DeleteUnresolvedBranchInfoForLabelIterate(label); |
611 } else { | |
612 DeleteUnresolvedBranchInfoForLabelTraverse(label); | |
ulan
2014/04/07 13:24:41
Ignoring ADR instructions, chain length <= unresol
Alexandre Rames
2014/04/09 13:22:06
Yes.
| |
564 } | 613 } |
565 } | 614 } |
566 if (unresolved_branches_.empty()) { | 615 if (unresolved_branches_.empty()) { |
567 next_veneer_pool_check_ = kMaxInt; | 616 next_veneer_pool_check_ = kMaxInt; |
568 } else { | 617 } else { |
569 next_veneer_pool_check_ = | 618 next_veneer_pool_check_ = |
570 unresolved_branches_first_limit() - kVeneerDistanceCheckMargin; | 619 unresolved_branches_first_limit() - kVeneerDistanceCheckMargin; |
571 } | 620 } |
572 } | 621 } |
573 | 622 |
(...skipping 2309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2883 adr(rd, 0); | 2932 adr(rd, 0); |
2884 MovInt64(scratch, target_offset); | 2933 MovInt64(scratch, target_offset); |
2885 add(rd, rd, scratch); | 2934 add(rd, rd, scratch); |
2886 } | 2935 } |
2887 } | 2936 } |
2888 | 2937 |
2889 | 2938 |
2890 } } // namespace v8::internal | 2939 } } // namespace v8::internal |
2891 | 2940 |
2892 #endif // V8_TARGET_ARCH_ARM64 | 2941 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |