OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <limits> | 11 #include <limits> |
12 #include <list> | 12 #include <list> |
13 #include <map> | 13 #include <map> |
14 #include <set> | 14 #include <set> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "base/bind.h" | |
19 #include "base/format_macros.h" | 18 #include "base/format_macros.h" |
20 #include "base/logging.h" | 19 #include "base/logging.h" |
21 #include "base/macros.h" | 20 #include "base/macros.h" |
22 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
23 #include "base/time/time.h" | 22 #include "base/time/time.h" |
24 #include "courgette/assembly_program.h" | 23 #include "courgette/assembly_program.h" |
25 #include "courgette/courgette.h" | 24 #include "courgette/courgette.h" |
26 #include "courgette/encoded_program.h" | 25 #include "courgette/encoded_program.h" |
27 | 26 |
28 /* | 27 /* |
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 Solve(rel32_trace_, rel32_model_end); | 1246 Solve(rel32_trace_, rel32_model_end); |
1248 prog_->AssignRemainingIndexes(); | 1247 prog_->AssignRemainingIndexes(); |
1249 return true; | 1248 return true; |
1250 } | 1249 } |
1251 | 1250 |
1252 private: | 1251 private: |
1253 void CollectTraces(const AssemblyProgram* program, Trace* abs32, Trace* rel32, | 1252 void CollectTraces(const AssemblyProgram* program, Trace* abs32, Trace* rel32, |
1254 bool is_model) { | 1253 bool is_model) { |
1255 label_info_maker_.ResetDebugLabel(); | 1254 label_info_maker_.ResetDebugLabel(); |
1256 | 1255 |
1257 AssemblyProgram::LabelHandler abs32_handler = base::Bind( | 1256 for (Label* label : program->abs32_label_annotations()) |
1258 &Adjuster::ReferenceLabel, base::Unretained(this), abs32, is_model); | 1257 ReferenceLabel(abs32, is_model, label); |
1259 AssemblyProgram::LabelHandler rel32_handler = base::Bind( | 1258 for (Label* label : program->rel32_label_annotations()) |
1260 &Adjuster::ReferenceLabel, base::Unretained(this), rel32, is_model); | 1259 ReferenceLabel(rel32, is_model, label); |
1261 | |
1262 program->HandleInstructionLabels({{ABS32, abs32_handler}, | |
1263 {ABS64, abs32_handler}, | |
1264 {REL32, rel32_handler}, | |
1265 {REL32ARM, rel32_handler}}); | |
1266 | 1260 |
1267 // TODO(sra): we could simply append all the labels in index order to | 1261 // TODO(sra): we could simply append all the labels in index order to |
1268 // incorporate some costing for entropy (bigger deltas) that will be | 1262 // incorporate some costing for entropy (bigger deltas) that will be |
1269 // introduced into the label address table by non-monotonic ordering. This | 1263 // introduced into the label address table by non-monotonic ordering. This |
1270 // would have some knock-on effects to parts of the algorithm that work on | 1264 // would have some knock-on effects to parts of the algorithm that work on |
1271 // single-occurrence labels. | 1265 // single-occurrence labels. |
1272 } | 1266 } |
1273 | 1267 |
1274 void Solve(const Trace& model, size_t model_end) { | 1268 void Solve(const Trace& model, size_t model_end) { |
1275 base::Time start_time = base::Time::Now(); | 1269 base::Time start_time = base::Time::Now(); |
(...skipping 19 matching lines...) Expand all Loading... |
1295 | 1289 |
1296 //////////////////////////////////////////////////////////////////////////////// | 1290 //////////////////////////////////////////////////////////////////////////////// |
1297 | 1291 |
1298 } // namespace adjustment_method_2 | 1292 } // namespace adjustment_method_2 |
1299 | 1293 |
1300 AdjustmentMethod* AdjustmentMethod::MakeShingleAdjustmentMethod() { | 1294 AdjustmentMethod* AdjustmentMethod::MakeShingleAdjustmentMethod() { |
1301 return new adjustment_method_2::Adjuster(); | 1295 return new adjustment_method_2::Adjuster(); |
1302 } | 1296 } |
1303 | 1297 |
1304 } // namespace courgette | 1298 } // namespace courgette |
OLD | NEW |