From fab6788358dfb64e5c370611ddbbbffab0ed0553 Mon Sep 17 00:00:00 2001 From: Richard Uhler Date: Mon, 13 Jul 2015 17:00:35 -0700 Subject: Fix FieldGap priority queue ordering bug. The priority queue for keeping track of gaps when packing fields in a class object had the order reversed, giving priority to smaller gaps instead of priority to larger gaps. This led to cases where fields were not placed in gaps when they could be. Bug: 22460222 Change-Id: I062e772e030c034adc227d75deed31c3322e203e --- runtime/class_linker.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'runtime/class_linker.cc') diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 06942275c6..fbb2796b9c 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -194,7 +194,9 @@ struct FieldGapsComparator { bool operator() (const FieldGap& lhs, const FieldGap& rhs) NO_THREAD_SAFETY_ANALYSIS { // Sort by gap size, largest first. Secondary sort by starting offset. - return lhs.size > rhs.size || (lhs.size == rhs.size && lhs.start_offset < rhs.start_offset); + // Note that the priority queue returns the largest element, so operator() + // should return true if lhs is less than rhs. + return lhs.size < rhs.size || (lhs.size == rhs.size && lhs.start_offset > rhs.start_offset); } }; typedef std::priority_queue, FieldGapsComparator> FieldGaps; -- cgit v1.2.3-59-g8ed1b