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

Unified Diff: courgette/adjustment_method_2.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 | « courgette/adjustment_method.cc ('k') | courgette/assembly_program.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/adjustment_method_2.cc
diff --git a/courgette/adjustment_method_2.cc b/courgette/adjustment_method_2.cc
index d783cdac81079969af84965c1be13cfc2411d58e..b5fbb7c610fabe2b8c08f3edabce4b6c957983f8 100644
--- a/courgette/adjustment_method_2.cc
+++ b/courgette/adjustment_method_2.cc
@@ -15,6 +15,7 @@
#include <string>
#include <vector>
+#include "base/bind.h"
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/macros.h"
@@ -1252,16 +1253,17 @@ class Adjuster : public AdjustmentMethod {
void CollectTraces(const AssemblyProgram* program, Trace* abs32, Trace* rel32,
bool is_model) {
label_info_maker_.ResetDebugLabel();
- 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->InstructionAbs64Label(instruction))
- ReferenceLabel(abs32, label, is_model);
- if (Label* label = program->InstructionRel32Label(instruction))
- ReferenceLabel(rel32, label, is_model);
- }
+
+ AssemblyProgram::LabelHandler abs32_handler = base::Bind(
+ &Adjuster::ReferenceLabel, base::Unretained(this), abs32, is_model);
+ AssemblyProgram::LabelHandler rel32_handler = base::Bind(
+ &Adjuster::ReferenceLabel, base::Unretained(this), rel32, is_model);
+
+ program->HandleInstructionLabels({{ABS32, abs32_handler},
+ {ABS64, 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
@@ -1277,7 +1279,7 @@ class Adjuster : public AdjustmentMethod {
<< (base::Time::Now() - start_time).InSecondsF();
}
- void ReferenceLabel(Trace* trace, Label* label, bool is_model) {
+ void ReferenceLabel(Trace* trace, bool is_model, Label* label) {
trace->push_back(label_info_maker_.MakeLabelInfo(
label, is_model, static_cast<uint32_t>(trace->size())));
}
« no previous file with comments | « courgette/adjustment_method.cc ('k') | courgette/assembly_program.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698