[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 22/25: Fix pool version of scm_array_for_each_cell by al
From: |
Daniel Llorens |
Subject: |
[Guile-commits] 22/25: Fix pool version of scm_array_for_each_cell by aligning pointers |
Date: |
Mon, 11 Jul 2016 08:21:12 +0000 (UTC) |
lloda pushed a commit to branch lloda-array-support
in repository guile.
commit 4a361f2902171a094d7f9b5bf2a98da9445fbd23
Author: Daniel Llorens <address@hidden>
Date: Wed Jun 22 14:54:01 2016 +0200
Fix pool version of scm_array_for_each_cell by aligning pointers
* libguile/array-map.c (scm_array_for_each_cell): Align all pointers to
pointer size.
---
libguile/array-map.c | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/libguile/array-map.c b/libguile/array-map.c
index 028f79b..3d1b3e3 100644
--- a/libguile/array-map.c
+++ b/libguile/array-map.c
@@ -651,7 +651,8 @@ scm_i_array_rebase (SCM a, size_t base)
return b;
}
-/*
+static inline size_t padtoptr(size_t d) { return (d + (sizeof (void *) - 1)) &
~(sizeof (void *) - 1); }
+
SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
(SCM frame_rank, SCM op, SCM args),
"Apply @var{op} to each of the cells of rank
rank(@var{arg})address@hidden"
@@ -679,23 +680,23 @@ SCM_DEFINE (scm_array_for_each_cell,
"array-for-each-cell", 2, 0, 1,
SCM dargs_ = SCM_EOL;
size_t stack_size = 0;
- stack_size += N*sizeof (scm_t_array_handle);
- stack_size += N*sizeof (SCM);
- stack_size += N*sizeof (scm_t_array_dim *);
- stack_size += N*sizeof (int);
-
- stack_size += frank*sizeof (ssize_t);
- stack_size += N*sizeof (SCM);
- stack_size += N*sizeof (SCM *);
- stack_size += frank*sizeof (ssize_t);
-
- stack_size += frank*sizeof (int);
- stack_size += N*sizeof (size_t);
+ stack_size += padtoptr(N*sizeof (scm_t_array_handle));
+ stack_size += padtoptr(N*sizeof (SCM));
+ stack_size += padtoptr(N*sizeof (scm_t_array_dim *));
+ stack_size += padtoptr(N*sizeof (int));
+
+ stack_size += padtoptr(frank*sizeof (ssize_t));
+ stack_size += padtoptr(N*sizeof (SCM));
+ stack_size += padtoptr(N*sizeof (SCM *));
+ stack_size += padtoptr(frank*sizeof (ssize_t));
+
+ stack_size += padtoptr(frank*sizeof (int));
+ stack_size += padtoptr(N*sizeof (size_t));
char * stack = scm_gc_malloc (stack_size, "stack");
#define AFIC_ALLOC_ADVANCE(stack, count, type, name) \
type * name = (void *)stack; \
- stack += count*sizeof (type);
+ stack += padtoptr(count*sizeof (type));
char * stack0 = stack;
AFIC_ALLOC_ADVANCE (stack, N, scm_t_array_handle, ah);
@@ -884,8 +885,8 @@ SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell",
2, 0, 1,
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
-*/
+/*
SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
(SCM frame_rank, SCM op, SCM args),
"Apply @var{op} to each of the cells of rank
rank(@var{arg})address@hidden"
@@ -909,8 +910,8 @@ SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell",
2, 0, 1,
#define FUNC_NAME s_scm_array_for_each_cell
{
// FIXME replace stack by scm_gc_malloc_pointerless()
- int const N = scm_ilength(args);
- int const frank = scm_to_int(frame_rank);
+ int const N = scm_ilength (args);
+ int const frank = scm_to_int (frame_rank);
SCM dargs_ = SCM_EOL;
scm_t_array_handle ah[N];
@@ -1097,6 +1098,7 @@ SCM_DEFINE (scm_array_for_each_cell,
"array-for-each-cell", 2, 0, 1,
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
+*/
SCM_DEFINE (scm_array_for_each_cell_in_order, "array-for-each-cell-in-order",
2, 0, 1,
(SCM frank, SCM op, SCM a),
- [Guile-commits] 13/25: Remove deprecated and unused generalized-vector functions, (continued)
- [Guile-commits] 13/25: Remove deprecated and unused generalized-vector functions, Daniel Llorens, 2016/07/11
- [Guile-commits] 09/25: Don't use array handles in scm_c_array_rank, Daniel Llorens, 2016/07/11
- [Guile-commits] 08/25: Rename array-set-from!, scm_array_set_from_x to array-amend!, scm_array_amend_x, Daniel Llorens, 2016/07/11
- [Guile-commits] 24/25: Remove uniform-array-read!, uniform-array-write from the manual, Daniel Llorens, 2016/07/11
- [Guile-commits] 07/25: Tests & doc for array-from, array-from*, array-set-from!, Daniel Llorens, 2016/07/11
- [Guile-commits] 23/25: Remove commented stack version of scm_array_for_each_cell(), Daniel Llorens, 2016/07/11
- [Guile-commits] 16/25: Draft documentation for (array-for-each-cell), Daniel Llorens, 2016/07/11
- [Guile-commits] 12/25: Speed up for multi-arg cases of scm_ramap functions, Daniel Llorens, 2016/07/11
- [Guile-commits] 21/25: Fix a corner case with empty arrays in (array-for-each-cell), Daniel Llorens, 2016/07/11
- [Guile-commits] 15/25: Draft of (array-for-each-cell), Daniel Llorens, 2016/07/11
- [Guile-commits] 22/25: Fix pool version of scm_array_for_each_cell by aligning pointers,
Daniel Llorens <=
- [Guile-commits] 25/25: Support typed arrays in some sort functions, Daniel Llorens, 2016/07/11