From 8abcfa68f609e3df59f3be95bb54490b4884409e Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Tue, 4 Aug 2015 15:26:50 +0200 Subject: [PATCH] [mcs] Cached labels definite assignment check does not need exact match but anything larger than original set satisfies the condition. Fixes #32732 --- mcs/mcs/context.cs | 2 +- mcs/mcs/flowanalysis.cs | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mcs/mcs/context.cs b/mcs/mcs/context.cs index 88e52370070..fbb21d0096f 100644 --- a/mcs/mcs/context.cs +++ b/mcs/mcs/context.cs @@ -497,7 +497,7 @@ namespace Mono.CSharp } foreach (var existing in das) { - if (DefiniteAssignmentBitSet.AreEqual (existing, DefiniteAssignment)) + if (DefiniteAssignmentBitSet.IsIncluded (existing, DefiniteAssignment)) return true; } diff --git a/mcs/mcs/flowanalysis.cs b/mcs/mcs/flowanalysis.cs index b9189c1f3d6..267879c043b 100644 --- a/mcs/mcs/flowanalysis.cs +++ b/mcs/mcs/flowanalysis.cs @@ -552,7 +552,7 @@ namespace Mono.CSharp public static DefiniteAssignmentBitSet operator & (DefiniteAssignmentBitSet a, DefiniteAssignmentBitSet b) { - if (AreEqual (a, b)) + if (IsEqual (a, b)) return a; DefiniteAssignmentBitSet res; @@ -575,7 +575,7 @@ namespace Mono.CSharp public static DefiniteAssignmentBitSet operator | (DefiniteAssignmentBitSet a, DefiniteAssignmentBitSet b) { - if (AreEqual (a, b)) + if (IsEqual (a, b)) return a; DefiniteAssignmentBitSet res; @@ -678,7 +678,7 @@ namespace Mono.CSharp large_bits[index >> 5] |= (1 << (index & 31)); } - public static bool AreEqual (DefiniteAssignmentBitSet a, DefiniteAssignmentBitSet b) + static bool IsEqual (DefiniteAssignmentBitSet a, DefiniteAssignmentBitSet b) { if (a.large_bits == null) return (a.bits & ~copy_on_write_flag) == (b.bits & ~copy_on_write_flag); @@ -690,5 +690,20 @@ namespace Mono.CSharp return true; } + + public static bool IsIncluded (DefiniteAssignmentBitSet set, DefiniteAssignmentBitSet test) + { + var set_bits = set.large_bits; + if (set_bits == null) + return (set.bits & test.bits & ~copy_on_write_flag) == (set.bits & ~copy_on_write_flag); + + var test_bits = test.large_bits; + for (int i = 0; i < set_bits.Length; ++i) { + if ((set_bits[i] & test_bits[i]) != set_bits[i]) + return false; + } + + return true; + } } } -- 2.11.4.GIT