From 663c93448e50599d411b2403585b90513dbf8e3a Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 22 Jul 2015 11:28:14 +0100 Subject: ART: Fix Thumb2 literal fixup. When processing a load literal during fixup, we use the current code size to determine whether we need to add the padding before literals. However, this may change by the end of the fixup, yet we didn't recalculate to see if the load literal is pushed out of range. Instead of making the load literal fixup also depend on all preceding fixups, add an extra pass over literals when we need the padding and repeat the fixup loop if needed. Change-Id: Ia21d660486167a2dcb1ad4afe8acc669b4af669d --- compiler/utils/arm/assembler_thumb2.cc | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'compiler/utils/arm/assembler_thumb2.cc') diff --git a/compiler/utils/arm/assembler_thumb2.cc b/compiler/utils/arm/assembler_thumb2.cc index 413b9eaa8c..b499dddb0c 100644 --- a/compiler/utils/arm/assembler_thumb2.cc +++ b/compiler/utils/arm/assembler_thumb2.cc @@ -133,14 +133,27 @@ uint32_t Thumb2Assembler::AdjustFixups() { AdjustFixupIfNeeded(&fixup, ¤t_code_size, &fixups_to_recalculate); } while (!fixups_to_recalculate.empty()) { - // Pop the fixup. - FixupId fixup_id = fixups_to_recalculate.front(); - fixups_to_recalculate.pop_front(); - Fixup* fixup = GetFixup(fixup_id); - DCHECK_NE(buffer_.Load(fixup->GetLocation()), 0); - buffer_.Store(fixup->GetLocation(), 0); - // See if it needs adjustment. - AdjustFixupIfNeeded(fixup, ¤t_code_size, &fixups_to_recalculate); + do { + // Pop the fixup. + FixupId fixup_id = fixups_to_recalculate.front(); + fixups_to_recalculate.pop_front(); + Fixup* fixup = GetFixup(fixup_id); + DCHECK_NE(buffer_.Load(fixup->GetLocation()), 0); + buffer_.Store(fixup->GetLocation(), 0); + // See if it needs adjustment. + AdjustFixupIfNeeded(fixup, ¤t_code_size, &fixups_to_recalculate); + } while (!fixups_to_recalculate.empty()); + + if ((current_code_size & 2) != 0 && !literals_.empty()) { + // If we need to add padding before literals, this may just push some out of range, + // so recalculate all load literals. This makes up for the fact that we don't mark + // load literal as a dependency of all previous Fixups even though it actually is. + for (Fixup& fixup : fixups_) { + if (fixup.IsLoadLiteral()) { + AdjustFixupIfNeeded(&fixup, ¤t_code_size, &fixups_to_recalculate); + } + } + } } if (kIsDebugBuild) { // Check that no fixup is marked as being in fixups_to_recalculate anymore. -- cgit v1.2.3-59-g8ed1b