[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 22/24: Fix pool version of scm_array_for_each_cell by al
From: |
Daniel Llorens |
Subject: |
[Guile-commits] 22/24: Fix pool version of scm_array_for_each_cell by aligning pointers |
Date: |
Fri, 24 Jun 2016 08:41:20 +0000 (UTC) |
lloda pushed a commit to branch lloda-array-support
in repository guile.
commit 9854fbc26c4f51c29f429d2a1a19c92a2894394b
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..5271765 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;
}
-/*
+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] branch lloda-array-support updated (b7adfdc -> d6bb2ab), Daniel Llorens, 2016/06/24
- [Guile-commits] 10/24: Fix compilation of rank 0 typed array literals, Daniel Llorens, 2016/06/24
- [Guile-commits] 17/24: New export (array-for-each-cell-in-order), Daniel Llorens, 2016/06/24
- [Guile-commits] 09/24: Don't use array handles in scm_c_array_rank, Daniel Llorens, 2016/06/24
- [Guile-commits] 02/24: Remove scm_from_contiguous_array, Daniel Llorens, 2016/06/24
- [Guile-commits] 22/24: Fix pool version of scm_array_for_each_cell by aligning pointers,
Daniel Llorens <=
- [Guile-commits] 08/24: Rename array-set-from!, scm_array_set_from_x to array-amend!, scm_array_amend_x, Daniel Llorens, 2016/06/24
- [Guile-commits] 18/24: Special case for array-map! with three arguments, Daniel Llorens, 2016/06/24
- [Guile-commits] 05/24: Compile in C99 mode, Daniel Llorens, 2016/06/24
- [Guile-commits] 19/24: Avoid variable stack use in scm_array_for_each_cell(), Daniel Llorens, 2016/06/24
- [Guile-commits] 14/24: Do not use array handles in scm_vector, Daniel Llorens, 2016/06/24
- [Guile-commits] 03/24: Unuse array 'contiguous' flag, Daniel Llorens, 2016/06/24
- [Guile-commits] 07/24: Tests & doc for array-from, array-from*, array-set-from!, Daniel Llorens, 2016/06/24
- [Guile-commits] 06/24: New functions array-from, array-from*, array-set-from!, Daniel Llorens, 2016/06/24
- [Guile-commits] 16/24: Draft documentation for (array-for-each-cell), Daniel Llorens, 2016/06/24
- [Guile-commits] 21/24: Fix a corner case with empty arrays in (array-for-each-cell), Daniel Llorens, 2016/06/24