1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
Commit graph

197 commits

Author SHA1 Message Date
Andy Wingo
214e887dbd Struct vtables store bitmask of unboxed fields
* libguile/struct.h (scm_vtable_index_unboxed_fields): Allocate slot for
  bitmask of which fields are unboxed.
  (SCM_VTABLE_FLAG_SIMPLE, SCM_VTABLE_FLAG_SIMPLE_RW): Remove flags.
  Renumber other flags.
  (SCM_VTABLE_SIZE, SCM_STRUCT_SIZE): New helpers; long overdue.
  (SCM_VTABLE_UNBOXED_FIELDS, SCM_VTABLE_FIELD_IS_UNBOXED):
  (SCM_STRUCT_FIELD_IS_UNBOXED): New macros.
* libguile/struct.c (set_vtable_access_fields): Rename from
  set_vtable_layout_flags, and initialize the unboxed flags bitmask
  instead of computing vtable flags.
  (scm_struct_init, scm_c_make_structv, scm_allocate_struct): Simplify.
  (scm_i_make_vtable_vtable): Adapt.
  (scm_i_struct_equalp, scm_struct_ref, scm_struct_set_x)
  (scm_struct_ref_unboxed, scm_struct_set_x_unboxed): Simplify.
* libguile/vm-engine.c (VM_VALIDATE_BOXED_STRUCT_FIELD):
  (VM_VALIDATE_UNBOXED_STRUCT_FIELD): Adapt definitions.
  (struct-ref, struct-set!, struct-ref/immediate)
  (struct-set!/immediate): Simplify definitions.
* libguile/hash.c (scm_i_struct_hash): Simplify.
* libguile/goops.c (scm_sys_clear_fields_x): Simplify.
* libguile/foreign-object.c (scm_make_foreign_object_n):
  (scm_foreign_object_unsigned_ref, scm_foreign_object_unsigned_set_x):
  Simplify.
2017-09-26 21:56:31 +02:00
Andy Wingo
84259f54e3 Merge 'stable-2.2'
Resolve conflicts by removing capability of struct-ref / struct-set! to
access unboxed slots.
2017-09-25 22:18:13 +02:00
Andy Wingo
a74d4ee4f6 Add struct-ref/unboxed, struct-set!/unboxed
* NEWS: Add news entry.
* doc/ref/api-data.texi (Vtables, Structure Basics): Update
  documentation.
* libguile/struct.c (scm_i_struct_equalp): Avoid using struct-ref on
  unboxed fields.
  (scm_struct_ref, scm_struct_set_x_unboxed): Issue deprecation warning
  when accessing unboxed fields.
  (scm_struct_ref_unboxed, scm_struct_set_x_unboxed): New functions.
* libguile/struct.h (scm_struct_ref_unboxed, scm_struct_set_x_unboxed):
  New functions.
* module/oop/goops.scm (class-add-flags!, class-clear-flags!):
  (class-has-flags?, <class>, %allocate-instance, <slot>):
  (compute-get-n-set, unboxed-get, unboxed-set, unboxed-slot?):
  (allocate-slots, %prep-layout!, make-standard-class, initialize):
  Adapt to access unboxed nfields and flags fields via the new
  accessors.
2017-09-25 21:54:36 +02:00
Andy Wingo
5870188eb4 Replace "pr" struct fields with "pw" fields
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT): Layout is a "pr" field.
* module/ice-9/boot-9.scm (record-type-vtable): Record vtable fields are
  writable.
  (<parameter>): "pw" fields.
* module/oop/goops.scm (<class>, %compute-layout): <read-only> fields
  are "pw" underneath.
* module/rnrs/records/procedural.scm (record-type-vtable)
  (record-constructor-vtable, make-record-type-descriptor): Use "pw"
  fields in vtables.
* module/srfi/srfi-35.scm (%condition-type-vtable)
  (struct-layout-for-condition): "pw" fields in vtables.
* test-suite/tests/goops.test:
* test-suite/tests/structs.test: Use "pw" fields only.
* benchmark-suite/benchmarks/structs.bm: Update for make-struct/no-tail,
  to use pw fields, and also to remove useless tests that the compiler
  would optimize away.
* doc/ref/api-data.texi (Vtables): Add a note about the now-vestigial
  permissions character and update documentation.
  (Structure Basics, Meta-Vtables): Update examples.
* libguile/hash.c (scm_i_struct_hash): Remove code that would handle
  opaque/self fields.
* libguile/print.h (SCM_PRINT_STATE_LAYOUT): Use "pw" fields.
* libguile/struct.c (scm_struct_init): Simplify check for hidden
  fields.
* libguile/values.c (scm_init_values): Field is "pw".
2017-09-23 15:33:02 +02:00
Andy Wingo
b7d88bfe63 Remove opaque slots
* libguile/struct.c (scm_make_struct_layout): Remove support for opaque
  slots.
  (set_vtable_layout_flags): Remove opaque slots, and make the "switch"
  total.
  (scm_is_valid_vtable_layout): Remove opaque slots.
  (scm_struct_ref, scm_struct_set_x): Remove case for opaque slots.
2017-09-23 14:29:37 +02:00
Andy Wingo
e26652b7e1 Merge 'stable-2.2' 2017-09-23 11:17:35 +02:00
Andy Wingo
b0ecf83ef0 Deprecate opaque struct fields
* NEWS: Add entry.
* doc/ref/api-data.texi (Vtables, Structure Basics): Remove mention of
  opaque field protection.
* libguile/struct.c (scm_make_struct_layout, scm_make_struct_no_tail):
  Remove discussion of opaque fields.
  (set_vtable_layout_flags): Issue a deprecation warning when opaque
  fields are used.
2017-09-23 11:14:27 +02:00
Andy Wingo
d354962b68 Remove support for tail arrays and self slots
* libguile/struct.c (scm_make_struct): Remove support for tail arrays
  and self slots.
  (set_vtable_layout_flags): Always initialize the nfields member.
  (scm_is_valid_vtable_layout): Remove support for tail arrays and self
  slots.
  (scm_i_struct_inherit_vtable_magic): No need to issue deprecation
  warning for self slots, as they are no longer supported.
  (scm_struct_init): Remove support for tail arrays and self slots.
  (scm_c_make_structv): Throw an exception if n_tail is not 0.
  (scm_allocate_struct): Adapt to scm_struct_init change.
  (scm_i_make_vtable_vtable): Initialize slots manually, to avoid
  relying on an already-initialized nfields member.
  (scm_struct_ref, scm_struct_set_x): Simplify.
* module/oop/goops.scm: As we now rely on nfields being valid, when
  recalculating slots during boot we need to avoid resetting nfields of
  <class>, even temporarily, as that would prevent any further access to
  <class>!
2017-09-22 15:43:10 +02:00
Andy Wingo
2f9ad7d9bc Merge stable-2.2 into master
This commit resolves conflicts by removing the deprecated make-struct.
2017-09-22 12:02:25 +02:00
Andy Wingo
c7c7588f24 Fix up make-struct-layout and make-struct/no-tail docstrings
* libguile/struct.c (scm_make_struct_layout, scm_make_struct_no_tail):
  Fix up docstrings for self and tail deprecation.
2017-09-22 11:38:41 +02:00
Andy Wingo
04f48e94b5 Deprecate struct "self" slots
* libguile/print.h (SCM_PRINT_STATE_LAYOUT): Use a normal slot instead
  of a self slot.
* libguile/print.c (make_print_state): Initialize "handle" slot
  manually.
* libguile/struct.c (issue_deprecation_warning_for_self_slots): New
  helper, called when making vtables to issue deprecation warnings for
  "self" slots.  Avoids warning for the "self" slot that's part of the
  fixed vtable slots.
  (scm_i_struct_inherit_vtable_magic): Call
  issue_deprecation_warning_for_self_slots.
* doc/ref/api-data.texi (Vtables, Structure Basics): Remove references
  to self slots.
* NEWS: Add entry.
2017-09-22 11:35:36 +02:00
Andy Wingo
9ac0544eff Remove unused code in struct.c
* libguile/struct.c (scm_make_struct_layout, scm_struct-ref)
  (scm_struct_set_x): Remove commented-out support for signed and double
  raw fields.
2017-09-22 10:32:36 +02:00
Andy Wingo
fe4a34d20d Deprecate make-struct
* libguile/struct.c: Replace uses of scm_make_struct with
  scm_make_struct_no_tail or scm_c_make_struct.
  (scm_make_struct_no_tail): Move this function to C instead of Scheme
  to be able to deprecate scm_make_struct.
* libguile/struct.h (scm_make_struct_no_tail): New public declaration.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_make_struct): Deprecate.
* libguile/print.c:
* libguile/procs.c:
* libguile/stacks.c: Replace uses of scm_make_struct with
  scm_make_struct_no_tail.
* test-suite/tests/coverage.test:
* test-suite/tests/structs.test: Use make-struct/no-tail instead of
  make-struct.
* NEWS: Add entry.
2017-09-22 10:32:33 +02:00
Andy Wingo
7e91ff651b Remove indirection in structs
* libguile/gc.c (scm_storage_prehistory): Register struct displacement
  here.
* libguile/goops.c (scm_sys_modify_instance): Fix the format of a
  comment.
* libguile/modules.c (scm_post_boot_init_modules): Update for new format
  of struct vtable references.
* libguile/struct.c (scm_i_alloc_struct): Update to include slots
  directly, instead of being indirected by an embedded pointer.
  (scm_c_make_structv, scm_allocate_struct, scm_i_make_vtable_vtable):
  Adapt to pass vtable bits as argument to scm_i_alloc_struct, not
  vtable data bits.
  (scm_init_struct): Remove two-word displacement from libgc.
* libguile/struct.h: Update comment.
  (SCM_STRUCT_SLOTS, SCM_STRUCT_DATA): Update definitions.
  (SCM_STRUCT_VTABLE_DATA, SCM_STRUCT_VTABLE_SLOTS): Remove.
  (SCM_STRUCT_VTABLE, SCM_STRUCT_LAYOUT, SCM_STRUCT_PRINTER)
  (SCM_STRUCT_FINALIZER, SCM_STRUCT_VTABLE_FLAGS)
  (SCM_STRUCT_VTABLE_FLAG_IS_SET): Simplify definitions.
* module/system/base/types.scm (cell->object, address->inferior-struct):
  Adapt to struct representation change.
2017-09-14 09:44:33 +02:00
Andy Wingo
105e36543f Remove scm_puts_unlocked.
* libguile/ports.h (scm_puts_unlocked): Remove.
* libguile/ports.c (scm_puts): Replace implementation with
  scm_puts_unlocked's implementation.
* libguile/arbiters.c:
* libguile/backtrace.c:
* libguile/bitvectors.c:
* libguile/continuations.c:
* libguile/deprecation.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/guardians.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/load.c:
* libguile/macros.c:
* libguile/mallocs.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/smob.c:
* libguile/srcprop.c:
* libguile/srfi-14.c:
* libguile/stackchk.c:
* libguile/struct.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/values.c:
* libguile/variable.c:
* libguile/vm.c:
* libguile/weak-set.c:
* libguile/weak-table.c: Use scm_puts instead of scm_puts_unlocked.
2016-04-26 23:07:28 +02:00
Andy Wingo
206b3f6e03 Remove scm_putc_unlocked.
* libguile/ports.h (scm_putc_unlocked): Remove.
* libguile/ports.c (scm_putc): Replace implementation with
  scm_putc_unlocked's implementation.
  (scm_port_print): Use scm_putc.
* libguile/arbiters.c:
* libguile/arrays.c:
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/continuations.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/macros.c:
* libguile/mallocs.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/r6rs-ports.c:
* libguile/smob.c:
* libguile/srcprop.c:
* libguile/struct.c:
* libguile/variable.c:
* libguile/weak-set.c:
* libguile/weak-table.c: Use scm_putc instead of scm_putc_unlocked.
2016-04-26 23:01:14 +02:00
Andy Wingo
cf80502c0a Fix scm_init_struct dependency on port conversion handlers
* libguile/struct.c (scm_init_struct): Use scm_from_latin1_string to
  avoid locale-dependency for what is really a latin1 string.  Also
  avoids an early dependency on the default port conversion handler,
  though I wonder if using port conversion handlers in strings is the
  right thing.
2016-04-14 11:06:40 +02:00
Andy Wingo
4702cbeb37 Move <class> initialization to Scheme
* libguile/goops.c (scm_sys_make_root_class): Just make the
  vtable-vtable, and leave initialization to Scheme.

* libguile/struct.c (scm_i_make_vtable_vtable): Change to take a full
  list of fields, not just the extra fields.
  (scm_init_struct): Adapt to scm_i_make_vtable_vtable change.

* module/oop/goops.scm (<class>): Compute layout for <class>, and
  initialize <class> from here.
2015-01-23 16:16:01 +01:00
Andy Wingo
14d102920f add allocate-struct primitive and rtl opcode
* libguile/struct.h:
* libguile/struct.c (scm_allocate_struct): New interface: allocates a
  struct.

* libguile/vm-engine.c (allocate_struct): Instead of make-struct with a
  rest arg, separate allocation from initialization.
2013-07-21 17:12:22 +02:00
Mark H Weaver
26d148066f Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	configure.ac
	libguile/deprecated.c
	libguile/deprecated.h
	libguile/filesys.h
	libguile/fluids.c
	libguile/fports.c
	libguile/gc.c
	libguile/guile.c
	libguile/numbers.c
	libguile/objcodes.c
	libguile/r6rs-ports.c
	libguile/smob.c
	libguile/socket.c
	libguile/threads.h
	module/language/scheme/decompile-tree-il.scm
	module/language/tree-il/peval.scm
	test-suite/tests/syncase.test
2013-03-28 05:09:53 -04:00
Andy Wingo
1b787ef9ec structs with tail arrays are not simple
* libguile/struct.h (SCM_VTABLE_FLAG_SIMPLE, SCM_VTABLE_FLAG_SIMPLE_RW):
* libguile/struct.c (set_vtable_layout_flags): Vtable whose layouts
  include a tail array are not simple.  Fixes bug 12808.
2013-03-07 07:52:00 +01:00
Andy Wingo
2f0db5ee96 update make-struct docstring
* libguile/struct.c (scm_make_struct): Remove reference to deprecated
  make-vtable-vtable.
2013-01-16 09:17:35 +01:00
Ludovic Courtès
8ac870dee4 Implement `hash' for structs.
* libguile/hash.c (scm_hasher): Call `scm_i_struct_hash' upon
  `scm_tcs_struct'.
* libguile/struct.c (scm_i_struct_hash): New function.
* libguile/struct.h (scm_i_struct_hash): New declaration.

* test-suite/tests/structs.test ("hash"): New test prefix.
2012-10-12 23:21:39 +02:00
Andy Wingo
880e114b9d set struct names for <standard-vtable>, etc
* libguile/struct.c (scm_init_struct): Set the struct names for
  <standard-vtable>, <applicable-struct-vtable>, and
  <applicable-struct-with-setter-vtable>.
2012-07-28 13:03:04 +02:00
Andy Wingo
6d46f1e48a deprecate make-vtable-vtable
* libguile/struct.h:
* libguile/struct.c (scm_make_vtable_vtable): Deprecate, as you can
  handle most of the use cases with make-vtable, and we don't want to
  promote the creation of new roots to the type hierarchy.
  (scm_i_make_vtable_vtable): The internal replacement.
2012-07-28 13:03:04 +02:00
Andy Wingo
40c73b5992 set struct names for <standard-vtable>, etc
* libguile/struct.c (scm_init_struct): Set the struct names for
  <standard-vtable>, <applicable-struct-vtable>, and
  <applicable-struct-with-setter-vtable>.
2012-07-28 12:28:21 +02:00
Andy Wingo
a38da400d7 Merge remote-tracking branch 'origin/stable-2.0'
This anticipates deprecation of make-vtable-vtable in stable-2.0, which
hasn't happened yet.

Conflicts:
	libguile/deprecated.c
	libguile/deprecated.h
	libguile/print.c
	libguile/struct.c
2012-07-06 19:28:06 +02:00
Andy Wingo
2921f53760 Scheme standard-vtable-fields binding
* libguile/struct.c (scm_init_struct): Export standard-vtable-fields to
  Scheme.
2012-07-06 18:32:14 +02:00
Andy Wingo
0bb1353a6b add Scheme binding for scm_standard_vtable_vtable
* libguile/struct.c (scm_init_struct): Export <standard-vtable> to
  Scheme.
2012-07-06 18:32:14 +02:00
Andy Wingo
d192791373 deprecate struct-vtable-tag
* libguile/deprecated.c:
* libguile/deprecated.h:
* libguile/struct.c:
* libguile/struct.h:
* doc/ref/api-compound.texi: Deprecate struct-vtable-tag.
2012-07-06 18:12:59 +02:00
Andy Wingo
2aed2667fc Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/expand.c
	libguile/hashtab.c
	libguile/ports.c
	libguile/vectors.c
	libguile/weaks.c
	module/language/ecmascript/compile-tree-il.scm
	module/language/tree-il/effects.scm
	module/language/tree-il/fix-letrec.scm
	module/language/tree-il/peval.scm
	test-suite/tests/peval.test
2012-07-06 16:52:54 +02:00
Ludovic Courtès
6922d92f96 Use void *' instead of GC_PTR' internally.
* libguile/finalizers.c, libguile/foreign.c, libguile/guardians.c,
  libguile/hashtab.c, libguile/numbers.c, libguile/ports.c,
  libguile/smob.c, libguile/struct.c, libguile/vectors.c,
  libguile/weaks.c: Use `void *' instead of `GC_PTR'.
2012-07-02 11:19:51 +02:00
Andy Wingo
75ba64d679 use the new finalizer helpers
* libguile/foreign.c (scm_set_pointer_finalizer_x)
* libguile/ports.c (finalize_port)
* libguile/smob.c (scm_i_new_smob, scm_i_new_double_smob)
* libguile/struct.c (scm_i_alloc_struct)
* libguile/numbers.c (make_bignum): Use the new API.
2012-03-08 12:40:27 +01:00
Andy Wingo
6978c67339 use the new finalizer helpers
* libguile/foreign.c (scm_set_pointer_finalizer_x)
* libguile/ports.c (finalize_port, scm_c_make_port_with_encoding)
  (open_iconv_descriptors)
* libguile/smob.c (scm_i_new_smob, scm_i_new_double_smob)
* libguile/struct.c (scm_i_alloc_struct)
* libguile/weak-set.c (weak_gc_finalizer)
  (scm_c_register_weak_gc_callback)
* libguile/weak-table.c (scm_c_register_weak_gc_callback)
  (weak_gc_finalizer)
* libguile/numbers.c (make_bignum): Use the new API.
2012-02-19 20:46:14 +01:00
Andy Wingo
0858753e82 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/gc-malloc.c
	libguile/ports.c
2012-02-08 11:48:08 +01:00
Bake Timmons
b7e64f8b26 Improve the usage of variable names in C docstrings.
* libguile/alist.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/bitvectors.c:
* libguile/filesys.c:
* libguile/foreign.c:
* libguile/generalized-arrays.c:
* libguile/hashtab.c:
* libguile/ioext.c:
* libguile/load.c:
* libguile/numbers.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/procprop.c:
* libguile/promises.c:
* libguile/simpos.c:
* libguile/socket.c:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Make the variable names in the C docstrings more
  consistent.  Replace a few instances of @var with @code when appropriate.
2012-02-02 12:22:10 +01:00
Andy Wingo
0aed71aa51 Revert "add SCM_HEAP_OBJECT_BASE"
This reverts commit 47ed8656db.

Conflicts:

	libguile/foreign.c
2012-01-31 22:58:24 +01:00
Andy Wingo
0818837f65 deprecate make-vtable-vtable
* libguile/struct.h:
* libguile/struct.c (scm_make_vtable_vtable): Deprecate, as you can
  handle most of the use cases with make-vtable, and we don't want to
  promote the creation of new roots to the type hierarchy.
  (scm_i_make_vtable_vtable): The internal replacement.
2011-11-24 11:47:36 +01:00
Andy Wingo
fb5f79a8b0 Scheme standard-vtable-fields binding
* libguile/struct.c (scm_init_struct): Export standard-vtable-fields to
  Scheme.
2011-11-24 11:47:36 +01:00
Andy Wingo
72d4db5d04 add Scheme binding for scm_standard_vtable_vtable
* libguile/struct.c (scm_init_struct): Export <standard-vtable> to
  Scheme.
2011-11-24 11:47:36 +01:00
Andy Wingo
0607ebbfcf locking for putc, puts
* libguile/ports.c (scm_putc, scm_puts):
* libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into
  _unlocked and locked variants.  Change all callers to use the
  _unlocked versions.
2011-11-08 00:55:05 +01:00
Andy Wingo
47ed8656db add SCM_HEAP_OBJECT_BASE
* libguile/tags.h (SCM_HEAP_OBJECT_BASE): New macro.  Given a SCM,
  returns a pointer to the start of its memory area on the heap.

* libguile/bytevectors.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/gc.h:
* libguile/guardians.c:
* libguile/numbers.h:
* libguile/ports.c:
* libguile/smob.c:
* libguile/struct.c:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Use it.
2011-10-24 18:59:35 +02:00
Andy Wingo
a141db8604 remove weak pairs, rewrite weak vectors
* libguile/weak-vector.c:
* libguile/weak-vector.h: Renamed from weaks.[ch].  Remove weak pairs.
  They were not safe to access with `car' and `cdr'.  Remove weak alist
  vectors, as we have weak tables and sets.  Reimplement weak vectors,
  moving the implementation here.

* libguile/vectors.c:
* libguile/vectors.h: Remove the extra header word.  Use
  scm_c_weak_vector_ref / scm_c_weak_vector_set_x to access weak
  vectors.

* libguile/snarf.h: Remove the extra header word in vectors.

* libguile/threads.c (do_thread_exit, fat_mutex_lock, fat_mutex_unlock):
  Instead of weak pairs, store thread-owned mutexes in a list of
  one-element weak vectors.

* libguile/guardians.c (finalize_guarded): Similarly, store object
  guardians in a list of one-element weak vectors.

* libguile/modules.c (scm_module_reverse_lookup): We no longer need to
  handle the case of weak references.

* libguile/print.c (iprin1): Use the standard vector accessor to print
  vectors.

* libguile.h:
* libguile/Makefile.am:
* libguile/gc-malloc.c:
* libguile/gc.c:
* libguile/goops.c:
* libguile/init.c:
* libguile/objprop.c:
* libguile/struct.c: Update includes.

* module/ice-9/weak-vector.scm: Load weak vector definitions using an
  extension instead of %init-weaks-builtins.

* test-suite/tests/weaks.test: Use the make-...-hash-table names instead
  of the old alist vector names.
2011-10-24 12:54:14 +02:00
Andy Wingo
f3c6a02c88 deprecate scm_struct_table
* libguile/goops.h:
* libguile/goops.c (scm_i_define_class_for_vtable): New internal helper,
  defines a class for a vtable, relying on the name slot being set
  correctly.
  (scm_class_of, create_struct_classes): Use the local vtable-to-class
  map instead of scm_struct_table.

* libguile/struct.h (SCM_STRUCT_TABLE_NAME, SCM_SET_STRUCT_TABLE_NAME)
  (SCM_STRUCT_TABLE_CLASS, SCM_SET_STRUCT_TABLE_CLASS, scm_struct_table)
  (scm_struct_create_handle): Deprecate these internals of the map
  between structs and classes.

* libguile/deprecated.h:
* libguile/deprecated.c (scm_struct_create_handle): Deprecated code over
  here now.
2011-05-01 23:01:14 +02:00
Andy Wingo
3d27ef4bd3 fix a number of assumptions that a pointer could fit into a long
* libguile/debug.c:
* libguile/eval.c:
* libguile/frames.c:
* libguile/objcodes.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/read.c:
* libguile/struct.c:
* libguile/vm.c: Fix a number of instances in which we assumed we could
  fit a pointer into a long.
2010-11-19 15:22:43 +01:00
Andy Wingo
a2220d7ea4 add flag to vtables to indicate that their layout is valid
* libguile/struct.h (SCM_VTABLE_FLAG_VALIDATED): New flag, indicates
  that the layout of a vtable has been validated. The other flags have
  been renumbered.

* libguile/struct.c (scm_i_struct_inherit_vtable_magic): Set the
  VALIDATED flag if everything goes through.
  (scm_struct_vtable_p): If the struct should be a vtable but isn't
  validated, throw an error.
  (scm_make_vtable_vtable): Validate the incoming user_fields layout
  bit. Set the VALIDATED flag.
  (scm_c_make_structv): Add a comment about the case in which we delay
  scm_i_struct_inherit_vtable_magic.
2010-08-29 11:41:42 -07:00
Andy Wingo
631237b46c check layout when making vtables
* libguile/struct.c (scm_is_valid_vtable_layout): New private layout
  validating function.
  (scm_i_struct_inherit_vtable_magic): Do a more proper layout
  validation, and don't abort.
2010-05-04 23:48:10 +02:00
Andy Wingo
9a974fd384 optimize and bugfix make-struct VM opcode
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump for make-struct
  change.

* libguile/struct.c (scm_i_alloc_struct): Use scm_words instead of
  scm_gc_malloc to simplify the code and inline the call to GC_MALLOC.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Compile
  make-struct/no-tail to make-struct.

* module/language/tree-il/primitives.scm (define-primitive-expander):
  Allow a conditional branch of #f to aboirt inlining.
  (make-struct): Expand into make-struct/no-tail in the case that
  tail-size is 0.

* libguile/vm-i-scheme.c (make-struct): Adapt to always assume tail-size
  is 0. Inline allocation if possible. Don't decrement the SP past live
  objects on the stack, which could cause GC to miss references. Use the
  NULLSTACK macro.
2010-05-01 00:31:18 +02:00
Ludovic Courtès
e03b7f73e2 Recognize structs with both "pr" and "pw" flags as simple.
* libguile/struct.c (set_vtable_layout_flags): Keep the
  `SCM_VTABLE_FLAG_SIMPLE' flag when VTABLE has a mixture of `r' and `w'
  fields.

* libguile/struct.h (SCM_VTABLE_FLAG_SIMPLE): Adjust comment.
2010-01-26 00:00:58 +01:00
Ludovic Courtès
227eff6a77 Reinstate 2-word displacement for structs.
* libguile/struct.c (scm_init_struct): Reinstate 2-word displacement
  removed by 01e74380f6.
2010-01-25 23:41:27 +01:00