Devirtualize monomorphic protocol calls (#227)
When the inference proves a protocol call's receiver is one record type, the back end resolves the impl by that static tag (find-protocol-method) instead of routing through the protocol var -> jolt-invoke -> protocol-resolve, which re-derives the tag and walks the type table. Same table lookup, minus the var-deref, the rest-cons, and the receiver-type computation. Fires only on a monomorphic site: a megamorphic receiver joins to :any and carries no :devirt-type, so it keeps ordinary dispatch (the dispatch bench is unaffected). The annotation comes from the whole-program fixpoint typing a reduce/HOF element or a ctor return as a specific record. Modest on the dispatch benchmarks (~6% on mono-dispatch) — float boxing in the reduce accumulator dominates there, a separate numeric lever — but it removes the dispatch overhead wherever a typed receiver is known. run-devirt.ss gate: emitted form uses find-protocol-method, and evaluating it matches ordinary dispatch for an inline impl, an extend-type impl, and the non-devirt path. make test / shakesmoke green, 0 new divergences. Co-authored-by: Yogthos <yogthos@gmail.com>
This commit is contained in:
parent
09712ec575
commit
af11aaa7ff
4 changed files with 167 additions and 78 deletions
10
Makefile
10
Makefile
|
|
@ -4,7 +4,7 @@
|
|||
# build step. `make test` is the full gate. `make remint` rebuilds the seed after a
|
||||
# source change.
|
||||
|
||||
.PHONY: test ci values corpus unit smoke buildsmoke selfhost sci certify ffi transient infer wp directlink numeric inline shakesmoke remint
|
||||
.PHONY: test ci values corpus unit smoke buildsmoke selfhost sci certify ffi transient infer wp devirt directlink numeric inline shakesmoke remint
|
||||
|
||||
# Full gate (dev machine). Includes the self-host byte-fixpoint, which only holds
|
||||
# on the same Chez that minted the seed.
|
||||
|
|
@ -15,7 +15,7 @@ test: selfhost ci
|
|||
# lockfile) — it RUNS correctly on any Chez, but `selfhost` rebuilds it and a
|
||||
# different Chez version may emit byte-different (gensym/order) output, so the
|
||||
# byte-fixpoint is a dev-machine check, not a CI one (jolt-8479).
|
||||
ci: values corpus unit smoke buildsmoke sci ffi transient infer wp directlink numeric inline certify
|
||||
ci: values corpus unit smoke buildsmoke sci ffi transient infer wp devirt directlink numeric inline certify
|
||||
@echo "OK: CI gates passed"
|
||||
|
||||
# Self-host fixpoint: bootstrap.ss rebuild == checked-in seed.
|
||||
|
|
@ -67,6 +67,12 @@ infer:
|
|||
wp:
|
||||
@chez --script host/chez/run-wp.ss
|
||||
|
||||
# Protocol-call devirtualization: a monomorphic call resolves its impl by the
|
||||
# inferred record tag (find-protocol-method) instead of routing through the
|
||||
# protocol var; the result must match ordinary dispatch.
|
||||
devirt:
|
||||
@chez --script host/chez/run-devirt.ss
|
||||
|
||||
# Direct-linking emission: a closed-world build binds top-level app defs to jv$
|
||||
# Scheme bindings and routes app->app calls/refs to them, skipping var-deref +
|
||||
# jolt-invoke; ^:dynamic/^:redef and nested defs opt out.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue