summaryrefslogtreecommitdiffstats
path: root/memory/mozjemalloc/rb.h
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-11-30 15:42:59 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-11-30 15:42:59 +0100
commitb4b589a11875ed290d8b632c7a69b89b293f864c (patch)
tree8f950a7ed4a02074d62ac2c1621c213f03f809cc /memory/mozjemalloc/rb.h
parenta954e19ea2f65cc4f7798027ef4658c5cbcb3290 (diff)
downloadUXP-b4b589a11875ed290d8b632c7a69b89b293f864c.tar
UXP-b4b589a11875ed290d8b632c7a69b89b293f864c.tar.gz
UXP-b4b589a11875ed290d8b632c7a69b89b293f864c.tar.lz
UXP-b4b589a11875ed290d8b632c7a69b89b293f864c.tar.xz
UXP-b4b589a11875ed290d8b632c7a69b89b293f864c.zip
Issue #1307 - Part 4: Stop using variable-length arrays.
"USING VLA'S IS ACTIVELY STUPID! It generates much more code, and much slower code (and more fragile code), than just using a fixed key size would have done." -- Linus Torvalds
Diffstat (limited to 'memory/mozjemalloc/rb.h')
-rw-r--r--memory/mozjemalloc/rb.h54
1 files changed, 20 insertions, 34 deletions
diff --git a/memory/mozjemalloc/rb.h b/memory/mozjemalloc/rb.h
index 431ad9ddb..a1b08973b 100644
--- a/memory/mozjemalloc/rb.h
+++ b/memory/mozjemalloc/rb.h
@@ -36,7 +36,6 @@
* (Optional.)
* #define SIZEOF_PTR ...
* #define SIZEOF_PTR_2POW ...
- * #define RB_NO_C99_VARARRAYS
*
* (Optional, see assert(3).)
* #define NDEBUG
@@ -769,39 +768,26 @@ a_prefix##remove(a_tree_type *tree, a_type *node) { \
* effort.
*/
-#ifdef RB_NO_C99_VARARRAYS
- /*
- * Avoid using variable-length arrays, at the cost of using more stack space.
- * Size the path arrays such that they are always large enough, even if a
- * tree consumes all of memory. Since each node must contain a minimum of
- * two pointers, there can never be more nodes than:
- *
- * 1 << ((SIZEOF_PTR<<3) - (SIZEOF_PTR_2POW+1))
- *
- * Since the depth of a tree is limited to 3*lg(#nodes), the maximum depth
- * is:
- *
- * (3 * ((SIZEOF_PTR<<3) - (SIZEOF_PTR_2POW+1)))
- *
- * This works out to a maximum depth of 87 and 180 for 32- and 64-bit
- * systems, respectively (approximatly 348 and 1440 bytes, respectively).
- */
-# define rbp_compute_f_height(a_type, a_field, a_tree)
-# define rbp_f_height (3 * ((SIZEOF_PTR<<3) - (SIZEOF_PTR_2POW+1)))
-# define rbp_compute_fr_height(a_type, a_field, a_tree)
-# define rbp_fr_height (3 * ((SIZEOF_PTR<<3) - (SIZEOF_PTR_2POW+1)))
-#else
-# define rbp_compute_f_height(a_type, a_field, a_tree) \
- /* Compute the maximum possible tree depth (3X the black height). */\
- unsigned rbp_f_height; \
- rbp_black_height(a_type, a_field, a_tree, rbp_f_height); \
- rbp_f_height *= 3;
-# define rbp_compute_fr_height(a_type, a_field, a_tree) \
- /* Compute the maximum possible tree depth (3X the black height). */\
- unsigned rbp_fr_height; \
- rbp_black_height(a_type, a_field, a_tree, rbp_fr_height); \
- rbp_fr_height *= 3;
-#endif
+/*
+ * Avoid using variable-length arrays.
+ * Size the path arrays such that they are always large enough, even if a
+ * tree consumes all of memory. Since each node must contain a minimum of
+ * two pointers, there can never be more nodes than:
+ *
+ * 1 << ((SIZEOF_PTR<<3) - (SIZEOF_PTR_2POW+1))
+ *
+ * Since the depth of a tree is limited to 3*lg(#nodes), the maximum depth
+ * is:
+ *
+ * (3 * ((SIZEOF_PTR<<3) - (SIZEOF_PTR_2POW+1)))
+ *
+ * This works out to a maximum depth of 87 and 180 for 32- and 64-bit
+ * systems, respectively (approximatly 348 and 1440 bytes, respectively).
+ */
+#define rbp_compute_f_height(a_type, a_field, a_tree)
+#define rbp_f_height (3 * ((SIZEOF_PTR<<3) - (SIZEOF_PTR_2POW+1)))
+#define rbp_compute_fr_height(a_type, a_field, a_tree)
+#define rbp_fr_height (3 * ((SIZEOF_PTR<<3) - (SIZEOF_PTR_2POW+1)))
#define rb_foreach_begin(a_type, a_field, a_tree, a_var) { \
rbp_compute_f_height(a_type, a_field, a_tree) \