unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: stefan <stefan.tampe@spray.se>
To: guile-devel@gnu.org
Subject: fmatch
Date: Thu, 6 May 2010 22:39:32 +0200	[thread overview]
Message-ID: <201005062239.32992.stefan.tampe@spray.se> (raw)

Hi,

I've been experimenting lately with an inline match construct, very much like 
using compiled regexps. That is I created a tiny VM that was targeted to 
do matching. to show it consider

guile> (def f ((x y 'a 'b) (+ x y)))

then

guile> ,x f
  0    (assert-nargs-ee 0 1)
   3    (reserve-locals 0 4)
   6    (object-ref 1)                  ;; #(1 9 0 1 2 3 4 1 2 2 4 1 3 a 4 1 3 
b 4 3 () 0)
   8    (fast-match)
   9    (br-if-not :L195)               ;; -> 19
  13    (local-ref 3)                   ;; `x'
  15    (local-ref 2)                   ;; `y'
  17    (add)                                  at standard input:1:20
  18    (return)
  19    (toplevel-ref 2)                ;; `error'
  21    (object-ref 3)                  ;; "no match in f"
  23    (tail-call 1)

large patterns yield a speedup of 15 times acording to my tests compared 
with (ice-9 match).

I used guile-1.9.10. Does this release have a lot of checks compiled in so 
that the comparison is unfair?

Anyway, I will try to tweak the code even further somthing along

(object-ref 1)
(fast-match)
(br L1)
(br L2)
(br L3)
....
(br Ln)

Here the fast-match routine can FETCH the br commands and issue them directly
and hence one can have one compiled pattern in stead of one for each row in 
the matcher. 

/Stefan

	    










             reply	other threads:[~2010-05-06 20:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-06 20:39 stefan [this message]
2010-05-07 11:59 ` fmatch Ludovic Courtès
2010-05-07 14:24   ` fmatch stefan
2010-05-07 20:23     ` fmatch Ludovic Courtès
2010-05-07 20:53       ` fmatch stefan
2010-05-09 20:57         ` fmatch Ludovic Courtès
2010-05-09 20:52           ` fmatch stefan
2010-05-10  8:26             ` fmatch Ludovic Courtès
2010-05-11 14:26               ` fmatch Stefan
2010-05-17 20:08               ` fmatch stefan
2010-05-22 21:03                 ` fmatch Ludovic Courtès
2010-05-22 21:31                   ` fmatch stefan
2010-05-23 16:06                     ` fmatch Ludovic Courtès
2010-05-23 15:47                   ` fmatch stefan
2010-05-24 20:08                     ` fmatch Ludovic Courtès
2010-05-24 21:05                       ` fmatch stefan
2010-05-25 17:41                         ` fmatch Ludovic Courtès
2010-05-25 21:10                           ` fmatch stefan
2010-06-16 21:31                             ` fmatch Ludovic Courtès
2010-06-20 19:58                               ` fmatch stefan
2010-06-20 21:56                                 ` fmatch Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201005062239.32992.stefan.tampe@spray.se \
    --to=stefan.tampe@spray.se \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).