forth: JIT cooperation hooks (vm-eligible flag + call-count + forth-hot-words)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 11s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 11s
This commit is contained in:
@@ -5,7 +5,39 @@
|
||||
|
||||
(define
|
||||
forth-execute-word
|
||||
(fn (state word) (let ((body (get word "body"))) (body state))))
|
||||
(fn
|
||||
(state word)
|
||||
(dict-set! word "call-count" (+ 1 (or (get word "call-count") 0)))
|
||||
(let ((body (get word "body"))) (body state))))
|
||||
|
||||
(define
|
||||
forth-hot-words
|
||||
(fn
|
||||
(state threshold)
|
||||
(forth-hot-walk
|
||||
(keys (get state "dict"))
|
||||
(get state "dict")
|
||||
threshold
|
||||
(list))))
|
||||
|
||||
(define
|
||||
forth-hot-walk
|
||||
(fn
|
||||
(names dict threshold acc)
|
||||
(if
|
||||
(= (len names) 0)
|
||||
acc
|
||||
(let
|
||||
((n (first names)))
|
||||
(let
|
||||
((w (get dict n)))
|
||||
(let
|
||||
((c (or (get w "call-count") 0)))
|
||||
(forth-hot-walk
|
||||
(rest names)
|
||||
dict
|
||||
threshold
|
||||
(if (>= c threshold) (cons (list n c) acc) acc))))))))
|
||||
|
||||
(define
|
||||
forth-interpret-token
|
||||
|
||||
Reference in New Issue
Block a user