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

103 commits

Author SHA1 Message Date
Andy Wingo
c957ec7ab0 Use atomics for async interrupts
* libguile/__scm.h (SCM_TICK): Always define as scm_async_tick().
* libguile/error.c (scm_syserror, scm_syserror_msg):
* libguile/fports.c (fport_read, fport_write):
* libguile/_scm.h (SCM_SYSCALL): Replace SCM_ASYNC_TICK with
  scm_async_tick ().
  (SCM_ASYNC_TICK, SCM_ASYNC_TICK_WITH_CODE)
  (SCM_ASYNC_TICK_WITH_GUARD_CODE): Remove internal definitions.  We
  inline into vm-engine.c, the only place where it matters.
* libguile/async.h:
* libguile/async.c (scm_async_tick, scm_i_setup_sleep):
  (scm_i_reset_sleep, scm_system_async_mark_for_thread):
* libguile/threads.h (struct scm_thread_wake_data):
* libguile/threads.h (scm_i_thread):
* libguile/threads.c (block_self, guilify_self_1, scm_std_select):
  Rewrite to use sequentially-consistent atomic references.
* libguile/atomics-internal.h (scm_atomic_set_pointer):
  (scm_atomic_ref_pointer): New definitions.
* libguile/finalizers.c (queue_finalizer_async): We can allocate, so
  just use scm_system_async_mark_for_thread instead of the set-cdr!
  shenanigans.
* libguile/scmsigs.c (take_signal):
* libguile/gc.c (queue_after_gc_hook): Adapt to new asyncs mechanism.
  Can't allocate but we're just manipulating the current thread when no
  other threads are running so we should be good.
* libguile/vm-engine.c (VM_HANDLE_INTERRUPTS): Inline the async_tick
  business.
2016-10-26 22:50:26 +02:00
Andy Wingo
f1c0434403 `define!' instruction returns the variable
* doc/ref/vm.texi (Top-Level Environment Instructions): Update
  documentation.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, sadly.
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
* libguile/vm-engine.c (define!): Change to store variable in dst slot.
* module/language/tree-il/compile-cps.scm (convert):
* module/language/cps/compile-bytecode.scm (compile-function): Adapt to
  define! change.
* module/language/cps/effects-analysis.scm (current-module): Fix define!
  effects.  Incidentally here was the bug: in Guile 2.2 you can't have
  effects on different object kinds in one instruction, without
  reverting to &unknown-memory-kinds.
* test-suite/tests/compiler.test ("regression tests"): Add a test.
2016-06-21 22:40:31 +02:00
Andy Wingo
da456d23be Bump objcode version
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump for
  Guile 2.1.3.
2016-05-16 09:38:09 +02:00
Andy Wingo
ac5a05d02e Bump bytecode version
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump
  bytecode version to prevent 2.1.1 users from thinking that they don't
  need to make clean after pulling.
2015-11-11 10:25:23 +01:00
Andy Wingo
d38ca16e2c Add make-vector opcode
* libguile/vm-engine.c (make-vector): New opcode.
* module/language/cps/compile-bytecode.scm (compile-fun):
* module/system/vm/assembler.scm (system): Support the new opcode.
  (*bytecode-minor-version*): Bump.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* test-suite/tests/compiler.test ("limits"): Add vector test.
2014-04-21 22:47:33 +02:00
Andy Wingo
1a82c2012b Bump minor objcode version for recent changes
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
2014-04-15 20:20:01 +02:00
Andy Wingo
b3ae2b5068 Add VM and compiler support for calls to known procedures
* module/language/cps.scm ($callk): New expression type, for calls to
  known labels.  Part of "low CPS".
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/verify.scm: Adapt call sites.

* libguile/vm-engine.c (call-label, tail-call-label): New instructions.
  Renumber the rest; this is an ABI change.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.

* doc/ref/compiler.texi (CPS in Guile): Document $callk.
2014-02-02 23:19:22 +01:00
Andy Wingo
4a1ce0169d VM copes with moving FP
* libguile/_scm.h (SCM_ASYNC_TICK_WITH_GUARD_CODE): New macro.
* libguile/vm-engine.c (VM_HANDLE_INTERRUPTS): Restore FP after
  ticking.
  (CACHE_FP): New macro.
  (CHECK_OVERFLOW): Use CACHE_FP.
  (BR_ARITHMETIC, RETURN_EXP, RETURN_ONE_VALUE, BINARY_INTEGER_OP):
  (call, return-values, subr-call, foreign-call)
  (resolve, define!, toplevel-box, module-box): Restore the FP from the
  vp where needed.
2013-11-22 18:44:33 +01:00
Andy Wingo
f8085163d6 Remove MVRA from VM frames
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump for frame layout
  change.

* libguile/frames.c: Update some static checks.
  (scm_frame_num_locals, scm_frame_local_ref, scm_frame_local_set_x):
  Update to not skip over uninitialized frames, as that's not a thing
  any more.

* libguile/frames.h: Update to remove MVRA.  Woo!

* libguile/vm-engine.c (ALLOC_FRAME, RETURN_ONE_VALUE):
  (rtl_vm_engine): Update for 3 words per frame instead of 4.

* libguile/vm.c (vm_return_to_continuation): Likewise.

* module/language/cps/slot-allocation.scm (allocate-slots): 3 words per
  frame, not 4.

* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.  Also
  remove a couple of tc7's that aren't around any more.
2013-11-15 17:13:27 +01:00
Andy Wingo
4c906ad5a5 Add specialize-primcalls pass; bump objcode version.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* libguile/objcodes.c (process_dynamic_segment): Expect the minor
  version to be present and, while we are still banging on the VM,
  exactly equal to SCM_OBJCODE_MINOR_VERSION.

* libguile/vm-engine.c: Renumber ops.  Remove the general make-vector.
  Rename constant-FOO to FOO/immediate.  Remove struct-ref and
  struct-set!, replace with struct-ref/immediate and
  struct-set!/immediate.

* module/Makefile.am:
* module/language/cps/specialize-primcalls.scm: New pass, inlines FOO to
  FOO/immediate -- e.g. vector-ref to vector-ref/immediate.

* module/language/cps/arities.scm: Remove struct-set! case, now that
  there is no struct-set! opcode.

* module/language/cps/compile-rtl.scm (compile-fun): Remove dispatch to
  constant-FOO versus FOO here -- that decision is made by
  specialize-primcalls.
  (optimize): Add specialize-primcalls pass.

* module/language/cps/dfg.scm (constant-needs-allocation?): Adapt to
  name changes.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*primitive-constructors*): Add allocate-struct.

* module/system/vm/assembler.scm (*bytecode-major-version*):
  (*bytecode-minor-version*, link-dynamic-section): Write minor version
  into resulting image.
2013-11-10 19:27:19 +01:00
Andy Wingo
1c33be992e Remove stack programs, objcode, and the old VM.
* libguile/Makefile.am:
* libguile/vm-i-loader.c:
* libguile/vm-i-scheme.c:
* libguile/vm-i-system.c: Remove the old VM files, and the rules to
  build the .i files.

* libguile/vm-engine.c:
* libguile/vm.c: Remove the old VM.  Woot!

* libguile/_scm.h (SCM_OBJCODE_COOKIE, SCM_OBJCODE_ENDIANNESS_OFFSET)
  (SCM_OBJCODE_WORD_SIZE_OFFSET): Remove.

* libguile/evalext.c (scm_self_evaluating_p): Remove objcode and program
  cases.

* libguile/frames.c (scm_frame_num_locals, scm_frame_previous): Remove
  program cases.

* libguile/gc.c (scm_i_tag_name): Remove objcode case.
* libguile/goops.c (scm_class_of, create_standard_classes): Remove
  objcode and program cases.

* libguile/instructions.h:
* libguile/instructions.c (scm_instruction_list, scm_instruction_p)
  (scm_instruction_length, scm_instruction_pops, scm_instruction_pushes)
  (scm_instruction_to_opcode, scm_opcode_to_instruction): Remove old VM
  code.

* libguile/objcodes.h:
* libguile/objcodes.c: Remove the objcode data type, and handling for
  objcode files.

* libguile/print.c: Remove objcode and program printers.

* libguile/procprop.c: Remove program cases.
* libguile/procs.c:

* libguile/programs.h:
* libguile/programs.c: Remove old program code.

* libguile/smob.c: Remove objcodes include.

* libguile/snarf.h: Remove static program defines.

* libguile/stacks.c: Remove program case.

* libguile/tags.h: Remove program and objcode tc7s.

* module/ice-9/session.scm (procedure-arguments)
* module/language/tree-il/analyze.scm (validate-arity)
* module/statprof.scm (get-call-data, procedure=?)
* module/system/vm/frame.scm (frame-bindings)
  (frame-call-representation): Remove old program cases.

* module/system/repl/debug.scm (frame->module): Add a FIXME.

* module/system/vm/instruction.scm: Remove old exports.

* module/system/vm/program.scm: Remove old program code.
2013-11-08 18:28:24 +01:00
Mark H Weaver
f82f62944a Merge remote-tracking branch 'origin/stable-2.0' 2013-07-18 15:31:34 -04:00
Ludovic Courtès
fe51c7b3e0 Fix 'SCM_SYSCALL' to really swallow EINTR.
* libguile/_scm.h (SCM_SYSCALL): Keep looping upon EINTR.
  Reported at
  <http://lists.gnu.org/archive/html/guile-devel/2013-06/msg00050.html>.
2013-07-17 17:58:04 +02:00
Andy Wingo
4d497b629b Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/vm-engine.c
	libguile/vm-i-system.c
2012-04-30 21:34:58 +02:00
Andy Wingo
7dbc03498a add internal SCM_NOINLINE definition
* libguile/_scm.h (SCM_NOINLINE): New internal define, for things that
  we definitely don't want the compiler to inline.
2012-04-30 20:29:49 +02:00
BT Templeton
5ddd9645c9 Merge branch 'bt/elisp'
Conflicts:
	am/guilec
	libguile/_scm.h
	libguile/vm-i-scheme.c
	module/language/elisp/compile-tree-il.scm
	module/language/elisp/runtime.scm
	module/language/elisp/runtime/macros.scm
	module/language/tree-il/compile-glil.scm
	module/language/tree-il/primitives.scm
2012-03-05 16:52:05 -05:00
BT Templeton
9348168ed5 add `nil?' primitive
* libguile/boolean.c (scm_nil_p): New function.

* libguile/vm-i-scheme.c (nilp, not_nilp):
* libguile/vm-i-system.c (br_if_nil, br_if_not_nil): New instructions.
  Renumber other ops.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Increment.

* module/language/assembly/compile-bytecode.scm (compile-bytecode): Add
  support for writing `br-if-nil' and `br-if-not-nil' instructions.

* module/language/assembly/disassemble.scm (code-annotation): Add
  `br-if-nil' and `br-if-not-nil' to the list of branch instructions.

* module/language/tree-il/compile-glil.scm: Add `nil?' to
  `*primcall-ops*'.
  (flatten): Use the new branch instructions for `nil?' conditionals.

* module/language/tree-il/primitives.scm: Add `nil?' to
  `*interesting-primitive-names*', `*effect-free-primitives', and
  `*effect+exception-free-primitives*'.
2012-02-03 18:53:38 -05:00
Andy Wingo
d5a4f51f9c add string-length, string-ref, vector-length instructions
* libguile/_scm.h (SCM_OBJCODE_MAJOR_VERSION): Bump the major version,
  indicating the first incompatibility between 2.0 and 2.2.

* libguile/vm-i-scheme.c (string-length, string-ref, vector-length): New
  instructions.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
  primcall ops for the new instructions.
2011-10-28 11:38:56 +02:00
Andy Wingo
46da7909e1 Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
	meta/Makefile.am
2011-06-02 22:49:33 +02:00
Andy Wingo
f0b7c3c6b9 write-objcode uses target-endianness, target-word-size
* libguile/_scm.h (SCM_OBJCODE_ENDIANNESS_OFFSET):
  (SCM_OBJCODE_WORD_SIZE_OFFSET): New defines.
* libguile/objcodes.c (scm_write_objcode): Use target-endianness and
  target-word-size when writing the objcode cookie.
2011-05-31 11:18:29 +02:00
Andy Wingo
27c6ebcb16 rename scm_async_click() to scm_async_tick(); privatize SCM_ASYNC_TICK
* libguile/_scm.h (SCM_ASYNC_TICK, SCM_ASYNC_TICK_WITH_CODE): Make these
  definitions private.  Call the tick() function instead of click().

* libguile/__scm.h:
* libguile/async.h (scm_async_tick): Move declaration here.  Remove
  scm_async_click declaration.  Tick is the new (and old!) click, you
  see.
  (SCM_CRITICAL_SECTION_END): Call tick() instead of click().

* libguile/async.c (scm_async_tick): Remove old definition, and rename
  scm_async_click to scm_async_tick.
  (decrease_block): Adapt to click() -> tick() name change.

* libguile/deprecated.h (scm_async_click, SCM_ASYNC_TICK): Define some
  GONE macros.

* libguile/threads.c (fat_mutex_unlock): Tick() instead of click().
2011-05-15 15:34:16 +02:00
Andy Wingo
04245bb72f make SCM_I_SETJMP and SCM_I_LONGJMP private
* libguile/_scm.h (SCM_I_SETJMP, SCM_I_LONGJMP): Move to this private
  header.
* libguile/__scm.h (scm_i_jmp_buf): Only define the scm_i_jmp_buf type
  in this public header.
2011-05-15 15:34:15 +02:00
Andy Wingo
e8ab529d57 bump objcode version to 2.0; introduce minor-version compatibility
* libguile/_scm.h (SCM_OBJCODE_MAJOR_VERSION): Bump to 2.
  (SCM_OBJCODE_MINOR_VERSION): Reset to 0.
  (SCM_OBJCODE_MACHINE_VERSION_STRING, SCM_OBJCODE_COOKIE): Reorder so
  the minor version is the last byte.

* libguile/objcodes.c (make_objcode_by_mmap): Accept objcodes whose
  minor version is less than SCM_OBJCODE_MINOR_VERSION, not just equal
  to.
2011-02-13 22:02:01 +01:00
Andy Wingo
51c1dba88a ASYNC_TICK after catching EINTR in SCM_SYSCALL
* libguile/_scm.h (SCM_SYSCALL): As in scm_syserror, do a SCM_ASYNC_TICK
  before resuming the syscall after an EINTR.
2010-12-03 15:17:35 +01:00
Andy Wingo
1c20cf1175 bump objcode version
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, as the
  process-define-module deprecation means that outside compiled code
  won't find process-define-module in the (guile) module, as they would
  before.
2010-11-19 17:51:16 +01:00
Andy Wingo
ddffdd788d _scm GUILE_USE_64_CALLS compilation warning fix
* libguile/_scm.h: Check that GUILE_USE_64_CALLS is defined. Fixes an
  error on i386-apple-darwin9.8.0.
2010-10-18 13:27:17 +02:00
Andy Wingo
cf45ff030c inline symbol? and vector? to opcodes, and a psyntax inlining tweak
* libguile/vm-i-scheme.c (symbol?, vector?): New
  instructions. Renumbered the rest.
* libguile/vm-i-system.c: Renumber instructions.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* module/ice-9/psyntax.scm (binding-type, binding-value): Define using
  macros so that we inline to car and cdr opcodes. Oh, for an inliner :)

* module/language/tree-il/compile-glil.scm (*primcall-ops*)
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*, *effect-free-primitives*)
  (*effect+exception-free-primitives*): Add symbol? and vector?
  inlines.
2010-10-08 12:31:56 +02:00
Ludovic Courtès
99765ed172 Remove `scm_t_aligned_cell'.
* libguile/_scm.h (scm_aligned_cell, scm_t_aligned_cell): Remove.  The
  whole approach was misguided as the compiler can't guarantee absolute
  alignment on the stack.
2010-09-27 01:28:49 +02:00
Andy Wingo
f42d8bd8ff simplify macro representation in the wake of module hygiene changes
* module/ice-9/psyntax.scm (chi-install-global, chi-macro)
  (eval-local-transformer): Now that we handle module hygiene through
  syntax objects, there is no more need to record the current module
  when installing syntax transformers.

* module/ice-9/psyntax-pp.scm: Regenerated (trickily).

* libguile/_scm.h: Bump objcode version for macro representation change.

* libguile/macros.c (scm_macro_transformer): Adapt to change in macro
  representation.
2010-06-06 13:39:44 +02:00
Ludovic Courtès
1880c97df1 Fix parenthesizing of the `ROUND_UP' macro; factorize.
* libguile/_scm.h (ROUND_UP): New macro.

* libguile/continuations.c (ROUND_UP): Remove.

* libguile/control.c (ROUND_UP): Remove.

* libguile/foreign.c (ROUND_UP): Remove.
2010-05-30 22:41:36 +02:00
Volker Grabsch
18dcd80e37 don't fail when HAVE_STAT64 is undefined
* libguile/_scm.h: Check whether `HAVE_STAT64' is defined instead of
  checking its value.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2010-05-28 17:02:13 +02:00
Ludovic Courtès
405a79ca7f Add `scm_t_aligned_cell' internal type.
* libguile/_scm.h (struct scm_aligned_cell)[__GNUC__]: New type.
  (union scm_aligned_cell)[!__GNUC__]: New type.
  (scm_t_aligned_cell): New type.

* libguile/vm.c (vm_dispatch_hook): Use it.
2010-05-28 17:02:13 +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
Andy Wingo
827dc8dcb6 renumber VM opcodes
* libguile/vm-i-loader.c:
* libguile/vm-i-scheme.c:
* libguile/vm-i-system.c: Renumber ops. Add a foreign-call op stub.
  Rearrange some ops.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump
2010-01-26 22:56:41 +01:00
Andy Wingo
6f16379e9a allocate free variables inline to closures
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* libguile/programs.h (SCM_PROGRAM_FREE_VARIABLES)
  (SCM_PROGRAM_FREE_VARIABLE_REF, SCM_PROGRAM_FREE_VARIABLE_SET)
  (SCM_PROGRAM_NUM_FREE_VARIABLES):
* libguile/programs.c (scm_make_program, scm_program_num_free_variables)
  (scm_program_free_variable_ref, scm_program_free_variable_set_x):
  Allocate free variables inline with programs, instead of being in a
  vect. Should improve locality, and require fewer local variables in
  the VM.

* libguile/vm-engine.c (vm_engine): Remove free_vars and free_vars_count
  variables.

* libguile/vm-engine.h (CACHE_PROGRAM): No need to muck with free_vars
  and free_vars_count.
  (CHECK_FREE_VARIABLE): Update for inline free vars.

* libguile/vm-i-system.c (FREE_VARIABLE_REF): Update for inline free
  vars.
  (make-closure, fix-closure): Take the closure vals as separate stack
  args, and copy or fix them inline into the appropriate closure.

* module/language/objcode/spec.scm (program-free-variables): Define a
  local version of this removed function.

* module/language/tree-il/compile-glil.scm (flatten): Adjust to not make
  a vector when making closures.

* module/system/vm/program.scm: Export program-num-free-variables,
  program-free-variable-ref, program-free-variable-set!, and remove
  program-free-variables.

* test-suite/tests/tree-il.test ("lambda"): Update to not make vectors
  when making closures.
2010-01-09 16:43:26 +01:00
Andy Wingo
fd12a19a5e subrs are now VM trampoline procedures
* libguile/_scm.h: Add foreign.h and programs.h to the private include
  list, as snarfing subrs with static allocation now needs access to
  some of their enums and macros.

* libguile/gsubr.c (create_gsubr): Instead of creating a tc7_gsubr
  object, create a VM program with the call-subr opcode, so that the
  representation of subrs is now gsubrs. CPP and elisp, together at
  last.
  (scm_subr_objcode_trampoline): New function, used by the SCM_DEFINE
  snarf macro.

* libguile/gsubr.h (SCM_SUBR_META_INFO, SCM_SUBR_PROPS)
  (SCM_SET_SUBR_GENERIC_LOC, SCM_SUBR_ARITY_TO_TYPE): Remove these
  macros. They were never deprecated, but hopefully people aren't using
  them.
  (SCM_SUBRF, SCM_SUBR_NAME, SCM_SUBR_GENERIC, SCM_SET_SUBR_GENERIC):
  Update to work on the new subr representation.

* libguile/objcodes.h (SCM_F_OBJCODE_IS_STATIC): New flag, indicates
  that the "backing store" of the objcode is statically allocated.

* libguile/procprop.c (scm_sym_name): Define here instead of in gsubr.c.

* libguile/snarf.h (SCM_DEFINE): If we are doing static allocation,
  statically allocate the foreign object, the object table, and the
  program, and use some SCM_SNARF_INITtery to fix things up.
  Unfortunately I have not been able to make this immutable. It might be
  possible, though.
  (SCM_IMMUTABLE_CELL, SCM_STATIC_DOUBLE_CELL, SCM_IMMUTABLE_FOREIGN):
  (SCM_STATIC_SUBR_OBJVECT, SCM_STATIC_PROGRAM): New helper macros.
2010-01-07 23:49:25 +01:00
Andy Wingo
e809758a7e clean up macros.[ch]
There are some incompatible changes here, but only to interfaces that
were introduced earlier in 1.9, or interfaces which have been broken
since early in 1.9.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, as the macro
  changes affect the interface that is called by psyntax-generated macro
  definitions.

* libguile/inline.h (scm_words): New function, allocates a variable
  number of contiguous scm_t_bits locations, with a given value in the
  0th word, and 0 in the rest of the words.

* libguile/macros.h: Rework interface to correspond more closely, and
  minimally, to the needs of memoize.c and psyntax.
  (SCM_ASSYNT, SCM_MACRO_TYPE_BITS, SCM_MACRO_TYPE_MASK)
  (SCM_F_MACRO_EXTENDED, SCM_MACROP, SCM_MACRO_TYPE)
  (SCM_MACRO_IS_EXTENDED, SCM_BUILTIN_MACRO_P, SCM_SYNCASE_MACRO_P)
  (SCM_MACRO_CODE, scm_tc16_macro): Remove CPP macros related to the
  representation of Scheme macros.
  (scm_i_make_primitive_macro): Renamed from scm_i_makbimacro.
  (scm_i_macro_primitive): New accessor so that memoize.c can get to the
  primitive syntax transformer.
  (scm_make_syncase_macro, scm_make_extended_syncase_macro)
  (scm_syncase_macro_type, scm_syncase_macro_binding): Removed these
  functions, replaced by make-syntax-transformer and its accessors.
  (scm_macro_binding): New accessor, the same as what
  scm_syncase_macro_binding was.

* libguile/macros.c: All representation details of syntax transformers
  are private to this file now.
  (macro_print): Print macros as #<syntax-transformer ...>, or
  #<primitive-syntax-transformer ...> if psyntax has not attached a
  transformer of its own.
  (scm_i_make_primitive_macro): Represent macros as 5-word smobs.
  (scm_make_syntax_transformer): New constructor for syntax transformers
  (macros), exported to scheme. Takes a name, and looks it up in the
  current module to determine the previous primitive transformer, if
  any.
  (scm_macro_type): Instead of returning 'builtin-macro!, etc, return
  the type as set by psyntax, or #f if it's a primitive.
  (scm_macro_name): Return the stored macro name.
  (scm_macro_transformer): Return the psyntax-set syntax transformer.
  Hacky, but should help introspection somewhat.

* libguile/memoize.c (memoize_env_ref_transformer): Use the new
  scm_i_macro_primitive, and adapt to other macro API changes.

* module/ice-9/psyntax.scm (put-global-definition-hook)
  (get-global-definition-hook, chi-install-global): Call (and generate
  calls to) the new macro constructors and accessors.

* module/ice-9/psyntax-pp.scm: Doubly regenerated.

* module/ice-9/debugging/traps.scm (trap-here): Comment out this
  definition and export, while it's not working.
2010-01-05 15:33:46 +01:00
Andy Wingo
e42573315b merge from master to elisp
* module/language/elisp/compile-tree-il.scm: Update for changes to
  tree-il (lambda-case, mainly).

* module/language/elisp/spec.scm: Update GPL version to 3. Update reader
  for new taking a port and environment argument.

* libguile/_scm.h: Bump objcode version.

* libguile/vm-i-system.c: Fix conflicts.

* module/Makefile.am: Fix conflicts, and add elisp modules to the build.
2009-12-11 10:45:18 +01:00
Ludovic Courtès
114bc68ac9 Don't rely on `HAVE_' macros in public header "tags.h".
* configure.ac: Check for `intptr_t' and `uintptr_t'.  Substitute
  `SCM_I_GSC_T_INTPTR' and `SCM_I_GSC_T_UINPTR'.

* libguile/__scm.h (SCM_T_UINTPTR_MAX, SCM_T_INTPTR_MIN,
  SCM_T_INTPTR_MAX): New macros.

* libguile/_scm.h (SIZEOF_SCM_T_BITS): New macro.

* libguile/gen-scmconfig.c (main): Produce typedefs for `scm_t_intptr'
  and `scm_t_uintptr'.

* libguile/gen-scmconfig.h.in (SCM_I_GSC_T_INTPTR, SCM_I_GSC_T_UINPTR):
  New macros.

* libguile/tags.h: Don't check for `HAVE_INTTYPES_H' and
  `HAVE_STDINT_H'; don't include <inttypes.h> nor <stdint.h>.
  (scm_t_signed_bits, scm_t_bits): Define unconditionally as aliases for
  `scm_t_intptr' and `scm_t_uintptr', respectively.
  (SCM_T_SIGNED_BITS_MAX, SCM_T_SIGNED_BITS_MIN, SCM_T_BITS_MAX):
  Likewise.
  (SIZEOF_SCM_T_BITS): Remove.
2009-11-24 23:12:03 +01:00
Ludovic Courtès
731dd0ce19 Merge branch 'bdw-gc-static-alloc'
Conflicts:
	acinclude.m4
	libguile/__scm.h
	libguile/bdw-gc.h
	libguile/eval.c
2009-11-01 18:17:31 +01:00
Andy Wingo
df435c8307 arities can have noncontiguous starts and ends
* module/language/glil/compile-assembly.scm (open-arity, close-arity)
  (begin-arity, glil->assembly): Refactor so that arities can have
  noncontiguous starts and ends. So within a prelude there is no arity
  -- only before (the previous arity) or after (the new arity).

* module/system/vm/program.scm (arity:end): Add this private accessor.
  Arities are expected to be in the new format. While not a change in
  objcode format, it is an incompatible change, so I'll bump the objcode
  cookie.
  (program-arity): Check that the ip is within both bounds of the arity.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* libguile/programs.c (scm_i_program_arity): Update for new arity format.

* module/system/vm/frame.scm (vm-frame-arguments): Avoid throwing an
  error in this function, which is called from the backtrace code.
2009-10-25 13:12:27 +01:00
Andy Wingo
3092a14d67 vm support for optional/kwarg init code, and bugfixes
* libguile/vm-i-system.c (local-bound?, long-local-bound?)
  (variable-bound?): New instructions, push #f unless the local is
  bound. You can get unbound locals from optional arguments.
  (bind-optionals/shuffle): A number of bugfixes.
  (bind-kwargs): Bugfixes. If we enocunter an improper kwarg list but
  the procedure has a rest argument, just stop kwarg processing, but
  without an error.
  Renumbered ops.

* libguile/_scm.h (SCM_OBJCODE_MAJOR_VERSION): Bump.
2009-10-23 15:59:07 +02:00
Andy Wingo
899d37a6cf more work towards compiling and interpreting keyword args
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bumparoo
* libguile/vm-i-system.c (push-rest, bind-rest): Logically there are
  actually two rest binders -- one that pops, conses, and pushes, and
  one that pops, conses, and local-sets. The latter is used on keyword
  arguments, because the keyword arguments themselves have been shuffled
  up on the stack. Renumber ops again.

* module/language/tree-il/compile-glil.scm (flatten): Attempt to handle
  compilation of lambda-case with keyword arguments. Might need some
  help.

* module/ice-9/psyntax.scm (build-lambda-case): An attempt to handle the
  interpreted case correctly. This might need a couple iterations, but
  at least it looks like the compile-glil code.

* module/ice-9/psyntax-pp.scm: Regenerated.

* module/language/glil.scm (<glil>): Rename "rest?" to "rest" in
  <glil-opt-prelude> and <glil-kw-prelude>, as it is no longer a simple
  boolean, but if true is an integer: the index of the local variable to
  which the rest should be bound.

* module/language/glil/compile-assembly.scm (glil->assembly): Adapt to
  "rest" vs "rest?". In the keyword case, use "bind-rest" instead of
  "push-rest".

* test-suite/tests/tree-il.test: Update for opt-prelude change.
2009-10-23 15:20:22 +02:00
Andy Wingo
7e01997e88 finish support for optional & keyword args; update ecmascript compiler
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.
* libguile/vm-i-system.c (br-if-nargs-ne, br-if-args-lt)
  (br-if-nargs-gt): New instructions, for use by different lambda cases.
  (bind-optionals, bind-optionals/shuffle, bind-kwargs): New
  instructions, for binding optional and keyword arguments. Renumber
  other ops.

* module/language/ecmascript/compile-tree-il.scm (comp, comp-body):
  Update for new tree-il. Use the new optional argument mechanism
  instead of emulating it with rest arguments.

* module/language/glil/compile-assembly.scm (glil->assembly): Tweaks for
  optional and keyword argument compilation.

* module/language/tree-il.scm (parse-tree-il, unparse-tree-il): Make the
  else case optional, in the s-expression serialization of tree-il.

* module/language/tree-il/compile-glil.scm (flatten): Handle all of the
  lambda-case capabilities.
2009-10-23 15:10:25 +02:00
Andy Wingo
56164a5a6c de-nargs struct scm_objcode; procedure-property refactor
* libguile/objcodes.h (struct scm_objcode): Remove nargs, nrest, and
  nlocs, as they are no longer needed. Also obviates the need for a
  padding word.

* libguile/procs.c (scm_thunk_p): Use scm_i_program_arity for programs.

* libguile/procprop.c (scm_i_procedure_arity): Use scm_i_program_arity
  for programs.
  (scm_procedure_properties, scm_set_procedure_properties_x)
  (scm_procedure_property, scm_set_procedure_property_x): Rework so that
  non-closure properties are stored directly in a weak hash, instead of
  needing a weak hash of "stand-in" closures to hold the properties. Fix
  docstrings also.

* libguile/root.h (scm_stand_in_procs): Remove from the scm_sys_protects
  set. Actually with libGC, we should be able to store the elements of
  scm_sys_protects directly as global variables.
* libguile/gc.c (scm_init_storage): Remove scm_stand_in_procs
  initialization.

* libguile/programs.c (scm_i_program_arity): New private accessor, tries
  to determine the "minimum arity" of a program.

* libguile/vm.c (really_make_boot_program): Adapt to changes in
  struct scm_objcode.

* module/language/assembly.scm (*program-header-len*, byte-length):
* module/language/assembly/compile-bytecode.scm (write-bytecode):
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
* module/language/assembly/disassemble.scm (disassemble-load-program):
  Adapt to changes in objcode.

* module/system/xref.scm (program-callee-rev-vars): Adapt to changes in
  assembly.

* module/language/glil.scm: Remove nargs, nrest, and nlocs from
  glil-program.

* module/language/glil/compile-assembly.scm (make-meta, glil->assembly):
* module/language/glil/decompile-assembly.scm (decompile-toplevel):
  (decompile-load-program): Adapt to changes in GLIL and assembly.

* module/language/tree-il/compile-glil.scm (flatten-lambda): Adapt to
  changes in GLIL.

* test-suite/tests/asm-to-bytecode.test: Adapt to assembly and bytecode
  changes.
* test-suite/tests/tree-il.test: Adapt to GLIL changes.
2009-10-23 14:51:19 +02:00
Andy Wingo
6c6a44390b runtime and debugging support for callee-parsed procedure args
* libguile/objcodes.h: Bump for metadata format change.

* libguile/frames.h: Rework so we don't frob the program's nargs, nlocs,
  etc at runtime. Instead we don't really know what's a local var, an
  argument, or an intermediate value. It's a little unfortunate, but
  this will allow for case-lambda, and eventually for good polymorphic
  generic dispatch; and the nlocs etc can be heuristically
  reconstructed. Such a reconstruction would be better done at the
  Scheme level, though.
  (SCM_FRAME_STACK_ADDRESS): New macro, the pointer to the base of the
  stack elements (not counting the program).
  (SCM_FRAME_UPPER_ADDRESS): Repurpose to be the address of the last
  element in the bookkeeping part of the stack -- i.e. to point to the
  return address.

* libguile/vm-engine.h:
* libguile/vm-i-system.c: Adapt to removal of stack_base. Though we
  still detect stack-smashing underflow, we don't do so as precisely as
  we did before, because now we only detect overwriting of the frame
  metadata.

* libguile/vm-engine.c (vm_engine): Remove the stack_base variable. It
  is unnecessary, and difficult to keep track of in the face of
  case-lambda. Also fix miscommented "ra" and "mvra" pushes. Push the
  vp->ip as the first ra...
* libguile/vm-i-system.c (halt): ...because here we can restore the
  vp->ip instead of setting ip to 0. Allows us to introspect ips all
  down the stack, including in recursive VM invocations.

* libguile/frames.h:
* libguile/frames.c (scm_vm_frame_stack): Removed, because it's getting
  more difficult to tell what's an argument and what's a temporary stack
  element.
  (scm_vm_frame_num_locals): New accessor.
  (scm_vm_frame_instruction_pointer): New accessor.
  (scm_vm_frame_arguments): Defer to an implementation in Scheme.
  (scm_vm_frame_num_locals scm_vm_frame_local_ref)
  (scm_vm_frame_local_set_x): Since we can get not-yet-active frames on
  the stack now, with our current calling convention, we have to add a
  heuristic here to jump over those frames -- because frames have
  pointers in them, not Scheme values.

* libguile/programs.h:
* libguile/programs.c (scm_program_arity): Remove, in favor of..
  (scm_program_arities): ...this, which a list of arities, in a new
  format, occupying a slot in the metadata.

* module/language/assembly/decompile-bytecode.scm (decode-load-program):
  Fix mv-call decompilation.

* module/system/vm/frame.scm (vm-frame-bindings, vm-frame-binding-ref)
  (vm-frame-binding-set!): New functions, to access bindings by name in
  a frame.
  (vm-frame-arguments): Function now implemented in Scheme. Commented
  fairly extensively.

* module/system/vm/program.scm (program-bindings-by-index)
  (program-bindings-for-ip): New accessors, parsing the program bindings
  metadata into something more useful.
  (program-arities, program-arguments): In a case-lambda world, we have
  to assume that programs can have multiple arities. But it's tough to
  detect this algorithmically; instead we're going to require that the
  program metadata include information about the arities, and the parts
  of the program that that metadata applies to.
  (program-lambda-list): New accessor.
  (write-program): Show multiple arities.

* module/language/glil/compile-assembly.scm (glil->assembly): Add
  "arities" to the state of the compiler, and add arities entries as
  appropriate.
2009-10-23 14:51:17 +02:00
Andy Wingo
1e2a8c266d steps on the way to have the callee check the number of arguments
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* libguile/vm-i-system.c (assert-nargs-ee, assert-nargs-ge)
  (push-rest-list): New instructions, which for now don't actually do
  anything. Renumber the rest of the ops in this file.

* module/language/glil.scm (<glil-arity>): New GLIL type, an entity that
  checks the number of args for a block, optionally consing a rest list,
  and either branching or erroring if the arity doesn't match.

* module/language/glil/compile-assembly.scm (glil->assembly): Compile
  <glil-arity> to assembly. Some of these VM ops are not implemented --
  notably the branching case.

* module/language/tree-il/compile-glil.scm (flatten-lambda): Emit
  <glil-arity>.

* test-suite/tests/tree-il.test: Update.
2009-10-23 14:51:17 +02:00
Andy Wingo
97fcf583b7 jumps encoded using 24 bits, not 19; blocks no longer aligned
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.
* libguile/vm-i-system.c (FETCH_OFFSET, BR): Labels are no longer 8-byte
  aligned; instead, jumps are encoded into 3 bytes instead of 2.
  (br, br-if, br-if-not, br-if-eq, br-if-not-eq, br-if-null)
  (br-if-not-null, mv-call): Adapt for new length of br instructions (3
  bytes instead of 2).

* libguile/vm.c (really_make_boot_program): Adapt hand-coded bytecode
  for new offset regime.

* module/language/assembly.scm (align-block): No alignment necessary.

* module/language/assembly/compile-bytecode.scm (write-bytecode): Write
  out breaks as 24-bit relative jumps.
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
  Decompile break instructions.
2009-10-16 15:56:11 +02:00
Ludovic Courtès
5f236208d0 Merge branch 'boehm-demers-weiser-gc' into bdw-gc-static-alloc
Conflicts:
	acinclude.m4
	libguile/strings.c
2009-09-02 01:37:37 +02:00
Andy Wingo
b7946e9ec6 push new frame on stack before procedure & args
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump

* libguile/vm-engine.c (vm_engine): Push a frame corresponding to the
  mv-call.

* libguile/vm-i-system.c: Renumber ops.
  (new-frame): New op, pushes a frame.
  (call, mv-call): No need to shuffle args, though we do need to pop the
  frame in the non-vm call case.
  (goto/args): Inconsequential tweaks.
  (call/cc): Push a frame if needed.

* module/language/tree-il/compile-glil.scm (flatten): Emit `new-frame'
  as appropriate.

* test-suite/tests/tree-il.test: Fix to expect new-frame.
2009-08-20 18:52:50 +02:00