summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2013-06-16tests: Don't rely on $TMPDIR and /tmp on Windows.Ludovic Courtès1-1/+12
* test-suite/standalone/test-unwind.c (check_ports)[__MINGW32__]: Use $TEMP, $TMP, or / as the value for TMPDIR. Patch by Eli Zaretskii <eliz@gnu.org>.
2013-06-16tests: Use double quotes around shell arguments, for Windows.Ludovic Courtès1-3/+5
* test-suite/standalone/test-system-cmds (test-system-cmd): Use double quotes around shell arguments. Reported by Eli Zaretskii <eliz@gnu.org>.
2013-06-16Define `AF_UNIX' only when Unix-domain sockets are supported.Ludovic Courtès1-1/+1
* libguile/socket.c (scm_init_socket): Defined `AF_UNIX' only when `HAVE_UNIX_DOMAIN_SOCKETS' is defined. Reported by Eli Zaretskii <eliz@gnu.org>.
2013-06-16Reduce call-with-values to let for singly-valued producersAndy Wingo2-4/+29
* module/language/tree-il/peval.scm (singly-valued-expression?): Add support for conditionals. In the future we should add more expressions here. (peval): Don't inline values into the body of a dynwind, as that could cause the consumer to run in the wrong dynamic context. If the producer is singly-valued and the consumer just has a rest arg, reduce to "let" and cons up a list in the consumer. This may reduce further. * test-suite/tests/peval.test ("partial evaluation"): Add a test.
2013-06-10Rewrite make-tree-il-folder to use the Wright matcher.Andy Wingo1-22/+23
* module/language/tree-il.scm (make-tree-il-folder): Rewrite to use the Wright matcher instead of record-case.
2013-06-10Rewrite unparse-tree-il to use the Wright matcher.Andy Wingo1-29/+33
* module/language/tree-il.scm (unparse-tree-il): Rewrite to use the Wright matcher.
2013-06-10Rewrite parse-tree-il to use the Wright matcher.Andy Wingo1-36/+35
* module/language/tree-il.scm (parse-tree-il): Rewrite to use match instead of pmatch. Remove pmatch import.
2013-06-10Implement tree-il-fold in terms of make-tree-il-folder.Andy Wingo6-163/+46
* module/language/tree-il.scm (tree-il-fold): Implement using make-tree-il-folder. This is an incompatible change: there is no more "leaf" procedure, and tree-il-fold only works on tree-il and not lists. * module/language/tree-il/analyze.scm (<tree-analysis>, analyze-tree): Adapt to tree-il-fold change, losing the "leaf" handler. (unused-variable-analysis, unused-toplevel-analysis) (unbound-variable-analysis, arity-analysis): Adapt to tree-analysis change. * module/language/tree-il/canonicalize.scm (tree-il-any) * module/language/tree-il/cse.scm (build-assigned-var-table) * module/language/tree-il/peval.scm (tree-il-any, build-var-table) (peval): Adapt to tree-il-fold change. * test-suite/tests/tree-il.test ("tree-il-fold"): Adapt tests for new interface and expectations.
2013-06-10Rewrite tree-il pre-post-order in terms of (ice-9 match)Andy Wingo1-27/+28
* module/language/tree-il.scm (pre-post-order): Re-implement in terms of (ice-9 match), so that we standardize on one matcher (more or less).
2013-06-10Pre-order tree-il rewrites are now non-destructiveAndy Wingo8-108/+23
* module/language/tree-il.scm (pre-order): Re-implement in terms of pre-post-order, and rename from pre-order!. * module/language/tree-il/primitives.scm (expand-primitives): Adapt to pre-order change, and rename from expand-primitives!. * module/language/tree-il/optimize.scm (optimize): Adapt to expand-primitives! change, and rename from optimize!. * module/language/tree-il/compile-glil.scm: * module/system/repl/common.scm: * test-suite/tests/cse.test: * test-suite/tests/peval.test: * test-suite/tests/tree-il.test: Adapt to expand-primitives and optimize changes.
2013-06-10Tree-il post-order rewriter no longer destructiveAndy Wingo10-138/+139
* module/language/tree-il.scm (pre-post-order): New helper, like pre-order! and post-order! but not destructive. (post-order): Implement in terms of pre-post-order, and rename from post-order!. * module/ice-9/compile-psyntax.scm (squeeze-tree-il): * module/language/tree-il/canonicalize.scm (canonicalize): * module/language/tree-il/fix-letrec.scm (fix-letrec): * module/language/tree-il/primitives.scm (resolve-primitives): Use post-order, and rename from the destructive variants (squeeze-tree-il!, canonicalize!, etc). Adapt callers. * test-suite/tests/tree-il.test (strip-source): Adapt to post-order. * test-suite/tests/cse.test: * test-suite/tests/peval.test: * module/language/tree-il/optimize.scm: Adapt callers.
2013-06-10Simplify let-values to let if consumer binds only one variableAndy Wingo2-1/+10
* module/language/tree-il/peval.scm (peval): let-values with a consumer that has only one argument is the same as let. * test-suite/tests/peval.test ("partial evaluation"): Add test.
2013-06-10fix linker.testAndy Wingo1-12/+6
* test-suite/tests/linker.test (link-elf-with-one-main-section): Fix test after string table change.
2013-06-10Allow #f as timeout argument to unlock-mutex and SRFI-18 mutex-unlock!Mark H Weaver2-4/+4
Reported by Chaos Eternal <chaoseternal@shlug.org> Based on a patch by Nala Ginrut <nalaginrut@gmail.com> * libguile/threads.c (scm_unlock_mutex_timed): If 'timeout' argument is false, interpret that as no timeout. * doc/ref/api-scheduling.texi (Mutexes and Condition Variables): Update documentation.
2013-06-10Fix tests for 'scm_c_bind_keyword_arguments'.Mark H Weaver1-17/+48
* test-suite/standalone/test-scm-c-bind-keyword-arguments.c (error_handler): Remove function. (unrecognized_keyword_error_handler, invalid_keyword_error_handler, odd_length_error_handler): New functions. (test_scm_c_bind_keyword_arguments): Use new error handler functions.
2013-06-09procedure-properties for RTL functionsAndy Wingo7-8/+179
* module/system/vm/assembler.scm (link-procprops, link-objects): Arrange to write procedure property links out to a separate section. * libguile/procprop.c (scm_procedure_properties): * libguile/programs.h: * libguile/programs.c (scm_i_rtl_program_properties): * module/system/vm/debug.scm (find-program-properties): Wire up procedure-properties for RTL procedures. Yeah! Fistpumps! :) * module/system/vm/debug.scm (find-program-debug-info): Return #f if the string is "", as it is if we don't have a name. Perhaps elf-symbol-name should return #f in that case... * test-suite/tests/rtl.test: Add some tests.
2013-06-09procedure-documentation works on RTL proceduresAndy Wingo9-20/+100
* libguile/procprop.h: * libguile/procprop.c (scm_procedure_documentation): Move here from procs.c, and to make the logic more similar to that of procedure-name, which allows RTL programs to dispatch to rtl-program-documentation. * libguile/programs.c (scm_i_rtl_program_documentation): * libguile/programs.h: * module/system/vm/program.scm (rtl-program-documentation): New plumbing. * module/system/vm/debug.scm (find-program-docstring): New interface to grovel ELF for a docstring.
2013-06-09Write docstrings into RTL ELF imagesAndy Wingo1-1/+52
* module/system/vm/assembler.scm (link-docstrs): Write docstrings. (link-objects): Link docstrings into the ELF.
2013-06-09Wire up ability to print RTL program aritiesAndy Wingo5-33/+99
* libguile/procprop.c (scm_i_procedure_arity): Allow RTL programs to dispatch to scm_i_program_arity. * libguile/programs.c (scm_i_program_print): Refactor reference to write-program. (scm_i_rtl_program_minimum_arity): New procedure, dispatches to Scheme. (scm_i_program_arity): Dispatch to scm_i_rtl_program_minimum_arity if appropriate. * module/system/vm/debug.scm (program-minimum-arity): New export. * module/system/vm/program.scm (rtl-program-minimum-arity): New internal function. (program-arguments-alists): New helper, implemented also for RTL procedures. (write-program): Refactor a bit, and call program-arguments-alists. * test-suite/tests/rtl.test ("simply procedure arity"): Add tests that arities make it all the way to cold ELF and back to warm Guile.
2013-06-09(system vm debug) can read arity informationAndy Wingo1-1/+173
* module/system/vm/debug.scm (<arity>): New object, for reading arities. Unlike <arity> in the assembler, this one only holds on to a couple of pointers, and doesn't even load in argument names. Unlike the arity lists in (system vm program), it can load in names. Very early days but it does seem to work. (find-program-arities, arity-arguments-alist): New higher-level interfaces.
2013-06-09RTL assembler writes arities information into separate section.Andy Wingo1-1/+198
* module/system/vm/assembler.scm: Write arities into a .guile.arities section and associated .guile.arities.strtab.
2013-06-09Beginnings of tracking of procedure arities in assemblerAndy Wingo2-24/+95
* module/system/vm/assembler.scm (<meta>, <arity>): Assembler now tracks arities of a function. (begin-standard-arity, begin-opt-arity, begin-kw-arity, end-arity): New macro-assemblers. * test-suite/tests/rtl.test: Adapt all tests to use begin-standard-arity and end-arity.
2013-06-09add procedure prelude macro-instructionsAndy Wingo2-20/+68
* module/system/vm/assembler.scm (pack-flags): New helper. (standard-prelude, opt-prelude, kw-prelude): New macro-instructions. * test-suite/tests/rtl.test: Update tests to use standard-prelude.
2013-06-09begin-program takes properties alistAndy Wingo2-27/+60
* module/system/vm/assembler.scm (assert-match): New helper macro to check argument types. (<meta>): Add properties field. Rename name field to "label" to indicate that it should be unique. (make-meta, meta-name): New helpers. (begin-program): Take additional properties argument. (emit-init-constants): Adapt to begin-program change. (link-symtab): Allow for anonymous procedures. * test-suite/tests/rtl.test: Adapt tests.
2013-06-09Add RTL disassemblerAndy Wingo4-4/+363
* module/Makefile.am: * module/system/vm/disassembler.scm: New module. * module/system/repl/command.scm (disassemble): Work with RTL programs.
2013-06-09RTL programs print with their nameAndy Wingo6-17/+60
* libguile/print.c (iprin1): Use scm_i_program_print for RTL programs too. * libguile/procprop.c (scm_procedure_name): For RTL programs, call scm_i_rtl_program_name if there is no override. * libguile/programs.h: * libguile/programs.c (scm_i_rtl_program_name): New helper, dispatches to (system vm program). (scm_i_program_print): For RTL programs, the fallback prints the code pointer too. * module/system/vm/program.scm (rtl-program-name): Use the debug info to get an RTL program name. (write-program): Work with RTL programs too. * test-suite/tests/rtl.test ("procedure name"): Add test.
2013-06-09move procedure-name and procedure-source to procprop.cAndy Wingo4-45/+49
* libguile/procprop.h: * libguile/procprop.c (scm_procedure_name, scm_procedure_source): Move these functions here, from debug.[ch].
2013-06-09Add runtime support for reading debug information from ELFAndy Wingo4-3/+203
* module/Makefile.am: * module/system/vm/debug.scm: New module. * module/system/vm/elf.scm (elf-section-by-name): New helper. (elf-symbol-table-len): New helper. * test-suite/tests/rtl.test: Add test for finding debug info.
2013-06-09Add RTL assemblerAndy Wingo5-1/+1379
* module/Makefile.am: * module/system/vm/assembler.scm: New module, implementing an assembler for RTL. * test-suite/Makefile.am: * test-suite/tests/rtl.test: New test suite. * module/system/vm/elf.scm (make-elf-symbol*): Add constructor; export as make-elf-symbol. (elf-symbol-len): New export. (write-elf32-symbol, write-elf64-symbol): New helpers. (write-elf-symbol): New export.
2013-06-09linker string tables are stateful objectsAndy Wingo2-39/+47
* module/system/vm/linker.scm (make-string-table): Rework to be a stateful object instead of a function object. Works better in this case. Adapt users. (string-table-intern!): Rename from string-table-intern, and just return the index of the string. (link-string-table!): Rename from link-string-table, and set a flag to prevent interning strings after linking, as that's not going to work well. * module/language/objcode/elf.scm (bytecode->elf): Adapt.
2013-06-08const cleanups in instructions.cAndy Wingo1-11/+11
* libguile/instructions.c (fetch_rtl_instruction_table) (fetch_instruction_table): Make the returned table const. Adapt callers. (scm_rtl_instruction_list): Fix comment about format of return value.
2013-06-05Report the faulty keyword in errors raised by `scm_c_bind_keyword_arguments'.Ludovic Courtès2-8/+28
Reported by Mark H. Weaver. * libguile/keywords.c (scm_c_bind_keyword_arguments): Use `scm_error_scm' instead of `scm_error'. Pass the faulty keyword enclosed in a list as the last argument. * test-suite/tests/optargs.test ("scm_c_bind_keyword_arguments"): New test prefix.
2013-06-04Print the faulty object upon invalid-keyword errors.Ludovic Courtès8-42/+41
* libguile/vm.c (vm_error_kwargs_invalid_keyword, vm_error_kwargs_unrecognized_keyword): Add parameter. Pass it enclosed in a list as the last argument to `scm_error_scm'. * libguile/vm-i-system.c (bind_kwargs): Adjust accordingly. * libguile/eval.c (error_invalid_keyword, error_unrecognized_keyword): Add parameter. (prepare_boot_closure_env_for_apply): Adjust accordingly. * module/ice-9/eval.scm (primitive-eval): Likewise. * libguile/error.c (scm_error_scm): Mention `keyword-argument-error' in docstring. * module/ice-9/boot-9.scm (keyword-error-printer): New procedure; use it. * test-suite/tests/optargs.test (c&e, with-test-prefix/c&e): Remove. ("define*")["unrecognized keyword"]: Test the value passed along the `keyword-argument-error' exception. ["invalid keyword"]: New test. * doc/ref/api-control.texi (Error Reporting): Update `scm-error' description.
2013-05-31add new rtl vmAndy Wingo19-27/+3624
* libguile/vm-engine.c (rtl_vm_engine): Add new VM. (vm_engine): Add support for calling RTL programs. * libguile/tags.h (scm_tc7_rtl_program): New type for procedures that run on the new VM. * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (scm_class_of): * libguile/print.c (iprin1): * libguile/procprop.c (scm_i_procedure_arity): * libguile/procs.c (scm_procedure_p): Add hooks for the new tc7. * libguile/programs.h: * libguile/programs.c (scm_make_rtl_program, scm_i_rtl_program_print) (scm_rtl_program_p, scm_rtl_program_code): * module/system/vm/program.scm: Add constructors and accessors for the new "RTL programs". * libguile/vm.c (rtl_boot_continuation): Define a boot program. (rtl_apply, rtl_values): New static RTL programs. * libguile/frames.c (scm_frame_num_locals): Adapt for frames of RTL programs. * libguile/frames.h: Add description of RTL frames. * libguile/Makefile.am: Add rules to generate vm-operations.h. * .gitignore: Ignore vm-operations.h. * module/system/vm/instruction.scm: * libguile/instructions.c: * libguile/instructions.h: Use vm-operations.h to define enumerated values for the new RTL opcodes. Define some helper macros to pack and unpack 32-bit instruction words. (rtl-instruction-list): New function, exported by (system vm instruction). * libguile/objcodes.c: Wire up the bits needed to detect the new RTL bytecode and load it, as appropriate.
2013-05-30Do not assume `pthread_t' is an integer type.Ludovic Courtès1-10/+15
Fixes <http://bugs.gnu.org/14469>. Reported by Panicz Maciej Godek <godek.maciek@gmail.com>. * libguile/finalizers.c (finalization_thread_is_running): New variable. (start_finalization_thread): Use it to determine whether FINALIZATION_THREAD is up and running. (stop_finalization_thread): Likewise.
2013-05-27refactor to resolve_variableAndy Wingo1-16/+13
* libguile/vm.c (resolve_variable): Slight refactor.
2013-05-27cpp hygiene in the vmAndy Wingo3-6/+47
* libguile/vm-engine.c: * libguile/vm-i-scheme.c: * libguile/vm-i-system.c: CPP hygiene: the code that #defines, #undefs. Makes things cleaner given the multiple inclusion dance we do.
2013-05-27pop-continuation abort-continuation hooks pass return vals directlyAndy Wingo8-112/+111
* doc/ref/api-debug.texi (VM Hooks): Update documentation. * libguile/vm.c (vm_dispatch_hook): * libguile/vm-engine.c: Rework the hook machinery so that they can receive an arbitrary number of arguments. The return and abort hooks will pass the values that they return to their continuations. (vm_engine): Adapt to ABORT_CONTINUATION_HOOK change. * libguile/vm-i-system.c (return, return/values): Adapt to POP_CONTINUATION_HOOK change. * module/system/vm/frame.scm (frame-return-values): Remove. The pop-continuation-hook will pass the values directly. * module/system/vm/trace.scm (print-return): (trace-calls-to-procedure): (trace-calls-in-procedure): Update to receive return values directly. * module/system/vm/traps.scm (trap-in-procedure) (trap-in-dynamic-extent): Ignore return values. (trap-frame-finish, trap-calls-in-dynamic-extent) (trap-calls-to-procedure): Pass return values to the handlers.
2013-05-27Allow vm_engine caller to pass arguments on the stack.Andy Wingo1-4/+13
* libguile/vm-engine.c (vm_engine): Allow the caller to pass arguments on the stack.
2013-05-27vm-engine: remove register assignmentsAndy Wingo1-61/+12
* libguile/vm-engine.c: Remove the register assignments inherited from the 1990s. GCC does seem to allocate reasonably on systems with enough registers (e.g. x86-64), and on system with too few (ia32) we disabled manual allocation. Anyway this code was never tested, so it's better to leave the compiler to do its own thing, until proven otherwise. Also in the RTL VM we don't need to allocate a register to the SP, because it isn't accessed as much.
2013-05-23remove some configurability in vm-engineAndy Wingo2-67/+3
* libguile/vm-engine.c: Remove the ability for the VM to check object access, free variable access, and the ip. They were off by default. Since they will be different in the RTL VM, their presence is just making things confusing. * libguile/vm.c: Remove corresponding error helpers.
2013-05-23minor vm-engine cleanupsAndy Wingo1-25/+18
* libguile/vm-engine.c: Some very minor cleanups: indenting, use of VM_ASSERT, commenting.
2013-05-23remove CONS macro in VM; use scm_cons insteadAndy Wingo3-42/+8
* libguile/vm-engine.c (CONS): Remove. Callers should use scm_cons instead, syncing registers beforehand. (POP_LIST): Adapt, only synchronizing once. (POP_LIST_MARK, POP_CONS_MARK): Remove unused macros. * libguile/vm-i-scheme.c (cons): * libguile/vm-i-system.c (push-rest, bind-rest): Adapt.
2013-05-23inline vm-engine.h into vm-engine.cAndy Wingo3-405/+377
* libguile/vm-engine.h: * libguile/vm-engine.c: Fold vm-engine.h into vm-engine.c. * libguile/Makefile.am: Adapt.
2013-05-23add (find-mapped-elf-image) procedure to (system vm objcode) moduleAndy Wingo2-2/+111
* libguile/objcodes.c (register_elf, scm_find_mapped_elf_image): New interfaces that keep a list of all ELF mappings. Exported from the (system vm objcode) module. * module/system/vm/objcode.scm: Export find-mapped-elf-image.
2013-05-23refactor and simplify ELF loader in objcodes.cAndy Wingo1-240/+196
* libguile/objcodes.c (sniff_elf_alignment, alloc_aligned) (copy_and_align_elf_data): New helpers for portably re-aligning ELF data from read(2) or from a bytevector. (load_thunk_from_memory): Simplify! Now there is only one procedure that loads ELF, and it does less: it simply receives the whole image in one array, hopefully from mmap. (scm_load_thunk_from_file): Use new map_file_contents helper, and go through load_thunk_from_memory. (scm_load_thunk_from_memory): Pass load_thunk_from_memory a piece of memory that it owns, and that is appropriately aligned.
2013-05-23add scm_{to,from}_{u,}intptr_tAndy Wingo2-13/+31
* libguile/numbers.h (scm_to_intptr_t, scm_from_intptr_t) (scm_to_uintptr_t, scm_from_uintptr_t): New defines. * libguile/foreign.c: Remove definitions here; adapt callers to use new names with _t suffixes.
2013-05-23refactor linker to lay out ELF files and memory in the same wayAndy Wingo2-170/+358
* module/system/vm/linker.scm (make-linker-object): (linker-object-section-symbol): (linker-object-symbols*): Create a symbol to the start of a linker object. Hide it from the external linker-object-symbols* accessor. (segment-kind, count-segments): Sections without SHF_ALLOC don't get segments. (collate-objects-into-segments): Allow for #f segment types. If two sections have the same type and flags, leave them in the same order. (align): Allow for 0 alignment. (add-elf-objects): New helper: puts the ELF data structures (header, segment table, and section table) in sections of their own. This lends a nice clarity and conceptual unity to the linker. (relocate-section-header, allocate-segment): Lay out segments with congruent, contiguous addresses, so that we can just mmap the file and if debugging sections that are not in segments are present, they can be lazily paged in if needed by the kernel's VM system. (link-elf): Refactor to use the new interfaces. * test-suite/tests/linker.test: Update to expect the additional sections for the header and section table.
2013-05-23elf: add accessors for header members that might need relocationAndy Wingo1-2/+22
* module/system/vm/elf.scm (elf-header-shoff-offset) (elf-section-header-addr-offset, elf-section-header-offset-offset): New accessors.
2013-05-23ELF refactor and consequent linker simplificationsAndy Wingo4-245/+288
* module/system/vm/elf.scm: Add commentary. (make-elf): Add a constructor similar to make-elf-segment and make-elf-section. (write-elf32-header, write-elf64-header, write-elf-header): Take an <elf> instead of all the fields separately. (<elf-segment>, <elf-section>): Add "index" property. Adapt constructors accordingly. * module/language/objcode/elf.scm (bytecode->elf): Arrange to set the section indexes when creating ELF sections. * module/system/vm/linker.scm (fold-values): New helper. (alloc-segment, relocate-section-header): Arrange to set segment and section indexes. (find-shstrndx): New helper, replaces compute-sections-by-name. Now that sections know their indexes, this is easier. (allocate-elf, write-elf): New helpers, factored out of link-elf. Easier now that sections have indexes. (link-elf): Simplify. Check that the incoming objects have sensible numbers. * test-suite/tests/linker.test: Update to set #:index on the linker objects.