guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fmatch


From: stefan
Subject: fmatch
Date: Thu, 6 May 2010 22:39:32 +0200
User-agent: KMail/1.12.4 (Linux/2.6.31.12-0.2-desktop; KDE/4.3.5; x86_64; ; )

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 via email to

[Prev in Thread] Current Thread [Next in Thread]