1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00
Commit graph

60 commits

Author SHA1 Message Date
Andy Wingo
dfadcf85cb Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/debug.h
	module/ice-9/psyntax-pp.scm
	module/ice-9/psyntax.scm
	module/language/tree-il/peval.scm
	module/language/tree-il/primitives.scm
2012-01-30 20:27:35 +01:00
Andy Wingo
6dc8c138f9 more readable gensyms
* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (dynamic-wind): When you make a
  gensym that just has to be compared against other gensyms, it will be
  unique if the prefix doesn't end in something that can be interpreted
  as a number.  There's no reason to make that character something
  difficult like " ".  So change to use a dash in that case.

* module/ice-9/psyntax-pp.scm: Regenerate.  More readable now.
2012-01-26 12:08:58 +01:00
Andy Wingo
880e794812 inline dynwind guards for normal control flow
* module/language/tree-il.scm (<tree-il>): Add `pre' and `post' fields
  to <dynwind>, so that we can inline the guard bodies in the normal
  control-flow case.  It also avoids duplicating code in compile-glil,
  which probably hides more bugs in 2.0.
  (parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold)
  (make-tree-il-folder, post-order!, pre-order!): Update.

* module/language/tree-il/analyze.scm (analyze-lexicals): Update.

* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Update
  to use `pre' and `post' instead of compiling code twice.

* module/language/tree-il/debug.scm (verify-tree-il): Update.

* module/language/tree-il/peval.scm (peval): Update.  Instead of doing
  complicated things in <dynwind>, handle 'dynamic-wind primcalls.

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove 'dynamic-wind mess.  Adapt '@dynamic-wind.

* test-suite/tests/tree-il.test ("partial evaluation"): Update tests.
2011-11-09 19:38:44 +01:00
Andy Wingo
acdf4fcc05 simplify primitives.scm for dynwind
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove a dynwind hack, as we have a good inliner now.
2011-11-09 16:54:43 +01:00
Andy Wingo
14b208185c resolve-primitives! does not primitivize local definitions
* module/language/tree-il/primitives.scm (resolve-primitives!): Don't
  resolve toplevels defined in the same compilation unit to primitives,
  as it could be that the module doesn't have those bindings yet.
2011-11-04 13:37:58 +01:00
Andy Wingo
ba9f9f0d63 add vector-length primitive
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*, *effect-free-primitives*): Recognize
  vector-length as an effect-free primitive.
2011-10-28 11:19:01 +02:00
Andy Wingo
f00a957499 simplify primitives.scm
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove a hack to compensate for the lack of a good inliner, now that
  we do have a good inliner.
2011-10-28 10:29:46 +02:00
Andy Wingo
4938d3cb74 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/deprecated.c
	libguile/gc-malloc.c
	module/language/tree-il/peval.scm
2011-10-27 13:45:04 +02:00
Andy Wingo
9be8a338ac recognize string primitives
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Add string?, string-length, and ref
  and set.
  (*primitive-accessors*): Add string-ref.
  (*effect-free-primitives*): Add string-length and string?
  (*effect+exception-free-primitives*): Add string?.
  (*singly-valued-primitives*): Add string-length and ref and set.
2011-10-10 20:19:07 +02:00
Andy Wingo
a215c15913 Merge remote-tracking branch 'origin/stable-2.0'
Does not include psyntax regeneration.

Conflicts:
	module/ice-9/psyntax-pp.scm
	module/language/tree-il/peval.scm
	test-suite/tests/tree-il.test
2011-10-10 16:20:08 +02:00
Andy Wingo
f26c3a93ec add accessor-primitive?, peval uses it
* module/language/tree-il/primitives.scm (*primitive-accessors*): New
  set of primitives: those that access mutable memory, but are otherwise
  pure.  Include bytevector references here.
  (accessor-primitive?): New public predicate.

* module/language/tree-il/peval.scm (peval): Refactor to distinguish
  constructor-primitive? from accessor-primitive?.
2011-10-10 14:43:37 +02:00
Andy Wingo
ca12824581 Merge remote-tracking branch 'origin/stable-2.0'
This was a pretty big merge involving a fair amount of porting,
especially to peval and its tests.  I did not update psyntax-pp.scm,
that comes in the next commit.

Conflicts:
	module/ice-9/boot-9.scm
	module/ice-9/psyntax-pp.scm
	module/language/ecmascript/compile-tree-il.scm
	module/language/tree-il.scm
	module/language/tree-il/analyze.scm
	module/language/tree-il/inline.scm
	test-suite/tests/tree-il.test
2011-09-29 18:02:28 +02:00
Andy Wingo
ea726a53b2 peval: add support for <prompt> and <abort>
* module/language/tree-il/optimize.scm (alpha-rename, peval): Handle
  <prompt> and <abort>.  Attempt to remove the prompt if the tag is
  otherwise unreferenced.

* module/language/tree-il/primitives.scm (*primitive-constructors*): Add
  make-prompt-tag as a constructor.

* test-suite/tests/tree-il.test ("partial evaluation"): Add a test that
  an prompt whose tag is unreferenced is removed.
2011-09-28 00:13:55 +02:00
Andy Wingo
d851e32fdc prevent propagation for memory-dependent operations like `car'
* module/language/tree-il/primitives.scm (*primitive-constructors*):
  Record car, cdr, vector-ref, and struct-ref as "constructors".
  Comment to come later.
  (*effect-free-primitives*): Update.

* test-suite/tests/tree-il.test ("partial evaluation"): Add tests.
2011-09-23 18:02:05 +02:00
Andy Wingo
03026d0fb8 add singly-valued-primitive?
* module/language/tree-il/primitives.scm (singly-valued-primitive?): New
  predicate, for primitives that return exactly one value.
2011-09-21 08:53:06 +02:00
Ludovic Courtès
11671bbacb Add a partial evaluator for use in the compiler.
Thanks to William R. Cook for his excellent tutorial,
<http://softlang.uni-koblenz.de/dsl11/>.

* module/language/tree-il/optimize.scm (optimize!): Call `peval' unless
  the #:partial-eval? option asks otherwise.
  (peval): New procedure.

* module/language/tree-il/inline.scm: Add comment.

* module/language/tree-il/primitives.scm (*primitive-constructors*): New
  variable.
  (*effect-free-primitives*): Use it.
  (constructor-primitive?): New primitive.

* test-suite/tests/tree-il.test (assert-tree-il->glil): Extend to
  support `with-partial-evaluation', `without-partial-evaluation', and
  `with-options'.
  (peval): New binding.
  (pass-if-peval): New macro.
  ("lexical refs"): Run tests without partial evaluation.
  ("letrec"): Likewise.
  ("the or hack"): Likewise.
  ("conditional"): Likewise, for some tests.
  ("sequence"): Adjust to new generated code.
  ("partial evaluation"): New test prefix.
2011-09-09 00:05:34 +02:00
Andy Wingo
78f0ef20a7 Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
	module/ice-9/psyntax-pp.scm
	module/language/tree-il/compile-glil.scm
2011-06-18 01:07:20 +02:00
Andy Wingo
b88fef5519 fix invalid transformation of (values x) -> x, (+ x) -> x, etc
* module/language/tree-il/primitives.scm (+, *, cons*): In the case of
  just one argument (the identity case), expand to (values x) instead of
  just x.  Fixes values truncation in that case.
  (values): Likewise remove (values x) -> x translation, as the compiler
  will do it for us, and this fixes (values (values 1 2)).

* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Handle
  `values' in a push context here.

* test-suite/tests/tree-il.test ("values"): Add some tests.
2011-06-17 19:42:55 +02:00
Andy Wingo
a881a4ae3b add <primcall> to tree-il
* libguile/expand.c:
* libguile/expand.h (SCM_EXPANDED_PRIMCALL_TYPE_NAME):
  (SCM_EXPANDED_PRIMCALL_FIELD_NAMES):
  (SCM_EXPANDED_PRIMCALL_SRC):
  (SCM_EXPANDED_PRIMCALL_NAME):
  (SCM_EXPANDED_PRIMCALL_ARGS):
  (SCM_MAKE_EXPANDED_PRIMCALL): Add "primcall" Tree-IL type.

* doc/ref/compiler.texi (Tree-IL): Update docs.

* libguile/memoize.c (memoize): Memoizer for primcalls.

* module/ice-9/psyntax.scm: Build primcalls, sometimes.  Also change
  build-primref to just make a primitive-ref.

* module/language/tree-il.scm: Add primcall to the exports, parsers,
  serializers, etc.

* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm:
* module/language/elisp/compile-tree-il.scm: Add primcall support.

* test-suite/tests/tree-il.test: Use primcalls sometimes.
2011-06-02 17:45:58 +02:00
Andy Wingo
7081d4f981 rename <application> to <call>
* doc/ref/compiler.texi (The Scheme Compiler): Update docs.

* libguile/expand.h:
* libguile/expand.c:
* module/language/tree-il.scm: Rename <application> to <call>.  Change
  the external representation from (apply proc arg ...) to (call proc
  arg ...).

* libguile/memoize.c:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm:
* module/language/brainfuck/compile-tree-il.scm:
* module/language/ecmascript/compile-tree-il.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm:
* test-suite/tests/tree-il.test: Update all callers.
2011-06-02 13:42:55 +02:00
Andy Wingo
cf45ff030c inline symbol? and vector? to opcodes, and a psyntax inlining tweak
* 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-10-08 12:31:56 +02:00
Andy Wingo
9b3cc65965 resolve-primitives tweaks
* module/ice-9/boot-9.scm (make-struct/no-tail): Define a version of
  this function. Because during optimization we resolve make-struct to
  make-struct/no-tail, we need an implemented make-struct/no-tail if we
  are to be able to run scheme made from tree-il->scheme.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Remove
  variable-set case, as there is no "variable-set!" primitive.
  (flatten): Add a special hack for variable-set!. Ugly, I know.

* module/language/tree-il/primitives.scm (*effect-free-primitives*): Add
  make-struct/no-tail.
  (*effect+exception-free-primitives*): Remove make-struct, as it could
  raise an exception.
  (variable-set!): Remove expansion to variable-set.
2010-06-17 13:43:26 +02:00
Andy Wingo
4ee781a688 add effect+exception-free-primitive? predicate
* module/language/tree-il/primitives.scm
  (effect+exception-free-primitive?): New predicate, like
  effect-free-primitive?, but excludes accessors that could raise
  exceptions.
2010-06-17 13:43:26 +02:00
Andy Wingo
38030bdf5d make-prompt-tag is an effect-free primitive
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*, *effect-free-primitives*): Recognize
  make-prompt-tag as interesting and effect-free.
2010-06-11 16:58:36 +02:00
Andy Wingo
07d22c0259 rename (rnrs bytevector) to (rnrs bytevectors)
* module/rnrs/bytevectors.scm: Rename to (rnrs bytevectors), from (rnrs
  bytevector), to match the name from the R6RS.

* benchmark-suite/benchmarks/bytevectors.bm:
* doc/ref/api-data.texi:
* doc/ref/api-foreign.texi:
* libguile/bytevectors.c:
* module/6/rnrs.scm:
* module/language/assembly.scm:
* module/language/assembly/compile-bytecode.scm:
* module/language/assembly/decompile-bytecode.scm:
* module/language/glil/compile-assembly.scm:
* module/language/tree-il/primitives.scm:
* module/srfi/srfi-4.scm:
* module/srfi/srfi-4/gnu.scm:
* module/system/foreign.scm:
* test-suite/standalone/test-ffi:
* test-suite/tests/asm-to-bytecode.test:
* test-suite/tests/bytevectors.test:
* test-suite/tests/foreign.test:
* test-suite/tests/r6rs-ports.test: Update all referrers.
2010-06-01 13:26:11 +02:00
Andy Wingo
9a974fd384 optimize and bugfix make-struct VM opcode
* 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-05-01 00:31:18 +02:00
Andy Wingo
8fc43b12c7 prompt, abort -> call-with-prompt, abort-to-prompt
* module/ice-9/boot-9.scm (default-prompt-tag, make-prompt-tag): New
  functions.
  (call-with-prompt, abort-to-prompt): Rename from `prompt' and `abort',
  respectively. These names are more clear, and allow `prompt' and
  `abort' to have more convenient, less general bindings.
  (default-throw-handler, custom-throw-handler, catch, %start-stack):
  Adapt callers.

* module/ice-9/control.scm: Adapt re-export list.
  (control): Remove binding, until we're sure that it is Sitaram's
  control.
  (abort): New binding, aborts to the nearest prompt with the default
  tag.
  (%): Use call-with-prompt.

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  (*interesting-primitive-names*): Adapt for prompt/abort changes.

* test-suite/tests/control.test: Take advantage of the defaults for %
  and abort.
2010-03-09 22:24:25 +01:00
Andy Wingo
2d026f04cc abort always dispatches to VM bytecode, to detect same-invocation aborts
* libguile/control.h:
* libguile/control.c (scm_c_make_prompt): Take an extra arg, a cookie.
  Continuations will be rewindable only if the abort has the same cookie
  as the prompt.
  (scm_at_abort): Redefine from scm_abort, and instead of taking rest
  args, take the abort values as a list directly. Also, don't allow
  rewinding, because we won't support rewinding the C stack with
  delimited continuations.

* libguile/eval.c (eval): Adapt to scm_c_make_prompt change.

* libguile/vm-engine.c (vm_engine): Use vp->cookie to get a unique value
  corresponding to this VM invocation.
* libguile/vm-i-system.c (prompt): Pass the cookie to scm_c_make_prompt.
  (abort): Take an additional tail arg.
* libguile/vm.c (vm_abort): Parse out the abort tail arg. This is for
  the @abort case, or the (apply abort ...) case.
  (make_vm): Initialize the cookie to 0.
* libguile/vm.h (struct scm_vm): Add cookie.

* module/ice-9/boot-9.scm (abort): Define here as a trampoline to
  @abort. Needed to make sure that a call to abort dispatches to a VM
  opcode, so the cookie will be the same.

* module/language/tree-il.scm (<tree-il>): Add a "tail" field to
  <abort>, for the (apply abort ...) case, or (@abort tag args). Should
  be #<const ()> in the normal case. Add support throughout.
* module/language/tree-il/analyze.scm (analyze-lexicals): Add abort-tail
  support here too.

* module/language/tree-il/compile-glil.scm (flatten): Compile the tail
  argument appropriately.
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Fix
  @abort and abort cases to pass the tail arg to make-abort.
2010-02-22 21:54:06 +01:00
Andy Wingo
f828ab4f30 prompt and abort inlining
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Add abort.
  (*primitive-expand-table*): Fix so that we inline `prompt' and
  `abort', and remove obsolete code dealing in `control'.
2010-02-22 21:54:00 +01:00
Andy Wingo
747022e4cb prompt as part of guile's primitive language
* libguile/control.h:
* libguile/control.c: Remove scm_atcontrol and scm_atprompt.
  (scm_c_make_prompt): Remove handler arg, as the handler is inline.
  (scm_abort): New primitive, exported to Scheme as `abort'. The
  compiler will also recognize calls to `abort', but this is the base
  case.
  (scm_init_control): Remove scm_register_control, just have this
  function, which adds `abort' to the `(guile)' module.

* libguile/eval.c (eval): Add SCM_M_PROMPT case.

* libguile/init.c (scm_i_init_guile): Change scm_register_control call
  into a nice orderly scm_init_control call.

* libguile/memoize.h: (scm_sym_at_prompt, SCM_M_PROMPT):
* libguile/memoize.c (MAKMEMO_PROMPT, scm_m_at_prompt, unmemoize): Add
  prompt support to the memoizer.

* libguile/vm-i-system.c (prompt): Fix to not expect a handler on the
  stack.

* module/ice-9/boot-9.scm (prompt): Add definition in terms of @prompt.

* module/ice-9/control.scm: Simplify, and don't play with the compiler
  here, now that prompt and abort are primitive.

* module/ice-9/eval.scm (primitive-eval): Add a prompt case.

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Add @prompt and prompt.
2010-02-19 22:44:24 +01:00
Andy Wingo
ea6b18e82f prompt handlers are always inline
* libguile/control.h (SCM_F_PROMPT_INLINE, SCM_PROMPT_INLINE_P): Remove;
  prompts always have "inline" handlers now.
* libguile/control.c (scm_c_make_prompt): Remove inline_handler_p arg.

* libguile/vm-i-system.c (prompt):
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
* module/language/assembly/compile-bytecode.scm (write-bytecode):
 Adapt to prompt changes.

* module/language/glil.scm (make-glil-prompt, glil-prompt-inline?):
  Remove inline? flag.
  (parse-glil, unparse-glil):
* module/language/glil/compile-assembly.scm (glil->assembly): Adapt to
  <glil-prompt> change.

* module/language/tree-il/compile-glil.scm (flatten): Require the
  handler of a <prompt> to be a lambda-case.

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Ensure that the handler of a <prompt> is a lambda-case.

* module/language/tree-il/inline.scm (inline!): Simplify a degenerate
  case: (lambda args (apply (lambda ...) args)) => (lambda ...).
2010-02-19 15:30:34 +01:00
Andy Wingo
f5b1f76af4 fluid-ref / fluid-set! compile to dynref/dynset
* module/language/tree-il/primitives.scm: Resolve fluid-ref and
  fluid-set! as primitives, and thence to dynref/dynset.
2010-02-19 12:10:12 +01:00
Andy Wingo
6e84cb95b1 rename <control> to <abort>
* libguile/vm-i-system.c (abort): Rename instruction from `throw'.
* libguile/vm.c (vm_abort): Rename from vm_throw.
* module/language/tree-il.scm (<abort>, make-abort, abort-src,
  abort-tag, abort-args: Rename from <control> & company.

* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/primitives.scm: Fix all callers.
2010-02-19 12:10:11 +01:00
Andy Wingo
07a0c7d5d9 <prompt> has no pre-unwind-handler, it's unnecessary
* libguile/control.h:
* libguile/control.c (scm_c_make_prompt, SCM_PROMPT_PRE_UNWIND_HANDLER):
* libguile/vm-i-system.c (prompt)
* module/language/tree-il.scm (<prompt> prompt-pre-unwind-handler):
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm: Remove the "pre-unwind"
  handler from prompt; it turns out not to be necessary. Adapt all
  references.
2010-02-19 12:10:11 +01:00
Andy Wingo
8da6ab34bd rename <dynamic-wind> to <dynwind>
* module/language/tree-il.scm (<dynwind>): Rename from <dynamic-wind>.
* module/language/tree-il/analyze.scm:
* module/language/tree-il/primitives.scm:
* module/language/tree-il/compile-glil.scm: All accessors and callers
  changed.
2010-02-18 22:15:43 +01:00
Andy Wingo
d69531e213 dynwind is now a part of guile's primitive language
* libguile/memoize.h (scm_sym_at_dynamic_wind, SCM_M_DYNWIND)
* libguile/memoize.c (memoized_tags, MAKMEMO_DYNWIND)
  (scm_m_at_dynamic_wind, unmemoize): Add dynwind as a primitive
  expression type.

* libguile/dynwind.c (scm_dynamic_wind): Downgrade to a normal C
  function.

* libguile/eval.c (eval):
* module/ice-9/eval.scm (primitive-eval): Add dynwind support.

* module/ice-9/r4rs.scm: More relevant docs.
  (apply): Define in a more regular way.
  (dynamic-wind): Add to this file, with docs, dispatching to
  @dynamic-wind.

* module/language/tree-il/primitives.scm: Parse @dynamic-wind into a
  tree-il dynamic-wind.
2010-02-18 22:12:55 +01:00
Andy Wingo
9b2a2a391a add (ice-9 control)
* module/language/tree-il/primitives.scm (define-primitive-expander):
  Allow quoted datums. Allow all self-evaluating expressions to be
  constants.
  (prompt, control): Add primitive expanders to turn these into @prompt
  and @control.

* module/ice-9/control.scm: New module, for delimited continuation
  operators.

* module/Makefile.am: Add.
2010-01-31 20:40:24 +01:00
Andy Wingo
1bf78495e9 dynamic-wind compilation to VM ops
* module/language/tree-il/primitives.scm: Resolve calls to dynamic-wind
  to <dynamic-wind>, thereby inlining the dynwind to VM ops, and
  allowing inline allocation of the body thunk.
2010-01-31 20:40:23 +01:00
Andy Wingo
d27a7811db inline calls to variable-bound?
* module/language/tree-il/compile-glil.scm (*primcall-ops*):
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Actually resolve calls to
  `variable-bound?' to the opcode that we have for it.
2010-01-27 21:48:06 +01:00
Ludovic Courtès
a752c0dc27 Add struct-ref' and struct-set' VM opcodes.
* libguile/vm-i-scheme.c (make_struct): Optimize the
  `SCM_VTABLE_FLAG_SIMPLE' case.
  (struct_ref, struct_set): New opcodes.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
  `struct-ref' and `struct-set!'.

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Likewise.
  (*effect-free-primitives*): Add `struct-ref'.
2010-01-23 16:43:50 +01:00
Andy Wingo
6c498233a1 inline srfi-4 vector accessors
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Inline srfi-4 vector accessors.
2010-01-07 23:40:59 +01:00
Ludovic Courtès
dd902692fd Fix expansion of `(+ 1 x)'.
* module/language/tree-il/primitives.scm (+): Fix typo.
2009-12-11 14:56:49 +01:00
Ludovic Courtès
bd91ecce14 Add opcodes for struct?', struct-vtable', and `make-struct'.
* libguile/vm-engine.c (VM_NAME)[vm_error_not_a_struct]: New label.

* libguile/vm-i-scheme.c (VM_VALIDATE_STRUCT): New macro.
  (struct_p, struct_vtable, make_struct): New instructions.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
  `struct?', `struct-vtable', and `make-struct'.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*,
  *effect-free-primitives*): Likewise.
2009-12-11 13:03:45 +01:00
Andy Wingo
349d5c4428 inline calls to (memv foo CONSTANT-LIST)
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Recognize memv and memq as well.

* module/language/tree-il/inline.scm (inline!): Inline calls to memq and
  memv where the list is a constant.
2009-12-11 12:20:55 +01:00
Andy Wingo
1d30393fbf wire through the existing vm ops for variable-ref and variable-set!
* module/language/tree-il/compile-glil.scm (*primcall-ops*): Compile
  variable-ref and variable-set instructions specially.

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Add cases for variable-ref and
  variable-set!. The latter is a little tricky, because the args are
  switched for the VM op, and we can't really change that easily.
2009-12-01 21:00:26 +01:00
Andy Wingo
83c7655002 goops moving away from evaluator opcodes, and a primitive compilation fix
* module/oop/goops.scm (@slot-ref, @slot-set!): Define "primitives" for
  these. Probably should do something more general, though, allowing
  @struct-ref.

* module/language/tree-il/primitives.scm (add-interesting-primitive!):
  Error if the primitive isn't bound.
2009-12-01 21:00:26 +01:00
Andy Wingo
b10d93309b opcodes for bit twiddling (ash, logand, logior, logxor)
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/primitives.scm:
* libguile/vm-i-scheme.c (ash, logand, logior, logxor): New opcodes.
2009-11-15 21:03:33 +01:00
Andy Wingo
0e249fd359 fix (apply f) -- without the args list
* module/language/tree-il/primitives.scm (apply): Only inline if we
  actually have an argument to apply.
2009-11-15 21:03:32 +01:00
Andy Wingo
8753fd537c fix brainfuck for new tree-il, and add tests
* test-suite/Makefile.am:
* test-suite/tests/brainfuck.test: Add a brainfuck test.

* module/system/base/compile.scm: Also export read-and-compile.

* module/language/tree-il/spec.scm (join): Fix the joiner in the
  0-expression case.

* module/language/tree-il/primitives.scm (+): Recognize (+ x -1) as 1-.

* module/language/brainfuck/parse.scm (read-brainfuck): Return EOF if we
  actually received EOF, and there were no expressions read.

* module/language/brainfuck/compile-tree-il.scm (compile-body): Fix the
  compiler for the new format of "lambda" in tree-il.
2009-10-23 15:10:25 +02:00
Andy Wingo
eebff6d7f1 fix compile-time bug compiling (+ "foo" " bar")
* module/language/tree-il/primitives.scm (+, -): Avoid calling exact? on
  non-numeric args.
2009-09-06 14:15:45 +02:00