Title: [284210] branches/safari-613.1.5-branch/Source/bmalloc
Revision
284210
Author
[email protected]
Date
2021-10-14 15:54:51 -0700 (Thu, 14 Oct 2021)

Log Message

Cherry-pick r284208. rdar://problem/84277677

    [libpas] Use `enum { ... }` instead of `static const size_t` for constant values used for array size
    https://bugs.webkit.org/show_bug.cgi?id=231778

    Reviewed by Chris Dumez.

    Since libpas is written in C (not C++), we cannot use `static const size_t` value for array's size.
    In C, it is not usable as a constant _expression_ for array size. Use `enum` hack instead.

    * libpas/src/libpas/pas_generic_large_free_heap.h:
    (pas_generic_large_free_heap_try_allocate):
    * libpas/src/libpas/pas_large_sharing_pool.c:
    (pas_large_sharing_pool_allocate_and_commit):
    * libpas/src/libpas/pas_segregated_view_allocator_inlines.h:
    (pas_segregated_view_will_start_allocating):
    * libpas/src/libpas/pas_simple_large_free_heap.c:
    (merge):

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

Modified Paths

Diff

Modified: branches/safari-613.1.5-branch/Source/bmalloc/ChangeLog (284209 => 284210)


--- branches/safari-613.1.5-branch/Source/bmalloc/ChangeLog	2021-10-14 22:54:09 UTC (rev 284209)
+++ branches/safari-613.1.5-branch/Source/bmalloc/ChangeLog	2021-10-14 22:54:51 UTC (rev 284210)
@@ -1,3 +1,45 @@
+2021-10-14  Alan Coon  <[email protected]>
+
+        Cherry-pick r284208. rdar://problem/84277677
+
+    [libpas] Use `enum { ... }` instead of `static const size_t` for constant values used for array size
+    https://bugs.webkit.org/show_bug.cgi?id=231778
+    
+    Reviewed by Chris Dumez.
+    
+    Since libpas is written in C (not C++), we cannot use `static const size_t` value for array's size.
+    In C, it is not usable as a constant _expression_ for array size. Use `enum` hack instead.
+    
+    * libpas/src/libpas/pas_generic_large_free_heap.h:
+    (pas_generic_large_free_heap_try_allocate):
+    * libpas/src/libpas/pas_large_sharing_pool.c:
+    (pas_large_sharing_pool_allocate_and_commit):
+    * libpas/src/libpas/pas_segregated_view_allocator_inlines.h:
+    (pas_segregated_view_will_start_allocating):
+    * libpas/src/libpas/pas_simple_large_free_heap.c:
+    (merge):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-14  Yusuke Suzuki  <[email protected]>
+
+            [libpas] Use `enum { ... }` instead of `static const size_t` for constant values used for array size
+            https://bugs.webkit.org/show_bug.cgi?id=231778
+
+            Reviewed by Chris Dumez.
+
+            Since libpas is written in C (not C++), we cannot use `static const size_t` value for array's size.
+            In C, it is not usable as a constant _expression_ for array size. Use `enum` hack instead.
+
+            * libpas/src/libpas/pas_generic_large_free_heap.h:
+            (pas_generic_large_free_heap_try_allocate):
+            * libpas/src/libpas/pas_large_sharing_pool.c:
+            (pas_large_sharing_pool_allocate_and_commit):
+            * libpas/src/libpas/pas_segregated_view_allocator_inlines.h:
+            (pas_segregated_view_will_start_allocating):
+            * libpas/src/libpas/pas_simple_large_free_heap.c:
+            (merge):
+
 2021-09-30  Filip Pizlo  <[email protected]>
 
         [libpas] Change the names of libpas heap runtime configs to something simpler (intrinsic, primitive, typed, and flex) and add comments describing what they are (update to 32abc1fd5489e01aa1c504ae4654967047d3f072)

Modified: branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_generic_large_free_heap.h (284209 => 284210)


--- branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_generic_large_free_heap.h	2021-10-14 22:54:09 UTC (rev 284209)
+++ branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_generic_large_free_heap.h	2021-10-14 22:54:51 UTC (rev 284210)
@@ -387,7 +387,7 @@
             }
         }
     } else {
-        static const size_t max_num_additions = 2;
+        enum { max_num_additions = 2 };
         pas_large_free additions[max_num_additions];
         size_t num_additions = 0;
         

Modified: branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_heap_config_kind.h (284209 => 284210)


--- branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_heap_config_kind.h	2021-10-14 22:54:09 UTC (rev 284209)
+++ branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_heap_config_kind.h	2021-10-14 22:54:51 UTC (rev 284210)
@@ -42,13 +42,13 @@
 
 typedef enum pas_heap_config_kind pas_heap_config_kind;
 
-static const unsigned pas_heap_config_kind_num_kinds =
+enum { pas_heap_config_kind_num_kinds =
     0
 #define PAS_DEFINE_HEAP_CONFIG_KIND(name, value) \
     + 1
 #include "pas_heap_config_kind.def"
 #undef PAS_DEFINE_HEAP_CONFIG_KIND
-    ;
+};
 
 static inline const char*
 pas_heap_config_kind_get_string(pas_heap_config_kind kind)

Modified: branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_large_sharing_pool.c (284209 => 284210)


--- branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_large_sharing_pool.c	2021-10-14 22:54:09 UTC (rev 284209)
+++ branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_large_sharing_pool.c	2021-10-14 22:54:51 UTC (rev 284210)
@@ -1068,7 +1068,7 @@
 
     case pas_physical_memory_is_locked_by_virtual_range_common_lock:
         if (commit_log.total || pas_physical_page_sharing_pool_balance < 0) {
-            static const size_t max_num_locks_held = 2;
+            enum { max_num_locks_held = 2 };
             
             pas_lock* locks_held[max_num_locks_held];
             size_t num_locks_held;

Modified: branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_segregated_view_allocator_inlines.h (284209 => 284210)


--- branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_segregated_view_allocator_inlines.h	2021-10-14 22:54:09 UTC (rev 284209)
+++ branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_segregated_view_allocator_inlines.h	2021-10-14 22:54:51 UTC (rev 284210)
@@ -140,7 +140,7 @@
                     return NULL;
                 }
             } else {
-                static const size_t max_num_locks_held = 1;
+                enum { max_num_locks_held = 1 };
                 pas_lock* locks_held[max_num_locks_held];
                 size_t num_locks_held;
                 bool did_lock_lock;

Modified: branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_simple_large_free_heap.c (284209 => 284210)


--- branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_simple_large_free_heap.c	2021-10-14 22:54:09 UTC (rev 284209)
+++ branches/safari-613.1.5-branch/Source/bmalloc/libpas/src/libpas/pas_simple_large_free_heap.c	2021-10-14 22:54:51 UTC (rev 284210)
@@ -136,7 +136,7 @@
 static void merge(pas_simple_large_free_heap* heap, pas_large_free new_free,
                   pas_large_free_heap_config* config)
 {
-    static const size_t max_num_victims = 2;
+    enum { max_num_victims = 2 };
     
     size_t victim_indices[max_num_victims];
     size_t num_victims = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to