smalltalk: per-call-site inline cache + 10 IC tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user