summaryrefslogtreecommitdiff
path: root/libguile/vm-i-scheme.c
AgeCommit message (Collapse)AuthorFilesLines
2013-11-08Remove stack programs, objcode, and the old VM.Andy Wingo1-1126/+0
* libguile/Makefile.am: * libguile/vm-i-loader.c: * libguile/vm-i-scheme.c: * libguile/vm-i-system.c: Remove the old VM files, and the rules to build the .i files. * libguile/vm-engine.c: * libguile/vm.c: Remove the old VM. Woot! * libguile/_scm.h (SCM_OBJCODE_COOKIE, SCM_OBJCODE_ENDIANNESS_OFFSET) (SCM_OBJCODE_WORD_SIZE_OFFSET): Remove. * libguile/evalext.c (scm_self_evaluating_p): Remove objcode and program cases. * libguile/frames.c (scm_frame_num_locals, scm_frame_previous): Remove program cases. * libguile/gc.c (scm_i_tag_name): Remove objcode case. * libguile/goops.c (scm_class_of, create_standard_classes): Remove objcode and program cases. * libguile/instructions.h: * libguile/instructions.c (scm_instruction_list, scm_instruction_p) (scm_instruction_length, scm_instruction_pops, scm_instruction_pushes) (scm_instruction_to_opcode, scm_opcode_to_instruction): Remove old VM code. * libguile/objcodes.h: * libguile/objcodes.c: Remove the objcode data type, and handling for objcode files. * libguile/print.c: Remove objcode and program printers. * libguile/procprop.c: Remove program cases. * libguile/procs.c: * libguile/programs.h: * libguile/programs.c: Remove old program code. * libguile/smob.c: Remove objcodes include. * libguile/snarf.h: Remove static program defines. * libguile/stacks.c: Remove program case. * libguile/tags.h: Remove program and objcode tc7s. * module/ice-9/session.scm (procedure-arguments) * module/language/tree-il/analyze.scm (validate-arity) * module/statprof.scm (get-call-data, procedure=?) * module/system/vm/frame.scm (frame-bindings) (frame-call-representation): Remove old program cases. * module/system/repl/debug.scm (frame->module): Add a FIXME. * module/system/vm/instruction.scm: Remove old exports. * module/system/vm/program.scm: Remove old program code.
2013-08-06Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-46/+145
Conflicts: libguile/numbers.c libguile/vm-i-scheme.c
2013-08-06VM: ash: Use SCM_SRS and handle large right shift in fast path.Mark H Weaver1-6/+5
* libguile/vm-i-scheme.c (ash): Use SCM_SRS. Handle inum right shift by more than SCM_I_FIXNUM_BIT-1 bits in fast path.
2013-08-04VM: ASM_ADD and ASM_SUB for x86: clobber _CX not "rcx".Mark H Weaver1-2/+2
* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB): Clobber _CX not "rcx".
2013-08-04VM: Define ASM_MUL on ARM only if SMULL instruction is supported.Mark H Weaver1-1/+17
* libguile/vm-i-scheme.c (ASM_MUL): Define only if the target architecture is known to implement the SMULL instruction.
2013-08-04VM: Implement ASM_ADD, ASM_SUB, and ASM_MUL for ARM processors.Mark H Weaver1-0/+46
* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB, ASM_MUL): Implement for ARM.
2013-08-03VM: Avoid untagging inums in 'logand' and 'logior'.Mark H Weaver1-2/+4
* libguile/vm-i-scheme.c (logand, logior): Avoid untagging.
2013-08-03VM: Add ASM_MUL for x86.Mark H Weaver1-3/+27
* libguile/vm-i-scheme.c (ASM_MUL): New macro. (mul): Use ASM_MUL if available.
2013-08-03VM: Support 32-bit x86 in ASM_ADD and ASM_SUB.Mark H Weaver1-16/+24
* libguile/vm-i-scheme.c (_CX): New macro. (ASM_ADD, ASM_SUB): Replace references to "rcx" with _CX.
2013-08-03VM: Add "cc" to the clobber list of ASM_ADD and ASM_SUB.Mark H Weaver1-2/+2
* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB): Add "cc" to the clobber list. Suggested by Göran Weinholt <goran@weinholt.se>.
2013-08-03VM: Avoid overflow in ASM_ADD when the result is most-positive-fixnum.Mark H Weaver1-1/+1
* libguile/vm-i-scheme.c (ASM_ADD): Remove the tag from one of the operands before adding, to avoid overflow when the result is the most positive fixnum.
2013-08-03VM: Avoid signed overflows in 'add1' and 'sub1'.Mark H Weaver1-12/+14
* libguile/vm-i-scheme.c (INUM_STEP): New macro. (add1, sub1): Avoid signed overflows, and use INUM_STEP.
2013-08-03VM: Redefine INUM_MIN and INUM_MAX without assumptions.Mark H Weaver1-2/+4
* libguile/vm-i-scheme.c (INUM_MIN, INUM_MAX): Redefine to avoid assumptions about the representation of inums.
2013-07-16Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-2/+6
Conflicts: libguile/keywords.c libguile/vm.c
2013-07-14Fix VM 'ash' for right shifts by large amounts.Mark H Weaver1-2/+6
Fixes <http://bugs.gnu.org/14864>. Reported by Göran Weinholt <goran@weinholt.se>. * libguile/vm-i-scheme.c (ash): Fallback to 'scm_ash' for right shifts with counts >= SCM_I_FIXNUM_BIT, since '>>' is not guaranteed to work correctly for large counts.
2013-05-27cpp hygiene in the vmAndy Wingo1-6/+18
* 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-23remove CONS macro in VM; use scm_cons insteadAndy Wingo1-1/+2
* 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-01-23merge stable-2.0Andy Wingo1-2/+2
There are some bugs with command-line handling that will be sorted out with the next commit.
2013-01-22fix compilation of glil to assemblyAndy Wingo1-2/+2
* libguile/vm-i-scheme.c (VM_VALIDATE_STRUCT): Fix the error message if the value was not a struct. * module/system/base/compile.scm (find-language-joint): Default to joining at the target language. (default-language-joiner): Allow sequences of one compiled expression to pass through. Otherwise error as before. (read-and-parse): New helper; actually parses. (read-and-compile): Use read-and-parse, and fall back to default-language-joiner. Thanks to Nala Ginrut for the report.
2012-04-30Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-22/+4
Conflicts: libguile/vm-engine.c libguile/vm-i-system.c
2012-04-30push error handlers out of line in the vmAndy Wingo1-22/+4
* libguile/vm.c: (vm_error): (vm_error_bad_instruction): (vm_error_unbound): (vm_error_unbound_fluid): (vm_error_not_a_variable): (vm_error_not_a_thunk): (vm_error_apply_to_non_list): (vm_error_kwargs_length_not_even): (vm_error_kwargs_invalid_keyword): (vm_error_kwargs_unrecognized_keyword): (vm_error_too_many_args): (vm_error_wrong_num_args): (vm_error_wrong_type_apply): (vm_error_stack_overflow): (vm_error_stack_underflow): (vm_error_improper_list): (vm_error_not_a_pair): (vm_error_not_a_bytevector): (vm_error_not_a_struct): (vm_error_no_values): (vm_error_not_enough_values): (vm_error_continuation_not_rewindable): (vm_error_bad_wide_string_length): (vm_error_invalid_address): (vm_error_object): (vm_error_free_variable): New internal helpers, implementing VM error handling. * libguile/vm-engine.h (VM_ASSERT): New helper macro. (ASSERT, CHECK_OBJECT, CHECK_FREE_VARIABLE): (PRE_CHECK_UNDERFLOW, PUSH_LIST): Use the new helper. * libguile/vm-i-loader.c: * libguile/vm-i-scheme.c: * libguile/vm-i-system.c: Use VM_ASSERT and the out-of-line error handlers. * libguile/vm-engine.c (vm_engine): Remove inline error handlers, and remove a couple of local vars. Use VM_ASSERT. Have halt handle the return itself.
2012-03-05Merge branch 'bt/elisp'BT Templeton1-79/+91
Conflicts: am/guilec libguile/_scm.h libguile/vm-i-scheme.c module/language/elisp/compile-tree-il.scm module/language/elisp/runtime.scm module/language/elisp/runtime/macros.scm module/language/tree-il/compile-glil.scm module/language/tree-il/primitives.scm
2012-02-03add `nil?' primitiveBT Templeton1-76/+88
* libguile/boolean.c (scm_nil_p): New function. * libguile/vm-i-scheme.c (nilp, not_nilp): * libguile/vm-i-system.c (br_if_nil, br_if_not_nil): New instructions. Renumber other ops. * libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Increment. * module/language/assembly/compile-bytecode.scm (compile-bytecode): Add support for writing `br-if-nil' and `br-if-not-nil' instructions. * module/language/assembly/disassemble.scm (code-annotation): Add `br-if-nil' and `br-if-not-nil' to the list of branch instructions. * module/language/tree-il/compile-glil.scm: Add `nil?' to `*primcall-ops*'. (flatten): Use the new branch instructions for `nil?' conditionals. * module/language/tree-il/primitives.scm: Add `nil?' to `*interesting-primitive-names*', `*effect-free-primitives', and `*effect+exception-free-primitives*'.
2012-01-29Revert "vm-i-scheme.c slight refactor"Andy Wingo1-125/+45
This reverts commit c0e4449908eee84bcb293ec21c10fec646bde45d. This refactor was needed for the introduction of DEAD(), which does not appear to have been necessary.
2012-01-29Revert "attempt to clear stale references on VM C stack"Andy Wingo1-120/+2
This reverts commit 04b2d773548c57b6eadd1808a8d15cce47af9630. Since it wasn't fixing the "lexical vars are collectable" test, it added complexity with no benefit.
2012-01-27attempt to clear stale references on VM C stackAndy Wingo1-2/+120
* libguile/vm-engine.h (DEAD): New macro, nulls out a value. * libguile/vm-i-system.c: * libguile/vm-i-loader.c: * libguile/vm-i-scheme.c: Use DEAD when variables become dead. Later we can #ifdef this out, but I want to give the buildbots a try with this patch to make sure it's correct.
2012-01-27vm-i-scheme.c slight refactorAndy Wingo1-45/+125
* libguile/vm-i-scheme.c: Refactor the RETURN macro to not include NEXT. Adapt all uses to NEXT on their own.
2011-12-19Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-1/+1
Conflicts: libguile/feature.c m4/gnulib-cache.m4 module/ice-9/deprecated.scm module/language/tree-il/peval.scm
2011-12-14Use `alignof_type' instead of `alignof'.Ludovic Courtès1-1/+1
* libguile/foreign.c: Use `alignof_type' instead of `alignof'; the latter was removed from Gnulib's <alignof.h> in 408e170e3ae81f73fb65686c5834693d89a96594 (Nov. 1 2011). * libguile/vm-i-scheme.c: Likewise.
2011-10-28add string-length, string-ref, vector-length instructionsAndy Wingo1-47/+94
* libguile/_scm.h (SCM_OBJCODE_MAJOR_VERSION): Bump the major version, indicating the first incompatibility between 2.0 and 2.2. * libguile/vm-i-scheme.c (string-length, string-ref, vector-length): New instructions. * module/language/tree-il/compile-glil.scm (*primcall-ops*): Add primcall ops for the new instructions.
2011-05-13more care regarding SCM_PACK and SCM_UNPACKAndy Wingo1-15/+15
* libguile/control.c (reify_partial_continuation): * libguile/eval.c (RETURN_BOOT_CLOSURE): * libguile/frames.c (scm_frame_num_locals, scm_frame_local_ref) (scm_frame_local_set_x) * libguile/frames.h (SCM_FRAME_SET_RETURN_ADDRESS): (SCM_FRAME_SET_MV_RETURN_ADDRESS, SCM_FRAME_SET_DYNAMIC_LINK): * libguile/goops.c (scm_class_of, scm_primitive_generic_generic) (scm_c_extend_primitive_generic, compute_getters_n_setters) (scm_sys_initialize_object): * libguile/guardians.c (finalize_guarded): * libguile/list.c (SCM_I_CONS): * libguile/macros.c (scm_i_make_primitive_macro) (scm_make_syntax_transformer): * libguile/memoize.c (MAKMEMO, SCM_MAKE_MEMOIZER) (SCM_MAKE_REST_MEMOIZER): * libguile/modules.c (scm_module_reverse_lookup) * libguile/print.c (iprin1): * libguile/promises.c (scm_make_promise) * libguile/srcprop.c (scm_make_srcprops): * libguile/vectors.c (scm_c_vector_ref): * libguile/vm-engine.c (vm_engine) * libguile/vm-i-scheme.c (REL, add1, sub1): * libguile/vm-i-system.c (new_frame, call_cc) * libguile/weaks.h (SCM_WEAK_PAIR_WORD_DELETED_P): Be more careful about SCM_PACK / SCM_UNPACK.
2011-05-05VM tweaksAndy Wingo1-13/+9
* libguile/vm-engine.c (VM_CHECK_OBJECT, VM_CHECK_FREE_VARIABLES): Set to 0 for both engines. These are really internal debugging variables, which don't affect user-visible features, provided that the compiler is correct of course. (VM_CHECK_UNDERFLOW): New var, also off by default: whether to check for stack underflow when popping values. (vm_engine): Don't declare object_count if we are not checking object table accesses. * libguile/vm-engine.h (CACHE_PROGRAM): Don't muck with object_count if we are not checking object table accesses. (CHECK_UNDERFLOW, PRE_CHECK_UNDERFLOW): Nop out if we are not checking underflow. (POP2, POP3): New macros which check for underflow before popping more than one value. * libguile/vm-i-loader.c (load_array): * libguile/vm-i-scheme.c (set_car, set_cdr, vector_set, slot_set) (BV_SET_WITH_ENDIANNESS, BV_FIXABLE_INT_SET, BV_INT_SET) (BV_FLOAT_SET): * libguile/vm-i-system.c (partial_cont_call, fix_closure, prompt) (fluid_set): Use POP2 / POP3. (local_set, long_local_set): Pop to locals instead of using values on the stack then dropping; allows for underflow to be checked before the value is accessed. (BR): Don't NULLSTACK or DROP after the operation. (br_if, br_if_not, br_if_eq, br_if_not_eq, br_if_null) (br_if_not_null): Pop to locals before doing the compare and jump.
2011-03-23fix a failure to sync regs in vm bytevector opsAndy Wingo1-22/+32
* libguile/vm-i-scheme.c (BV_SET_WITH_ENDIANNESS, BV_FIXABLE_INT_SET) (BV_INT_SET, BV_FLOAT_SET): Sync registers before dispatching to the C function.
2010-11-19fix a number of assuptions that a long could hold an inumAndy Wingo1-10/+16
* libguile/bytevectors.c: * libguile/goops.c: * libguile/instructions.c: * libguile/numbers.c: * libguile/random.c: * libguile/read.c: * libguile/vm-i-scheme.c: Fix a number of assumptions that a long could hold an inum. This is not the case on platforms whose void* is larger than their long. * libguile/numbers.c (scm_i_inum2big): New helper, only implemented for sizeof(void*) == sizeof(long); produces a compile error on other platforms. Basically gmp doesn't have a nice interface for converting between mpz values and intmax_t.
2010-11-19Optimize fixnum comparison.Ludovic Courtès1-3/+4
* libguile/vm-i-scheme.c (REL): Don't untag X and Y since tagging preserves ordering.
2010-11-19Add optimized tagged integer addition/subtractions for x86_64.Ludovic Courtès1-0/+71
This results in a 17% improvement in the execution time of the "+" and "-" benchmarks for fixnums. * libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB)[defined __x86_64__ && SCM_GNUC_PREREQ (4, 5)]: New macros. (add)[defined ASM_ADD]: Use `ASM_ADD' for the fast path. (sub)[defined ASM_SUB]: Use `ASM_SUB' for the fast path. * test-suite/tests/numbers.test ("+")["fixnum + fixnum = bignum (32-bit)", "fixnum + fixnum = bignum (64-bit)", "bignum + fixnum = fixnum", "wrong type"]: New tests. ("-")["fixnum - fixnum = bignum (32-bit)", "fixnum - fixnum = bignum (64-bit)", "bignum - fixnum = fixnum", "wrong type"]: New tests. * test-suite/tests/00-initial-env.test ("goopsless")["+ wrong type argument"]: Use `with-test-prefix/c&e' instead of `with-test-prefix'. ["- wrong type argument"]: New test prefix.
2010-10-13Optimize `1+' and `1-' on fixnums.Ludovic Courtès1-8/+30
* libguile/vm-i-scheme.c (INUM_MAX, INUM_MIN): New macros. (add1, sub1): Add/subtract without untagging the operand. This leads to a 44% run time improvement compared to the previous implementation. * libguile/vm.c: Include <stdint.h>. * test-suite/tests/numbers.test ("1+", "1-"): Add tests for MOST-POSITIVE-FIXNUM, resp. MOST-NEGATIVE-FIXNUM, for 32-bit and 34-bit values thereof. * benchmark-suite/benchmarks/arithmetic.bm: New file. * benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add it.
2010-10-08inline symbol? and vector? to opcodes, and a psyntax inlining tweakAndy Wingo1-70/+82
* libguile/vm-i-scheme.c (symbol?, vector?): New instructions. Renumbered the rest. * libguile/vm-i-system.c: Renumber instructions. * libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump. * module/ice-9/psyntax.scm (binding-type, binding-value): Define using macros so that we inline to car and cdr opcodes. Oh, for an inliner :) * module/language/tree-il/compile-glil.scm (*primcall-ops*) * module/language/tree-il/primitives.scm (*interesting-primitive-names*, *effect-free-primitives*) (*effect+exception-free-primitives*): Add symbol? and vector? inlines.
2010-07-15better error reporting from the vmAndy Wingo1-15/+18
* libguile/vm-engine.c: Add func_name local, for error reporting. (vm_error_apply_to_non_list): New error case. (vm_error_wrong_type_arg): Remove this generic error case. (vm_error_wrong_type_apply): Remove FUNC_NAME -- no sense in seeing "vm-debug-engine" in the error report. (vm_error_not_a_pair, vm_error_not_a_bytevector) (vm_error_not_a_struct, vm_error_not_a_thunk): Use func_name instead of FUNC_NAME, so we can indicate what caused the error. * libguile/vm-i-scheme.c (VM_VALIDATE_CONS, car, cdr, set-car!) (set-cdr!): Indicate provenance of errors. (VM_VALIDATE_STRUCT, struct-vtable): (VM_VALIDATE_BYTEVECTOR, BV_FIXABLE_INT_REF, BV_INT_REF) (BV_FLOAT_REF, BV_FIXABLE_INT_SET, BV_INT_SET, BV_FLOAT_SET): Same. * libguile/vm-i-system.c (apply, tail-apply): Use vm_error_apply_to_non_list.
2010-06-01Fix `VM_VALIDATE_BYTEVECTOR' macro wrt. trailing semicolons.Ludovic Courtès1-5/+10
* libguile/vm-i-scheme.c (VM_VALIDATE_BYTEVECTOR): Enclose in "do { } while (0)".
2010-06-01Fix unaligned accesses by the bytevector instructions.Ludovic Courtès1-59/+96
* libguile/vm-i-scheme.c (ALIGNED_P): New macro. (BV_FIXABLE_INT_REF, BV_INT_REF, BV_FLOAT_REF, BV_FIXABLE_INT_SET, BV_INT_SET, BV_FLOAT_SET): Check the alignment of the pointer instead of checking "i % size == 0". This fixes bus errors on `sparc64-linux-gnu'. * libguile/vm.c: Include <alignof.h>.
2010-05-02add underflow check in make-arrayAndy Wingo1-0/+1
* libguile/vm-i-scheme.c (make-array): Check for underflow before making the array.
2010-05-01simplify make-structAndy Wingo1-2/+1
* libguile/vm-i-scheme.c: Use DROPN idiom.
2010-05-01optimize and bugfix make-struct VM opcodeAndy Wingo1-22/+20
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump for make-struct change. * libguile/struct.c (scm_i_alloc_struct): Use scm_words instead of scm_gc_malloc to simplify the code and inline the call to GC_MALLOC. * module/language/tree-il/compile-glil.scm (*primcall-ops*): Compile make-struct/no-tail to make-struct. * module/language/tree-il/primitives.scm (define-primitive-expander): Allow a conditional branch of #f to aboirt inlining. (make-struct): Expand into make-struct/no-tail in the case that tail-size is 0. * libguile/vm-i-scheme.c (make-struct): Adapt to always assume tail-size is 0. Inline allocation if possible. Don't decrement the SP past live objects on the stack, which could cause GC to miss references. Use the NULLSTACK macro.
2010-04-08sync regs before calling scm_class_ofAndy Wingo1-1/+4
* libguile/vm-i-scheme.c (class-of): Sync registers before calling scm_class_of.
2010-04-01fix vector-ref and vector-set opcodes for weak vectorsAndy Wingo1-2/+2
* libguile/vectors.h (SCM_I_IS_NONWEAK_VECTOR): New internal predicate. * libguile/vm-i-scheme.c (vector-ref, vector-set): Only inline access to nonweak vectors.
2010-03-31fix bug in ash opcodeAndy Wingo1-3/+16
* libguile/vm-i-scheme.c (ash): Fix embarrassing bug in (ash 1 32). * test-suite/tests/bit-operations.test ("bitshifts on word boundaries"): Add tests.
2010-03-30nil is null, wheeAndy Wingo1-4/+4
* libguile/pairs.h (scm_is_null): Nil is also null. * libguile/vm-i-scheme.c (not, not-not, null?, not-null?): * libguile/vm-i-system.c (br-if-null, br-if-not-null): Remove some more nil special cases.
2010-03-15Make sure the whole VM stack is always scanned by the GC.Ludovic Courtès1-45/+59
Thanks to Andy for noticing this. * libguile/vm-engine.h (SYNC_REGISTER, CACHE_REGISTER): Add comment. * libguile/vm-i-scheme.c (make_struct): Call `SYNC_REGISTER ()' in all cases since the GC is going to run. (struct_ref, struct_set): Call `SYNC_REGISTER ()' on the slow path. (BV_REF_WITH_ENDIANNESS, BV_FIXABLE_INT_REF, BV_INT_REF): Likewise. (BV_FLOAT_REF): Always `SYNC_REGISTER ()'.
2010-01-26renumber VM opcodesAndy Wingo1-223/+236
* libguile/vm-i-loader.c: * libguile/vm-i-scheme.c: * libguile/vm-i-system.c: Renumber ops. Add a foreign-call op stub. Rearrange some ops. * libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump