Andy Wingo [Fri, 19 Jul 2013 07:55:20 +0000 (09:55 +0200)]
rtl: propagate OP_DST to scheme
* libguile/instructions.c (scm_rtl_instruction_list): Add an element to
the list to indicate that an instruction outputs to its first
argument.
* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm: Adapt.
Andy Wingo [Fri, 19 Jul 2013 14:21:18 +0000 (16:21 +0200)]
free variable debugging access procedures for rtl
* libguile/programs.c (scm_program_num_free_variables)
(scm_program_free_variable_ref, scm_program_free_variable_set_x): Add
support for RTL programs.
Andy Wingo [Fri, 19 Jul 2013 14:19:34 +0000 (16:19 +0200)]
fix rtl program arity functions
* libguile/programs.c (parse_arity): Lookup rtl-program-minimum-arity
from (system vm debug).
* module/system/vm/debug.scm (find-first-arity): Fix the linear search.
Whoops!
Mark H Weaver [Thu, 18 Jul 2013 19:31:34 +0000 (15:31 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Thu, 18 Jul 2013 18:10:43 +0000 (14:10 -0400)]
Modify SCM_UNPACK type check to avoid warnings in clang.
* libguile/tags.h (SCM_UNPACK): Change (*(SCM*)0=(x)) to
(*(volatile SCM *)0=(x)), to avoid null-dereference warnings
from clang. Reported by Shane Celis <shane.celis@gmail.com>.
Ludovic Courtès [Wed, 17 Jul 2013 15:57:43 +0000 (17:57 +0200)]
Fix 'SCM_SYSCALL' to really swallow EINTR.
* libguile/_scm.h (SCM_SYSCALL): Keep looping upon EINTR.
Reported at
<http://lists.gnu.org/archive/html/guile-devel/2013-06/msg00050.html>.
Ludovic Courtès [Wed, 17 Jul 2013 13:11:51 +0000 (15:11 +0200)]
build: Add `gdbinit' to the distribution.
* Makefile.am (EXTRA_DIST): Add gdbinit.
Mark H Weaver [Fri, 7 Jun 2013 04:47:33 +0000 (00:47 -0400)]
Add support for HTTP proxies.
* module/web/http.scm (http-proxy-port?, set-http-proxy-port?!): New
exported procedures.
(write-request-line): If we're using an http proxy, write an
absolute-URI in the request line.
* module/web/client.scm: Import (web http).
(current-http-proxy): New exported parameter.
(open-socket-for-uri): If 'current-http-proxy' is not false,
connect to the proxy instead of the URI host, and use
'set-http-proxy-port?!' to make note of that fact.
* doc/ref/web.texi (Web Client): Document 'current-http-proxy'.
Mark H Weaver [Tue, 16 Jul 2013 21:38:14 +0000 (17:38 -0400)]
Fix R6RS 'fixnum-width'.
Fixes <http://bugs.gnu.org/14879>.
Reported by Göran Weinholt <goran@weinholt.se>.
* module/rnrs/arithmetic/fixnums.scm (fixnum-width): Rewrite to avoid
inexact arithmetic, and correct the off-by-one error.
* test-suite/tests/r6rs-arithmetic-fixnums.test (fixnum-width): Add
tests.
Mark H Weaver [Tue, 16 Jul 2013 16:12:25 +0000 (12:12 -0400)]
Update copyright dates of recently-changed R6RS bitwise/flonums files.
* module/rnrs/arithmetic/bitwise.scm:
module/rnrs/arithmetic/flonums.scm:
test-suite/tests/r6rs-arithmetic-bitwise.test:
test-suite/tests/r6rs-arithmetic-flonums.test: Add 2013 to the
copyright dates.
Mark H Weaver [Tue, 16 Jul 2013 16:06:45 +0000 (12:06 -0400)]
Fix 'fxbit-count' for negative arguments.
Reported by Göran Weinholt <goran@weinholt.se>.
* module/rnrs/arithmetic/fixnums.scm (fxbit-count): If the argument is
negative, return the 'bitwise-not' of the result of 'logcount', as per
R6RS. Previously, 'fxbit-count' was identical to 'logcount'.
* test-suite/tests/r6rs-arithmetic-fixnums.test (fxbit-count): Add test.
Mark H Weaver [Tue, 16 Jul 2013 10:49:20 +0000 (06:49 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
libguile/numbers.c
Mark H Weaver [Tue, 16 Jul 2013 10:38:38 +0000 (06:38 -0400)]
gcd and lcm support inexact integer arguments.
Fixes <http://bugs.gnu.org/14870>.
Reported by Göran Weinholt <goran@weinholt.se>.
* libguile/numbers.c (scm_gcd, scm_lcm): Support inexact integers.
* test-suite/tests/numbers.test (gcd, lcm): Add tests.
Mark H Weaver [Tue, 16 Jul 2013 09:18:15 +0000 (05:18 -0400)]
min and max: NaNs beat infinities, per R6RS errata.
Fixes <http://bugs.gnu.org/14865>.
Reported by Göran Weinholt <goran@weinholt.se>.
* libguile/numbers.c (scm_min, scm_max): NaNs beat infinities, as per
the R6RS errata.
* test-suite/tests/numbers.test (min, max): Update tests.
Mark H Weaver [Tue, 16 Jul 2013 08:43:07 +0000 (04:43 -0400)]
Flonum operations always return flonums.
Fixes <http://bugs.gnu.org/14871>.
Reported by Göran Weinholt <goran@weinholt.se>.
* module/rnrs/arithmetic/flonums.scm (ensure-flonum): New procedure.
(fllog): Rewrite using case-lambda. Handle negative zeroes. Use
'ensure-flonum'.
(flatan): Rewrite using case-lambda.
(flasin, flacos, flsqrt, flexpt): Use 'ensure-flonum'.
* test-suite/tests/r6rs-arithmetic-flonums.test
(fllog, flasin, flacos, flsqrt, flexpt): Add tests.
Mark H Weaver [Tue, 16 Jul 2013 07:42:52 +0000 (03:42 -0400)]
flfinite? applied to a NaN returns false.
Fixes <http://bugs.gnu.org/14868>.
Reported by Göran Weinholt <goran@weinholt.se>.
* module/rnrs/arithmetic/flonums.scm (flfinite?): If the argument is a
NaN, return false.
* test-suite/tests/r6rs-arithmetic-flonums.test (flfinite?): Add test.
Mark H Weaver [Tue, 16 Jul 2013 07:38:27 +0000 (03:38 -0400)]
flonum? returns false for complex number objects.
Fixes <http://bugs.gnu.org/14866>.
Reported by Göran Weinholt <goran@weinholt.se>.
* module/rnrs/arithmetic/flonums.scm (flonum?): Use 'real?' instead of
'number?'.
* test-suite/tests/r6rs-arithmetic-flonums.test (flonum?): Add tests.
Mark H Weaver [Tue, 16 Jul 2013 07:33:02 +0000 (03:33 -0400)]
Allow fl+ and fl* to accept zero arguments.
Fixes <http://bugs.gnu.org/14869>.
Reported by Göran Weinholt <goran@weinholt.se>.
* module/rnrs/arithmetic/flonums.scm (fl+, fl*): Accept zero arguments.
* test-suite/tests/r6rs-arithmetic-flonums.test (fl+, fl*): Add tests.
Mark H Weaver [Tue, 16 Jul 2013 05:48:19 +0000 (01:48 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Tue, 16 Jul 2013 05:46:05 +0000 (01:46 -0400)]
numbers.test: Fix inum/flonum comparison test on 32-bit machines.
* test-suite/tests/numbers.test (<): Fix inum/flonum test.
Mark H Weaver [Tue, 16 Jul 2013 05:33:27 +0000 (01:33 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
libguile/keywords.c
libguile/vm.c
Mark H Weaver [Tue, 16 Jul 2013 04:26:11 +0000 (00:26 -0400)]
Avoid lossy conversion from inum to double in numerical comparisons.
* libguile/numbers.c (scm_less_p): Avoid converting inums to doubles.
* test-suite/tests/numbers.test (<): Add tests.
Mark H Weaver [Tue, 16 Jul 2013 04:22:10 +0000 (00:22 -0400)]
numbers.test: Avoid inexact arithmetic in computation of fixnum-bit.
* test-suite/tests/numbers.test (fixnum-bit): Rewrite to avoid
inexact arithmetic.
Mark H Weaver [Tue, 16 Jul 2013 04:18:40 +0000 (00:18 -0400)]
Fix bugs in numerical equality predicate.
* libguile/numbers.c (scm_num_eq_p): Fix bug comparing fractions to
infinities (reported by Göran Weinholt <goran@weinholt.se>). Fix
erroneous comment describing the logic behind inum/flonum comparison.
Use similar logic for inum/complex comparison to avoid rounding
errors. Make minor indentation fixes and simplifications.
* test-suite/tests/numbers.test (=): Add tests.
Mark H Weaver [Tue, 16 Jul 2013 04:00:23 +0000 (00:00 -0400)]
Fix rounding in scm_i_divide2double for negative arguments.
* libguile/numbers.c (INUM_LOSSLESSLY_CONVERTIBLE_TO_DOUBLE):
New macro.
(scm_i_divide2double): Use INUM_LOSSLESSLY_CONVERTIBLE_TO_DOUBLE to
determine if our fast path is safe. Previously, negative arguments
were not checked properly.
* test-suite/tests/numbers.test (exact->inexact): Add tests.
Mark H Weaver [Sun, 14 Jul 2013 18:47:10 +0000 (14:47 -0400)]
Fix VM 'ash' for right shifts by large amounts.
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.
Mark H Weaver [Sun, 14 Jul 2013 18:08:33 +0000 (14:08 -0400)]
Fix 'bitwise-bit-count' for negative arguments.
Fixes <http://bugs.gnu.org/14864>.
Reported by Göran Weinholt <goran@weinholt.se>.
* module/rnrs/arithmetic/bitwise.scm (bitwise-bit-count): If the
argument is negative, return the 'bitwise-not' of the result of
'logcount', as per R6RS. Previously, 'bitwise-bit-count' was
identical to 'logcount'.
Andy Wingo [Sat, 6 Jul 2013 11:06:02 +0000 (20:06 +0900)]
<prompt> body and handler are lambdas; add escape-only? field
* module/language/tree-il.scm (<prompt>): Change to have the body and
handler be lambdas, and add an "escape-only?" field. This will make
generic prompts work better in CPS or ANF with the RTL VM, as it
doesn't make sense in that context to capture only part of a frame.
Escape-only prompts can still be fully inlined.
(parse-tree-il, unparse-tree-il): Add escape-only? to the
serialization.
(make-tree-il-folder, pre-post-order): Deal with escape-only?.
* module/language/tree-il/analyze.scm (analyze-lexicals): Handle
escape-only?, and the new expectations for the body and handler.
* module/language/tree-il/canonicalize.scm (canonicalize): Ensure that
the body of an escape-only continuation is a thunk, and that the
handler is always a lambda.
* module/language/tree-il/debug.scm (verify-tree-il): Assert that
escape-only? is a boolean.
* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
* test-suite/tests/peval.test ("partial evaluation"):
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Adapt
to <prompt> change.
Andy Wingo [Fri, 28 Jun 2013 18:01:35 +0000 (20:01 +0200)]
Simplify dynstack API to only wind one fluid at a time
* libguile/dynstack.h (SCM_DYNSTACK_TYPE_WITH_FLUID): Rename from
with-fluids.
* libguile/dynstack.c (scm_dynstack_push_fluid):
(scm_dynstack_unwind_fluid): Change API to only wind/unwind one
fluid binding.
(WITH_FLUID_WORDS): New define, always 2 words (fluid and value box).
(WITH_FLUID_FLUID, WITH_FLUID_VALUE_BOX): New macros to get offsets of
fluid and value box.
(scm_dynstack_push_rewinder, scm_dynstack_push_unwinder): Use
WINDER_WORDS.
(scm_dynstack_push_dynwind): Use DYNWIND_WORDS.
(scm_dynstack_wind_1): Update for scm_swap_fluid API change.
* libguile/fluids.h:
* libguile/fluids.c (scm_prepare_fluids): Remove; no longer needed.
(scm_swap_fluid): Update to just swap one fluid binding.
(scm_c_with_fluids, scm_c_with_fluid): Update to use
scm_dynstack_push_fluid.
* libguile/memoize.c (do_push_fluid, do_pop_fluid): Adapt to API
change.
* libguile/vm-engine.c (rtl_vm_engine): Change wind-fluids / unwind-fluids
to push-fluid / pop-fluid, and actually enable. Woo!
* libguile/vm-i-system.c (push-fluid, pop-fluid): Update to new API.
Andy Wingo [Fri, 28 Jun 2013 17:47:03 +0000 (19:47 +0200)]
Remove with-fluids; replaced by with-fluid* and inlined push-fluid primops
* libguile/vm-i-system.c (push-fluid, pop-fluid):
* doc/ref/vm.texi (Dynamic Environment Instructions): Rename wind-fluids
to push-fluid, and unwind-fluids to pop-fluid. They now only work on
one fluid binding at a time.
* module/ice-9/boot-9.scm (with-fluid*): Implement in Scheme in terms of
primcalls to push-fluid and pop-fluid.
(custom-throw-handler, catch, with-throw-handler): Use with-fluid*
instead of with-fluids, as with-fluids is no longer available before
psyntax is loaded.
(with-fluids): Define in Scheme in terms of with-fluid*.
* libguile/fluids.c (scm_with_fluid): Rename from scm_with_fluids, and
don't expose to Scheme.
* libguile/eval.c (eval): Remove SCM_M_WITH_FLUIDS case.
* libguile/expand.c (expand_with_fluids): Remove with-fluids syntax.
(DYNLET): Remove, no longer defining dynlet in the %expanded-vtables.
* libguile/expand.h: Remove dynlet definitions.
* module/ice-9/eval.scm (primitive-eval): Remove with-fluids case.
* libguile/memoize.c (do_push_fluid, do_pop_fluid): New primitive
helpers, like wind and unwind.
(memoize): Memoize wind and unwind primcalls. Don't memoize dynlet to
with-fluids.
(scm_init_memoize): Initialize push_fluid and pop_fluid here.
* libguile/memoize.h (SCM_M_WITH_FLUIDS): Remove definition.
* module/ice-9/psyntax.scm (build-dynlet): Remove; this just supported
with-fluids, which is now defined in boot-9.
* module/ice-9/psyntax-pp.scm: Regenerate.
* doc/ref/compiler.texi (Tree-IL):
* module/language/tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/canonicalize.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/cse.scm:
* module/language/tree-il/debug.scm:
* module/language/tree-il/effects.scm: Remove <dynlet>. Add cases for
primcalls to push-fluid and pop-fluid in compile-glil.scm and
effects.scm.
* module/language/tree-il/peval.scm (peval): Factor out
with-temporaries; probably a bad idea, but works for now. Factor out
make-begin0 (a better idea). Inline primcalls to with-fluid*, and
remove dynlet cases.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
Add with-fluid*.
Andy Wingo [Thu, 27 Jun 2013 17:38:32 +0000 (19:38 +0200)]
replace <dynset> with primcalls to fluid-set!
* doc/ref/compiler.texi (Tree-IL): Remove mention of <dynset>.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
(choose-output-names): Remove dynset.
* module/language/tree-il.scm (<tree-il>, parse-tree-il):
(unparse-tree-il, make-tree-il-folder, pre-post-order): Remove
<dynset>.
* module/language/tree-il/analyze.scm (analyze-lexicals):
* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
fluid-set!.
(flatten-lambda-case): Remove <dynset> case.
* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il): Remove <dynset>
cases.
* module/language/tree-il/effects.scm (make-effects-analyzer): Remove
<dynset> case. Add a primcall fluid-set! case.
* module/language/tree-il/peval.scm (peval): Remove dynset cases.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Remove fluid-set! -> dynset transformation.
Andy Wingo [Thu, 27 Jun 2013 17:28:42 +0000 (19:28 +0200)]
replace <dynref> with primcalls to fluid-ref
* doc/ref/compiler.texi (Tree-IL): Remove mention of <dynref>.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
(choose-output-names): Remove dynref.
* module/language/tree-il.scm (<tree-il>, parse-tree-il):
(unparse-tree-il, make-tree-il-folder, pre-post-order): Remove
<dynref>.
* module/language/tree-il/analyze.scm (analyze-lexicals):
* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
fluid-ref.
(flatten-lambda-case): Remove <dynref> case.
* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il): Remove <dynref>
cases.
* module/language/tree-il/effects.scm (make-effects-analyzer): Remove
<dynref> case. Add a primcall fluid-ref case.
* module/language/tree-il/peval.scm (peval): Remove dynref cases.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Remove fluid-ref -> dynref transformation.
Andy Wingo [Thu, 27 Jun 2013 16:49:21 +0000 (18:49 +0200)]
dynamic-wind in terms of wind and unwind; remove <dynwind>, @dynamic-wind
* doc/ref/compiler.texi: Remove mention of <dynwind>.
* libguile/eval.c (eval): Remove SCM_M_DYNWIND case.
* libguile/expand.c: Remove scm_sym_at_dynamic_wind.
* libguile/memoize.c (do_wind, do_unwind): A couple of hacky subrs. If
we see a wind or unwind primcall, we expand to a call of a quoted subr
value. It works and removes a kind of memoized value from the
interpreter. For the compiler,primcalls to wind and unwind are
handled specially.
(MAKMEMO_DYNWIND): Remove.
(scm_tc16_memoizer): Remove. Yay!
(memoize): Remove speculative lookup for toplevels to see if they are
memoizers: there are no more memoizers. Memoize calls to the wind and
unwind primitives.
(m_dynamic_wind): Remove.
(unmemoize): Remove dynwind case.
(scm_init_memoize): Add wind and unwind local definitions.
* module/ice-9/boot-9.scm (dynamic-wind): Reimplement in terms of "wind"
and "unwind" primitives. These primitives are not exposed to other
modules.
* module/ice-9/eval.scm (primitive-eval): Remove dynwind case.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
(choose-output-names): Remove dynwind cases.
* module/language/tree-il.scm: Remove <dynwind>. Yaaay!
* module/language/tree-il/analyze.scm (analyze-lexicals): Remove dynwind
cases.
* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add wind
and unwind.
(flatten-lambda-case): Remove dynwind case. Yay!
* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/peval.scm (singly-valued-expression?, peval):
Remove <dywind> cases. Inline primcalls to dynamic-wind. Add
constant folding for thunk?.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
Remove @dynamic-wind, and add procedure? and thunk?.
(*effect+exception-free-primitives*): Add procedure? and thunk?.
(*multiply-valued-primitives*): Remove @dynamic-wind.
Remove @dynamic-wind expander.
* test-suite/tests/peval.test ("partial evaluation"): Update tests for
dynwind desugaring.
Andy Wingo [Thu, 27 Jun 2013 10:20:36 +0000 (12:20 +0200)]
remove @call-with-values memoizer
* libguile/memoize.h:
* libguile/expand.c (scm_sym_at_call_with_values): Remove.
* libguile/memoize.c (memoize, m_call_values, unmemoize): Adapt to
memoize call-with-values primcalls.
* module/ice-9/boot-9.scm (call-with-values): Expand to a
call-with-values primcall.
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Expect
call-with-values primcall, without the @, and fall back to a normal
call.
* module/language/tree-il/peval.scm (peval): Match bare
call-with-values.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
(*multiply-valued-primitives*): Remove @call-with-values.
Andy Wingo [Thu, 27 Jun 2013 10:10:37 +0000 (12:10 +0200)]
remove @call-with-current-continuation memoizer
* module/ice-9/boot-9.scm (call-with-current-continuation): Change to
primcall call-with-current-continuation.
* libguile/memoize.h:
* libguile/expand.c (scm_sym_atcall_cc): Remove.
* libguile/memoize.c (memoize): Memoize call/cc primcalls to
SCM_M_CONT.
(m_call_cc): Remove.
(unmemoize): Unmemoize to call-with-current-continuation.
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Update
to call-with-current-continuation without @ prefix, and fix fallback
case.
* module/language/tree-il/primitives.scm (*multiply-valued-primitives*):
(*interesting-primitive-names*): Remove
@call-with-current-continuation.
(call/cc): Expand to call-with-current-continuation.
* test-suite/tests/tree-il.test ("call/cc"): Update to use and expect
call-with-current-continuation primcalls / toplevel refs.
Andy Wingo [Thu, 27 Jun 2013 09:26:11 +0000 (11:26 +0200)]
remove apply:nconc2last
* libguile/eval.c (scm_nconc2last): Remove, now unused.
* doc/ref/api-evaluation.texi (Fly Evaluation): Remove docs.
Andy Wingo [Thu, 27 Jun 2013 09:25:34 +0000 (11:25 +0200)]
remove @apply memoizer
* libguile/memoize.c (memoize): Recognize a primcall to 'apply as
SCM_M_APPLY.
(@apply): Remove @apply memoizer.
(unmemoize): Unmemoize using "apply", not "@apply".
* libguile/memoize.h:
* libguile/expand.c (scm_sym_atapply): Remove.
* module/ice-9/boot-9.scm (apply): Re-implement using apply primcall.
Use case-lambda, so as to give an appropriate minimum arity.
* module/language/tree-il/compile-glil.scm (flatten-lambda-case):
Compile a primcall of "apply" specially, not "@apply".
* module/language/tree-il/peval.scm (peval): Match primcalls to "apply",
not "@apply". Residualize "apply" primcalls.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
(*multiply-valued-primitives*): Remove @apply, and apply primitive
expander.
* test-suite/tests/peval.test:
* test-suite/tests/tree-il.test: Update tests to expect residualized
"apply".
* test-suite/tests/procprop.test ("procedure-arity"): Update test for
better apply arity.
* test-suite/tests/strings.test ("string"): Update expected error.
Andy Wingo [Tue, 25 Jun 2013 20:36:08 +0000 (22:36 +0200)]
Remove @prompt memoizer
* libguile/memoize.h:
* libguile/memoize.c (MAKMEMO_CALL_WITH_PROMPT, memoize, unmemoize):
Remove the @prompt memoizer in favor of recognizing call-with-prompt
primcalls. Rename SCM_M_PROMPT to SCM_M_CALL_WITH_PROMPT, and pass a
thunk instead of an expression so that it has normal applicative
order.
* libguile/expand.c (PRIMITIVE_REF, PRIMCALL, expand): Produce primcalls
from forms whose car is a primitive.
(expand_atat): Recognize (@@ primitive FOO) as being a primitive-ref.
* module/ice-9/boot-9.scm (call-with-prompt): Instead of dispatching to
the wonky @prompt memoizer, residualize a primcall to
call-with-prompt. The memoizer will DTRT to allow call-with-prompt to
be interpreted correctly without needing an additional binding.
* module/ice-9/eval.scm (primitive-eval): Change the 'prompt clause to a
call to call-with-prompt.
* module/language/tree-il/primitives.scm: No more need to recognize
@prompt.
* libguile/eval.c (eval): Adapt to SCM_M_PROMPT renaming to
SCM_M_CALL_WITH_PROMPT, and apply the thunk.
* libguile/throw.c (pre_init_throw): Adapt to scm_abort_to_prompt_star
rename.
Andy Wingo [Tue, 25 Jun 2013 19:53:52 +0000 (21:53 +0200)]
abort-to-prompt* instead of @abort
* libguile/control.h:
* libguile/control.c (scm_abort_to_prompt_star): Rename from
scm_at_abort.
* module/ice-9/boot-9.scm (abort-to-prompt): Use abort-to-prompt*.
* module/language/tree-il/primitives.scm: Handle abort-to-prompt*
instead of @abort.
Andy Wingo [Sun, 23 Jun 2013 19:36:08 +0000 (21:36 +0200)]
psyntax: ((@@ primitive NAME) ARG ...) in (guile) module is a primcall
* ice-9/psyntax.scm (@@): Recognize new form, (@@ primitive NAME), which
in operator position expands to a primcall. This expansion is only
available for forms in the (guile) module. Added an argument to @@
and @ procedures, the module, for use by expanded syntax objects;
adapted callers.
(analyze-variable): Error when accessing a primitive for value.
(get-global-definition-hook): Primitives are not macros.
(syntax-type): A form with a primitive in the car is a
primitive-call.
(expand-expr): Residualize primitive calls as primcalls.
(syntax-local-binding): Return 'primitive as the type for primitives.
Mark H Weaver [Mon, 17 Jun 2013 18:43:58 +0000 (14:43 -0400)]
Fix bug in remqueue in threads.c when removing last element.
Reported and debugged by Andrew Gaylard <ag@computer.org>.
* libguile/threads.c (remqueue): When removing the last element from a
queue with more than one element, set (car q) to the previous element.
* THANKS: Thank Andrew Gaylard.
Ludovic Courtès [Sun, 16 Jun 2013 19:47:39 +0000 (21:47 +0200)]
Fix #ifdefery for `setegid'.
* libguile/posix.c (scm_setegid): Change to #ifdef HAVE_SETEGID.
Ludovic Courtès [Sun, 16 Jun 2013 18:58:10 +0000 (20:58 +0200)]
tests: Don't rely on `scm_call_2' being visible.
* test-suite/tests/coverage.test ("procedure-execution-count")["called
from C"]: Throw 'unresolved when `scm_call_2' cannot be resolved.
Reported by Eli Zaretskii <eliz@gnu.org>.
Ludovic Courtès [Sun, 16 Jun 2013 18:56:31 +0000 (20:56 +0200)]
Augment `.dir-locals.el'.
Ludovic Courtès [Sun, 16 Jun 2013 14:54:12 +0000 (16:54 +0200)]
tests: Remove symlink only when it exists.
* test-suite/tests/filesys.test: Delete (test-symlink) only if it
exists---i.e., not on Windows.
Reported by Eli Zaretskii <eliz@gnu.org>.
Ludovic Courtès [Sun, 16 Jun 2013 14:52:38 +0000 (16:52 +0200)]
tests: Skip FFI tests that use `qsort' when it's not accessible.
* test-suite/tests/foreign.test ("procedure->pointer")[qsort]: Wrap in
`false-if-exception'.
["qsort", "qsort, wrong return type", "qsort, wrong arity"]: Throw
'unresolved when QSORT if #f.
Reported by Eli Zaretskii <eliz@gnu.org>.
Andy Wingo [Sun, 16 Jun 2013 13:06:59 +0000 (15:06 +0200)]
<dynwind> no longer has "pre" or "post" fields
* module/language/tree-il.scm (<tree-il>): Remove pre and post fields
from <dynwind>. A dynwind now assumes that in normal entry and exit,
that the code runs the winders and unwinders using <seq> and
<let-values> and such things.
(parse-tree-il, unparse-tree-il, make-tree-il-folder, pre-post-order):
Adapt <dynwind> users.
* module/language/tree-il/analyze.scm (analyze-lexicals):
* module/language/tree-il/compile-glil.scm (flatten-lambda-case):
* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il):
* module/language/tree-il/effects.scm (make-effects-analyzer): Adapt.
* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Produce tree-il that calls the winder and unwinder. Recognize
singly-valued dynamic-wind expressions.
* test-suite/tests/peval.test ("partial evaluation"): Add tests.
Ludovic Courtès [Sun, 16 Jun 2013 14:42:01 +0000 (16:42 +0200)]
tests: Don't rely on $TMPDIR and /tmp on Windows.
* 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>.
Ludovic Courtès [Sun, 16 Jun 2013 14:39:14 +0000 (16:39 +0200)]
tests: Use double quotes around shell arguments, for Windows.
* test-suite/standalone/test-system-cmds (test-system-cmd): Use double
quotes around shell arguments.
Reported by Eli Zaretskii <eliz@gnu.org>.
Ludovic Courtès [Sun, 16 Jun 2013 14:19:21 +0000 (16:19 +0200)]
Define `AF_UNIX' only when Unix-domain sockets are supported.
* libguile/socket.c (scm_init_socket): Defined `AF_UNIX' only when
`HAVE_UNIX_DOMAIN_SOCKETS' is defined.
Reported by Eli Zaretskii <eliz@gnu.org>.
Andy Wingo [Sun, 16 Jun 2013 13:02:34 +0000 (15:02 +0200)]
Reduce call-with-values to let for singly-valued producers
* 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.
Andy Wingo [Tue, 28 May 2013 16:38:16 +0000 (12:38 -0400)]
Rewrite make-tree-il-folder to use the Wright matcher.
* module/language/tree-il.scm (make-tree-il-folder): Rewrite to use the
Wright matcher instead of record-case.
Andy Wingo [Tue, 28 May 2013 16:28:56 +0000 (12:28 -0400)]
Rewrite unparse-tree-il to use the Wright matcher.
* module/language/tree-il.scm (unparse-tree-il): Rewrite to use the
Wright matcher.
Andy Wingo [Tue, 28 May 2013 16:20:48 +0000 (12:20 -0400)]
Rewrite parse-tree-il to use the Wright matcher.
* module/language/tree-il.scm (parse-tree-il): Rewrite to use match
instead of pmatch. Remove pmatch import.
Andy Wingo [Tue, 28 May 2013 16:06:30 +0000 (12:06 -0400)]
Implement tree-il-fold in terms of make-tree-il-folder.
* 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.
Andy Wingo [Tue, 28 May 2013 15:07:02 +0000 (11:07 -0400)]
Rewrite tree-il pre-post-order in terms of (ice-9 match)
* 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).
Andy Wingo [Tue, 28 May 2013 15:02:25 +0000 (11:02 -0400)]
Pre-order tree-il rewrites are now non-destructive
* 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.
Andy Wingo [Tue, 28 May 2013 14:56:05 +0000 (10:56 -0400)]
Tree-il post-order rewriter no longer destructive
* 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.
Andy Wingo [Tue, 28 May 2013 15:20:29 +0000 (11:20 -0400)]
Simplify let-values to let if consumer binds only one variable
* 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.
Andy Wingo [Mon, 10 Jun 2013 20:42:46 +0000 (22:42 +0200)]
fix linker.test
* test-suite/tests/linker.test (link-elf-with-one-main-section): Fix
test after string table change.
Mark H Weaver [Mon, 10 Jun 2013 06:05:17 +0000 (02:05 -0400)]
Allow #f as timeout argument to unlock-mutex and SRFI-18 mutex-unlock!
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.
Mark H Weaver [Mon, 10 Jun 2013 06:26:11 +0000 (02:26 -0400)]
Fix tests for 'scm_c_bind_keyword_arguments'.
* 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.
Andy Wingo [Fri, 17 May 2013 20:10:16 +0000 (22:10 +0200)]
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 Wingo [Thu, 16 May 2013 21:38:29 +0000 (23:38 +0200)]
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 Wingo [Thu, 16 May 2013 20:30:51 +0000 (22:30 +0200)]
Write docstrings into RTL ELF images
* module/system/vm/assembler.scm (link-docstrs): Write docstrings.
(link-objects): Link docstrings into the ELF.
Andy Wingo [Thu, 16 May 2013 18:58:54 +0000 (20:58 +0200)]
Wire up ability to print RTL program arities
* 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.
Andy Wingo [Thu, 16 May 2013 16:56:22 +0000 (18:56 +0200)]
(system vm debug) can read arity information
* 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.
Andy Wingo [Thu, 16 May 2013 12:06:10 +0000 (14:06 +0200)]
RTL assembler writes arities information into separate section.
* module/system/vm/assembler.scm: Write arities into a .guile.arities
section and associated .guile.arities.strtab.
Andy Wingo [Tue, 14 May 2013 09:18:05 +0000 (11:18 +0200)]
Beginnings of tracking of procedure arities in assembler
* 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.
Andy Wingo [Tue, 14 May 2013 08:33:43 +0000 (10:33 +0200)]
add procedure prelude macro-instructions
* 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.
Andy Wingo [Tue, 14 May 2013 08:25:38 +0000 (10:25 +0200)]
begin-program takes properties alist
* 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.
Andy Wingo [Wed, 1 May 2013 20:45:19 +0000 (22:45 +0200)]
Add RTL disassembler
* module/Makefile.am:
* module/system/vm/disassembler.scm: New module.
* module/system/repl/command.scm (disassemble): Work with RTL programs.
Andy Wingo [Sun, 5 May 2013 16:26:53 +0000 (18:26 +0200)]
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 Wingo [Sun, 5 May 2013 15:52:59 +0000 (17:52 +0200)]
move procedure-name and procedure-source to procprop.c
* libguile/procprop.h:
* libguile/procprop.c (scm_procedure_name, scm_procedure_source): Move
these functions here, from debug.[ch].
Andy Wingo [Wed, 1 May 2013 20:17:51 +0000 (22:17 +0200)]
Add runtime support for reading debug information from ELF
* 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.
Andy Wingo [Mon, 28 May 2012 10:37:56 +0000 (12:37 +0200)]
Add RTL assembler
* 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.
Andy Wingo [Sun, 9 Jun 2013 14:03:18 +0000 (16:03 +0200)]
linker string tables are stateful objects
* 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.
Andy Wingo [Sat, 8 Jun 2013 12:58:10 +0000 (14:58 +0200)]
const cleanups in instructions.c
* 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.
Ludovic Courtès [Tue, 4 Jun 2013 22:25:39 +0000 (00:25 +0200)]
Report the faulty keyword in errors raised by `scm_c_bind_keyword_arguments'.
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.
Ludovic Courtès [Mon, 3 Jun 2013 22:29:59 +0000 (00:29 +0200)]
Print the faulty object upon invalid-keyword errors.
* 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.
Andy Wingo [Thu, 23 May 2013 12:52:29 +0000 (14:52 +0200)]
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.
Ludovic Courtès [Thu, 30 May 2013 21:30:27 +0000 (23:30 +0200)]
Do not assume `pthread_t' is an integer type.
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.
Andy Wingo [Mon, 28 May 2012 10:25:43 +0000 (12:25 +0200)]
refactor to resolve_variable
* libguile/vm.c (resolve_variable): Slight refactor.
Andy Wingo [Thu, 17 May 2012 16:35:05 +0000 (18:35 +0200)]
cpp hygiene in the vm
* 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.
Andy Wingo [Thu, 23 May 2013 13:07:37 +0000 (15:07 +0200)]
pop-continuation abort-continuation hooks pass return vals directly
* 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.
Andy Wingo [Thu, 23 May 2013 13:16:20 +0000 (15:16 +0200)]
Allow vm_engine caller to pass arguments on the stack.
* libguile/vm-engine.c (vm_engine): Allow the caller to pass arguments
on the stack.
Andy Wingo [Fri, 18 May 2012 10:21:33 +0000 (12:21 +0200)]
vm-engine: remove register assignments
* 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.
Andy Wingo [Fri, 18 May 2012 10:21:08 +0000 (12:21 +0200)]
remove some configurability in vm-engine
* 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.
Andy Wingo [Fri, 18 May 2012 09:57:51 +0000 (11:57 +0200)]
minor vm-engine cleanups
* libguile/vm-engine.c: Some very minor cleanups: indenting, use of
VM_ASSERT, commenting.
Andy Wingo [Thu, 17 May 2012 09:39:35 +0000 (11:39 +0200)]
remove CONS macro in VM; use scm_cons instead
* 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.
Andy Wingo [Fri, 18 May 2012 09:52:12 +0000 (11:52 +0200)]
inline vm-engine.h into vm-engine.c
* libguile/vm-engine.h:
* libguile/vm-engine.c: Fold vm-engine.h into vm-engine.c.
* libguile/Makefile.am: Adapt.
Andy Wingo [Sun, 28 Apr 2013 12:42:01 +0000 (14:42 +0200)]
add (find-mapped-elf-image) procedure to (system vm objcode) module
* 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.
Andy Wingo [Sun, 28 Apr 2013 12:23:20 +0000 (14:23 +0200)]
refactor and simplify ELF loader in objcodes.c
* 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.
Andy Wingo [Thu, 23 May 2013 12:18:47 +0000 (14:18 +0200)]
add scm_{to,from}_{u,}intptr_t
* 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.
Andy Wingo [Sun, 28 Apr 2013 07:31:28 +0000 (09:31 +0200)]
refactor linker to lay out ELF files and memory in the same way
* 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.
Andy Wingo [Sun, 28 Apr 2013 05:51:42 +0000 (07:51 +0200)]
elf: add accessors for header members that might need relocation
* module/system/vm/elf.scm (elf-header-shoff-offset)
(elf-section-header-addr-offset, elf-section-header-offset-offset):
New accessors.
Andy Wingo [Sun, 21 Apr 2013 14:06:36 +0000 (16:06 +0200)]
ELF refactor and consequent linker simplifications
* 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.
Andy Wingo [Wed, 17 Apr 2013 21:07:04 +0000 (23:07 +0200)]
split linker out of elf module
* module/Makefile.am:
* module/system/vm/linker.scm: New file, split out of (system vm elf).
(make-string-table, string-table-intern): Export under their bare
names, instead of make-elf-string-table and elf-string-table-intern.
* module/system/vm/elf.scm: Remove linking capabilities.
(string-table-ref): Export.
* module/language/objcode/elf.scm (bytecode->elf): Adapt to use (system
vm linker).
* test-suite/tests/linker.test: New test.
Aleix Conchillo Flaque [Thu, 2 May 2013 19:13:31 +0000 (12:13 -0700)]
web: uri-encode hexadecimal percent-encoding is now uppercase
* module/web/uri.scm (uri-encode): the hexadecimal percent-encoding %HH
is now uppercased as suggested by RFC3986:
"For consistency, URI producers and normalizers should use
uppercase hexadecimal digits for all percent-encodings."
* test-suite/tests/web-uri.test ("encode"): update tests.
Mark H Weaver [Sun, 14 Apr 2013 17:36:20 +0000 (13:36 -0400)]
Manual: fix 'my-or' examples to use let-bound variable.
Fixes <http://bugs.gnu.org/14203> reported by Nikita Karetnikov.
* doc/ref/api-macros.texi (Defining Macros, Syntax Rules): Fix
definition of 'my-or' example macro to use the let-bound variable.