aboutsummaryrefslogtreecommitdiff
path: root/zucchini_gen.cc
diff options
context:
space:
mode:
authorSamuel Huang <huangs@chromium.org>2018-03-13 21:35:53 +0000
committerEdward Lesmes <ehmaldonado@google.com>2021-07-23 21:52:01 +0000
commit56a6ff47bca7087db1916b2beeedee283cd1caf2 (patch)
tree4dba54508860de2e38422e938f49a9d8b9666155 /zucchini_gen.cc
parent06f1ae9aaca969ee95ef840f22b6b461c304542d (diff)
downloadzucchini-56a6ff47bca7087db1916b2beeedee283cd1caf2.tar.gz
[Zucchini] Zucchini-gen: Make number of CreateEquivalenceMap() generations depend on Disassembler.
The number of CreateEquivalenceMap() iterations used be constant kNumIteraitons = 2. This CL makes the value depend on architecture. Current assignment: - DisassemblerNoOp: 1, since no pointers are identified (though in this case, CreateEquivalenceMap() should not be called). - DisassemblerWin32: 2. Upcoming DisassemblerDex will use 4. Also applying generic cleanups on headers and comments. Bug: 729154 Change-Id: Ia12d98fcba500e4c81c8a5d356ce4cadf424ffde Reviewed-on: https://chromium-review.googlesource.com/961273 Reviewed-by: agrieve <agrieve@chromium.org> Commit-Queue: Samuel Huang <huangs@chromium.org> Cr-Commit-Position: refs/heads/master@{#542919} NOKEYCHECK=True GitOrigin-RevId: 55aea0a875b80e614464fdd157d9717471f9d64f
Diffstat (limited to 'zucchini_gen.cc')
-rw-r--r--zucchini_gen.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/zucchini_gen.cc b/zucchini_gen.cc
index 4be0b8b..0758e5a 100644
--- a/zucchini_gen.cc
+++ b/zucchini_gen.cc
@@ -33,7 +33,6 @@ namespace {
// Parameters for patch generation.
constexpr double kMinEquivalenceSimilarity = 12.0;
constexpr double kMinLabelAffinity = 64.0;
-constexpr size_t kNumIterations = 2;
} // namespace
@@ -46,21 +45,21 @@ std::vector<offset_t> FindExtraTargets(const TargetPool& projected_old_targets,
return extra_targets;
}
+// Label matching (between "old" and "new") can guide EquivalenceMap
+// construction; but EquivalenceMap induces Label matching. This apparent "chick
+// and egg" problem is solved by alternating 2 steps |num_iterations| times:
+// - Associate targets based on previous EquivalenceMap. Note on the first
+// iteration, EquivalenceMap is empty, resulting in a no-op.
+// - Construct refined EquivalenceMap based on new targets associations.
EquivalenceMap CreateEquivalenceMap(const ImageIndex& old_image_index,
- const ImageIndex& new_image_index) {
- // Label matching (between "old" and "new") can guide EquivalenceMap
- // construction; but EquivalenceMap induces Label matching. This apparent
- // "chick and egg" problem is solved by multiple iterations alternating 2
- // steps:
- // - Association of targets based on previous EquivalenceMap. Note that the
- // EquivalenceMap is empty on first iteration, so this is a no-op.
- // - Construction of refined EquivalenceMap based on new targets associations.
+ const ImageIndex& new_image_index,
+ int num_iterations) {
size_t pool_count = old_image_index.PoolCount();
// |target_affinities| is outside the loop to reduce allocation.
std::vector<TargetsAffinity> target_affinities(pool_count);
EquivalenceMap equivalence_map;
- for (size_t i = 0; i < kNumIterations; ++i) {
+ for (int i = 0; i < num_iterations; ++i) {
EncodedView old_view(old_image_index);
EncodedView new_view(new_image_index);
@@ -259,7 +258,8 @@ bool GenerateExecutableElement(ExecutableType exe_type,
DCHECK_EQ(old_image_index.PoolCount(), new_image_index.PoolCount());
EquivalenceMap equivalences =
- CreateEquivalenceMap(old_image_index, new_image_index);
+ CreateEquivalenceMap(old_image_index, new_image_index,
+ new_disasm->num_equivalence_iterations());
OffsetMapper offset_mapper(equivalences);
ReferenceDeltaSink reference_delta_sink;