Merge pull request #5014 from vkargov/vk-kasha
authorRodrigo Kumpera <kumpera@users.noreply.github.com>
Fri, 16 Jun 2017 18:42:20 +0000 (14:42 -0400)
committerGitHub <noreply@github.com>
Fri, 16 Jun 2017 18:42:20 +0000 (14:42 -0400)
[jit] Always cache the latest image set in case of a cache miss.

mono/metadata/metadata.c

index dd1ea04a33edf386bbbe223a2b2c5ded843b5ce5..133310e69216ef965510445729d7c4cc7ff13861 100644 (file)
@@ -2556,8 +2556,11 @@ get_image_set (MonoImage **images, int nimages)
                        }
 
                        // If we iterated all the way through images without breaking, all items in images were found in set->images
-                       if (j == nimages)
-                               break; // Break on "found a set with equal members"
+                       if (j == nimages) {
+                               // Break on "found a set with equal members".
+                               // This happens in case of a hash collision with a previously cached set.
+                               break;
+                       }
                }
 
                l = l->next;
@@ -2581,10 +2584,11 @@ get_image_set (MonoImage **images, int nimages)
 
                g_ptr_array_add (image_sets, set);
                ++img_set_count;
-
-               img_set_cache_add (set);
        }
 
+       /* Cache the set. If there was a cache collision, the previously cached value will be replaced. */
+       img_set_cache_add (set);
+
        if (nimages == 1 && images [0] == mono_defaults.corlib) {
                mono_memory_barrier ();
                mscorlib_image_set = set;