bpt/guile.git
10 years agoRename objcodes?.{scm,c,h} to loader.{scm,c,h}
Andy Wingo [Tue, 19 Nov 2013 20:45:07 +0000 (21:45 +0100)]
Rename objcodes?.{scm,c,h} to loader.{scm,c,h}

* libguile/loader.c:
* libguile/loader.h: Rename from objcodes.[ch].
* module/system/vm/loader.scm: Rename from objcode.scm.

* libguile/Makefile.am:
* libguile/gsubr.c:
* libguile/init.c:
* libguile/procs.c:
* libguile/vm.c:
* module/Makefile.am:
* module/ice-9/eval-string.scm:
* module/language/rtl/spec.scm:
* module/system/base/target.scm:
* module/system/repl/command.scm:
* module/system/repl/common.scm:
* module/system/vm/debug.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/objcode.scm:
* test-suite/tests/compiler.test:
* test-suite/tests/dwarf.test:
* test-suite/tests/rtl-compilation.test:
* test-suite/tests/rtl.test: Adapt.

10 years agoRemove (oop goops) <objcode> export
Andy Wingo [Tue, 19 Nov 2013 20:32:42 +0000 (21:32 +0100)]
Remove (oop goops) <objcode> export

* module/oop/goops.scm (oop): Remove objcode export.

10 years agoFix gsubr comment
Andy Wingo [Tue, 19 Nov 2013 20:27:38 +0000 (21:27 +0100)]
Fix gsubr comment

* libguile/gsubr.c: Update comment to excise RTL.

10 years agoLingering RTL excision in vm.c
Andy Wingo [Tue, 19 Nov 2013 20:26:26 +0000 (21:26 +0100)]
Lingering RTL excision in vm.c

* libguile/vm-engine.c:
* libguile/vm.c: Rework VM inclusion so that we don't define VM_ENGINE
  and expect vm-engine.c to understand that -- since there is only
  VM_USE_HOOKS, define that in vm.c directly.  Rename rtl_vm_foo to
  vm_foo.

* libguile/vm.h: Remove scm_t_vm_engine typedef.

10 years agoMove RTL unpack macros to vm-engine.c
Andy Wingo [Tue, 19 Nov 2013 20:11:28 +0000 (21:11 +0100)]
Move RTL unpack macros to vm-engine.c

* libguile/instructions.h: Remove SCM_UNPACK macros from here.
* libguile/vm-engine.c: Add them here, without the RTL_, and without the
  SCM_ prefix.

10 years agoChange SCM_PACK_RTL macros to SCM_PACK_OP / SCM_PACK_OP_ARG
Andy Wingo [Tue, 19 Nov 2013 20:04:24 +0000 (21:04 +0100)]
Change SCM_PACK_RTL macros to SCM_PACK_OP / SCM_PACK_OP_ARG

* libguile/instructions.h: Guard in BUILDING_LIBGUILE.
  (SCM_PACK_OP_24):
  (SCM_PACK_OP_8_8_8):
  (SCM_PACK_OP_8_16):
  (SCM_PACK_OP_16_8):
  (SCM_PACK_OP_12_12): Rename from SCM_PACK_RTL_*, and splice in the
  opcode.
  (SCM_PACK_OP_ARG_8_24): New helper.

* libguile/vm.c:
* libguile/gsubr.c:
* libguile/foreign.c:
* libguile/control.c:
* libguile/continuations.c: Adapt.

10 years agoscm_rtl_op_* -> scm_op_*
Andy Wingo [Tue, 19 Nov 2013 19:31:21 +0000 (20:31 +0100)]
scm_rtl_op_* -> scm_op_*

* libguile/instructions.h (scm_opcode): Rename from scm_rtl_opcode.
  Rename opcodes from scm_rtl_op_* to scm_op_*.

* libguile/continuations.c:
* libguile/control.c:
* libguile/foreign.c:
* libguile/gsubr.c:
* libguile/instructions.c:
* libguile/vm.c: Adapt.

10 years ago(system vm instruction) rtl-instruction-list -> (language rtl) instruction-list
Andy Wingo [Tue, 19 Nov 2013 19:45:57 +0000 (20:45 +0100)]
(system vm instruction) rtl-instruction-list -> (language rtl) instruction-list

* libguile/instructions.c (struct scm_instruction, fetch_instruction_table)
  (scm_instruction_list): Remove rtl_ infix.
* libguile/instructions.h: Adapt.

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

* module/language/rtl.scm: Export instruction-list from here.

* module/Makefile.am:
* module/language/cps/primitives.scm:
* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/frame.scm:
* module/system/vm/program.scm:
* module/system/vm/trace.scm:
* module/system/vm/traps.scm: Adapt.

10 years agoInternal RTL excision in vm.c
Andy Wingo [Tue, 19 Nov 2013 19:05:45 +0000 (20:05 +0100)]
Internal RTL excision in vm.c

* libguile/vm.c (vm_boot_continuation, vm_boot_continuation_code):
  Rename from rtl_boot_continuation[_code].
  (scm_bootstrap_vm):
* libguile/vm-engine.c (rtl_vm_engine): Adapt.

10 years agoSmall comment fix.
Andy Wingo [Tue, 19 Nov 2013 19:02:49 +0000 (20:02 +0100)]
Small comment fix.

* libguile/vm-builtins.h: Rename RTL to VM in a comment.

10 years agoRename DT_GUILE_VM_VERSION.
Andy Wingo [Tue, 19 Nov 2013 19:02:15 +0000 (20:02 +0100)]
Rename DT_GUILE_VM_VERSION.

* libguile/objcodes.c (DT_GUILE_VM_VERSION, process_dynamic_segment):
* module/system/vm/elf.scm (DT_GUILE_VM_VERSION): Rename from
  DT_GUILE_RTL_VERSION.
* module/system/vm/assembler.scm (link-dynamic-section): Adapt.

10 years agoRename internal rtl-program-properties -> program-properties
Andy Wingo [Tue, 19 Nov 2013 18:50:15 +0000 (19:50 +0100)]
Rename internal rtl-program-properties -> program-properties

* module/system/vm/program.scm (program-properties): Rename from
  rtl-program-properties.

* libguile/programs.c (scm_i_program_properties): Adapt.

10 years agoExcise "rtl-" from fallback program printer
Andy Wingo [Tue, 19 Nov 2013 18:47:33 +0000 (19:47 +0100)]
Excise "rtl-" from fallback program printer

* libguile/programs.c (scm_i_program_print): Fallback printer uses
  "program", not "rtl-program".

10 years agoRename internals of (system vm program) program-minimum-arity
Andy Wingo [Tue, 19 Nov 2013 18:45:56 +0000 (19:45 +0100)]
Rename internals of (system vm program) program-minimum-arity

* module/system/vm/debug.scm (find-program-minimum-arity): Rename from
  program-minimum-arity.

* module/system/vm/program.scm (program-minimum-arity): Rename from
  rtl-program-minimum-arity.

* libguile/programs.c (scm_i_program_arity): Adapt.

10 years agoRename (system vm program) internal functions to remove rtl-
Andy Wingo [Tue, 19 Nov 2013 18:36:16 +0000 (19:36 +0100)]
Rename (system vm program) internal functions to remove rtl-

* module/system/vm/program.scm (program-name)
  (program-documentation): Rename (removing rtl-).
* libguile/programs.c (scm_i_program_name):
  (scm_i_program_documentation): Adapt callers.

10 years agoRemove unused C scm_program_source.
Andy Wingo [Tue, 19 Nov 2013 18:19:55 +0000 (19:19 +0100)]
Remove unused C scm_program_source.

* libguile/programs.c (scm_program_source): Remove; not called.  (The
  definition is in Scheme.)

10 years agoReorganize programs.h.
Andy Wingo [Tue, 19 Nov 2013 18:18:36 +0000 (19:18 +0100)]
Reorganize programs.h.

* libguile/programs.h: Reorganize.

10 years agortl-program-code -> program-code
Andy Wingo [Tue, 19 Nov 2013 18:16:26 +0000 (19:16 +0100)]
rtl-program-code -> program-code

* libguile/programs.h:
* libguile/programs.c (scm_program_code): Rename from
  scm_rtl_program_code.  Also renames rtl-program-code to program-code.

* module/statprof.scm:
* module/system/repl/command.scm:
* module/system/repl/debug.scm:
* module/system/vm/coverage.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/program.scm:
* module/system/vm/traps.scm:
* test-suite/tests/dwarf.test:
* test-suite/tests/rtl.test: Adapt callers.

10 years agortl-program? -> program?
Andy Wingo [Tue, 19 Nov 2013 18:11:40 +0000 (19:11 +0100)]
rtl-program? -> program?

* libguile/programs.c (scm_program_p): Rename from scm_rtl_program_p.
  Changes name also from rtl-program? to program?.

* libguile/programs.h:
* module/ice-9/session.scm:
* module/language/tree-il/analyze.scm:
* module/statprof.scm:
* module/system/repl/command.scm:
* module/system/repl/debug.scm:
* module/system/vm/coverage.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/frame.scm:
* module/system/vm/program.scm:
* module/system/vm/traps.scm:
* module/system/xref.scm: Adapt.

10 years agoRemove make-rtl-program.
Andy Wingo [Tue, 19 Nov 2013 18:03:09 +0000 (19:03 +0100)]
Remove make-rtl-program.

* libguile/programs.h:
* libguile/programs.c (scm_make_rtl_program): Remove.  Unused.

* module/system/vm/program.scm (system): Remove make-rtl-program
  export.  Unused.

10 years agoscm_i_rtl_program_* -> scm_i_program_*
Andy Wingo [Tue, 19 Nov 2013 17:57:31 +0000 (18:57 +0100)]
scm_i_rtl_program_* -> scm_i_program_*

* libguile/programs.h (scm_i_make_program):
* libguile/programs.c (scm_i_program_name):
  (scm_i_program_documentation):
  (scm_i_program_properties): Remove "rtl_" infix.

* libguile/objcodes.c:
* libguile/procprop.c:
* libguile/vm.c: Adapt callers.

10 years agoscm_i_make_rtl_program in BUILDING_LIBGUILE
Andy Wingo [Tue, 19 Nov 2013 17:55:03 +0000 (18:55 +0100)]
scm_i_make_rtl_program in BUILDING_LIBGUILE

* libguile/programs.h (scm_i_make_rtl_program): Enclose in a
  BUILDING_LIBGUILE guard.

10 years agoRemove RTL_ infix from macros
Andy Wingo [Tue, 19 Nov 2013 17:28:19 +0000 (18:28 +0100)]
Remove RTL_ infix from macros

* libguile/programs.h (SCM_PROGRAM_P):
  (SCM_PROGRAM_CODE):
  (SCM_PROGRAM_FREE_VARIABLES):
  (SCM_PROGRAM_FREE_VARIABLE_REF):
  (SCM_PROGRAM_FREE_VARIABLE_SET):
  (SCM_PROGRAM_NUM_FREE_VARIABLES):
  (SCM_VALIDATE_PROGRAM): Remove RTL_ infix.

* libguile/continuations.c:
* libguile/continuations.h:
* libguile/control.c:
* libguile/foreign.c:
* libguile/frames.c:
* libguile/gsubr.c:
* libguile/gsubr.h:
* libguile/procprop.c:
* libguile/procs.c:
* libguile/programs.c:
* libguile/stacks.c:
* libguile/vm-engine.c: Adapt.

10 years agoRename scm_tc7_rtl_program to scm_tc7_program
Andy Wingo [Tue, 19 Nov 2013 17:24:22 +0000 (18:24 +0100)]
Rename scm_tc7_rtl_program to scm_tc7_program

* libguile/tags.h (scm_tc7_program): Rename from scm_tc7_rtl_program.
* libguile/continuations.c:
* libguile/control.c:
* libguile/evalext.c:
* libguile/foreign.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/programs.h:
* libguile/vm-engine.c: Adapt users.

* module/system/vm/assembler.scm: Rename a tc7-rtl-program local to
  tc7-program.
* libguile/tags.h (scm_tc7_program): Rename from scm_tc7_rtl_program. * libguile/continuations.c: * libguile/control.c: * libguile/evalext.c: * libguile/foreign.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/print.c: * libguile/programs.c: * libguile/programs.h: * libguile/vm-engine.c: Adapt users.

* module/system/vm/assembler.scm: Rename a tc7-rtl-program local to
  tc7-program.

10 years agoAll instruction pointers are now scm_t_uint32*
Andy Wingo [Tue, 19 Nov 2013 17:09:34 +0000 (18:09 +0100)]
All instruction pointers are now scm_t_uint32*

* libguile/frames.h (SCM_FRAME_RTL_RETURN_ADDRESS)
  (SCM_FRAME_SET_RTL_RETURN_ADDRESS): Remove.  The variants without _RTL
  now work fine.
  (struct scm_vm_frame): Change the return address to be a
  scm_t_uint32*.
  (struct scm_frame): Change IP to be scm_t_uint32*.

* libguile/frames.c (scm_c_make_frame)
* libguile/control.c (reify_partial_continuation, scm_c_abort)
* libguile/dynstack.c (PROMPT_IP)
  (scm_dynstack_push_prompt, scm_dynstack_find_prompt)
* libguile/dynstack.h:
* libguile/vm-engine.c (SYNC_IP, RETURN_ONE_VALUE)
  (call, return-values, prompt): Adapt.

10 years agoFrame pointer points to local 0 instead of local 1
Andy Wingo [Sun, 17 Nov 2013 21:07:44 +0000 (22:07 +0100)]
Frame pointer points to local 0 instead of local 1

* libguile/frames.h: Change so that fp points at local 0 instead of
  local 1, and clean up a bit.
  (struct scm_vm_frame): Remove program, and rename stack to locals.
  (SCM_FRAME_DATA_ADDRESS): Remove; it was redundant with
  SCM_FRAME_LOWER_ADDRESS.
  (SCM_FRAME_STACK_ADDRESS): Remove; replace with the new
  SCM_FRAME_LOCALS_ADDRESS.
  (SCM_FRAME_UPPER_ADDRESS): Remove; unused.
  (SCM_FRAME_NUM_LOCALS, SCM_FRAME_PREVIOUS_SP): New defines.
  (SCM_FRAME_BYTE_CAST, SCM_FRAME_STACK_CAST): Remove; unused;
  (SCM_FRAME_LOCAL): New define, replaces SCM_FRAME_VARIABLE.
  (SCM_FRAME_PROGRAM): Add cautionary commentary.

* libguile/frames.c: Adapt static asserts.
  (scm_frame_num_locals, scm_frame_local_ref, scm_frame_local_set_x):
  Adapt.  This means that frame-local-ref 0 now returns the procedure.

* libguile/vm-engine.c (ALLOC_FRAME, RESET_FRAME)
  (FRAME_LOCALS_COUNT, LOCAL_REF, LOCAL_SET, RETURN_VALUE_LIST): Adapt
  to change in fp.
  (LOCAL_ADDRESS): New helper.
  (POP_CONTINUATION_HOOK): Reimplement, taking the previous FP as an
  argument.
  (ABORT_CONTINUATION_HOOK): Reimplement, taking no arguments.
  (RETURN_ONE_VALUE): Reimplement.
  (RETURN_VALUE_LIST): Adapt to FP change.
  (halt, return-values, subr-call, foreign-call, prompt)
  (continuation-call, compose-continuation, call/cc, abort): Adapt to FP
  change, mostly via using LOCAL_ADDRESS, etc abstractions instead of
  using the raw frame pointer.

* libguile/control.c (reify_partial_continuation): Update for fp
  change.

* libguile/vm.c (vm_reinstate_partial_continuation): Adapt to removal of
  SCM_FRAME_UPPER_ADDRESS.

* module/system/vm/frame.scm (frame-call-representation): Adapt to
  frame-local-ref change.

* module/system/vm/trace.scm (print-return): Remove unused
  frame-num-locals call.

10 years agoRemove use of SCM_CRITICAL_SECTION in smob.c
Andy Wingo [Fri, 15 Nov 2013 16:14:15 +0000 (17:14 +0100)]
Remove use of SCM_CRITICAL_SECTION in smob.c

* libguile/smob.c (scm_make_smob_type): Use a mutex instead of a
  critical section, which does an async tick.  Not important, just a
  thing I saw.

10 years agoRemove MVRA from VM frames
Andy Wingo [Fri, 15 Nov 2013 16:13:10 +0000 (17:13 +0100)]
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.

10 years agoRemove MVRA accessors in libguile
Andy Wingo [Fri, 15 Nov 2013 14:39:38 +0000 (15:39 +0100)]
Remove MVRA accessors in libguile

* libguile/vm.c (scm_i_vm_capture_stack): Remove MVRA argument, in
  preparation for removing MVRA from frames.
  (scm_i_capture_current_stack): Adapt to scm_i_vm_capture_stack
  change.
  (vm_reinstate_partial_continuation): Remove references to MVRA.

* libguile/vm.h (struct scm_vm_cont): Remove mvra member.

* libguile/vm-engine.c (call): Set MVRA to 0.  Will remove later.
  (return-values): Return to RA.
  (call/cc): Remove MVRA from capture call.

* libguile/frames.c:
* libguile/frames.h (SCM_FRAME_MV_RETURN_ADDRESS)
  (SCM_FRAME_RTL_MV_RETURN_ADDRESS, scm_frame_mv_return_address): Remove
  accessors.

* libguile/control.c (reify_partial_continuation): Adapt to
  scm_i_vm_capture_stack change.

10 years agoTry to allocate arguments directly in call frames
Andy Wingo [Fri, 15 Nov 2013 13:57:05 +0000 (14:57 +0100)]
Try to allocate arguments directly in call frames

* module/language/cps/slot-allocation.scm (allocate-slots): Convert
  cont-table to a vector, for ease of access.  Run a pass before
  allocation that determines the set of variables whose slot allocation
  can and should be delayed, so that they can ideally be allocated
  directly in an argument slot.

10 years agoRewrite slot allocation pass
Andy Wingo [Fri, 15 Nov 2013 10:17:18 +0000 (11:17 +0100)]
Rewrite slot allocation pass

* module/language/cps/slot-allocation.scm ($allocation): Refactor
  internal format of allocations.  Instead of an allocation being a hash
  table of small $allocation objects, it is an $allocation object that
  contains packed vectors.
  (find-first-trailing-zero): Rework to not need a maximum.
  (lookup-maybe-slot): New interface.
  (lookup-slot): Raise an error if a var has no slot.
  (lookup-call-allocation): New helper.
  (lookup-constant-value, lookup-maybe-constant-value):
  (lookup-call-proc-slot, lookup-parallel-moves): Adapt to $allocation
  change

  (allocate-slots): Rewrite so that instead of being recursive, it
  traverses the blocks in CFA order.  Also, procedure call frames are
  now allocated with respect to the live set after using arguments (and
  killing any dead-after-use vars); this should make call frames more
  compact but it does necessitate a parallel move solution.  Therefore
  parallel moves are recorded for all calls, for arguments; also if the
  continuation is a $ktrunc, the continuation gets parallel moves for
  the results.

  This rewrite is in preparation to allocating call args directly in the
  appropriate slots, where possible.

* module/language/cps/compile-rtl.scm (compile-fun): Adapt to slot
  allocation changes, using lookup-maybe-slot where appropriate,
  performing parallel moves when calling functions, and expecting return
  moves to be associated with $ktrunc continuations.

10 years agoReplace ($var sym) with ($values (sym)).
Andy Wingo [Wed, 13 Nov 2013 18:58:55 +0000 (19:58 +0100)]
Replace ($var sym) with ($values (sym)).

* module/language/cps.scm: Remove $var.  Replaced by $values with one
  value.

* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-rtl.scm:
* module/language/cps/dfg.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt all the world.

10 years agoAdd specialize-primcalls pass; bump objcode version.
Andy Wingo [Sun, 10 Nov 2013 18:27:19 +0000 (19:27 +0100)]
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.

10 years agoEffects analysis distinguishes between struct fields
Andy Wingo [Sun, 10 Nov 2013 11:05:35 +0000 (12:05 +0100)]
Effects analysis distinguishes between struct fields

* module/language/tree-il/effects.scm (compile-time-cond):
  (define-effects): Make the effects analysis more precise,
  distinguishing between different kinds of mutable data.  On 64-bit
  systems we take advantage of the additional bits to be even more
  precise.
  (make-effects-analyzer): Inline handlers for all "accessor" primitives
  and their corresponding mutators.

* module/language/tree-il/peval.scm (peval): Reflow to remove use of the
  "accessor-primitive?" predicate.

* module/language/tree-il/primitives.scm (accessor-primitive?): Remove.

10 years agoEffects analysis sees match-error, throw-bad-structs as bailouts
Andy Wingo [Sun, 10 Nov 2013 09:13:37 +0000 (10:13 +0100)]
Effects analysis sees match-error, throw-bad-structs as bailouts

* module/language/tree-il/effects.scm (make-effects-analyzer): Allow
  module-ref calls to be treated as bailouts, if the procedure has the
  "definite-bailout?" property.  Perhaps this should be renamed.

* module/ice-9/match.upstream.scm (match-error):
* module/srfi/srfi-9.scm (throw-bad-struct): Give these procedures the
  definite-bailout? property.

10 years agoBinary search to find procedure properties.
Andy Wingo [Sat, 9 Nov 2013 15:25:12 +0000 (16:25 +0100)]
Binary search to find procedure properties.

* module/system/vm/debug.scm (find-program-properties): Use binary
  search.

10 years agoFix RTL linking of procedure properties.
Andy Wingo [Sat, 9 Nov 2013 15:23:35 +0000 (16:23 +0100)]
Fix RTL linking of procedure properties.

* module/system/vm/assembler.scm (link-procprops): Fix procedure
  property embedding in bytecode.

10 years agoBinary search to find docstrings.
Andy Wingo [Sat, 9 Nov 2013 15:15:12 +0000 (16:15 +0100)]
Binary search to find docstrings.

* module/system/vm/debug.scm (find-program-docstring): Use binary
  search.

10 years agoFinding a procedure's arity uses binary search
Andy Wingo [Sat, 9 Nov 2013 15:02:13 +0000 (16:02 +0100)]
Finding a procedure's arity uses binary search

* module/system/vm/assembler.scm (pack-arity-flags):
  (write-arity-headers): Add a flag to indicate that an arity is part of
  a case-lambda, so that we can use binary search to find arities.

* module/system/vm/debug.scm (is-in-case-lambda?)
  (arity-is-in-case-lambda?, find-first-arity): Use binary search.

10 years agoUse binary search in find-elf-symbol
Andy Wingo [Sat, 9 Nov 2013 14:51:54 +0000 (15:51 +0100)]
Use binary search in find-elf-symbol

* module/system/vm/debug.scm (binary-search): New helper.
  (find-elf-symbol): Use binary search.

10 years agoFix run-vm-tests
Andy Wingo [Fri, 8 Nov 2013 18:26:18 +0000 (19:26 +0100)]
Fix run-vm-tests

* test-suite/vm/run-vm-tests.scm: Fix for RTL.

10 years agoRemove stack programs, objcode, and the old VM.
Andy Wingo [Fri, 8 Nov 2013 17:28:24 +0000 (18:28 +0100)]
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.

10 years agoMiscellaneous fixups related to objcode removal.
Andy Wingo [Fri, 8 Nov 2013 16:42:54 +0000 (17:42 +0100)]
Miscellaneous fixups related to objcode removal.

* module/scripts/compile.scm: Fix --help message.

* module/system/repl/command.scm (disassemble): Fix error message.

* module/system/vm/frame.scm: Remove objcode import.

* module/system/vm/objcode.scm: Remove some exports related to the
  objcode type.

10 years agoRemove program-sources-pre-retire case for stack programs.
Andy Wingo [Fri, 8 Nov 2013 16:41:31 +0000 (17:41 +0100)]
Remove program-sources-pre-retire case for stack programs.

* module/system/vm/program.scm (program-sources-pre-retire): Remove
  stack program case.

10 years agoRemove (language objcode)
Andy Wingo [Fri, 8 Nov 2013 16:40:46 +0000 (17:40 +0100)]
Remove (language objcode)

* module/language/objcode.scm: Remove.  Seems to have been unused.

10 years agoMove assemble-program to test cases.
Andy Wingo [Fri, 8 Nov 2013 16:36:45 +0000 (17:36 +0100)]
Move assemble-program to test cases.

* module/system/vm/assembler.scm (assemble-program): Remove.
* test-suite/tests/rtl.test (assemble-program): Move here.

10 years agoPer-instruction tracing doesn't try to disassemble stack VM code
Andy Wingo [Fri, 8 Nov 2013 16:32:41 +0000 (17:32 +0100)]
Per-instruction tracing doesn't try to disassemble stack VM code

* module/system/vm/trace.scm (trace-instructions-in-procedure): Don't
  try to disassemble the procedure, for now.

10 years ago(system vm traps) support for rtl programs
Andy Wingo [Fri, 8 Nov 2013 16:31:51 +0000 (17:31 +0100)]
(system vm traps) support for rtl programs

* module/system/vm/debug.scm: Export program-debug-info-size.

* module/system/vm/traps.scm (frame-matcher): Remove stack program
  case.  Use absolute frame-instruction-procedure to match if
  match-code?.
  (program-last-ip): Use (system vm debug) interfaces.
  (program-sources-by-line): Use program-sources, as
  program-sources-pre-retire will go away soon.  Return absolute
  addresses.

10 years agoRemove objcode language.
Andy Wingo [Fri, 8 Nov 2013 15:51:44 +0000 (16:51 +0100)]
Remove objcode language.

* module/language/objcode/elf.scm:
* module/language/objcode/spec.scm: Remove objcode language.

* module/Makefile.am: Adapt.

10 years agoRemove bytecode language.
Andy Wingo [Fri, 8 Nov 2013 15:49:04 +0000 (16:49 +0100)]
Remove bytecode language.

* module/language/bytecode/spec.scm: Remove.

* module/Makefile.am: Adapt.

10 years agoRemove assembly language.
Andy Wingo [Fri, 8 Nov 2013 15:45:10 +0000 (16:45 +0100)]
Remove assembly language.

* module/system/repl/command.scm: Remove disassembly cases for stack
  procedures.

* module/system/vm/inspect.scm: Adapt to disassemble RTL programs.

* module/language/assembly.scm:
* module/language/assembly/compile-bytecode.scm:
* module/language/assembly/decompile-bytecode.scm:
* module/language/assembly/disassemble.scm:
* module/language/assembly/spec.scm: Remove assembly language.

* module/Makefile.am: Adapt.

10 years agoDecompile goes from tree-il to scheme by default.
Andy Wingo [Fri, 8 Nov 2013 15:40:27 +0000 (16:40 +0100)]
Decompile goes from tree-il to scheme by default.

* module/system/base/compile.scm (decompile): By default, go from
  tree-il to Scheme, now that the assembly language is going away.

10 years agoRewrite (system xref) to work with RTL programs
Andy Wingo [Fri, 8 Nov 2013 15:31:29 +0000 (16:31 +0100)]
Rewrite (system xref) to work with RTL programs

* module/system/xref.scm (nested-procedures): New helper.
  (program-callee-rev-vars): Rewrite using fold-program-code and
  nested-procedures.
  (add-sources, forget-sources): Use match instead of pmatch.  Use
  nested-procedures.

10 years agoAdd fold-program-code to (system vm disassembler)
Andy Wingo [Fri, 8 Nov 2013 14:58:27 +0000 (15:58 +0100)]
Add fold-program-code to (system vm disassembler)

* module/system/vm/disassembler.scm (fold-code-range): New helper.
  (fold-program-code): New interface.

10 years agoRemove GLIL language
Andy Wingo [Fri, 8 Nov 2013 13:58:40 +0000 (14:58 +0100)]
Remove GLIL language

* module/Makefile.am:
* module/language/glil.scm:
* module/language/glil/compile-assembly.scm:
* module/language/glil/spec.scm: Remove.

10 years agoRemove tree-il->glil compiler
Andy Wingo [Fri, 8 Nov 2013 13:57:43 +0000 (14:57 +0100)]
Remove tree-il->glil compiler

* module/Makefile.am:
* module/language/tree-il/compile-glil.scm: Remove.

* module/language/tree-il/spec.scm: Remove tree-il->glil link.

10 years agoMove useful parts of asm-to-bytecode.test to cross-compilation.test
Andy Wingo [Fri, 8 Nov 2013 13:54:38 +0000 (14:54 +0100)]
Move useful parts of asm-to-bytecode.test to cross-compilation.test

* test-suite/tests/cross-compilation.test: Rename from asm-to-bytecode,
  and remove the bits testing assembly->bytecode but keep the
  cross-compilation things.

* test-suite/Makefile.am: Adapt.

10 years agoTree-IL warnings tests compile to CPS instead of "assembly"
Andy Wingo [Fri, 8 Nov 2013 13:45:01 +0000 (14:45 +0100)]
Tree-IL warnings tests compile to CPS instead of "assembly"

* test-suite/tests/tree-il.test ("warnings"): Change warnings test to
  compile to CPS instead of assembly.

10 years agoRemove tree-il->glil test cases
Andy Wingo [Fri, 8 Nov 2013 13:41:22 +0000 (14:41 +0100)]
Remove tree-il->glil test cases

* test-suite/tests/tree-il.test: Remove GLIL test cases.  They have
  never been helpful to me in the 2.0 series, so there is no loss.

10 years agoRemove a couple of uses of GLIL from the test suite.
Andy Wingo [Fri, 8 Nov 2013 13:27:13 +0000 (14:27 +0100)]
Remove a couple of uses of GLIL from the test suite.

* test-suite/tests/cse.test ("cse"):
* test-suite/tests/peval.test: Remove uses of GLIL.

10 years agoFix program-minimum-arity to work better with case-lambda.
Andy Wingo [Fri, 8 Nov 2013 13:19:41 +0000 (14:19 +0100)]
Fix program-minimum-arity to work better with case-lambda.

* module/system/vm/debug.scm (program-minimum-arity): Be more precise
  with case-lambdas.

10 years agoBuiltins have procedure properties
Andy Wingo [Fri, 8 Nov 2013 13:08:42 +0000 (14:08 +0100)]
Builtins have procedure properties

* libguile/vm-builtins.h (FOR_EACH_VM_BUILTIN): Add arity information.
  (enum scm_vm_builtins):
* libguile/vm.c (scm_vm_builtin_ref):
  (scm_vm_builtin_name_to_index):
  (scm_vm_builtin_index_to_name): Adapt to macro interface change.
  (scm_init_vm_builtin_properties): New helper, sets procedure
  properties on builtins.
  (scm_bootstrap_vm): Just define the builtins here.  Later in the
  bootstrap we set their properties.
  (scm_sym_apply): Move definition here from expand.c.

* libguile/procprop.c (scm_init_procprop): Call
  scm_init_vm_builtin_properties.

10 years agoFix procedure-arguments on RTL programs, and tweak session.test
Andy Wingo [Fri, 8 Nov 2013 12:29:03 +0000 (13:29 +0100)]
Fix procedure-arguments on RTL programs, and tweak session.test

* module/ice-9/session.scm (procedure-arguments): Add an rtl-program?
  case.

* module/system/vm/debug.scm (arity-arguments-alist): Use the order that
  session.test expects.

* test-suite/tests/session.test ("procedure-arguments"): Adapt tests
  with keywords for the new starting-with-the-procedure numbering of
  locals.

10 years agoFix make-vector peval test
Andy Wingo [Fri, 8 Nov 2013 12:25:08 +0000 (13:25 +0100)]
Fix make-vector peval test

* test-suite/tests/peval.test ("partial evaluation"): Fix to expect a
  primcall.

10 years agoFix case-lambda* dispatching to agree with manual.
Andy Wingo [Fri, 8 Nov 2013 10:41:28 +0000 (11:41 +0100)]
Fix case-lambda* dispatching to agree with manual.

* module/system/vm/assembler.scm (kw-prelude): Emit br-if-npos-gt as
  appropriate.

10 years agoAdd br-if-npos-gt
Andy Wingo [Fri, 8 Nov 2013 10:38:34 +0000 (11:38 +0100)]
Add br-if-npos-gt

* libguile/vm-engine.c (br-if-npos-gt): New instruction (sigh!).  For
  case-lambda* dispatching on the number of positional args, as the
  manual describes.  Renumber other opcodes.

10 years agoFix BR_NARGS data type width
Andy Wingo [Fri, 8 Nov 2013 10:36:53 +0000 (11:36 +0100)]
Fix BR_NARGS data type width

* libguile/vm-engine.c (BR_NARGS): Fix width of "expected".  Fixes bug
  with > 65536 arguments in case-lambda clauses.

10 years agoFix arity selection in compute-contification
Andy Wingo [Fri, 8 Nov 2013 09:59:52 +0000 (10:59 +0100)]
Fix arity selection in compute-contification

* module/language/cps/contification.scm (compute-contification): Fail as
  soon as we see an arity with rest, optional, or keyword arguments.
  Fixes ((case-lambda ((a . b) #t) ((a b) #f)) 1 2).

10 years agoFix error message in lambda* eval closures with keywords
Andy Wingo [Fri, 8 Nov 2013 09:37:09 +0000 (10:37 +0100)]
Fix error message in lambda* eval closures with keywords

* module/ice-9/eval.scm (primitive-eval): For ((lambda* (#:key foo) foo) 'bar),
  give an "invalid keyword" error instead of a "wrong number of
  arguments" error.

10 years agoFix reading and writing arities into DWARF.
Andy Wingo [Fri, 8 Nov 2013 09:03:48 +0000 (10:03 +0100)]
Fix reading and writing arities into DWARF.

* libguile/gsubr.h:
* libguile/gsubr.c (scm_i_primitive_call_ip):
* libguile/programs.c (scm_primitive_call_ip): Adapt to return an
  absolute address.

* module/system/vm/assembler.scm (write-arity-headers): Adapt to write
  byte addresses (relative to the text base).

* module/system/vm/debug.scm (arity-low-pc, arity-high-pc): Return
  absolute addresses, instead of word offsets relative to the text
  base.
  (find-first-arity): Adapt for absolute addresses.

* module/system/vm/program.scm (program-arguments-alist): Adapt for
  arity-low-pc / arity-high-pc absolute addresses.

10 years agoFix eval.test: stack involving a primitive
Andy Wingo [Fri, 8 Nov 2013 08:07:32 +0000 (09:07 +0100)]
Fix eval.test: stack involving a primitive

* test-suite/tests/eval.test ("stacks"): Revert expect-fail introduced
  in 27337b6373954e1a975d97d0bf06b5c03d65b64d.

10 years agoFix coverage.test: instrumented-source-files
Andy Wingo [Fri, 8 Nov 2013 08:02:30 +0000 (09:02 +0100)]
Fix coverage.test: instrumented-source-files

* test-suite/tests/coverage.test ("instrumented-source-files"): Adapt to
  new expectation that all files loaded on the system will be present in
  the source information.

10 years agoFix coverage.test: "procedure-execution-count: never"
Andy Wingo [Fri, 8 Nov 2013 08:00:06 +0000 (09:00 +0100)]
Fix coverage.test: "procedure-execution-count: never"

* test-suite/tests/coverage.test ("procedure-execution-count"): Adapt
  test to new behavior of procedure-execution-count of an unseen
  procedure: zero, not false.

10 years agoFix coverage.test: "line-execution-counts: one proc hit, one proc unused"
Andy Wingo [Fri, 8 Nov 2013 07:56:52 +0000 (08:56 +0100)]
Fix coverage.test: "line-execution-counts: one proc hit, one proc unused"

* test-suite/tests/coverage.test ("line-execution-counts"): Fix test for
  even/odd? in letrec.  The test profiles the execution of even?, not
  the letrec, so the last line is in fact not reached.

10 years agoframe-instruction-pointer is absolute; rewrite (system vm coverage)
Andy Wingo [Thu, 7 Nov 2013 22:03:45 +0000 (23:03 +0100)]
frame-instruction-pointer is absolute; rewrite (system vm coverage)

* libguile/frames.c (scm_frame_source): Instead of assuming that
  scm_frame_procedure is correct, use the IP to get the source.
  (scm_frame_instruction_pointer): Return an absolute value instead of
  assuming that slot 0 is correct.  (It isn't, when preparing for a tail
  call.)

* libguile/programs.h:
* libguile/programs.c (scm_find_source_for_addr): New internal helper.

* module/system/repl/debug.scm (print-registers): Readably print
  absolute instruction pointers.

* module/system/vm/coverage.scm: Complete rewrite to use absolute IP's.
  We can't assume that frame-procedure is cheap if it is correct, or
  correct if it is cheap.  Anyway using the address is better anyway.
  (coverage-data->lcov): Disable per-function info temporarily.
  (loaded-modules, module-procedures, closest-source-line)
  (closed-over-procedures): Remove these.  Instead of going from
  procedures to source info, now we go from ELF image to source info.

* module/system/vm/debug.scm (debug-context-length): New interface.

* module/system/vm/program.scm (source-for-addr): New internal helper.

10 years agoscm_from_uintptr_t / scm_from_ptrdiff_t usage
Andy Wingo [Thu, 7 Nov 2013 17:11:00 +0000 (18:11 +0100)]
scm_from_uintptr_t / scm_from_ptrdiff_t usage

* libguile/frames.c:
* libguile/programs.c: Use scm_from_ptrdiff_t and scm_from_uintptr_t
  where appropriate.

10 years agoProgram sources are always pre-retire now
Andy Wingo [Thu, 7 Nov 2013 17:00:40 +0000 (18:00 +0100)]
Program sources are always pre-retire now

* module/system/repl/debug.scm (<debug>): Remove for-trap?.  Backtraces
  with RTL will always happen pre-retire on the top frame, source info
  is pre-retire, and continuations will always have a source-marked
  receive or receive-values or whatever with the right source marking,
  so we can remove this complication.
  (print-frame): Use frame-source.
  (print-frames): Remove for-trap? kw.

* module/system/repl/command.scm (define-stack-command, backtrace)
  (up, down, frame): Remove for-trap? introduced local, and its uses.
  (repl-pop-continuation-resumer): Adapt to make-debug change.

* module/system/repl/error-handling.scm (call-with-error-handling):
  Adapt to make-debug change.

* module/system/vm/frame.scm (frame-next-source): Remove.  RTL sources
  are pre-retire.

* module/system/vm/trap-state.scm (add-ephemeral-stepping-trap!): Adapt
  to use frame-source.  Still some work to do here.

10 years agoadd fold-all-debug-contexts, fold-source-locations
Andy Wingo [Thu, 7 Nov 2013 16:53:04 +0000 (17:53 +0100)]
add fold-all-debug-contexts, fold-source-locations

* module/system/vm/objcode.scm:
* libguile/objcodes.c (scm_all_mapped_elf_images): New proc.

* module/system/vm/debug.scm (fold-all-debug-contexts):
  (fold-source-locations): New public interfaces.

10 years agoFix DWARF source test now that we have more precise source info.
Andy Wingo [Thu, 7 Nov 2013 10:16:24 +0000 (11:16 +0100)]
Fix DWARF source test now that we have more precise source info.

* test-suite/tests/dwarf.test: Fix test after the $continue/$cont source
  change, which reifies proper source info for the +.

10 years agoFix line advance DWARF opcodes when line advance is exactly 128
Andy Wingo [Thu, 7 Nov 2013 10:10:36 +0000 (11:10 +0100)]
Fix line advance DWARF opcodes when line advance is exactly 128

* module/system/vm/assembler.scm (link-debug): Fix off-by-one error in
  which forward jumps of 128 were mis-rendered.

10 years agoWrite DWARF files list in correct order.
Andy Wingo [Thu, 7 Nov 2013 09:52:47 +0000 (10:52 +0100)]
Write DWARF files list in correct order.

* module/system/vm/assembler.scm (link-debug): Fix order of writing the
  source files list; it was being written backwards.

10 years agoSource information goes on the $continue, not the $cont.
Andy Wingo [Thu, 7 Nov 2013 09:32:21 +0000 (10:32 +0100)]
Source information goes on the $continue, not the $cont.

* module/language/cps.scm ($continue, $cont): Put source information on
  the $continue, not on the $cont.  Otherwise it is difficult for CPS
  conversion to preserve source information.
  ($fun): Add a src member to $fun.  Otherwise we might miss the source
  info for the start of the function.

* .dir-locals.el:
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-rtl.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/dfg.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Update the whole CPS world
  for this change.

10 years agoFix first find-program-sources result
Andy Wingo [Wed, 6 Nov 2013 16:33:43 +0000 (17:33 +0100)]
Fix first find-program-sources result

* module/system/vm/debug.scm (find-program-sources): Manually set the pc
  of the first result in a function.

10 years agocompiler.test fix for rtl compilation
Andy Wingo [Tue, 5 Nov 2013 20:33:00 +0000 (21:33 +0100)]
compiler.test fix for rtl compilation

* test-suite/tests/compiler.test ("current-reader"): Fix the way we make
  programs from objcode.

10 years agofix docstring assembly and fetching
Andy Wingo [Tue, 5 Nov 2013 20:29:46 +0000 (21:29 +0100)]
fix docstring assembly and fetching

* module/system/vm/assembler.scm (link-docstrs): Write pc offsets as
  byte addresses.  Works better with native code.
* module/system/vm/debug.scm (find-program-docstring): Fix the linear
  search.  How embarassing!

10 years agoasm-labels is a hash table
Andy Wingo [Tue, 5 Nov 2013 19:18:23 +0000 (20:18 +0100)]
asm-labels is a hash table

* module/system/vm/assembler.scm (make-assembler, label):
  (link-data, process-relocs, process-labels): Change labels to be a
  hash table.

10 years agofix make-long-immediate, make-long-long-immediate for dst >= 256
Andy Wingo [Tue, 5 Nov 2013 18:22:26 +0000 (19:22 +0100)]
fix make-long-immediate, make-long-long-immediate for dst >= 256

* libguile/vm-engine.c (make-long-immediate, make-long-long-immediate):
  Fix declaration of "dst" variable.

10 years agoRe-add the list hack to compile-cps
Andy Wingo [Tue, 5 Nov 2013 17:16:13 +0000 (18:16 +0100)]
Re-add the list hack to compile-cps

* module/language/tree-il/compile-cps.scm (convert): Re-add the list
  hack.  Ideally these go into some tree-il pass.

10 years agosquish to primitive reification
Andy Wingo [Tue, 5 Nov 2013 17:06:08 +0000 (18:06 +0100)]
squish to primitive reification

* test-suite/tests/tree-il.test: Update for primitive-ref reification
  fix.

10 years agoFix test case for uniform-array->bytevector on bitvectors
Andy Wingo [Sun, 3 Nov 2013 21:00:18 +0000 (22:00 +0100)]
Fix test case for uniform-array->bytevector on bitvectors

* test-suite/tests/bytevectors.test ("uniform-array->bytevector"):
  Bitvectors are accessed in 32-bit chunks.

10 years agoRTL compiler supports static bitvectors
Andy Wingo [Sun, 3 Nov 2013 20:45:34 +0000 (21:45 +0100)]
RTL compiler supports static bitvectors

* libguile/arrays.c (scm_from_contiguous_typed_array):
* libguile/bytevectors.c (scm_uniform_array_to_bytevector): For
  bitvectors, round up the length to 32-bit units, as they are stored
  internally.  Otherwise I think this probably does the wrong thing for
  the last word on big-endian systems.
* libguile/bitvectors.c (BITVECTOR_LENGTH, BITVECTOR_BITS):
  (scm_c_make_bitvector): Reorder the length and pointer words to match
  the layout of bytevectors.

* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/system/vm/assembler.scm (br-if-bitvector):
* module/system/vm/disassembler.scm (code-annotation): Add bitvector
  test support.

* module/system/vm/assembler.scm (<uniform-vector-backing-store>): Add
  an element-size field.
  (intern-constant): Adapt make-uniform-vector-backing-store call.  Use
  uniform-array->bytevector, as the old compiler did.
  (link-data): Add bitvector cases.

10 years agostruct-set! returns a value, yuck
Andy Wingo [Sun, 3 Nov 2013 19:24:54 +0000 (20:24 +0100)]
struct-set! returns a value, yuck

* module/language/cps/arities.scm (fix-clause-arities): Add a hack to
  ensure that (struct-set! OBJ POS VAL) evaluates to VAL.  Yuck.

10 years agoCorrectness fix for vector constructor inlining.
Andy Wingo [Sun, 3 Nov 2013 11:28:47 +0000 (12:28 +0100)]
Correctness fix for vector constructor inlining.

* module/language/tree-il/compile-cps.scm (convert): Don't inline the
  vector constructor if any arg could capture the current continuation.

10 years agoEval evaluates initializers before creating environment ribs.
Andy Wingo [Sun, 3 Nov 2013 11:16:49 +0000 (12:16 +0100)]
Eval evaluates initializers before creating environment ribs.

* module/ice-9/eval.scm (let-env-evaluator, primitive-eval): Evaluate
  initializers of let expressions before creating the environment rib.
  This prevents call/cc-related shenanigans.

10 years ago"length" is an interesting primitive
Andy Wingo [Sun, 3 Nov 2013 11:15:09 +0000 (12:15 +0100)]
"length" is an interesting primitive

* module/language/tree-il/primitives.scm (*effect-free-primitives*):
  (*interesting-primitive-names*): Add "length", so that we can
  constant-fold it.

10 years agoRevert "Compile-time debugging"
Andy Wingo [Fri, 1 Nov 2013 18:43:45 +0000 (19:43 +0100)]
Revert "Compile-time debugging"

This reverts commit 6a37b7faaf150e9fb7945ef79969cb7671d17367.

10 years agoFix call/cc with the RTL VM
Andy Wingo [Fri, 1 Nov 2013 18:28:36 +0000 (19:28 +0100)]
Fix call/cc with the RTL VM

* libguile/vm.c (vm_return_to_continuation): The RTL VM saves the
  registers for the caller of call/cc, but the caller will expect values
  in the normal MV return location: above the frame.  Make it so, number
  four!

10 years agoFix order of evaluation in elisp lexer
Andy Wingo [Fri, 1 Nov 2013 17:23:51 +0000 (18:23 +0100)]
Fix order of evaluation in elisp lexer

* module/language/elisp/lexer.scm (lex): Use let*, to ensure that the
  port position is read before reading the next char.

10 years agoFix contification of non-recursive closures
Andy Wingo [Fri, 1 Nov 2013 17:22:58 +0000 (18:22 +0100)]
Fix contification of non-recursive closures

* module/language/cps/contification.scm (compute-contification): When
  eliding let-bound functions, also record the cont that declares the
  function.
  (apply-contification): Instead of reifying ($values ()) gotos instead
  of the elided function, inline the body that binds the function
  directly.  This ensures that the function gets contified in its own
  scope.

10 years agoRTL compilation sorts continuations topologically before visiting them
Andy Wingo [Fri, 1 Nov 2013 13:37:57 +0000 (14:37 +0100)]
RTL compilation sorts continuations topologically before visiting them

* module/language/cps/compile-rtl.scm (compile-fun): Rewrite to visit
  conts in reverse-post-order, which is a topological sort on the basic
  blocks.

* module/language/cps/slot-allocation.scm (allocate-slots): Expect a DFG
  as an argument.