smalltalk: per-call-site inline cache + 10 IC tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-25 15:30:36 +00:00
parent 5d369daf2b
commit df62c02a21
4 changed files with 137 additions and 2 deletions

View File

@@ -29,6 +29,14 @@
st-method-cache-clear!
(fn () (set! st-method-cache {})))
;; Inline-cache generation. Eval-time IC slots check this; bumping it
;; invalidates every cached call-site method record across the program.
(define st-ic-generation 0)
(define
st-ic-bump-generation!
(fn () (set! st-ic-generation (+ st-ic-generation 1))))
(define
st-method-cache-key
(fn (cls sel class-side?) (str cls "|" sel "|" (if class-side? "c" "i"))))
@@ -154,6 +162,7 @@
:methods
(assoc (get cls :methods) selector m))))
(st-method-cache-clear!)
(st-ic-bump-generation!)
selector)))))))
(define
@@ -178,6 +187,7 @@
:class-methods
(assoc (get cls :class-methods) selector m))))
(st-method-cache-clear!)
(st-ic-bump-generation!)
selector)))))))
;; Remove a method from a class (instance side). Mostly for tests; runtime
@@ -208,6 +218,7 @@
cls-name
(assoc cls :methods new-md)))
(st-method-cache-clear!)
(st-ic-bump-generation!)
true))))))))))
;; Walk-only lookup. Returns the method record (with :defining-class) or nil.