summaryrefslogtreecommitdiff
path: root/libguile/inline.h
diff options
context:
space:
mode:
authorLudovic Courtes <ludovic.courtes@laas.fr>2006-03-21 22:16:33 +0000
committerLudovic Courtès <ludo@gnu.org>2008-09-05 00:45:58 +0200
commit26224b3f5d795e523e921ec32ffec424893ea035 (patch)
treed5c47fc98334b4c068610b66435cdce0788f4268 /libguile/inline.h
parent5695ccd43b051caf99f1ca94f00f7231c1466439 (diff)
downloadguile-26224b3f5d795e523e921ec32ffec424893ea035.tar.gz
Merge from lcourtes@laas.fr--2005-mobile
Patches applied: * lcourtes@laas.fr--2005-mobile/guile-core--boehm-gc--1.9 (base, patch 1) - tag of lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--base-0 - Initial hack for Boehm's GC support: nothing works. git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-1
Diffstat (limited to 'libguile/inline.h')
-rw-r--r--libguile/inline.h96
1 files changed, 9 insertions, 87 deletions
diff --git a/libguile/inline.h b/libguile/inline.h
index 621b4fb36..5337c90a5 100644
--- a/libguile/inline.h
+++ b/libguile/inline.h
@@ -38,6 +38,9 @@
#include "libguile/pairs.h"
+#include <gc/gc.h>
+
+
SCM_API SCM scm_cell (scm_t_bits car, scm_t_bits cdr);
SCM_API SCM scm_double_cell (scm_t_bits car, scm_t_bits cbr,
scm_t_bits ccr, scm_t_bits cdr);
@@ -64,71 +67,16 @@ static
#endif
SCM_C_INLINE
#endif
+
SCM
scm_cell (scm_t_bits car, scm_t_bits cdr)
{
- SCM z;
- SCM *freelist = SCM_FREELIST_LOC (scm_i_freelist);
+ SCM cell = SCM_PACK ((scm_t_bits) (GC_malloc (sizeof (scm_t_cell))));
- if (scm_is_null (*freelist))
- z = scm_gc_for_newcell (&scm_i_master_freelist, freelist);
- else
- {
- z = *freelist;
- *freelist = SCM_FREE_CELL_CDR (*freelist);
- }
-
- /*
- We update scm_cells_allocated from this function. If we don't
- update this explicitly, we will have to walk a freelist somewhere
- later on, which seems a lot more expensive.
- */
- scm_cells_allocated += 1;
-
-#if (SCM_DEBUG_CELL_ACCESSES == 1)
- if (scm_debug_cell_accesses_p)
- {
- if (SCM_GC_MARK_P (z))
- {
- fprintf(stderr, "scm_cell tried to allocate a marked cell.\n");
- abort();
- }
- else if (SCM_GC_CELL_WORD(z, 0) != scm_tc_free_cell)
- {
- fprintf(stderr, "cell from freelist is not a free cell.\n");
- abort();
- }
- }
+ SCM_GC_SET_CELL_WORD (cell, 0, car);
+ SCM_GC_SET_CELL_WORD (cell, 1, cdr);
- /*
- Always set mark. Otherwise cells that are alloced before
- scm_debug_cell_accesses_p is toggled seem invalid.
- */
- SCM_SET_GC_MARK (z);
-
- /*
- TODO: figure out if this use of mark bits is valid with
- threading. What if another thread is doing GC at this point
- ... ?
- */
-
-#endif
-
-
- /* Initialize the type slot last so that the cell is ignored by the
- GC until it is completely initialized. This is only relevant
- when the GC can actually run during this code, which it can't
- since the GC only runs when all other threads are stopped.
- */
- SCM_GC_SET_CELL_WORD (z, 1, cdr);
- SCM_GC_SET_CELL_WORD (z, 0, car);
-
-#if (SCM_DEBUG_CELL_ACCESSES == 1)
- if (scm_expensive_debug_cell_accesses_p )
- scm_i_expensive_validation_check (z);
-#endif
-
- return z;
+ return cell;
}
#if defined SCM_C_INLINE && ! defined SCM_INLINE_C_INCLUDING_INLINE_H
@@ -145,18 +93,8 @@ scm_double_cell (scm_t_bits car, scm_t_bits cbr,
scm_t_bits ccr, scm_t_bits cdr)
{
SCM z;
- SCM *freelist = SCM_FREELIST_LOC (scm_i_freelist2);
-
- if (scm_is_null (*freelist))
- z = scm_gc_for_newcell (&scm_i_master_freelist2, freelist);
- else
- {
- z = *freelist;
- *freelist = SCM_FREE_CELL_CDR (*freelist);
- }
-
- scm_cells_allocated += 2;
+ z = SCM_PACK ((scm_t_bits) (GC_malloc (2 * sizeof (scm_t_cell))));
/* Initialize the type slot last so that the cell is ignored by the
GC until it is completely initialized. This is only relevant
when the GC can actually run during this code, which it can't
@@ -167,22 +105,6 @@ scm_double_cell (scm_t_bits car, scm_t_bits cbr,
SCM_GC_SET_CELL_WORD (z, 3, cdr);
SCM_GC_SET_CELL_WORD (z, 0, car);
-#if (SCM_DEBUG_CELL_ACCESSES == 1)
- if (scm_debug_cell_accesses_p)
- {
- if (SCM_GC_MARK_P (z))
- {
- fprintf(stderr,
- "scm_double_cell tried to allocate a marked cell.\n");
- abort();
- }
- }
-
- /* see above. */
- SCM_SET_GC_MARK (z);
-
-#endif
-
/* When this function is inlined, it's possible that the last
SCM_GC_SET_CELL_WORD above will be adjacent to a following
initialization of z. E.g., it occurred in scm_make_real. GCC