unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* fmatch
@ 2010-05-06 20:39 stefan
  2010-05-07 11:59 ` fmatch Ludovic Courtès
  0 siblings, 1 reply; 21+ messages in thread
From: stefan @ 2010-05-06 20:39 UTC (permalink / raw)
  To: guile-devel

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

	    










^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2010-06-20 21:56 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-06 20:39 fmatch stefan
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

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).