summaryrefslogtreecommitdiff
path: root/libguile/programs.h
Commit message (Expand)AuthorAgeFilesLines
* Remove primitive?, add primitive-code?...We need to be able to identify frames that are primitive applications without assuming that slot 0 in a frame is an SCM value and without assuming that value is the procedure being applied. * libguile/gsubr.c (scm_i_primitive_code_p): New helper. (scm_i_primitive_arity): Use the new helper. * libguile/gsubr.h: Declare the new helper. * libguile/programs.h: * libguile/programs.c (scm_program_code_p): New function, replacing scm_primitive_p. (scm_primitive_call_ip): Fix FUNC_NAME definition. * module/statprof.scm (sample-stack-procs, count-call): Identify primitive frames from the IP, not the frame-procedure. Avoids the assumption that slot 0 in a frame is a SCM value. (statprof-proc-call-data): Adapt to primitive-code? change. * module/system/vm/frame.scm (frame-call-representation): Identify primitive frames from the IP, not the closure. Still more work to do here to avoid assuming slot 0 is a procedure. * module/system/vm/program.scm: Export primitive-code? instead of primitive?. (program-arguments-alist, program-arguments-alists): Identify primitives from the code instead of the flags on the program. Not sure this is a great change, but it does avoid having to define a primitive? predicate in Scheme. Andy Wingo2015-12-011-1/+1
* Fix inner and outer stack cuts to match on procedure code...* doc/ref/api-debug.texi (Stack Capture): Update make-stack docs. * libguile/programs.h: * libguile/programs.c (scm_program_address_range): New internal procedure. * libguile/stacks.c (narrow_stack): Interpret a pair of integers as an address range. If a cut is a procedure, attempt to resolve it to an address range. (scm_make_stack): Update docstring. * module/system/vm/program.scm (program-address-range): New exported procedure. * module/statprof.scm (statprof, gcprof): Use program-address-range to get the outer-cut, for efficiency. Andy Wingo2014-05-011-1/+3
* Remove unused C scm_program_source....* libguile/programs.c (scm_program_source): Remove; not called. (The definition is in Scheme.) Andy Wingo2013-11-191-1/+0
* Reorganize programs.h....* libguile/programs.h: Reorganize. Andy Wingo2013-11-191-19/+15
* 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. Andy Wingo2013-11-191-1/+1
* 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. Andy Wingo2013-11-191-1/+1
* 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. Andy Wingo2013-11-191-1/+0
* 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. Andy Wingo2013-11-191-4/+4
* scm_i_make_rtl_program in BUILDING_LIBGUILE...* libguile/programs.h (scm_i_make_rtl_program): Enclose in a BUILDING_LIBGUILE guard. Andy Wingo2013-11-191-0/+2
* 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. Andy Wingo2013-11-191-7/+7
* 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. Andy Wingo2013-11-191-2/+2
* 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. Andy Wingo2013-11-081-22/+0
* 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. Andy Wingo2013-11-071-0/+2
* Foreign procedures are RTL programs...* libguile/foreign.c: Convert to using RTL stubs. Because RTL code has different GC characteristics than objcode -- it's mostly assumed that RTL code will never go away -- we go ahead and pre-generate code for 100 arguments. This is actually less memory than the stack VM code, and doesn't require any relocations at load-time: bonus! We'll cross the >=100 args bridge if we ever come to it. (get_foreign_stub_code) New function. (scm_i_foreign_arity): New helper, like scm_i_primitive_arity. (cif_to_procedure): Rework to make RTL programs. * libguile/foreign.h: Declare scm_pointer_to_scm and scm_scm_to_pointer. Declare new internal helpers. * libguile/gsubr.c (create_subr): Refactor to set the flags when the object is allocated. * libguile/instructions.h: Define SCM_PACK_RTL_12_12. * libguile/programs.c (scm_i_rtl_program_minimum_arity): Dispatch to scm_i_foreign_arity if the procedure has the FOREIGN flag. * libguile/programs.h (SCM_F_PROGRAM_IS_FOREIGN) (SCM_PROGRAM_IS_FOREIGN): New interfaces. * test-suite/tests/foreign.test ("procedure->pointer"): Add a test for foreign arities. Andy Wingo2013-10-181-0/+2
* Subrs are RTL programs...* libguile/gsubr.c: Define RTL stubs instead of stack VM stubs. (SUBR_STUB_CODE, get_subr_stub_code): Adapt to return a uint32_t* pointer instead of a SCM value. (create_subr): Create RTL procedures instead of stack VM procedures. For RTL procedures, the function pointer, name, and generic address pointer go inline to the procedure, as free variables. (scm_i_primitive_arity, scm_i_primitive_call_ip): New helpers. (scm_c_make_gsubr, scm_c_define_gsubr, scm_c_make_gsubr_with_generic) (scm_c_define_gsubr_with_generic): Adapt to create_gsubr being renamed to create_subr. Remove gsubr test code. * libguile/gsubr.h (SCM_PRIMITIVE_P, SCM_PRIMITIVE_GENERIC_P): Only RTL programs can be primitives now. (SCM_SUBRF, SCM_SUBR_NAME, SCM_SUBR_GENERIC): These fields are now in the RTL free variables, not the object table. * libguile/programs.c (scm_i_rtl_program_name): (scm_i_rtl_program_documentation): (scm_i_rtl_program_properties): (scm_i_rtl_program_minimum_arity): Implement these appropriately for primitives, which lack debugging information. (scm_primitive_p, scm_primitive_call_ip): New helpers. * libguile/snarf.h: Remove static allocation for subrs. Since there is nothing to allocate besides the program itself, which needs runtime relocation, static allocation is not a win. * system/vm/program.scm: Fix up various arity-related things for primitives, which don't use ELF arity info. * test-suite/tests/eval.test ("stack involving a primitive"): Add an XFAIL until we get just one VM. Andy Wingo2013-10-181-0/+3
* Merge remote-tracking branch 'origin/stable-2.0'...Conflicts: libguile/deprecated.h libguile/programs.c libguile/programs.h Andy Wingo2013-10-031-2/+0
|\
| * Deprecate scm_c_program_source, as it has no internal users....* libguile/programs.c: * libguile/programs.h: * libguile/deprecated.h: * libguile/deprecated.c (scm_c_program_source): Deprecate. Andy Wingo2013-10-031-3/+1
* | procedure-properties for RTL functions...* 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. Andy Wingo2013-06-091-0/+1
* | procedure-documentation works on RTL procedures...* 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. Andy Wingo2013-06-091-0/+1
* | RTL programs print with their name...* 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. Andy Wingo2013-06-091-2/+1
* | add new rtl vm...* 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. Andy Wingo2013-05-311-1/+26
* | refactor tc7 and tc16 checks...* libguile/tags.h (SCM_HAS_TYP7, SCM_HAS_TYP7S, SCM_HAS_TYP16): New macros. * libguile/bytevectors.h (SCM_BYTEVECTOR_P): * libguile/control.h (SCM_PROMPT_P): * libguile/filesys.h (SCM_DIRP): * libguile/fluids.h (SCM_WITH_FLUIDS_P, SCM_FLUID_P) (SCM_I_DYNAMIC_STATE_P): * libguile/foreign.h (SCM_POINTER_P): * libguile/fports.h (SCM_FPORTP): * libguile/frames.h (SCM_VM_FRAME_P): * libguile/hashtab.h (SCM_HASHTABLE_P): * libguile/inline.h (scm_get_byte_or_eof): * libguile/numbers.h (SCM_REALP, SCM_BIGP, SCM_COMPLEXP, SCM_FRACTIONP): * libguile/objcodes.h (SCM_OBJCODE_P): * libguile/ports.h (SCM_OUTPUT_PORT_P): * libguile/programs.h (SCM_PROGRAM_P): * libguile/smob.h (SCM_SMOB_PREDICATE): * libguile/srfi-14.h (SCM_CHARSETP): * libguile/strings.c (IS_STRING): * libguile/strports.h (SCM_STRPORTP): * libguile/symbols.h (scm_is_symbol): * libguile/variable.h (SCM_VARIABLEP): * libguile/vectors.h (SCM_I_IS_VECTOR, SCM_I_IS_NONWEAK_VECTOR): * libguile/vm-i-system.c (call, tail-call, mv-call) * libguile/vm.h (SCM_VM_P, SCM_VM_CONT_P): * libguile/weak-set.c (SCM_WEAK_SET_P): * libguile/weak-table.c (SCM_WEAK_TABLE_P): * libguile/weak-vector.h (SCM_I_WVECTP): Use them. Andy Wingo2011-10-241-2/+2
|/
* add program-sources-pre-retire to core and define frame-next-source...* libguile/programs.h: * libguile/programs.c (scm_program_source): Add an optional arg, the sources table to traverse. Defaults to the result of scm_program_sources. * module/system/vm/program.scm (program-sources-pre-retire): Move definition here from (system vm traps), and export. * module/system/vm/traps.scm: Adapt. * module/system/vm/frame.scm (frame-next-source): New exported binding, returns the source line corresponding to the next instruction instead of the previous instruction. Andy Wingo2010-10-081-1/+1
* remove program-name, program-documentation...* libguile/programs.h: * libguile/programs.c (scm_program_name): Remove. procedure-name is sufficient. * module/system/vm/program.scm (program-name): Remove from exports list. (program-documentation): Remove; procedure-documentation is sufficient. * libguile/debug.c (scm_procedure_name): Remove special case for programs. * module/language/tree-il/analyze.scm (validate-arity): Use procedure-name. * module/ice-9/documentation.scm (object-documentation): Just use procedure-documentation, without special cases for programs. Andy Wingo2010-04-171-1/+0
* scm_i_program_properties is internal; just use procedure-properties...* libguile/programs.h: * libguile/programs.c (scm_i_program_properties): Make internal. (scm_program_name): Use scm_i_program_properties. * libguile/procprop.c (scm_procedure_properties): Use scm_i_program_properties, for programs. * libguile/procs.c (scm_procedure_documentation): Use procedure-property to get to 'documentation, not program-property. * module/system/vm/program.scm (program-properties, program-property): Remove from the exports list. (program-documentation): Use procedure-property. * module/texinfo/reflection.scm (macro-arguments) (macro-additional-stexi) (object-stexi-documentation): Use procedure-property, not program-property. Andy Wingo2010-04-171-1/+1
* partial continuations print as #<partial-continuation ...>...* libguile/control.c (reify_partial_continuation): * libguile/programs.c (scm_i_program_print): * libguile/programs.h (SCM_F_PROGRAM_IS_PARTIAL_CONTINUATION) (SCM_PROGRAM_IS_PARTIAL_CONTINUATION): Distinguish partial continuations from full continuations. Andy Wingo2010-03-041-0/+2
* continuations are vm procedures...* libguile/vm-i-system.c (continuation-call): New op, like subr-call or foreign-call, but for continuations. * libguile/continuations.h: Add scm_i_continuation_call internal declaration. (SCM_CONTINUATIONP): Reimplement in terms of SCM_PROGRAM_IS_CONTINUATION. (scm_tc16_continuation, SCM_CONTREGS, SCM_CONTINUATION_LENGTH) (SCM_SET_CONTINUATION_LENGTH, SCM_JMPBUF, SCM_DYNENV, SCM_THROW_VALUE) (SCM_CONTINUATION_ROOT, SCM_DFRAME): Remove these from the exposed API. (scm_i_continuation_to_frame): New internal declaration. * libguile/continuations.c * libguile/continuations.c: Add trickery like in foreign.c, smob.c, and gsubr.c, so that we can make procedural trampolines for continuations. (scm_i_continuation_to_frame): New internal function, from stacks.c. * libguile/programs.h (SCM_F_PROGRAM_IS_CONTINUATION) (SCM_PROGRAM_IS_CONTINUATION): Add a flag for programs that are continuations. Probably should add flags for the other trampoline types too. * libguile/programs.c (scm_i_program_print): Print continuations as before. * libguile/stacks.c (scm_stack_id, scm_make_stack): Use scm_i_continuation_to_frame in the continuation case. Andy Wingo2010-02-081-2/+4
* 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. Andy Wingo2010-01-091-2/+7
* remove scm_tc7_gsubr...* libguile/tags.h (scm_tc7_gsubr): Return to the pool of unused tc7s, as there are no more gsubrs. Yay :) * libguile/programs.h (SCM_F_PROGRAM_IS_PRIMITIVE): (SCM_PROGRAM_IS_PRIMITIVE): New flag and accessor. * libguile/gsubr.c (create_gsubr): * libguile/snarf.h (SCM_STATIC_PROGRAM): Give subrs a PRIMITIVE flag. * libguile/smob.h: * libguile/smob.c (scm_i_smob_arity): New internal procedure. Uses the old GSUBR type macros, local to the file. * libguile/procprop.c (scm_i_procedure_arity): Call out to scm_i_smob_arity, and remove a gsubr case. * libguile/gc.c (scm_i_tag_name): * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (scm_class_of): * libguile/vm.c (apply_foreign): * libguile/hash.c (scm_hasher): * libguile/debug.c (scm_procedure_name): * libguile/print.c (iprin1): Remove gsubr cases. * libguile/gsubr.h (SCM_PRIMITIVE_P): Fix to work with the new VM program regimen. (SCM_GSUBR_TYPE, SCM_GSUBR_MAKTYPE, SCM_GSUBR_MAX, SCM_GSUBR_REQ) (SCM_GSUBR_OPT, SCM_GSUBR_REST): Remove these macros, that are no longer useful. * libguile/gsubr.c (scm_i_gsubr_apply, scm_i_gsubr_apply_list) (scm_i_gsubr_apply_array): Remove internal gsubr application functions. Andy Wingo2010-01-071-0/+2
* add SCM_PROGRAM_IS_PRIMITIVE_GENERIC flag and checker...* libguile/programs.h (SCM_F_PROGRAM_IS_PRIMITIVE_GENERIC) (SCM_PROGRAM_IS_PRIMITIVE_GENERIC): Add a primitive-generic flag and accessor, for when we switch primitives to be implemented using VM trampolines. Andy Wingo2010-01-071-1/+3
* 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. Andy Wingo2009-10-231-0/+1
* 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. Andy Wingo2009-10-231-1/+1
* Fix omission of VM frames from backtrace...From the time when a #<program> was a SMOB, really_make_boot_program in vm.c was still using SCM_SET_SMOB_FLAGS to set the SCM_F_PROGRAM_IS_BOOT flag - which meant that it was setting flag 1<<32 :-) which obviously was then missed by the SCM_PROGRAM_IS_BOOT calls in stacks.c. * libguile/programs.h (SCM_F_PROGRAM_IS_BOOT): Use a less significant bit for this flag, now that programs use a tc7 type. * libguile/vm.c (really_make_boot_program): Don't use SCM_SET_SMOB_FLAGS, now that programs aren't SMOBs. Neil Jerram2009-09-171-1/+1
* programs have their own tc7 now...* libguile/tags.h (scm_tc7_program): * libguile/programs.h: Programs now have their own tc7 code. Fix up the macros appropriately. * libguile/programs.c: Remove smobby bits, leaving marking, printing, and application for other parts of Guile. * libguile/debug.c (scm_procedure_source): * libguile/eval.c (scm_trampoline_0, scm_trampoline_1) (scm_trampoline_2): Add cases for tc7_program. * libguile/eval.i.c (CEVAL, SCM_APPLY): * libguile/evalext.c (scm_self_evaluating_p): * libguile/gc-card.c (scm_i_sweep_card, scm_i_tag_name): * libguile/gc-mark.c (1): * libguile/print.c (iprin1): * libguile/procs.c (scm_procedure_p, scm_thunk_p) * libguile/vm-i-system.c (make-closure): Adapt to new procedure representation. * libguile/procprop.c (scm_i_procedure_arity): Do the right thing for programs. * test-suite/tests/procprop.test ("procedure-arity"): Arity test now succeeds. * libguile/goops.c (scm_class_of): Programs now belong to the class <procedure>, not a smob class. * libguile/vm.h (struct vm, struct vm_cont): * libguile/vm-engine.c (vm_engine): * libguile/frames.h (SCM_FRAME_BYTE_CAST, struct vm_frame): * libguile/frames.c (scm_c_make_vm_frame): Fix usages of scm_byte_t, changing them to scm_t_uint8. Andy Wingo2009-08-201-10/+8
* rename "closure-ref" to "free-ref"; s/vars/variables/ in some names...* libguile/programs.h: * libguile/programs.c: (SCM_PROGRAM_FREE_VARIABLES): Rename from SCM_PROGRAM_FREE_VARS. Callers changed. * libguile/programs.c (scm_make_program): Rename arg to "free_variables". (scm_program_free_variables): Rename from program-free-vars. * libguile/vm-engine.h: * libguile/vm-engine.c (VM_CHECK_FREE_VARIABLES): Rename from VM_CHECK_CLOSURE. (vm_engine, CACHE_PROGRAM): Rename closure and closure_count to free_vars and free_vars_vount. * libguile/vm-i-system.c (FREE_VARIABLE_REF): Rename from CLOSURE_REF. (free-ref, free-boxed-ref, free-boxed-set): Rename from closure-ref, closure-boxed-ref, closure-boxed-set. (make-closure): Renamed from make-closure2. * module/language/glil/compile-assembly.scm (glil->assembly): Hack to never write out the the old "make-closure" instruction. Will fix better later. Change to emit free-ref etc instead of closure-ref. * module/language/tree-il/compile-glil.scm (flatten): Emit make-closure instead of make-closure2, now that the old make-closure is gone. * module/system/vm/program.scm (system): Rename program-free-vars to program-free-variables. * test-suite/tests/tree-il.test ("lambda"): Update for make-closure. Andy Wingo2009-07-231-3/+3
* remove "externals" from the vm...* libguile/frames.c (scm_frame_external_link): Removed. * libguile/frames.h: No need to have the "external link" in the stack frame -- update macros to take the new situation into account. * libguile/objcodes.h (struct scm_objcode): Rename the nexts field to "unused". In the future we can use it for nlocs, I think. (SCM_OBJCODE_NEXTS): removed. * libguile/programs.h: * libguile/programs.c (scm_make_program): Expect the third argument to be a vector of free variables, not a list of free variables. SCM_BOOL_F indicates no free variables, not SCM_EOL. (program_mark): Adapt. (scm_program_arity): No more nexts. (scm_program_free_vars): Replaces scm_program_externals. * libguile/vm-engine.c (VM_CHECK_EXTERNAL) (vm_engine): No need for the "external" var. * libguile/vm-engine.h (CACHE_PROGRAM): Update for SCM_PROGRAM_FREE_VARS instead of SCM_PROGRAM_EXTERNALS. (NEW_FRAME): Update for new frame size, and no need to cons up externals. Yay :) * libguile/vm-i-loader.c (load-program): Update for scm_make_program. * libguile/vm-i-system.c (external-ref, external-set): No more. (make-closure): No more. (goto/args): No need to re-cons externals here. Update for new stack frame size. (mv-call, return, return/values): Update for new frame size. No need to reinstate externals on return. * libguile/vm.c (really_make_boot_program, scm_load_compiled_with_vm): Update for scm_make_program. * module/language/objcode/spec.scm (objcode-env-externals): Treat '() as #f, for the externals. Need to clean this up later... * module/system/vm/program.scm (arity:nexts): Remove. Rename program-external to program-free-vars. Andy Wingo2009-07-231-5/+4
* Change Guile license to LGPLv3+...(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* ) Neil Jerram2009-06-171-6/+7
* adjust VM copyright notices to LGPL, use SCM_INTERNAL/API properly...* libguile/frames.c: * libguile/frames.h: * libguile/instructions.c: * libguile/instructions.h: * libguile/objcodes.c: * libguile/objcodes.h: * libguile/programs.c: * libguile/programs.h: * libguile/vm-bootstrap.h: * libguile/vm-engine.c: * libguile/vm-engine.h: * libguile/vm-expand.h: * libguile/vm-i-scheme.c: * libguile/vm.c: * libguile/vm.h: Update to use SCM_API and SCM_INTERNAL correctly. Adjust copyright to be the same as the copyright of Guile itself, which should be fine given that the FSF holds the whole thing. Andy Wingo2009-05-261-55/+31
* propagate much more source info through compilation...* module/language/ghil/compile-glil.scm (codegen): Record source location for offset 0 into a lambda, if we can. * module/language/scheme/compile-ghil.scm (translate-1) (define-scheme-translator): In the retrans procedures, propagate the location information from the enclosing expression if the subexpression has no location information. Gives source information to many more expressions. (location): Just propagate the source properties as they are, the glil->assembly compiler will interpret them. * module/language/glil.scm (<glil>): Change glil-source to take "props" and not "loc", as it's the source properties that we're interested in. * module/language/glil/compile-assembly.scm (limn-sources): New function, takes a list of addr-source property pairs and "compresses" them for serialization to disk. (glil->assembly): Limn the sources before writing them to disk. Avoid non-tail recursion when determining total byte length of code. * module/system/vm/program.scm (source:file, source:line, source:column): Update for new source representation. (program-source): Export. (write-program): Nicer pretty-printing of anonymous procedures. * libguile/backtrace.c (display_backtrace_get_file_line): Update for the new VM source representation. * libguile/programs.h: * libguile/programs.c (scm_program_sources): Update for the new serialized source representation, where the filename is not in the stream unless it changes. (scm_program_source): New exported function, looks up the source for a given ip offset. (scm_c_program_source): Update to return the last source information that was <= the given IP, because we only serialize source info when it changes. Andy Wingo2009-02-101-0/+1
* fix boot program detection, which in turn makes `make-stack' actually work...* libguile/programs.h (SCM_F_PROGRAM_IS_BOOT, SCM_PROGRAM_IS_BOOT): Flags for determining if a program is a boot program. It turns out that our heuristics e.g. in stacks.c would catch non-boot programs, like programs that end with (goto/args 1), because the 1 is the same byte as `halt'. That took a while to find... * libguile/stacks.c (stack_depth, read_frames): Use the new boot prog macros. (scm_make_stack): Assert that we read the number of frames that we said we would. * libguile/vm.c (really_make_boot_program): Mark boot programs appropriately. Andy Wingo2009-02-051-0/+3
* tick in calls, procedure-name works on compiled procedures...* module/system/vm/program.scm: * libguile/programs.h: * libguile/programs.c (scm_program_bindings, scm_program_bindings) (scm_program_properties, scm_program_name): Unfortunately, implement more procs in C, so that C can use them more easily. * libguile/debug.c (scm_procedure_name): Dispatch to scm_program_name as appropriate. * libguile/vm-i-system.c (call): Tick in a call. Andy Wingo2009-02-021-0/+4
* static opcodes; refactor program/objcode division; use new assembly pipeline...* gdbinit: Untested attempts to get the stack fondling macros to deal with the new program representation. * libguile/frames.c (scm_vm_frame_arguments, scm_vm_frame_source) (scm_vm_frame_local_ref, scm_vm_frame_local_set_x): SCM_PROGRAM_DATA is a struct scm_objcode*. * libguile/instructions.h: * libguile/instructions.c: Hide the instruction table and the struct scm_instruction structure; all access to instructions now goes through procedures. This is because instructions are no longer in a packed array indexed by opcode. Also, declare a mask that all instructions should fit in. * libguile/objcodes.h: * libguile/objcodes.c: Rewrite so that object code directly maps its arity and length from its bytecode. This makes it unnecessary to keep this information in programs, allowing programs to be simple conses between the code (objcodes) and data (the object table and the closure variables). * libguile/programs.c (scm_make_program): Rework so that make-program takes objcode, an object table, and externals as arguments. It's much clearer this way, and we avoid malloc(). * libguile/stacks.c (is_vm_bootstrap_frame): Update for program/objcode changes. * libguile/vm-engine.c (vm_run): Initialize the jump table on the first run, with the opcodes declared in the instruction sources, and with bad instructions raising an error instead of wandering off into the Unknown. * libguile/vm-engine.h (FETCH_LENGTH): Always represent lengths as 3 bytes. The old code was too error-prone. (NEXT_JUMP): Mask the instruction with SCM_VM_INSTRUCTION_MASK. (NEW_FRAME): Update for program/objcode changes. * libguile/vm-expand.h (VM_DEFINE_FUNCTION, VM_DEFINE_INSTRUCTION) (VM_DEFINE_LOADER): Update so that we explicitly specify opcodes, so that we have a stable bytecode API. * libguile/vm-i-loader.c: Update license to LGPLv2+. Explicitly declare opcodes. (load-integer): Use an int instead of a long as the accumulator; still need to revisit this code at some point, I think. (load-program): Simplify, thankfully!! Just creates the objcode slice and rolls with it. * libguile/vm-i-scheme.c: Number the opcodes explicitly. * libguile/vm-i-system.c: Update license to LGPLv2+. Explicitly declare opcodes. (make-closure): Update for new program API. * libguile/vm.c (vm_make_boot_program): Update for new program/objcode API. Still a bit ugly. (scm_load_compiled_with_vm): Update for new program/objcode API. * module/language/assembly.scm (byte-length): Fix byte-length calculation for loaders, and load-program. (code-pack, code-unpack): Start to move things from (system vm conv) here. (object->code, code->object): More things from conv.scm. * module/language/glil.scm (<glil-program>): Add a new field, closure-level. (make-glil-program, compute-closure-level): Calculate the "closure level" when making a glil program. This is the maximum depth of external binding refs in this closure. (unparse-glil): Fix label serialization. * module/language/glil/compile-assembly.scm (make-meta): Prepend #f for the meta's object table, though maybe in the future we can avoid creating assembly in the first place. (assoc-ref-or-acons, object-index-and-alist): GRRR! Caught again by the different sets of arguments to assoc and assoc-ref! (glil->assembly): Attempt to make the <glil-program> case more readable, and fix the bugs. Sorry I don't know how to comment this change any more than this. (glil->assembly): For <glil-module> serialize the whole key, not just the name. (dump-object): subprogram-code is already a list. Serialize integers as strings, not u8vectors. Fix the order of lists and vectors. * module/language/glil/spec.scm (glil): Switch orders, so we prefer glil -> assembly -> objcode. Actually glil->objcode doesn't work any more, needs to be removed I think. * module/language/objcode/spec.scm (objcode->value): s/objcode->program/make-program/. * module/language/scheme/inline.scm: Add acons inline. * module/system/vm/conv.scm (make-byte-decoder): Skip the first 8 bytes, they are header. Handle subprograms properly. Still needs help though. (decode-length): Lengths are always 3 bytes now. * module/system/vm/disasm.scm: Superficial changes to keep things working. I'd like to fix this better in the future. * module/system/vm/frame.scm (bootstrap-frame?): Fixes for program-bytecode. * module/system/vm/program.scm: Export make-program. It's program-objcode now, no more program-bytecode. * module/system/vm/vm.scm (vm-load): Use make-program. * test-suite/tests/asm-to-bytecode.test: New test, very minimal. * module/system/vm/objcode.scm: Export word-size, byte-order, and write-objcode. Andy Wingo2009-01-291-17/+8
* move module and meta inside programs' object tables...* libguile/programs.h (struct scm_program): Remove the module and meta fields. * libguile/programs.c (scm_c_make_program): Add a new argument, `objs'. If it's a vector, we'll look for the module and the metadata in there, instead of having them in the scm_program structure. (scm_c_make_closure, program_mark, scm_program_meta) (scm_c_program_source, scm_program_module): Adapt to the new program representation. * libguile/objcodes.c (scm_objcode_to_program): Pass #f as the object table when making the program. * libguile/vm-engine.h (CACHE_PROGRAM): * libguile/vm-engine.c (vm_run): Rework to use the simple vector API for getting the current object table. Call the helper, vm_make_boot_program, to make the boot program. * libguile/vm-i-loader.c (load-program): Set the current module and the meta in the object vector, which we pass to scm_c_make_program. * libguile/vm-i-system.c (toplevel-ref, toplevel-set): Adapt to the new program representation. * module/language/glil/compile-objcode.scm (codegen): Clarify. Andy Wingo2009-01-171-3/+1
* add scm_c_program_source...* libguile/programs.h: * libguile/programs.c (scm_c_program_source): New helper for getting source information from C. Andy Wingo2008-12-261-0/+2
* rework late binding resolution to be simpler and more efficient...* libguile/programs.h (struct scm_program): * libguile/programs.c (scm_c_make_program): Record the current module when making a program. This replaces the per-late binding recorded module in the generated code, which should be more efficient, both in terms of garbage, and in not calling resolve-module. (program-module): New accessor. * module/system/vm/program.scm: Add program-module to exports. * libguile/vm-i-loader.c (link-later): Remove this instruction, since now the entry in the object table is just a symbol, and can be loaded with load-symbol. * libguile/vm-i-system.c (late-variable-ref, late-variable-set): Rework so as to look up in the module of the current program. The logic could be condensed quite a bit if scm_module_lookup () knew what to do with mod==#f. * module/system/vm/assemble.scm (dump-object!): Dump <vlink-later> just as load-symbol, as mentioned in the note on link-later. * module/system/il/ghil.scm: Update comment to reflect the new reality. Andy Wingo2008-09-091-0/+2
* merge guile-vm into libguile itself...* ice-9/boot-9.scm: Only define load-compiled as #f if it's not already defined, which won't normally be the case. * libguile/guile-vm.c: Removed, there's no more guile-vm binary. * libguile/frames.c: (with change frame? -> heap-frame?) * libguile/frames.h: * libguile/instructions.c: * libguile/instructions.h: * libguile/objcodes.c: * libguile/objcodes.h: * libguile/programs.c: * libguile/programs.h: * libguile/vm-bootstrap.h: (was bootstrap.h) * libguile/vm-engine.c: (was vm_engine.c) * libguile/vm-engine.h: (was vm_engine.h) * libguile/vm-expand.h: (was vm_expand.h) * libguile/vm-i-loader.c: (was vm_loader.c) * libguile/vm-i-scheme.c: (was vm_scheme.c) * libguile/vm-i-system.c: (was vm_system.c) * libguile/vm.c: * libguile/vm.h: These files moved here from src/, as guile-vm is now a part of libguile. * libguile/init.c: Bootstrap the VM. Yay! * libguile/Makefile.am: The necessary chicanery here. * module/system/vm/Makefile.am: * module/system/vm/bootstrap.scm: * module/system/vm/frame.scm: * module/system/vm/instruction.scm: * module/system/vm/objcode.scm: * module/system/vm/program.scm: * module/system/vm/vm.scm: * pre-inst-guile-env.in: Add builddirs to the load path; add module/ to the path in the empty-$GUILE_LOAD_PATH case as well. * src/Makefile.am: Moved out everything except guilec and guile-disasm, which probably should be moved to the scripts directory? * testsuite/Makefile.am: Update to find guile-vm in the right place. * module/system/vm/Makefile.am: * module/system/vm/bootstrap.scm: Removed bootstrap.scm, scm_init_guile handles the bootstrapping for us. * module/system/vm/frame.scm: * module/system/vm/instruction.scm: * module/system/vm/objcode.scm: * module/system/vm/program.scm: * module/system/vm/vm.scm: Call the init functions in libguile; should fix at some point to avoid the dlopen? Andy Wingo2008-08-211-0/+93