Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Unified Diff: courgette/adjustment_method.cc

Issue 2457133002: [Courgette] Refactor: Add AssemblyProgram::DispatchInstructionLabels() to hide InstructionVector us… (Closed)
Patch Set: Rename 'Dispatch' to 'Handle'. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | courgette/adjustment_method_2.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/adjustment_method.cc
diff --git a/courgette/adjustment_method.cc b/courgette/adjustment_method.cc
index ce93a21a87b3bc8be3103a7b8572c5e1045781a5..d6718bc8d919add050c364381bd038c3c34d67ee 100644
--- a/courgette/adjustment_method.cc
+++ b/courgette/adjustment_method.cc
@@ -14,6 +14,7 @@
#include <string>
#include <vector>
+#include "base/bind.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
@@ -592,17 +593,19 @@ class GraphAdjuster : public AdjustmentMethod {
}
private:
-
void CollectTraces(const AssemblyProgram* program, Trace* abs32, Trace* rel32,
bool is_model) {
- const InstructionVector& instructions = program->instructions();
- for (size_t i = 0; i < instructions.size(); ++i) {
- Instruction* instruction = instructions[i];
- if (Label* label = program->InstructionAbs32Label(instruction))
- ReferenceLabel(abs32, label, is_model);
- if (Label* label = program->InstructionRel32Label(instruction))
- ReferenceLabel(rel32, label, is_model);
- }
+ AssemblyProgram::LabelHandler abs32_handler =
+ base::Bind(&GraphAdjuster::ReferenceLabel, base::Unretained(this),
+ abs32, is_model);
+ AssemblyProgram::LabelHandler rel32_handler =
+ base::Bind(&GraphAdjuster::ReferenceLabel, base::Unretained(this),
+ rel32, is_model);
+
+ program->HandleInstructionLabels({{ABS32, abs32_handler},
+ {REL32, rel32_handler},
+ {REL32ARM, rel32_handler}});
+
// TODO(sra): we could simply append all the labels in index order to
// incorporate some costing for entropy (bigger deltas) that will be
// introduced into the label address table by non-monotonic ordering. This
@@ -634,7 +637,7 @@ class GraphAdjuster : public AdjustmentMethod {
}
}
- void ReferenceLabel(Trace* trace, Label* label, bool is_model) {
+ void ReferenceLabel(Trace* trace, bool is_model, Label* label) {
trace->push_back(
MakeLabelInfo(label, is_model, static_cast<uint32_t>(trace->size())));
}
« no previous file with comments | « no previous file | courgette/adjustment_method_2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698