| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "courgette/adjustment_method.h" | 5 #include "courgette/adjustment_method.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 struct OrderLabelInfoByAddressAscending { | 76 struct OrderLabelInfoByAddressAscending { |
| 77 bool operator()(const LabelInfo* a, const LabelInfo* b) const { | 77 bool operator()(const LabelInfo* a, const LabelInfo* b) const { |
| 78 return a->label_->rva_ < b->label_->rva_; | 78 return a->label_->rva_ < b->label_->rva_; |
| 79 } | 79 } |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 static std::string ToString(LabelInfo* info) { | 82 static std::string ToString(LabelInfo* info) { |
| 83 std::string s; | 83 std::string s; |
| 84 StringAppendF(&s, "%c%d", "pm"[info->is_model_], info->debug_index_); | 84 base::StringAppendF(&s, "%c%d", "pm"[info->is_model_], info->debug_index_); |
| 85 if (info->label_->index_ != Label::kNoIndex) | 85 if (info->label_->index_ != Label::kNoIndex) |
| 86 StringAppendF(&s, " (%d)", info->label_->index_); | 86 base::StringAppendF(&s, " (%d)", info->label_->index_); |
| 87 | 87 |
| 88 StringAppendF(&s, " #%u", info->refs_); | 88 base::StringAppendF(&s, " #%u", info->refs_); |
| 89 return s; | 89 return s; |
| 90 } | 90 } |
| 91 | 91 |
| 92 // General graph matching is exponential, essentially trying all permutations. | 92 // General graph matching is exponential, essentially trying all permutations. |
| 93 // The exponential algorithm can be made faster by avoiding consideration of | 93 // The exponential algorithm can be made faster by avoiding consideration of |
| 94 // impossible or unlikely matches. We can make the matching practical by eager | 94 // impossible or unlikely matches. We can make the matching practical by eager |
| 95 // matching - by looking for likely matches and commiting to them, and using the | 95 // matching - by looking for likely matches and commiting to them, and using the |
| 96 // committed assignment as the basis for further matching. | 96 // committed assignment as the basis for further matching. |
| 97 // | 97 // |
| 98 // The basic eager graph-matching assignment is based on several ideas: | 98 // The basic eager graph-matching assignment is based on several ideas: |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 AdjustmentMethod* method = AdjustmentMethod::MakeProductionAdjustmentMethod(); | 685 AdjustmentMethod* method = AdjustmentMethod::MakeProductionAdjustmentMethod(); |
| 686 bool ok = method->Adjust(model, program); | 686 bool ok = method->Adjust(model, program); |
| 687 method->Destroy(); | 687 method->Destroy(); |
| 688 if (ok) | 688 if (ok) |
| 689 return C_OK; | 689 return C_OK; |
| 690 else | 690 else |
| 691 return C_ADJUSTMENT_FAILED; | 691 return C_ADJUSTMENT_FAILED; |
| 692 } | 692 } |
| 693 | 693 |
| 694 } // namespace courgette | 694 } // namespace courgette |
| OLD | NEW |