mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Revert "add SCM_HEAP_OBJECT_BASE"
This reverts commit 47ed8656db
.
Conflicts:
libguile/foreign.c
This commit is contained in:
parent
3bf3d735ac
commit
0aed71aa51
14 changed files with 28 additions and 44 deletions
|
@ -333,7 +333,7 @@ scm_c_shrink_bytevector (SCM bv, size_t c_new_len)
|
|||
SCM_BYTEVECTOR_SET_LENGTH (bv, c_new_len);
|
||||
|
||||
if (SCM_BYTEVECTOR_CONTIGUOUS_P (bv))
|
||||
new_bv = SCM_PACK_POINTER (scm_gc_realloc (SCM_HEAP_OBJECT_BASE (bv),
|
||||
new_bv = PTR2SCM (scm_gc_realloc (SCM2PTR (bv),
|
||||
c_len + SCM_BYTEVECTOR_HEADER_BYTES,
|
||||
c_new_len + SCM_BYTEVECTOR_HEADER_BYTES,
|
||||
SCM_GC_BYTEVECTOR));
|
||||
|
|
|
@ -160,7 +160,7 @@ new_fluid (SCM init)
|
|||
SCM_SET_CELL_WORD_0 (fluid, (scm_tc7_fluid | (n << 8)));
|
||||
|
||||
GC_GENERAL_REGISTER_DISAPPEARING_LINK (&allocated_fluids[n],
|
||||
SCM_HEAP_OBJECT_BASE (fluid));
|
||||
SCM2PTR (fluid));
|
||||
|
||||
scm_dynwind_end ();
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ scm_from_pointer (void *ptr, scm_t_pointer_finalizer finalizer)
|
|||
/* Register a finalizer for the newly created instance. */
|
||||
GC_finalization_proc prev_finalizer;
|
||||
GC_PTR prev_finalizer_data;
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM_HEAP_OBJECT_BASE (ret),
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (ret),
|
||||
pointer_finalizer_trampoline,
|
||||
finalizer,
|
||||
&prev_finalizer,
|
||||
|
@ -316,7 +316,7 @@ SCM_DEFINE (scm_set_pointer_finalizer_x, "set-pointer-finalizer!", 2, 0, 0,
|
|||
|
||||
c_finalizer = SCM_POINTER_VALUE (finalizer);
|
||||
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM_HEAP_OBJECT_BASE (pointer),
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (pointer),
|
||||
pointer_finalizer_trampoline,
|
||||
c_finalizer,
|
||||
&prev_finalizer,
|
||||
|
|
|
@ -45,13 +45,12 @@ typedef struct scm_t_cell
|
|||
* in debug mode. In particular these macros will even work for free cells,
|
||||
* which should never be encountered by user code. */
|
||||
|
||||
#define SCM_GC_CELL_OBJECT(x, n) (SCM_PACK (SCM_HEAP_OBJECT_BASE (x)[n]))
|
||||
#define SCM_GC_CELL_WORD(x, n) (SCM_HEAP_OBJECT_BASE (x)[n])
|
||||
#define SCM_GC_CELL_OBJECT(x, n) (((SCM *)SCM2PTR (x)) [n])
|
||||
#define SCM_GC_CELL_WORD(x, n) (SCM_UNPACK (SCM_GC_CELL_OBJECT ((x), (n))))
|
||||
|
||||
#define SCM_GC_SET_CELL_OBJECT(x, n, v) \
|
||||
(SCM_HEAP_OBJECT_BASE (x)[n] = SCM_UNPACK (v))
|
||||
#define SCM_GC_SET_CELL_OBJECT(x, n, v) ((((SCM *)SCM2PTR (x)) [n]) = (v))
|
||||
#define SCM_GC_SET_CELL_WORD(x, n, v) \
|
||||
(SCM_HEAP_OBJECT_BASE (x)[n] = (v))
|
||||
(SCM_GC_SET_CELL_OBJECT ((x), (n), SCM_PACK (v)))
|
||||
|
||||
#define SCM_GC_CELL_TYPE(x) (SCM_GC_CELL_OBJECT ((x), 0))
|
||||
|
||||
|
@ -97,8 +96,7 @@ typedef struct scm_t_cell
|
|||
#define SCM_SET_CELL_OBJECT_2(x, v) SCM_SET_CELL_OBJECT ((x), 2, (v))
|
||||
#define SCM_SET_CELL_OBJECT_3(x, v) SCM_SET_CELL_OBJECT ((x), 3, (v))
|
||||
|
||||
#define SCM_CELL_WORD_LOC(x, n) (SCM_VALIDATE_CELL((x), &SCM_GC_CELL_WORD ((x), (n))))
|
||||
#define SCM_CELL_OBJECT_LOC(x, n) ((SCM *) SCM_CELL_WORD_LOC (x, n))
|
||||
#define SCM_CELL_OBJECT_LOC(x, n) (SCM_VALIDATE_CELL((x), &SCM_GC_CELL_OBJECT ((x), (n))))
|
||||
#define SCM_CARLOC(x) (SCM_CELL_OBJECT_LOC ((x), 0))
|
||||
#define SCM_CDRLOC(x) (SCM_CELL_OBJECT_LOC ((x), 1))
|
||||
|
||||
|
|
|
@ -218,8 +218,6 @@ scm_i_guard (SCM guardian, SCM obj)
|
|||
SCM_EOL);
|
||||
finalizer_data = scm_cons (SCM_BOOL_F, guardians_for_obj);
|
||||
|
||||
/* FIXME: should be SCM_HEAP_OBJECT_BASE, but will the finalizer
|
||||
strip the tag bits of pairs or structs? */
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM_UNPACK_POINTER (obj), finalize_guarded,
|
||||
SCM_UNPACK_POINTER (finalizer_data),
|
||||
&prev_finalizer, &prev_data);
|
||||
|
|
|
@ -103,7 +103,7 @@ SCM_DEFINE (scm_make_syntax_transformer, "make-syntax-transformer", 3, 0, 0,
|
|||
SCM_VALIDATE_SYMBOL (2, type);
|
||||
|
||||
z = scm_words (scm_tc16_macro, 5);
|
||||
SCM_SET_SMOB_DATA_N (z, 1, (scm_t_bits)prim);
|
||||
SCM_SET_SMOB_DATA_N (z, 1, prim);
|
||||
SCM_SET_SMOB_OBJECT_N (z, 2, name);
|
||||
SCM_SET_SMOB_OBJECT_N (z, 3, type);
|
||||
SCM_SET_SMOB_OBJECT_N (z, 4, binding);
|
||||
|
|
|
@ -128,9 +128,9 @@ typedef scm_t_int32 scm_t_wchar;
|
|||
#define SCM_REALP(x) (SCM_HAS_TYP16 (x, scm_tc16_real))
|
||||
#define SCM_COMPLEXP(x) (SCM_HAS_TYP16 (x, scm_tc16_complex))
|
||||
|
||||
#define SCM_REAL_VALUE(x) (((scm_t_double *) SCM_HEAP_OBJECT_BASE (x))->real)
|
||||
#define SCM_COMPLEX_REAL(x) (((scm_t_complex *) SCM_HEAP_OBJECT_BASE (x))->real)
|
||||
#define SCM_COMPLEX_IMAG(x) (((scm_t_complex *) SCM_HEAP_OBJECT_BASE (x))->imag)
|
||||
#define SCM_REAL_VALUE(x) (((scm_t_double *) SCM2PTR (x))->real)
|
||||
#define SCM_COMPLEX_REAL(x) (((scm_t_complex *) SCM2PTR (x))->real)
|
||||
#define SCM_COMPLEX_IMAG(x) (((scm_t_complex *) SCM2PTR (x))->imag)
|
||||
|
||||
/* Each bignum is just an mpz_t stored in a double cell starting at word 1. */
|
||||
#define SCM_I_BIG_MPZ(x) (*((mpz_t *) (SCM_CELL_OBJECT_LOC((x),1))))
|
||||
|
|
|
@ -541,8 +541,7 @@ register_finalizer_for_port (SCM port)
|
|||
|
||||
/* Register a finalizer for PORT so that its iconv CDs get freed and
|
||||
optionally its type's `free' function gets called. */
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM_HEAP_OBJECT_BASE (port),
|
||||
finalize_port, 0,
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (port), finalize_port, 0,
|
||||
&prev_finalizer,
|
||||
&prev_finalization_data);
|
||||
}
|
||||
|
|
|
@ -601,7 +601,7 @@ scm_i_new_smob (scm_t_bits tc, scm_t_bits data)
|
|||
GC_finalization_proc prev_finalizer;
|
||||
GC_PTR prev_finalizer_data;
|
||||
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM_HEAP_OBJECT_BASE (ret),
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (ret),
|
||||
finalize_smob, NULL,
|
||||
&prev_finalizer, &prev_finalizer_data);
|
||||
}
|
||||
|
@ -635,7 +635,7 @@ scm_i_new_double_smob (scm_t_bits tc, scm_t_bits data1,
|
|||
GC_finalization_proc prev_finalizer;
|
||||
GC_PTR prev_finalizer_data;
|
||||
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM_HEAP_OBJECT_BASE (ret),
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (ret),
|
||||
finalize_smob, NULL,
|
||||
&prev_finalizer, &prev_finalizer_data);
|
||||
}
|
||||
|
|
|
@ -448,7 +448,7 @@ scm_i_alloc_struct (scm_t_bits *vtable_data, int n_words)
|
|||
/* Register a finalizer for the newly created instance. */
|
||||
GC_finalization_proc prev_finalizer;
|
||||
GC_PTR prev_finalizer_data;
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM_HEAP_OBJECT_BASE (ret),
|
||||
GC_REGISTER_FINALIZER_NO_ORDER (SCM2PTR (ret),
|
||||
struct_finalizer_trampoline,
|
||||
NULL,
|
||||
&prev_finalizer,
|
||||
|
|
|
@ -391,17 +391,6 @@ typedef union SCM { struct { scm_t_bits n; } n; } SCM;
|
|||
#define scm_tc3_tc7_2 7
|
||||
|
||||
|
||||
/* As we have seen, heap objects have a tag in their three lowest bits.
|
||||
If you have a heap object and want the pointer to the start of the
|
||||
object, perhaps for GC purposes, you need to mask off the low bits,
|
||||
which is what SCM_HEAP_OBJECT_BASE does.
|
||||
|
||||
Note that you can avoid this macro if you know the specific type of
|
||||
the object (pair, struct, or other).
|
||||
*/
|
||||
#define SCM_HEAP_OBJECT_BASE(x) ((scm_t_bits*)((SCM_UNPACK (x)) & ~7))
|
||||
|
||||
|
||||
/* Definitions for tc7: */
|
||||
|
||||
#define SCM_ITAG7(x) (127 & SCM_UNPACK (x))
|
||||
|
|
|
@ -525,7 +525,7 @@ weak_set_add_x (scm_t_weak_set *set, unsigned long hash,
|
|||
|
||||
if (SCM_HEAP_OBJECT_P (obj))
|
||||
SCM_I_REGISTER_DISAPPEARING_LINK ((GC_PTR) &entries[k].key,
|
||||
(GC_PTR) SCM_HEAP_OBJECT_BASE (obj));
|
||||
(GC_PTR) SCM2PTR (obj));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ scm_c_register_weak_gc_callback (SCM obj, void (*callback) (SCM))
|
|||
|
||||
weak[0] = SCM_UNPACK_POINTER (obj);
|
||||
weak[1] = (void*)callback;
|
||||
GC_GENERAL_REGISTER_DISAPPEARING_LINK (weak, SCM_HEAP_OBJECT_BASE (obj));
|
||||
GC_GENERAL_REGISTER_DISAPPEARING_LINK (weak, SCM2PTR (obj));
|
||||
|
||||
#ifdef HAVE_GC_SET_START_CALLBACK
|
||||
scm_c_hook_add (&scm_after_gc_c_hook, weak_gc_hook, weak, 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2011, 2012 Free Software Foundation, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
|
@ -131,13 +131,13 @@ register_disappearing_links (scm_t_weak_entry *entry,
|
|||
&& (kind == SCM_WEAK_TABLE_KIND_KEY
|
||||
|| kind == SCM_WEAK_TABLE_KIND_BOTH))
|
||||
SCM_I_REGISTER_DISAPPEARING_LINK ((GC_PTR) &entry->key,
|
||||
(GC_PTR) SCM_HEAP_OBJECT_BASE (k));
|
||||
(GC_PTR) SCM2PTR (k));
|
||||
|
||||
if (SCM_UNPACK (v) && SCM_HEAP_OBJECT_P (v)
|
||||
&& (kind == SCM_WEAK_TABLE_KIND_VALUE
|
||||
|| kind == SCM_WEAK_TABLE_KIND_BOTH))
|
||||
SCM_I_REGISTER_DISAPPEARING_LINK ((GC_PTR) &entry->value,
|
||||
(GC_PTR) SCM_HEAP_OBJECT_BASE (v));
|
||||
(GC_PTR) SCM2PTR (v));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -162,7 +162,7 @@ move_disappearing_links (scm_t_weak_entry *from, scm_t_weak_entry *to,
|
|||
GC_move_disappearing_link ((GC_PTR) &from->key, (GC_PTR) &to->key);
|
||||
#else
|
||||
GC_unregister_disappearing_link (&from->key);
|
||||
SCM_I_REGISTER_DISAPPEARING_LINK (&to->key, SCM_HEAP_OBJECT_BASE (key));
|
||||
SCM_I_REGISTER_DISAPPEARING_LINK (&to->key, SCM2PTR (key));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ move_disappearing_links (scm_t_weak_entry *from, scm_t_weak_entry *to,
|
|||
GC_move_disappearing_link ((GC_PTR) &from->value, (GC_PTR) &to->value);
|
||||
#else
|
||||
GC_unregister_disappearing_link (&from->value);
|
||||
SCM_I_REGISTER_DISAPPEARING_LINK (&to->value, SCM_HEAP_OBJECT_BASE (value));
|
||||
SCM_I_REGISTER_DISAPPEARING_LINK (&to->value, SCM2PTR (value));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ mark_weak_key_table (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
|
|||
if (entries[k].hash && entries[k].key)
|
||||
{
|
||||
SCM value = SCM_PACK (entries[k].value);
|
||||
mark_stack_ptr = GC_MARK_AND_PUSH ((GC_word*) SCM_HEAP_OBJECT_BASE (value),
|
||||
mark_stack_ptr = GC_MARK_AND_PUSH ((GC_word*) SCM2PTR (value),
|
||||
mark_stack_ptr, mark_stack_limit,
|
||||
NULL);
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ mark_weak_value_table (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
|
|||
if (entries[k].hash && entries[k].value)
|
||||
{
|
||||
SCM key = SCM_PACK (entries[k].key);
|
||||
mark_stack_ptr = GC_MARK_AND_PUSH ((GC_word*) SCM_HEAP_OBJECT_BASE (key),
|
||||
mark_stack_ptr = GC_MARK_AND_PUSH ((GC_word*) SCM2PTR (key),
|
||||
mark_stack_ptr, mark_stack_limit,
|
||||
NULL);
|
||||
}
|
||||
|
@ -810,7 +810,7 @@ scm_c_register_weak_gc_callback (SCM obj, void (*callback) (SCM))
|
|||
|
||||
weak[0] = SCM_UNPACK_POINTER (obj);
|
||||
weak[1] = (void*)callback;
|
||||
GC_GENERAL_REGISTER_DISAPPEARING_LINK (weak, SCM_HEAP_OBJECT_BASE (obj));
|
||||
GC_GENERAL_REGISTER_DISAPPEARING_LINK (weak, SCM2PTR (obj));
|
||||
|
||||
#ifdef HAVE_GC_TABLE_START_CALLBACK
|
||||
scm_c_hook_add (&scm_after_gc_c_hook, weak_gc_hook, weak, 0);
|
||||
|
|
|
@ -177,7 +177,7 @@ scm_c_weak_vector_set_x (SCM wv, size_t k, SCM x)
|
|||
|
||||
if (SCM_HEAP_OBJECT_P (x))
|
||||
SCM_I_REGISTER_DISAPPEARING_LINK ((GC_PTR) &elts[k],
|
||||
(GC_PTR) SCM_HEAP_OBJECT_BASE (x));
|
||||
(GC_PTR) SCM2PTR (x));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue