Title: [291660] branches/safari-613-branch/Source/bmalloc
Revision
291660
Author
[email protected]
Date
2022-03-22 10:56:19 -0700 (Tue, 22 Mar 2022)

Log Message

Cherry-pick r291097. rdar://problem/89116983

    [libpas] We should gurantee that in-flux-stash is fully baked when pointing table is set
    https://bugs.webkit.org/show_bug.cgi?id=237697
    rdar://89116983

    Reviewed by Mark Lam.

    To support enumerating hashtable which can be in the middle of resizing, we have in-flux-stash: this
    small stash is used to keep old table and size while resizing. However, Mark pointed that
    pas_tiny_large_map_hashtable_for_each_entry_remote's assertion is firing, which is ensuring that table's
    underlying pointer should be NULL when the size is 0. But in-flux-stash, we did not guarantee that
    in-flux-stash data is consistent when it is exposed to the enumerator (when setting hashtable_being_resized).

    This patch inserts pas_compiler_fence when exposing and unexposing in-flux-stash. pas_compiler_fence is
    enough (pas_store_store_fence is not necessary) because pas_enumerator runs after suspending the process.
    Thus, data structure's consistency between instruction boundary is enough.

    * libpas/src/libpas/pas_hashtable.h:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291097 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-613-branch/Source/bmalloc/ChangeLog (291659 => 291660)


--- branches/safari-613-branch/Source/bmalloc/ChangeLog	2022-03-22 17:56:17 UTC (rev 291659)
+++ branches/safari-613-branch/Source/bmalloc/ChangeLog	2022-03-22 17:56:19 UTC (rev 291660)
@@ -1,5 +1,49 @@
 2022-03-21  Alan Coon  <[email protected]>
 
+        Cherry-pick r291097. rdar://problem/89116983
+
+    [libpas] We should gurantee that in-flux-stash is fully baked when pointing table is set
+    https://bugs.webkit.org/show_bug.cgi?id=237697
+    rdar://89116983
+    
+    Reviewed by Mark Lam.
+    
+    To support enumerating hashtable which can be in the middle of resizing, we have in-flux-stash: this
+    small stash is used to keep old table and size while resizing. However, Mark pointed that
+    pas_tiny_large_map_hashtable_for_each_entry_remote's assertion is firing, which is ensuring that table's
+    underlying pointer should be NULL when the size is 0. But in-flux-stash, we did not guarantee that
+    in-flux-stash data is consistent when it is exposed to the enumerator (when setting hashtable_being_resized).
+    
+    This patch inserts pas_compiler_fence when exposing and unexposing in-flux-stash. pas_compiler_fence is
+    enough (pas_store_store_fence is not necessary) because pas_enumerator runs after suspending the process.
+    Thus, data structure's consistency between instruction boundary is enough.
+    
+    * libpas/src/libpas/pas_hashtable.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291097 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-03-09  Yusuke Suzuki  <[email protected]>
+
+            [libpas] We should gurantee that in-flux-stash is fully baked when pointing table is set
+            https://bugs.webkit.org/show_bug.cgi?id=237697
+            rdar://89116983
+
+            Reviewed by Mark Lam.
+
+            To support enumerating hashtable which can be in the middle of resizing, we have in-flux-stash: this
+            small stash is used to keep old table and size while resizing. However, Mark pointed that
+            pas_tiny_large_map_hashtable_for_each_entry_remote's assertion is firing, which is ensuring that table's
+            underlying pointer should be NULL when the size is 0. But in-flux-stash, we did not guarantee that
+            in-flux-stash data is consistent when it is exposed to the enumerator (when setting hashtable_being_resized).
+
+            This patch inserts pas_compiler_fence when exposing and unexposing in-flux-stash. pas_compiler_fence is
+            enough (pas_store_store_fence is not necessary) because pas_enumerator runs after suspending the process.
+            Thus, data structure's consistency between instruction boundary is enough.
+
+            * libpas/src/libpas/pas_hashtable.h:
+
+2022-03-21  Alan Coon  <[email protected]>
+
         Cherry-pick r291007. rdar://problem/89984164
 
     [libpas] Report more actionable crash in pas_enumerator

Modified: branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_hashtable.h (291659 => 291660)


--- branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_hashtable.h	2022-03-22 17:56:17 UTC (rev 291659)
+++ branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_hashtable.h	2022-03-22 17:56:19 UTC (rev 291660)
@@ -149,10 +149,11 @@
             PAS_TESTING_ASSERT(!in_flux_stash->hashtable_being_resized); \
             in_flux_stash->table_before_resize = old_table; \
             in_flux_stash->table_size_before_resize = old_size; \
+            pas_compiler_fence(); /* When hashtable_being_resized is pointing at table, table_before_resize and table_size_before_resize need to be right values. */ \
             in_flux_stash->hashtable_being_resized = table; \
         } \
         pas_compiler_fence(); \
-        \
+        /* We do not need to ensure the ordering of the following stores since in-flux-stash is effective while running this code. */ \
         table->table = new_table; \
         table->table_size = new_size; \
         table->table_mask = new_table_mask; \
@@ -161,6 +162,7 @@
         pas_compiler_fence(); \
         if (in_flux_stash) { \
             in_flux_stash->hashtable_being_resized = NULL; \
+            pas_compiler_fence(); /* We should clear hashtable_being_resized first to tell memory enumerator that in_flux_stash is no longer effective. */ \
             in_flux_stash->table_before_resize = NULL; \
             in_flux_stash->table_size_before_resize = 0; \
         } \
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to