summaryrefslogtreecommitdiff
path: root/libguile/objcodes.c
AgeCommit message (Collapse)AuthorFilesLines
2013-05-31add new rtl vmAndy Wingo1-13/+41
* 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-23add (find-mapped-elf-image) procedure to (system vm objcode) moduleAndy Wingo1-0/+108
* 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-03-28Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-2/+3
Conflicts: configure.ac libguile/deprecated.c libguile/deprecated.h libguile/filesys.h libguile/fluids.c libguile/fports.c libguile/gc.c libguile/guile.c libguile/numbers.c libguile/objcodes.c libguile/r6rs-ports.c libguile/smob.c libguile/socket.c libguile/threads.h module/language/scheme/decompile-tree-il.scm module/language/tree-il/peval.scm test-suite/tests/syncase.test
2013-02-19fix an error message loading invalid bytecodeAndy Wingo1-1/+3
* libguile/objcodes.c (make_objcode_from_file): Add correct error message if full_read failed without an errno.
2013-02-19copy-file and load-objcode use O_BINARYAndy Wingo1-2/+2
* libguile/filesys.c (scm_copy_file): * libguile/objcodes.c (scm_load_objcode): Use O_BINARY. Thanks to Eli Zaretskii for the patch.
2012-06-22instead of our custom .go format, use elfAndy Wingo1-280/+54
* libguile/objcodes.c: Change to expect objcode on disk to be embedded in ELF instead of having the funky cookie. (to_native_order): Use already existing SCM_BYTE_ORDER style byte order instead of chars. (bytecode_to_objcode): No need for word_size arg. (scm_bytecode_to_objcode, scm_objcode_to_bytecode): Take optional endianness arg instead of sometimes using target-endianness. (scm_load_objcode, scm_write_objcode, scm_bytecode_to_native_objcode): Remove. * libguile/objcodes.h: Adapt. * libguile/vm.c (scm_load_compiled_with_vm): Use scm_load_thunk_from_file. (make_boot_program): Adapt to use scm_bytecode_to_objcode with endianness arg. * module/Makefile.am (OBJCODE_LANG_SOURCES): Add (language objcode elf). * module/language/objcode/elf.scm: New module, embeds objcode in ELF. * module/language/bytecode/spec.scm (compile-objcode): (decompile-objcode): Use (target-endianness). * module/language/objcode/spec.scm: use (language objcode elf) for write-objcode. * module/scripts/disassemble.scm (disassemble): * module/system/repl/command.scm (disassemble-file): Use load-thunk-from-file. * module/system/vm/objcode.scm: Remove load-objcode and write-objcode. * test-suite/tests/asm-to-bytecode.test (test-target): Adapt to the new ELF world.
2012-06-22add ELF loaderAndy Wingo1-1/+551
* libguile/objcodes.h: * libguile/objcodes.c (scm_load_thunk_from_file) (scm_load_thunk_from_memory): New procedures. * libguile/elf.h: Import from glibc. Not installed. * libguile/Makefile.am: Adapt for elf.h. * module/system/vm/objcode.scm: (load-thunk-from-file) (load-thunk-from-memory): New exports.
2012-01-10Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-4/+3
Conflicts: libguile/__scm.h libguile/array-map.c libguile/procprop.c libguile/tags.h module/ice-9/deprecated.scm module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm test-suite/standalone/test-num2integral.c test-suite/tests/regexp.test
2012-01-07don't leak file descriptors when mmaping objcodeAndy Wingo1-4/+3
* libguile/objcodes.c (make_objcode_from_file): Close the mmap'd file, so that we don't leak the descriptor. I was previously under the mistaken impression that closing the fd unmapped the memory, which is not the case. Thanks to Cedric Cellier for the tip!
2011-12-01Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-30/+100
Conflicts: configure.ac libguile/fluids.c libguile/gc.c libguile/gc.h libguile/objcodes.c libguile/procprop.c libguile/vm.c module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm
2011-11-22Complete cross-compilation support.Ludovic Courtès1-30/+100
* module/system/base/target.scm (%target-endianness, %target-word-size): New fluids. (%native-word-size): New variable. (with-target): Set these fluids. (cpu-endianness, cpu-word-size, triplet-cpu, triplet-vendor, triplet-os): New procedures. (target-cpu, target-vendor, target-os): Use them. (target-endianness, target-word-size): Refer to the corresponding fluid. * libguile/objcodes.c (target_endianness_var, target_word_size_var): New global variables. (NATIVE_ENDIANNESS): New macro. (target_endianness, target_word_size, to_native_order): New functions. (make_objcode_from_file): Use `scm_bytecode_to_native_objcode' instead of `scm_bytecode_to_objcode'. (bytecode_to_objcode): New function, based on `scm_bytecode_to_objcode', with the addition of an `endianness' and `word_size' parameters. (scm_bytecode_to_objcode): Use it. (scm_bytecode_to_native_objcode): New function. (scm_write_objcode): Use `target_word_size' and `target_endianness'. Convert OBJCODE's len and meta-len to native byte order. (scm_init_objcodes): Initialize `target_endianness_var' and `target_word_size_var'. * libguile/objcodes.h (scm_bytecode_to_native_objcode): New declaration. * libguile/vm.c (really_make_boot_program): Use `scm_bytecode_to_native_objcode' instead of `scm_bytecode_to_objcode'. * test-suite/tests/asm-to-bytecode.test (%objcode-cookie-size): New variable. (test-target): New procedure. ("cross-compilation"): Add `test-target' calls and the "unknown target" test.
2011-11-08locking for write, lfwriteAndy Wingo1-3/+4
* libguile/ports.c (scm_c_write_unlocked, scm_c_write) (scm_lfwrite_unlocked, scm_lfwrite): Add locking and _unlocked variants. Change uses to _unlocked.
2011-11-08locking for putc, putsAndy Wingo1-2/+2
* libguile/ports.c (scm_putc, scm_puts): * libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into _unlocked and locked variants. Change all callers to use the _unlocked versions.
2011-08-31Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-2/+2
Conflicts: libguile/bytevectors.c libguile/bytevectors.h libguile/objcodes.c libguile/r6rs-ports.c libguile/strings.c libguile/vm.c
2011-08-18fix a couple of leaksAndy Wingo1-2/+2
* libguile/bytevectors.h: * libguile/bytevectors.c (scm_c_take_gc_bytevector): Rename this internal function, from scm_c_take_bytevector. This indicates that unlike the other scm_take_* functions, this one takes GC-managed memory. * libguile/objcodes.c (scm_objcode_to_bytecode): * libguile/vm.c (really_make_boot_program): Use scm_gc_malloc_pointerless, not scm_malloc. Thanks to Stefan Israelsson Tampe! * libguile/r6rs-ports.c: * libguile/strings.c: Adapt to renames.
2011-06-16Merge remote-tracking branch 'local-2.0/stable-2.0'Andy Wingo1-1/+1
2011-06-16O_CLOEXEC usageAndy Wingo1-1/+1
* libguile/objcodes.c (scm_load_objcode): * libguile/scmsigs.c (start_signal_delivery_thread): * libguile/threads.c (guilify_self_1): Use O_CLOEXEC.
2011-06-02Merge remote-tracking branch 'local-2.0/stable-2.0'Andy Wingo1-1/+29
Conflicts: meta/Makefile.am
2011-05-31write-objcode uses target-endianness, target-word-sizeAndy Wingo1-1/+29
* libguile/_scm.h (SCM_OBJCODE_ENDIANNESS_OFFSET): (SCM_OBJCODE_WORD_SIZE_OFFSET): New defines. * libguile/objcodes.c (scm_write_objcode): Use target-endianness and target-word-size when writing the objcode cookie.
2011-05-07bytevectors have internal parent fieldAndy Wingo1-5/+2
* libguile/bytevectors.h (SCM_BYTEVECTOR_HEADER_SIZE): Bump, giving bytevectors another word: a parent pointer. Will allow for sub-bytevectors and efficient mmap bindings. * libguile/bytevectors.c (make_bytevector): (make_bytevector_from_buffer): Init parent to #f. (scm_c_take_bytevector, scm_c_take_typed_bytevector): Another argument, the parent, which gets set in the bytevector. * libguile/foreign.c (scm_pointer_to_bytevector): Use the parent field instead of registering a weak reference from bytevector to foreign pointer. * libguile/objcodes.c (scm_objcode_to_bytecode): Use the parent field to avoid copying the objcode. * libguile/srfi-4.c (DEFINE_SRFI_4_C_FUNCS): * libguile/strings.c (scm_from_stringn): * libguile/vm.c (really_make_boot_program): * libguile/r6rs-ports.c (scm_get_bytevector_some) (scm_get_bytevector_all, bytevector_output_port_procedure): Set the parent to #f.
2011-04-01support loading objcode even if mmap(2) is unavailableAndy Wingo1-52/+118
* configure.ac: Check for sys/mman.h. * libguile/objcodes.c (verify_cookie): Factor cookie verification out to a helper function. (make_objcode_from_file): Rename from make_objcode_by_mmap. If mmap is unavailable, just read(2) to a bytevector.
2011-04-01make_objcode_by_mmap uses MAP_PRIVATE, not MAP_SHAREDAndy Wingo1-1/+1
* libguile/objcodes.c (make_objcode_by_mmap): MAP_PRIVATE, not MAP_SHARED -- we don't need to update the underlying file, nor do we need to see updates.
2011-02-13bump objcode version to 2.0; introduce minor-version compatibilityAndy Wingo1-1/+17
* libguile/_scm.h (SCM_OBJCODE_MAJOR_VERSION): Bump to 2. (SCM_OBJCODE_MINOR_VERSION): Reset to 0. (SCM_OBJCODE_MACHINE_VERSION_STRING, SCM_OBJCODE_COOKIE): Reorder so the minor version is the last byte. * libguile/objcodes.c (make_objcode_by_mmap): Accept objcodes whose minor version is less than SCM_OBJCODE_MINOR_VERSION, not just equal to.
2011-01-27for mmap objcodes, store the fd in the third word, as a scheme intAndy Wingo1-6/+5
This leaves space for native code. * libguile/objcodes.h (SCM_OBJCODE_NATIVE_CODE) (SCM_SET_OBJCODE_NATIVE_CODE): Reserve the fourth word of objcode for "native code", whatever that means. * libguile/objcodes.c: Update a comment. (make_objcode_by_mmap): Put the fd in the third word.
2011-01-27objcode type is an enumeration, not flagsAndy Wingo1-3/+3
* libguile/objcodes.h (SCM_OBJCODE_TYPE_MMAP) (SCM_OBJCODE_TYPE_BYTEVECTOR, SCM_OBJCODE_TYPE_SLICE) (SCM_OBJCODE_TYPE_STATIC): Enumerate objcode types instead of expressing them as flags. (SCM_OBJCODE_TYPE): Type is held in bits 8-15. (SCM_OBJCODE_FLAGS): Flags are now shifted by 16 bits, not 8. (SCM_MAKE_OBJCODE_TAG): New helper. * libguile/continuations.c (STATIC_OBJCODE_TAG): * libguile/control.c (STATIC_OBJCODE_TAG): * libguile/foreign.c (STATIC_OBJCODE_TAG): * libguile/gsubr.c (STATIC_OBJCODE_TAG): * libguile/smob.c (STATIC_OBJCODE_TAG): * libguile/objcodes.c (make_objcode_by_mmap, scm_c_make_objcode_slice) (scm_bytecode_to_objcode): : Use SCM_MAKE_OBJCODE_TAG.
2011-01-27Use `scm_from_latin1_stringn' in `objcodes.c'.Ludovic Courtès1-2/+2
* libguile/objcodes.c (make_objcode_by_mmap): Use `scm_from_latin1_stringn', not `scm_from_locale_stringn', to display the invalid cookie in the error case.
2010-11-19fix a number of assumptions that a pointer could fit into a longAndy Wingo1-5/+6
* libguile/debug.c: * libguile/eval.c: * libguile/frames.c: * libguile/objcodes.c: * libguile/print.c: * libguile/programs.c: * libguile/read.c: * libguile/struct.c: * libguile/vm.c: Fix a number of instances in which we assumed we could fit a pointer into a long.
2010-08-18objcodes.c commentsAndy Wingo1-2/+12
* libguile/objcodes.c: Comments from Noah Lavine
2010-08-18Whitespace fixNoah Lavine1-1/+1
Add a space in libguile/objcodes.c to comply with the GNU Coding Standards.
2010-03-16rename libguile to libguile-@EFFECTIVE_VERSION@, currently libguile-2.0Andy Wingo1-1/+2
* libguile/Makefile.am (lib_LTLIBRARIES): Instead of just "libguile.la", make "libguile-@EFFECTIVE_VERSION@.la". This allows multiple versions of Guile to be installed at once. See http://www106.pair.com/rhp/parallel.html for a rationale. (libguile_@GUILE_EFFECTIVE_VERSION@_la_CFLAGS): (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (libguile_@GUILE_EFFECTIVE_VERSION@_la_DEPENDENCIES): (libguile_@GUILE_EFFECTIVE_VERSION@_la_LIBADD): (libguile_@GUILE_EFFECTIVE_VERSION@_la_LDFLAGS): Fixup automake vars to include the effective version. (guile_LDADD): Fix up the spelling of libguile. * libguile/bytevectors.c (scm_bootstrap_bytevectors): * libguile/foreign.c (scm_register_foreign): * libguile/i18n.c (scm_bootstrap_i18n): * libguile/instructions.c (scm_bootstrap_instructions): * libguile/objcodes.c (scm_bootstrap_objcodes): * libguile/programs.c (scm_bootstrap_programs): * libguile/vm.c (scm_bootstrap_vm): Register extensions using e.g. "libguile-2.0" as the libname -- i.e., including the effective version in the libname. * module/ice-9/i18n.scm: * module/rnrs/bytevector.scm: * module/rnrs/io/ports.scm: * module/system/foreign.scm: * module/system/vm/instruction.scm: * module/system/vm/objcode.scm: * module/system/vm/program.scm: * module/system/vm/vm.scm: When doing a load-extension for something in Guile, use the effective version also. * meta/guile-2.0-uninstalled.pc.in (Libs): * meta/guile-2.0.pc.in (Libs): Use -lguile-@EFFECTIVE_VERSION@. This change should mean that code built against Guile should not be affected by the libguile rename. * guile-readline/Makefile.am (libguilereadline_v_@LIBGUILEREADLINE_MAJOR@_la_LIBADD): * srfi/Makefile.am (libguile_srfi_srfi_1_v_@LIBGUILE_SRFI_SRFI_1_MAJOR@_la_LIBADD): (libguile_srfi_srfi_4_v_@LIBGUILE_SRFI_SRFI_4_MAJOR@_la_LIBADD): (libguile_srfi_srfi_13_14_v_@LIBGUILE_SRFI_SRFI_13_14_MAJOR@_la_LIBADD): (libguile_srfi_srfi_60_v_@LIBGUILE_SRFI_SRFI_60_MAJOR@_la_LIBADD): * test-suite/standalone/Makefile.am (test_num2integral_LDADD): (test_round_LDADD): (libtest_asmobs_la_LIBADD): (libtest_ffi_la_LIBADD): (test_list_LDADD): (test_unwind_LDADD): (test_conversion_LDADD): (test_loose_ends_LDADD): (test_scm_c_read_LDADD): (test_scm_take_locale_symbol_LDADD): (test_scm_take_u8vector_LDADD): (libtest_extensions_la_LIBADD): (test_with_guile_module_LDADD): (test_scm_with_guile_LDADD): Fix up the spelling of libguile.la.
2010-01-07tc7 tags for vm-related dataAndy Wingo1-16/+16
* libguile/tags.h (scm_tc7_frame, scm_tc7_objcode, scm_tc7_vm) (scm_tc7_vm_cont): Take more tc7s for VM-related data structures. * libguile/evalext.c (scm_self_evaluating_p): * libguile/gc.c (scm_i_tag_name): * libguile/goops.c (scm_class_of, create_standard_classes): * libguile/print.c (iprin1): Add cases for the new tc7s. * libguile/frames.c: * libguile/frames.h: * libguile/objcodes.c: * libguile/objcodes.h: * libguile/vm.c: * libguile/vm.h: Desmobify. * libguile/vm.c (scm_vm_apply): Export to Scheme, because VM objects are no longer applicable. * module/system/repl/command.scm (profile): * module/system/vm/trace.scm (vm-trace): * module/system/vm/vm.scm (vm-load): Call vm-apply to run a program in a VM instead of treating the VM as applicable.
2010-01-07properly integrate vm bootstrapping into init.cAndy Wingo1-3/+0
* libguile/Makefile.am (modinclude_HEADERS): * libguile/vm-bootstrap.h: Remove vm-bootstrap.h. * libguile/frames.c: No more vm-bootstrap.h. * libguile/instructions.c (scm_init_instructions): * libguile/objcodes.c (scm_init_objcodes): * libguile/programs.c (scm_init_programs): No need to call scm_bootstrap_vm, init.c does that for us. * libguile/vm.c (scm_bootstrap_vm): No need call e.g. scm_bootstrap_frames, init.c does that. Remove a twice-calling guard, should be unnecessary. Don't define the load-compiled subr here. * libguile/load.c (scm_init_load): Define the load-compiled subr here. * libguile/vm.h: Declare scm_bootstrap_vm here. * libguile/init.c (scm_i_init_guile): Properly integrate VM bootstrapping into this file.
2010-01-07reimplement srfi-4 vectors on top of bytevectorsAndy Wingo1-15/+14
* libguile/srfi-4.h: * libguile/srfi-4.c (scm_make_srfi_4_vector): New function, exported by (srfi srfi-4 gnu). * libguile/srfi-4.i.c: Removed. * module/srfi/srfi-4.scm: * module/srfi/srfi-4/gnu.scm: Reimplement srfi-4 vectors on top of bytevectors. The implementation is mostly in Scheme now. * test-suite/tests/unif.test: Update to use (srfi srfi-4 gnu). * libguile/bytevectors.c (bytevector_ref_c32, bytevector_ref_c64) (bytevector_set_c32, bytevector_set_c64): Fix some embarrassing bugs. Still need to do an upper bounds check. * libguile/deprecated.h: Remove deprecated array functions: scm_i_arrayp, scm_i_array_ndim, scm_i_array_mem, scm_i_array_v, scm_i_array_base, scm_i_array_dims, and the deprecated macros: SCM_ARRAYP, SCM_ARRAY_NDIM, SCM_ARRAY_CONTP, SCM_ARRAY_MEM, SCM_ARRAY_V, SCM_ARRAY_BASE, SCM_ARRAY_DIMS. * libguile/deprecated.c (scm_uniform_vector_read_x) (scm_uniform_vector_write, scm_uniform_array_read_x) (scm_uniform_array_write): Newly deprecated functions. * libguile/generalized-arrays.c (scm_array_type): Remove the bytevector hack. * libguile/objcodes.c (scm_bytecode_to_objcode, scm_objcode_to_bytecode): Rework to operate on bytevectors, as scm_make_u8vector now causes a module lookup, which can't be done e.g. when loading the VM boot program for psyntax-pp.go on a fresh bootstrap. * libguile/objcodes.h (SCM_F_OBJCODE_IS_BYTEVECTOR): (SCM_OBJCODE_IS_BYTEVECTOR): s/U8VECTOR/BYTEVECTOR/. * module/ice-9/boot-9.scm (the-scm-module): A terrible hack to pull in (srfi srfi-4), as the bindings are primarily there now. We'll worry about this later.
2009-12-15Don't use GCC zero-length arrays.Ludovic Courtès1-8/+10
* libguile/frames.c, libguile/objcodes.c, libguile/programs.c, libguile/vm-engine.c, libguile/vm-i-system.c, libguile/vm.c: Use `SCM_C_OBJCODE_BASE ()' instead of accessing the `base' field of `struct scm_objcode'. * libguile/objcodes.h (struct scm_objcode)[base]: Remove.
2009-11-28Remove remaining uses of discouraged constructs.Ludovic Courtès1-1/+1
* libguile/frames.c, libguile/instructions.c, libguile/objcodes.c, libguile/programs.c, libguile/throw.c, libguile/vm-i-scheme.c, libguile/vm.c: Replace uses of discouraged constructs by their current counterparts.
2009-11-16Use Gnulib's `alignof' module.Ludovic Courtès1-3/+3
* m4/gnulib-cache.m4: Use `alignof'. * libguile/objcodes.c (scm_c_make_objcode_slice): Use `alignof_type'.
2009-09-01Fix leaky behavior of `scm_take_TAGvector ()'.Ludovic Courtès1-2/+2
* libguile/srfi-4.c (free_user_data): New function. * libguile/srfi-4.i.c (scm_take_TAGvector): Register `free_user_data ()' as a finalizer for DATA. * libguile/objcodes.c (scm_objcode_to_bytecode): Allocate with `scm_malloc ()' since the memory taken by `scm_take_u8vector ()' will eventually be free(3)d. * libguile/vm.c (really_make_boot_program): Likewise.
2009-08-18Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-63/+64
Conflicts: lib/Makefile.am libguile/Makefile.am libguile/frames.c libguile/gc-card.c libguile/gc-freelist.c libguile/gc-mark.c libguile/gc-segment.c libguile/gc_os_dep.c libguile/load.c libguile/macros.c libguile/objcodes.c libguile/programs.c libguile/strings.c libguile/vm.c m4/gnulib-cache.m4 m4/gnulib-comp.m4 m4/inline.m4
2009-08-13Uncomment run-time objcode alignment check.Ludovic Courtès1-4/+4
This should now work thanks to the changes in 28b119ee3da0f4b14cb87e638794d22843778cda ("make sure all programs are 8-byte aligned"). This commit is a follow-up to ec99fe8ecb412e49e8e981246eb62ca46b32754b ("Add FIXMEs about misaligned objcode-metas."). * libguile/objcodes.c (scm_c_make_objcode_slice): Uncomment assertion that checks for proper alignment of PTR. * module/language/assembly/compile-bytecode.scm (write-bytecode): Update comment about META's alignment.
2009-08-11include objcode cookie in the fallback pathAndy Wingo1-28/+9
* libguile/_scm.h (SCM_OBJCODE_COOKIE): Move the objcode cookie define here, so that load.c can use it. This is a private header. * libguile/load.c (FALLBACK_DIR): Include the objcode cookie in the fallback path. Should fix problems when objcode changes incompatibly during the 1.9 series. * libguile/objcodes.c: Adapt to SCM_OBJCODE_COOKIE move. This should fix http://article.gmane.org/gmane.lisp.guile.devel/9059.
2009-07-26increase range of relative jumps by aligning blocks to 8-byte boundariesAndy Wingo1-1/+1
* libguile/objcodes.c (OBJCODE_COOKIE): Bump again, as our jump offsets are now multiplied by 8. * libguile/vm-i-system.c (BR): Interpret the 16-bit offset as a relative jump to the nearest 8-byte-aligned block -- increasing relative jump range from +/-32K to +/-240K. (mvra): Do the same for the mvra jump. * libguile/vm.c (really_make_boot_program): Align the mvra. * module/language/assembly.scm (align-block): New export, for aligning blocks. * module/language/assembly/compile-bytecode.scm (write-bytecode): Emit jumps to the nearest 8-byte-aligned block. Effectively our range is 18 bits in either direction. I would like to do this differently -- have long-br and long-br-if, and all the other br instructions go to 8 bits only. But the assembler doesn't have an appropriate representation to allow me to do this yet, so for now this is what we have. * module/language/assembly/decompile-bytecode.scm (decode-load-program): Decode the 19-bit jumps.
2009-07-26make sure all programs are 8-byte alignedAndy Wingo1-1/+1
* libguile/objcodes.c (OBJCODE_COOKIE): Bump objcode cookie, as we added to struct scm_objcode. * libguile/objcodes.h (struct scm_objcode): Add a uint32 after metalen and before base, so that if the structure has 8-byte alignment, base will have 8-byte alignment too. (Before, base was 12 bytes from the start of the structure, now it's 16 bytes.) * libguile/vm-engine.h (ASSERT_ALIGNED_PROCEDURE): Add a check that can be turned on with VM_ENABLE_PARANOID_ASSERTIONS. (CACHE_PROGRAM): Call ASSERT_ALIGNED_PROCEDURE. * libguile/vm-i-system.c (long-local-ref): Add a missing semicolon. * libguile/vm.c (really_make_boot_program): Rework to operate directly on a malloc'd buffer, so that the program will be 8-byte aligned. * module/language/assembly.scm (*program-header-len*): Add another 4 for the padding. (object->assembly): Fix case in which we would return (make-int8 0) instead of (make-int8:0). This would throw off compile-assembly.scm's use of addr+. * module/language/assembly/compile-bytecode.scm (write-bytecode): Write out the padding int. * module/language/assembly/decompile-bytecode.scm (decode-load-program): And pop off the padding int too. * module/language/glil/compile-assembly.scm (glil->assembly): Don't pack the assembly, assume that assembly.scm has done it for us. If a program has a meta, pad out the program so that meta will be aligned. * test-suite/tests/asm-to-bytecode.test: Adapt to expect programs to have the extra 4-byte padding int.
2009-07-21renumber vm ops (objcode cookie bumped)Andy Wingo1-1/+1
* libguile/objcodes.c (OBJCODE_COOKIE): Bump. * libguile/vm-i-loader.c: * libguile/vm-i-scheme.c: * libguile/vm-i-system.c: Renumber instructions, so I can have a bit more space to work.
2009-07-15Add FIXMEs about misaligned objcode-metas.Ludovic Courtès1-0/+6
* libguile/objcodes.c (scm_c_make_objcode_slice): Add comment about misaligned `objcode-meta'. * module/language/assembly/compile-bytecode.scm (write-bytecode): Likewise.
2009-07-15Const-qualify buffers passed to `scm_c_make_objcode_slice ()'.Ludovic Courtès1-2/+2
* libguile/objcodes.c (scm_c_make_objcode_slice): Add `const' qualifier for PTR and DATA. * libguile/objcodes.h: Update accordingly.
2009-07-15Fix typo in the compile-type verification of `OBJCODE_COOKIE'.Ludovic Courtès1-1/+1
* libguile/objcodes.c: Fix `sizeof (OBJCODE_COOKIE)' assertion: the trailing 0 must not be taken into account, and multiple of 8 means the 3 LSBs are clear.
2009-07-15Make sure at compile-time that `OBJCODE_COOKIE' has the right size.Ludovic Courtès1-1/+7
* libguile/objcodes.c: Use `verify' to assert that the size of `OBJCODE_COOKIE' is a multiple of 8.
2009-07-15Augment `OBJCODE_COOKIE' to detect wrong endianness or word size.Ludovic Courtès1-1/+15
* libguile/objcodes.c (OBJCODE_ENDIANNESS, _OBJCODE_STRINGIFY, OBJCODE_STRINGIFY, OBJCODE_WORD_SIZE): New macros. (OBJCODE_COOKIE): Use them. The intent is that `.go' files compiled for a different endianness or word size are detected.
2009-07-02fix error message for bad objcode cookieAndy Wingo1-3/+3
* libguile/objcodes.c: Whoop-dee :)